Specman 18.09: Avoiding the small annoying mistakes
In almost every industry, one has the potential of making a small mistake that may cost hours or days to find. The following interesting article takes the small mistakes to the extreme and mentions a few cases of small mistakes that had a huge effect: Messing up big time: 10 tiny mistakes that have caused HUGE problems.
How is it relevant to Specman? As a verification engineer, you want to avoid silly mistakes (mistakes that may occur regardless of how smart you are). True, usually these mistakes may not result in a catastrophe like in the article, but might cost you hours of debugging and loads of frustration that ends with saying “I do not believe I have spent the whole day looking for this careless mistake” or something like “Who is this guy that messed the order of these values? Ha… it was me...”.
This blog is about trying to avoid errors around equivalent enums in HDL and the testbench. It is a very common requirement to create an enumeration in e to drive (with a port) an equivalent HDL enum. For example, assume you have System Verilog object of type:
typedef enum {M_IDLE = 2'b00 , M_DATA = 2'b10 , M_ADDR = 2'b01 , M_END = 2'b11} rcvstate;
Then you need to define in e the following type:
type rcvstate [M_IDLE = 2'b00 , M_DATA = 2'b10 , M_ADDR = 2'b01 , M_END = 2'b11];
In Specman 18.03, we added the set e2hdl checks command. This command compares two enum existing definitions (in HDL and in the Test bench) to ensure that they are compatible. The purpose of this command is to ensure that if someone changes one of these enums, assuming that you have this command running on a regular basis, you will get to know about it right away and it will save you the time that you may have used in debugging to understand what went wrong. You can read more about this in the blog: Enum compatibility error in Specman.
In Specman 18.09, we took this functionality one step further by adding a new command, write type_map. This command saves you the time to define the enum in the testbench in the first place. It extracts the HDL data and creates the equivalent enum in e for each enum in the design. The write type_map command gets the snapshot as an input and creates an e package files with all the e enumerators. Naturally, this means that you can use this command only after elaboration.
Let’s take an example. Let’s assume that we have a DUT with SV module called types that includes the following enums:
typedef enum integer {IDLE=0, GNT0=1, GNT1=2} state;
typedef enum int {ADD = 1,SUBTRACT = 3,MULTIPLY = 7} cmd ;
typedef enum bit [3:0] {bronze='h1, silver, gold='h5} newMedal;
When we elaborate the design and run the command:
xrun -elaborate top.sv
specman -c "write type_map worklib.top:sv”
An e file called top.e is created with the following content:
<'
package types;
type state : [IDLE =0, GNT0 =1, GNT1 =2](bits:32);
type cmd : [ADD =1, SUBTRACT =3, MULTIPLY =7](bits:32);
type newMedal : [bronze =1, silver =2, gold =5](bits:4);
'>
This way we are eliminating the option of making an error while defining the enums (most likely with the order of the enum values).
This command has few options you can use. You can read about it in cdnshelp.
We strongly recommend that you have a look at all the new features of Specman 18.09 in “What’s new in the Xcelium 18.09”.
Orit Kirshenberg
Specman Team