您可以直接将 Specman 的pack
andunpack
功能与“物理场”(那些以修饰符前缀的实例成员%
)一起使用。
例子:
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*
如果您的结构已经将物理字段用于其他目的,那么您需要为该结构寻求某种方法。