tags:

views:

119

answers:

1

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;
};
+1  A: 

Specman 6.1 docs don't show a reduce pseudo-method. For your specific example, you can acheive what you want with:

bitmap = pack(packing.low, x)

You may find the "reduce" psuedo-method in your version of Specman by searching "List Pseudo-Methods" in your docs.

Section "Math and Logic Pseudo-Methods" shows methods and_all(), average(), or_all(), product(), and sum(). I know this is not the meta-solution, but its better than a kick in the teeth.

Ross Rogers