Re: [sv-ec] Associative array with enum index

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Sat Oct 21 2006 - 22:53:22 PDT
> What would be the most likely uses of an AA with an enum index?

Don't know what's most likely, but one way to use an enum index with a
regular array would be to impose a range, as with

    typedef logic [2:11] My_Array_T;
    typedef enum logic [3:0] { _dont_use_[10]='h2 } My_Array_Index_T;

Unless you cast bogus values to the enum type, then, if you consistenly
use only indices of type My_Array_Index_T to index into arrays of type
My_Array_T, then you can't mistakenly do an out-of-bounds write, which
simulators happily and quietly allow as a no-op unless they detect it at
compile time.

You could do the same thing with an associative array

    typedef logic My_Assoc_Array_T[My_Array_Index_T];

-- Brad
Received on Sat Oct 21 22:53:32 2006

This archive was generated by hypermail 2.1.8 : Sat Oct 21 2006 - 22:54:02 PDT