in my verification environment I have different registers' types with almost the same name that differs only by index, e.g.: timer_load_0
, timer_load_1
etc..
I try to create a macro that gets 2 parameters: string
(the 'name' of the register without its index) and uint
(the register's index) and returns a variable of "concatenated" register type.
For example I would like that the command:
my_idx : uint = 0;
create_reg "timer_load" my_idx;
will return the variable timer_load_0
.
My macro code:
define <var_by_idx'action> "create_reg <name'any> <idx'exp>" as computed {
var idx : uint = <idx'exp>.as_a(uint);
result = appendf("%s_%d",<name'any>, idx);
};
The compilation error I get:
Error: Looking for a number but found 'my_idx'
at line 45 in @macros
var idx : uint = <idx'exp>.as_a(uint);
during execution of a define-as-computed macro:
at line 380 in @timer_monitor
create_reg "timer_load" my_idx;
The macro does not recognize my_idx
as uint
variable but as string
..
Thank you for any help.