Specman e: Is there a way to extend multiple structure types?
in my validation environment, we are working with a package vr_ad
UVM
where there is a common structure for a register vr_ad_reg
that has been extended with a different type for each register in the environment, etc .:
reg_def TIMER_LOAD_0 TIMER 20'h00010 {
reg_fld timer_load : uint : RW : 0xffff;
}:
vr_ad_reg
has a predefined function post_access()
that I would like to extend for every case type that starts with the word " TIMER
". Is there a way to do this? For example:
extend TIMER_* vr_ad_reg { //The intention here to extend the vr_ad_reg for all types that starts with the word TIMER
post_access() is also {
var some_var : uint;
};
}
thanks for the help
source to share
There is no built-in construct to extend multiple subtypes. However, you can use a macro based solution. The Specman team had a blog post on this topic: http://www.cadence.com/Community/blogs/fv/archive/2009/10/20/extending-multiple-when-subtypes-simultaneously.aspx
They created a macro define as computed
that takes multiple subtypes and extends them:
define <multi_when'statement> "extend \[<detr'name>,...\] <base'type> (<MEMBERS {<struct_member>;...})" as computed {
for each in <detr'names> do {
result = appendf("%s extend %s %s %s;",result,it,<base'type>,<MEMBERS>);
};
};
Then you can use like this:
extend [ TIMER_LOAD_0, TIMER_LOAD_1, TIMER_LOAD_2 ] vr_ad_reg {
post_access() is also {
// ...
};
};
source to share
If you have many registers that match your expression, or you don't know the exact name beforehand, you might need to use a runtime solution:
extend vr_reg {
post_access() is also {
var some_var: uint;
if str_match(kind.as_a(string), "/^TIMER_*/") {
... // do stuff for the TIMER_* registers
};
};
};
source to share