[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  SVN::S4
  SystemPerl
  Voneline
  WFH
General Info
  Papers

Issue #314

always@(in1 or in2 or in3) has bugs

Added by Michael Perrott over 2 years ago. Updated over 2 years ago.

Status:WillNotFix Start date:01/11/2011
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:Unsupported
Target version:-

Description

The code within the first always loop below will be executed differently depending on the clk signal being observed in the second always loop. For instance, when the clk is quiet, the first always loop will be executed a few times (it should really only happen once) with static in1, in2, in3 values, and many times when the clk signal starts toggling.

module transition_statement_bug(sig1, sig2, sig3, clk);

input sig1;
input sig2;
input sig3;
input clk;
reg state_val;
reg flag;

initial begin
   state_val = 1'b0;
   flag = 1'b0;
end

always @(sig1 or sig2 or sig3) begin
   case({sig1,sig2,sig3})
      3'b111 : begin
          flag = 1'b0;
          $display("---- Flag is zero %d %d %d",sig1,sig2,sig3);
      end
      default : begin
          if(flag == 0) begin
             flag = 1'b1;
             $display("---- Flag is one %d %d %d",sig1,sig2,sig3);
          end
      end
   endcase
end

always @(posedge clk) begin
   state_val <= (state_val == 1'b0) ? 1'b1 : 1'b0;
end

endmodule
<pre>

History

Updated by Wilson Snyder over 2 years ago

  • Category set to Unsupported
  • Status changed from New to WillNotFix

Verilator doesn't do well with generated clocks as it's not an event based simulator. Someday this will be addressed, but it's a major change.

This also isn't synthesizable code. If you think of Verilator as a synthesized simulator, with non-clocked always meaning "combo logic" that can be evaluated at any time, you have a reasonable model of what it's doing.

Also available in: Atom