Covered covered-0.7.6
Linux 2.6.9-78.0.13.ELsmp x86_64
Simulator: NCVerilog.
When the fsm state transitions are reported in verbose mode, the minimum width specification in the format string in fsm_display_arc_verbose (fsm.c) isn't wide enough for a 32bit register format description (ie. 32'h00000001) and the value is truncated.
A state parameter:
parameter MYSTATE=1;
Is represented as 32'h00000001 (at least using ncverilog).
In this case you need a minimum width of 12 characters, NOT 10 as line 956 currently states.
width = (width > 10) ? width : 10;
Changing the 10 to 12 fixes the truncation and the report displays the correct state transitions.
I attempted to replicate this issue with the attached test which seems to output the correct coverage information for FSM coverage (i.e., nothing is truncated). The code that is referenced in the report is a calculation of the minimal value (the width that is output can be much greater than 10 characters). The minimal value is the output of the "Froms State", "To State" string and the underline string that is displayed below it. At a minimum, I need 10 characters to output this header string properly. The code is saying that if the FSM string requires more than 10 characters, make the width of the output match the data. If the FSM string requires less than 10 characters, make the width of the output 10 characters. This makes sure that the data is never truncated and the header is also never truncated.
Could you refine my example code to get things to fail as you see it? I'll use that test case to do further debugging if necessary.
Thanks,
Trevor
Example code that does not fail
Module coverage report generated from example code
In fsm_arg_parse_value, when parsing the trans attribute. We drop into the last else if on line 487. We sucessfully find the parameter. The width is correct, but not for the head and tail which are used to add the link:
and in this else if, the width is not explicitly set as it (looks like anyway) it is in previous else if's.
(gdb) p mparm->expr->value->width
$39 = 32
(gdb) p mparm->exp_head->exp->value->width
$42 = 0
(gdb) p mparm->exp_tail->exp->value->width
$43 = 0
It looks like, at this point, we lose the width information for the parameterized fsm states.
If this is still not the correct issue, give me a hint as to where the widths should be set.
Including the testcase file here since I can't figure out how to add an attachment.
module test (/AUTOARG/);
parameter IDLE=0;
parameter RUN=1;
parameter NOGO=2;
parameter DONE=3;
reg clk;
reg reset_n;
reg [1:0] state;
reg [1:0] nxt_state;
reg [1:0] done;
wire go_to_nogo;
initial begin
reset_n = 0;
clk = 0;
# 100
reset_n = 1;
end
always
#(20) clk <= ~clk;
always @ (done)
if ( done == 2'b10 )
$finish;
assign go_to_nogo = 1'b0;
( covered_fsm, my_fsm, os="state",
trans="IDLE->RUN",
trans="RUN->NOGO",
trans="NOGO->DONE",
trans="RUN->DONE",
trans="DONE->IDLE" )
always @ (posedge clk) begin
if ( !reset_n ) begin
state <= IDLE;
done <= 0;
end
else begin
case (state)
IDLE: begin
$display("In IDLE");
if ( reset_n != 0 )
state <= RUN;
end
NOGO: begin
$display("In NOGO");
state <= DONE;
end
RUN: begin
$display("In RUN");
if ( go_to_nogo == 1'b1 )
state <= NOGO;
else
state <= DONE;
end
DONE: begin
$display("In DONE %d", done);
done <= done + 2'b01;
state <= IDLE;
end
endcase // case (state)
end // else: !if( !reset_n )
end // always @ (posedge clk)
Let me back up and say that the issue in the verbose print is that the width is 0. I traced through the assigning of the parameter values and they look fine (at least the width field). My guess is that the issue is where the parameter value gets inserted into the fsm states. Hence the previous comment.
Using your example, I'm now able to reproduce the issue. I'll take a look and get a patch added to this bug report soon.
Thanks,
Trevor
I have attached a bug patch for this issue. The problem was that the width of the parameter was being output using the width of the output/input state. The report should output the width of the output/input state. The included patch performs this type of output.
The patch has been applied to CVS and will be generally available in the 0.7.8 stable release.
Bug fix patch
Works great. Thanks!