Specman DAC macro: How to define 2 inputs of different type (uint and string)? -
in verification environment have different registers' types same name differs index, e.g.: timer_load_0
, timer_load_1
etc.. try create macro gets 2 parameters: string
(the 'name' of register without index) , uint
(the register's index) , returns variable of "concatenated" register type. example command:
my_idx : uint = 0; create_reg "timer_load" my_idx;
will return variable timer_load_0
.
my macro code:
define <var_by_idx'action> "create_reg <name'any> <idx'exp>" computed { var idx : uint = <idx'exp>.as_a(uint); result = appendf("%s_%d",<name'any>, idx); };
the compilation error get:
error: looking number found 'my_idx' @ line 45 in @macros var idx : uint = <idx'exp>.as_a(uint); during execution of define-as-computed macro: @ line 380 in @timer_monitor create_reg "timer_load" my_idx;
the macro not recognize my_idx
uint
variable string
.. thank help.
a macro want can passed constant value, need change <idx'num>
.
as yuri mentioned, define computed macros expanded @ compile time. means macro needs constant value idx
know type of variable allocate created_reg
. value of idx
variable want pass macro set @ run-time, late.
Comments
Post a Comment