Specman: Assign multiple structural elements in a single expression

Hy

I am extending the existing specman test where the following code 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 structure members on a single line? as:

foo = { 0xff, ... };
+3
source share
3 answers

Currently, I can’t think of a direct way to set all the members as you want, but there is a way to initialize the variables (I'm not sure if it also works with structure elements). In any case, something like the following may work for you:

myfunc() is {
    var foo : dataset = new dataset with {
        .register = 0xff;
        .bar = 0xfa;
    }
    data.push(foo.copy());
}

More information on newcan be found in the help new structspecman invitation.

Hope this helps!

+4
source

- , , .

:

struct s {
  a : int;
  b : string;
  c : bit;
};

extend sys {
  ex() is {
    var s := new s with {.a = 0x0; .b = "zero"; .c = 0;};
  };
  run() is also {
    var s;
    gen s keeping {.a == 0x0; .b == "zero"; .c == 0;};
  };
};

i data.push(new dataset with {.reg = 0xff; bar = 0x0;});, , .

: unpack() (. ross-), , IMO. ( , ), , unpack().

+2

pack unpack Specman " " ( , %).

:

define FLOODLES_WIDTH 47;
type floodles_t : uint(bits:FLOODLES_WIDTH);

define FLABNICKERS_WIDTH 28;
type flabnickers_t : uint(bits:FLABNICKERS_WIDTH);

struct foo_s {
   %!floodle : floodles_t;
   %!flabnicker : flabnickers_t;
};

extend sys {
   run() is also {
      var f : foo_s = new;
      unpack(packing.low,64'hdeadbeefdeadbeef,f);
      print f;

      unpack(packing.low,64'hacedacedacedaced,f);
      print f;

   };
   setup() is also {
      set_config(print,radix,hex);
   };
};

, :

Loading /nfs/pdx/home/rbroger1/tmp.e ...
read...parse...update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...

Starting the test ...
Running the test ...
  f = foo_s-@0: foo_s   of unit: sys
        ----------------------------------------------  @tmp
0       !%floodle:                      0x3eefdeadbeef
1       !%flabnicker:                   0x001bd5b
  f = foo_s-@0: foo_s   of unit: sys
        ----------------------------------------------  @tmp
0       !%floodle:                      0x2cedacedaced
1       !%flabnicker:                   0x00159db

packing, unpacking, physical fields, packing.low, packing.high Specman.

, DUT. - , - set* .

+1
source

Source: https://habr.com/ru/post/1733201/


All Articles