ASIC/FPGA Design and Verification Out Source Services
How to drive a specman state (enumerated type) to wave, to aid debug.
-
Suppose you have a state machine with a type like this:
type sbt_fsm_state_t : [ADDR_WAIT, DATA_LOAD, PARITY_LOAD, HOLD_STATE, BUSY_STATE];
-
In my case a monitor had such a state with much more states. To facilitate the
debug, I wrote the state to waves with its meaningful names.
-
To do that one first has to declare a string variable in the verilog bench.
reg [14*8:0] spc_usb_2G_mon;
//for debug
initial begin
spc_usb_2G_mon[ 7:0]=8'h61;
spc_usb_2G_mon[15:8]=8'h62;
end
-
Next comes the specman side. First in your signal map instance add the string
port:
//spc debug - drive state to wave
spc_usb_2G_tms_mon: out simple_port of uint(bits:113) is instance;
keep bind(spc_usb_2G_tms_mon, external);
-
Add this method and use it to drive the debug port:
- str_to_uint_113(st : usb_2G_states_t) : uint(bits:113) is {
- var bytes_l := appendf("%s", st).as_a(list of byte);
- bytes_l=bytes_l.reverse();
- result=0;
- for each (b) in bytes_l {
- result[8*index+7:8*index]=b;
- };//for each (b) in bytes_l
- };
Use it:
sig.spc_usb_2G_mon$=str_to_uint_113(usb_2G_state);
|