views:

399

answers:

2

In E (specman) I want to declare variables that are lists, and I want to fix their lengths.

It's easy to do for a member of a struct:

thread[2] : list of thread_t;

while for a "regular" variable in a function the above doesn't work, and I have to do something like:

var warned : list of bool;
gen warned keeping {
    it.size() == 5;
};

Is there a better way to declare a list of fixed size?

A: 

I know nothing of specman, but a fixed sized list is an array, so that might point you somewhere.

Joel Coehoorn
+3  A: 

A hard keep like you have is only going to fix the size at initialization but elements could still be added or dropped later, are you trying to guard against this condition? The only way I can think of to guarantee that elements aren't added or dropped later is emitting an event synced on the size != the predetermined amount:

event list_size_changed is true (wanted.size() != 5) @clk;

The only other thing that I can offer is a bit of syntactic sugar for the hard keep:

var warned : list of bool;
keep warned.size() == 5;
JawnV6