Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  IPC::Locker
  Parallel::Forker
  Voneline
General Info
  Papers

Using AUTOASCIIENUM for indexed-parameter one-hot state machines

Added by Lloyd Gomez almost 11 years ago

Hello,

I'm using the indexed-parameter style with registered outputs for coding my one-hot state machine. This coding style is described in section 2.4.1 of the following white paper from Sunburst Design:

http://www.sunburst-design.com/papers/CummingsSNUG2003SJ_SystemVerilogFSM.pdf

If you can't read the link above, the following example below shows it:

module my_block (
  input    clk,
  input    rst_n,
  output   done
);

  //----------------------------------------------
  // localparam values no longer represent one-hot
  // state encoding, but rather indices into
  // next state and current state vectors
  //----------------------------------------------

  localparam // synopsys enum state_info
                IDLE = 0,
                S1   = 1,
                S2   = 2,
                S3   = 3,
                DONE = 4;

  reg [4:0] // synopsys enum state_info
                cur_state, nxt_state;

  always @ (*) begin
    nxt_state = 5'h0;

    case (1'b1)
      cur_state[IDLE] : nxt_state[S1] = 1'b1;
      cur_state[S1]   : nxt_state[S2] = 1'b1;
      cur_state[S2]   : nxt_state[S3] = 1'b1;
      cur_state[S3]   : nxt_state[DONE] = 1'b1;
      cur_state[DONE] : nxt_state[DONE] = 1'b1;
    endcase
  end

  always @ (posedge clk or negedge rst_n)
    if (rst_n == 1'b0) begin
      cur_state <= 'h1;
    end
    else begin
      cur_state <= nxt_state;
    end

  assign done = cur_state[DONE];

  /*AUTOASCIIENUM("cur_state", "cur_state_ascii")*/

endmodule

Is there a way for AUTOASCIIENUM to work with the above case? AUTOASCIIENUM currently assumes the localparams above are state-encodings.

Thanks for your help!


Replies (4)

RE: Using AUTOASCIIENUM for indexed-parameter one-hot state machines - Added by Wilson Snyder almost 11 years ago

That's a great idea. I'd like to detect it automatically, but am not sure if it can be failsafe enough. Let me try a few things; if I can't make it work automagically I'll make a new AUTO for it.

RE: Using AUTOASCIIENUM for indexed-parameter one-hot state machines - Added by Wilson Snyder almost 11 years ago

Please try version 502 here on veripool.org.

RE: Using AUTOASCIIENUM for indexed-parameter one-hot state machines - Added by Lloyd Gomez almost 11 years ago

Hi Wilson,

Version 502 works, thanks! FYI, I ran my simulation on Synopsys VCS B-2008.12 using DVE as the waveform viewer.

Thanks again, Lloyd

RE: Using AUTOASCIIENUM for indexed-parameter one-hot state machines - Added by Ensoul Chi almost 11 years ago

That's really a good feature for me before. But from now on, I think more and more simulator support SystemVerilog. So I use the enum type for FSM description. That's really cool.

Using the AUTOASCIIENUM before, it always cause the DVE crash when I try to change that from BIN to String display.

    (1-4/4)