specman

How do I declare a list of fixed length in specman?

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; ...

Specman macro to do set subtraction with int_range_list objects

I work with a bunch of sets in order to generate constrained random traffic, but I want to be able to call a Specman macro that computes the complement of a set with syntax like: COMPLEMENT begin domain=[0..10,24..30], complmenting_set=[2..3,27..30] end and have it generate: [0..1,4..10,24..26] Every time I need the complemen...

How do I change the default *.elog log file name for an interpreted Specman session?

I want to be able to specify the file name stem for the log file in a Specman test. I need to hard-code the main *.elog filename so that I don't get variance between tests and confuse the post-processing scripts. Is there a constraint or command line I can pass into Specman? ...

can I set the constraints for a variable once and generate a few times in specman?

I have a variable that I want to generate a few times in the same function, each time with the same set of constraints. Can I set the constraints once and the just gen it many times? That is, instead of this: var a:uint; gen a keeping {it in [100..120];}; // some code that uses a . . . gen a keeping {it in [100..120];}; // some code t...

In Specman, how can I tell if a reference to a unit has the do-not-generate modifier in front of it?

In Specman, how can I tell if a reference to a unit has the do-not-generate modifier, '!', at the reference's definition? e.g. unit foo_u { }; extend sys { foo : foo_u is instance; foo_ptr_generated : foo_u; keep foo_ptr_generated == foo; !foo_ptr_notgenerated : foo_u; connect_pointers() is also { foo_ptr_notgene...

how can I count the number of set bits in a uint in specman?

I want to count the number of set bits in a uint in Specman: var x: uint; gen x; var x_set_bits: uint; x_set_bits = ?; What's the best way to do this? ...

VIM syntax file for specman

Where can I find an updated syntax file for specman? There are a number of these on the web, but I want one with recommendations. ...

Returning an array in Specman

How do I return an array from a method call in Specman? E.g. method a : list of uint is { var data: list of uint; ..... result = data; }; extend sys { var data_sys: list of uint; run() is also { data_sys = a(); }; }; My print out shows some elements are different from array data and data_sys. Can you tell me what I mi...

does specman have static variables?

I have the following code in specman that I inherited: some_method() is { var a: bool; if (!a) { a = some_other_method(); }; }; My understanding is that each time some_method() is called, a is generated anew, and there's no sense in checking a's value before it's assigned. However, it may be that I'm missing some...

splitting a string into a list in specman

Supposing I have a string: str = “ab,cd,ef” and I want to split it into a list lst = [“ab”,”cd”,ef”] How can I do it best, assuming that I don’t know ahead of time how many items are in the string? Basically I'm looking for a specman equivalent to Perl's: $str = "ab,cd,ef"; @lst = split /,/, $str; ...

How can I join a list of strings in specman?

I have a list that I want to print: foo: list of string; I want to create a string bar that is the concatenation of the elements of foo. In Perl I would do: $bar = join " ", @foo; The only way I can think of to do this in specman is: var bar: string = ""; for each in foo { bar = appendf("%s %s", bar, it); }; This seems like...

how can I create a reference to a variable in specman?

I have the following code in specman: var x := some.very.long.path.to.a.variable.in.another.struct; while (x == some_value) { //do something that uses x; //wait for something //get a new value for x x = some.very.long.path.to.a.variable.in.another.struct; }; Now, it seems wasteful to write the assignment to x twice; ...

using "apply()" with methods that return void in specman

Specman has the apply() method to perform the same action on all elements of a list: var a: list of int; a = somefunction.that.returns.list.of.int(); var b:= a.apply(it * 2); Where apply() does the same as: for each in a { b.add(it.*2); }; Now, if I want to call a method on the elements of a, I can use apply() so long as the me...

reduce list in Specman like in Python

Is there a reduce() list method in Specman that I can use for general reduction functions? I'm thinking of something like: var x: list of bit = some_function_that_returns_list_of_bit; var bitmap: uint = x.reduce(foo()); where reduce() works like in Python: foo(last: uint, val: bit) is: uint { return (last << 1 ) | bit; }; ...

How can I call a routine automatically when the run ends in specman?

Is there any way to specify that a function should be called when a test ends in Specman? I'm looking for something similar to C's atexit(). ...

What's the difference between to_string() and as_a(string) in specman?

In Specman I can convert a variable to a string using either: x.to_string(); or x.as_a(string); Is there any difference between the two? If not, why does Specman provide both? ...

How can I wait for one event out of a list of events in specman?

I have a struct in specman: struct foo_s { event foo_ev; // some code that will emit foo_ev sometimes }; And a list: var foo_l: list of foo_s; // later code will manage the list And now I want to sync on any of the foo_ev events in the list: first of { sync @foo_l[0].foo_ev; sync @foo_l[1].foo_ev; sync @foo_l...

How can I get the stack trace in Specman?

Is there any way to get the stack trace in Specman? I patched the functions that force signals to tell me when signals are forced. I want to be able to tell where the forcing originated. ...

specman: Assign multiple struct member in one expression

Hy, I expanding an existing specman test where some code like this appears: struct dataset { !register : int (bits:16); ... other members } ... data : list of dataset; foo : dataset; gen foo; foo.register = 0xfe; ... assign other foo members ... data.push(foo.copy()); is there a way to assign to the members of the struct in on...

Specman: how to retrieve values of var which is stored in another var

I have stored var name in another var and I want to retrieve values from original var. for ex: var var_A: list of uint = {1,3,2}; var var_A_str:string = "var_A"; //Now i want to print var_A list of values using var_A_str. How can i do that? print $var_A_str; ...