Specmanのpack
and機能は、「物理フィールド」(修飾子の前に付けられたインスタンスメンバー)で直接使用できます。unpack
%
例:
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
Specmanpacking, unpacking, physical fields, packing.low, packing.high
ドキュメントで調べてください。
構造体がDUTにマップされていない場合でも、物理フィールドを使用できます。構造体がすでに他の目的で物理フィールドを使用している場合は、その構造体に対して何らかのset*
方法を追求する必要があります。