verilog-auto-ascii-enum

verilog-auto-ascii-enum is a compiled Lisp function in `verilog-mode.el'.

(verilog-auto-ascii-enum)

Expand AUTOASCIIENUM statements, as part of M-x verilog-auto.
Create a register to contain the ASCII decode of an enumerated signal type.
This will allow trace viewers to show the ASCII name of states.

First, parameters are built into an enumeration using the synopsys enum
comment. The comment must be between the keyword and the symbol.
(Annoying, but that's what Synopsys's dc_shell FSM reader requires.)

Next, registers which that enum applies to are also tagged with the same
enum.

Finally, an AUTOASCIIENUM command is used.

The first parameter is the name of the signal to be decoded.

The second parameter is the name to store the ASCII code into. For the
signal foo, I suggest the name _foo__ascii, where the leading _ indicates
a signal that is just for simulation, and the magic characters _ascii
tell viewers like Dinotrace to display in ASCII format.

The third optional parameter is a string which will be removed
from the state names. It defaults to "" which removes nothing.

The fourth optional parameter is "onehot" to force one-hot
decoding. If unspecified, if and only if the first parameter
width is 2^(number of states in enum) and does NOT match the
width of the enum, the signal is assumed to be a one-hot
decode. Otherwise, it's a normal encoded state vector.

`verilog-auto-wire-type' may be used to change the datatype of
the declarations.

"auto enum" may be used in place of "synopsys enum".

An example:

//== State enumeration
parameter [2:0] // synopsys enum state_info
SM_IDLE = 3'b000,
SM_SEND = 3'b001,
SM_WAIT1 = 3'b010;
//== State variables
reg [2:0] /* synopsys enum state_info */
state_r; /* synopsys state_vector state_r */
reg [2:0] /* synopsys enum state_info */
state_e1;

/*AUTOASCIIENUM("state_r", "state_ascii_r", "SM_")*/

Typing M-x verilog-auto will make this into:

... same front matter ...

/*AUTOASCIIENUM("state_r", "state_ascii_r", "SM_")*/
// Beginning of automatic ASCII enum decoding
reg [39:0] state_ascii_r; // Decode of state_r
always @(state_r) begin
case ({state_r})
SM_IDLE: state_ascii_r = "idle ";
SM_SEND: state_ascii_r = "send ";
SM_WAIT1: state_ascii_r = "wait1";
default: state_ascii_r = "%Erro";
endcase
end
// End of automatics