How to bring the enum string on waveform for debug
Hi,
Today I would like to discuss about how to bring the enum literals on waveform for debugging
Though there are many ways in which this can be done, the below method should take the least efforts.
Step 1: Take care while declaring the typedef enum
typedef enum by default is int type if your string is of length greater than 32 bits else it will give error. So take care of the size of the string to be declared.
e.g typedef enum bit[127:0] {RESET="RESET",STEP1="STEP1"} string_et;
Step 2: Declaration inside interface
Inside interface declare string debug disp, with this you don't have to take change the radix on waveform to ASCII. It will by default show the string.
e.g
interface itf;
// string disp; // Correction instead take instance of string_et
string_et disp;// This way there won't be need to do casting
endinterface
Step 3: Using it inside the class
The following is the example to use it inside the class.
class abc;
// Virtual interface inst
virtual interface itf v_if;
// Enum string_st inst
string_et st;
// Assign virtual interface here
function new(virtual interface itf v_if_0);
this.v_if = v_if_0;
endfunction
// Task to assign the var and display
task x( );
repeat(5) begin
st = RESET;
$display ($time," %s",st);
// this.v_if.disp = string'(st); // Correction as both the datatypes are same no casting required
this.v_if.disp = (st);
#10;
st = st.next;
$display ($time," %s",st);
this.v_if.disp = (st);
#10;
end
endtask
endclass
STEP 4: Call it from the module
module top;
abc a;
itf itf_0();
initial
begin
a = new(itf_0);
a.x();
end
endmodule
If you run the code you should be able to see the string value on waveform.
If you a better and easy way please let me know.
Senior ASIC Design Verification Engineer
9 年Thanks Vikas Kumar