This page contains documentation extracted from verilog-mode, revision 638. Functions are described here beginning with verilog-mode and verilog-auto, then alphabetically.
See also the other Verilog-mode Documentation
You may copy this document, but it will soon get out of date; you are thus better linking to &BASE;verilog-mode-help.html, or getting these pages from the Emacs help system.
Copyright 2006, the Free Software Foundation. By Michael McNamara (mac@verilog.com). and Wilson Snyder (wsnyder@wsnyder.org)
verilog-mode (function)
Major mode for editing Verilog code.
Use M-x verilog-faq for a pointer to frequently asked questions.
NEWLINE, TAB indents for Verilog code. Delete converts tabs to spaces as it moves back.
Supports highlighting.
Turning on Verilog mode calls the value of the variable verilog-mode-hook
with no args, if that value is non-nil.
Variables controlling indentation/edit style:
variable verilog-indent-level (default 3)
- Indentation of Verilog statements with respect to containing block.
verilog-indent-level-module (default 3)
- Absolute indentation of Module level Verilog statements. Set to 0 to get initial and always statements lined up on the left side of your screen.
verilog-indent-level-declaration (default 3)
- Indentation of declarations with respect to containing block. Set to 0 to get them list right under containing block.
verilog-indent-level-behavioral (default 3)
- Indentation of first begin in a task or function block Set to 0 to get such code to lined up underneath the task or function keyword.
verilog-indent-level-directive (default 1)
- Indentation of `ifdef/`endif blocks.
verilog-cexp-indent (default 1)
- Indentation of Verilog statements broken across lines i.e.:
if (a)
begin
verilog-case-indent (default 2)
- Indentation for case statements.
verilog-auto-newline (default nil)
- Non-nil means automatically newline after semicolons and the punctuation mark after an end.
verilog-auto-indent-on-newline (default t)
- Non-nil means automatically indent line after newline.
verilog-tab-always-indent (default t)
- Non-nil means TAB in Verilog mode should always reindent the current line, regardless of where in the line point is when the TAB command is used.
verilog-indent-begin-after-if (default t)
- Non-nil means to indent begin statements following a preceding if, else, while, for and repeat statements, if any. Otherwise, the begin is lined up with the preceding token. If t, you get:
if (a)
begin // amount of indent based on verilog-cexp-indent
- otherwise you get:
if (a)
begin
verilog-auto-endcomments (default t)
- Non-nil means a comment /* ... */ is set after the ends which ends cases, tasks, functions and modules. The type and name of the object will be set between the braces.
verilog-minimum-comment-distance (default 10)
- Minimum distance (in lines) between begin and end required before a comment will be inserted. Setting this variable to zero results in every end acquiring a comment; the default avoids too many redundant comments in tight quarters.
verilog-auto-lineup (default 'declarations)
- List of contexts where auto lineup of code should be done.
Variables controlling other actions:
verilog-linter (default surelint)
- Unix program to call to run the lint checker. This is the default command for M-x compile-command and M-x verilog-auto-save-compile.
See M-x customize for the complete list of variables.
AUTO expansion functions are, in part:
M-x verilog-auto Expand AUTO statements.
M-x verilog-delete-auto Remove the AUTOs.
M-x verilog-inject-auto Insert AUTOs for the first time.
Some other functions are:
M-x verilog-complete-word Complete word with appropriate possibilities.
M-x verilog-mark-defun Mark function.
M-x verilog-beg-of-defun Move to beginning of current function.
M-x verilog-end-of-defun Move to end of current function.
M-x verilog-label-be Label matching begin ... end, fork ... join, etc statements.
M-x verilog-comment-region Put marked area in a comment.
M-x verilog-uncomment-region Uncomment an area commented with M-x verilog-comment-region.
M-x verilog-insert-block Insert begin ... end.
M-x verilog-star-comment Insert /* ... */.
M-x verilog-sk-always Insert an always @(AS) begin .. end block.
M-x verilog-sk-begin Insert a begin .. end block.
M-x verilog-sk-case Insert a case block, prompting for details.
M-x verilog-sk-for Insert a for (...) begin .. end block, prompting for details.
M-x verilog-sk-generate Insert a generate .. endgenerate block.
M-x verilog-sk-header Insert a header block at the top of file.
M-x verilog-sk-initial Insert an initial begin .. end block.
M-x verilog-sk-fork Insert a fork begin .. end .. join block.
M-x verilog-sk-module Insert a module .. (/*AUTOARG*/);.. endmodule block.
M-x verilog-sk-primitive Insert a primitive .. (.. );.. endprimitive block.
M-x verilog-sk-repeat Insert a repeat (..) begin .. end block.
M-x verilog-sk-specify Insert a specify .. endspecify block.
M-x verilog-sk-task Insert a task .. begin .. end endtask block.
M-x verilog-sk-while Insert a while (...) begin .. end block, prompting for details.
M-x verilog-sk-casex Insert a casex (...) item: begin.. end endcase block, prompting for details.
M-x verilog-sk-casez Insert a casez (...) item: begin.. end endcase block, prompting for details.
M-x verilog-sk-if Insert an if (..) begin .. end block.
M-x verilog-sk-else-if Insert an else if (..) begin .. end block.
M-x verilog-sk-comment Insert a comment block.
M-x verilog-sk-assign Insert an assign .. = ..; statement.
M-x verilog-sk-function Insert a function .. begin .. end endfunction block.
M-x verilog-sk-input Insert an input declaration, prompting for details.
M-x verilog-sk-output Insert an output declaration, prompting for details.
M-x verilog-sk-state-machine Insert a state machine definition, prompting for details.
M-x verilog-sk-inout Insert an inout declaration, prompting for details.
M-x verilog-sk-wire Insert a wire declaration, prompting for details.
M-x verilog-sk-reg Insert a register declaration, prompting for details.
M-x verilog-sk-define-signal Define signal under point as a register at the top of the module.
All key bindings can be seen in a Verilog-buffer with M-x describe-bindings.
Key bindings specific to verilog-mode-map are:
\{verilog-mode-map}
verilog-auto (function)
Expand AUTO statements. Look for any /*AUTO...*/ commands in the code, as used in instantiations or argument headers. Update the list of signals following the /*AUTO...*/ command.
Use M-x verilog-delete-auto to remove the AUTOs.
Use M-x verilog-inject-auto to insert AUTOs for the first time.
Use M-x verilog-faq for a pointer to frequently asked questions.
The hooks verilog-before-auto-hook and verilog-auto-hook are
called before and after this function, respectively.
For example:
module ModuleName (/*AUTOARG*/) /*AUTOINPUT*/ /*AUTOOUTPUT*/ /*AUTOWIRE*/ /*AUTOREG*/ InstMod instName #(/*AUTOINSTPARAM*/) (/*AUTOINST*/);
You can also update the AUTOs from the shell using:
emacs --batch <filenames.v> -f verilog-batch-autoOr fix indentation with:
emacs --batch <filenames.v> -f verilog-batch-indentLikewise, you can delete or inject AUTOs with:
emacs --batch <filenames.v> -f verilog-batch-delete-auto emacs --batch <filenames.v> -f verilog-batch-inject-auto
Using M-x describe-function, see also:
verilog-auto-arg for AUTOARG module instantiations
verilog-auto-ascii-enum for AUTOASCIIENUM enumeration decoding
verilog-auto-inout-comp for AUTOINOUTCOMP copy complemented i/o
verilog-auto-inout-module for AUTOINOUTMODULE copying i/o from elsewhere
verilog-auto-inout for AUTOINOUT making hierarchy inouts
verilog-auto-input for AUTOINPUT making hierarchy inputs
verilog-auto-insert-lisp for AUTOINSERTLISP insert code from lisp function
verilog-auto-inst for AUTOINST instantiation pins
verilog-auto-star for AUTOINST .* SystemVerilog pins
verilog-auto-inst-param for AUTOINSTPARAM instantiation params
verilog-auto-output for AUTOOUTPUT making hierarchy outputs
verilog-auto-output-every for AUTOOUTPUTEVERY making all outputs
verilog-auto-reg for AUTOREG registers
verilog-auto-reg-input for AUTOREGINPUT instantiation registers
verilog-auto-reset for AUTORESET flop resets
verilog-auto-sense for AUTOSENSE always sensitivity lists
verilog-auto-tieoff for AUTOTIEOFF output tieoffs
verilog-auto-unused for AUTOUNUSED unused inputs/inouts
verilog-auto-wire for AUTOWIRE instantiation wires
verilog-read-defines for reading `define values
verilog-read-includes for reading `includes
If you have bugs with these autos, please file an issue at URL `http://www.veripool.org/verilog-mode' or contact the AUTOAUTHOR Wilson Snyder (wsnyder@wsnyder.org).
verilog-active-low-regexp (customizable variable)
If set, treat signals matching this regexp as active low.
This is used for AUTORESET and AUTOTIEOFF. For proper behavior,
you will probably also need verilog-auto-reset-widths set.
verilog-auto-arg (function)
Expand AUTOARG statements. Replace the argument declarations at the beginning of the module with ones automatically derived from input and output statements. This can be dangerous if the module is instantiated using position-based connections, so use only name-based when instantiating the resulting module. Long lines are split based on the `fill-column', see M-x set-fill-column.
Limitations:
-
Concatenation and outputting partial busses is not supported.
Typedefs must match
verilog-typedef-regexp, which is disabled by default.
For example:
module ExampArg (/*AUTOARG*/); input i; output o; endmodule
Typing M-x verilog-auto will make this into:
module ExampArg (/*AUTOARG*/ // Outputs o, // Inputs i ); input i; output o; endmodule
The argument declarations may be printed in declaration order to best suit
order based instantiations, or alphabetically, based on the
verilog-auto-arg-sort variable.
Any ports declared between the ( and /*AUTOARG*/ are presumed to be predeclared and are not redeclared by AUTOARG. AUTOARG will make a conservative guess on adding a comma for the first signal, if you have any ifdefs or complicated expressions before the AUTOARG you will need to choose the comma yourself.
Avoid declaring ports manually, as it makes code harder to maintain.
verilog-auto-arg-sort (customizable variable)
If set, AUTOARG signal names will be sorted, not in delaration order. Declaration order is advantageous with order based instantiations and is the default for backward compatibility. Sorted order reduces changes when declarations are moved around in a file, and it's bad practice to rely on order based instantiations anyhow.
verilog-auto-ascii-enum (function)
Expand AUTOASCIIENUM statements, as part of M-x verilog-auto. Create a register to contain the ASCII decode of a enumerated signal type. This will allow trace viewers to show the ASCII name of states.
First, parameters are built into a 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. Synopsys also suggests labeling state vectors, but verilog-mode
doesn't care.
Finally, a AUTOASCIIENUM command is used.
-
The first parameter is the name of the signal to be decoded.
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.
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 final optional parameter is a string which will be removed from the state names.
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
verilog-auto-endcomments (customizable variable)
True means insert a comment /* ... */ after 'end's. The name of the function or case will be set between the braces.
verilog-auto-hook (customizable variable)
Hook run after verilog-mode updates AUTOs.
verilog-auto-indent-on-newline (customizable variable)
True means automatically indent line after newline.
verilog-auto-inout (function)
Expand AUTOINOUT statements, as part of M-x verilog-auto. Make inout statements for any inout signal in an /*AUTOINST*/ that isn't declared elsewhere inside the module.
Limitations:
-
This ONLY detects outputs of AUTOINSTants (see
verilog-read-sub-decls).If placed inside the parenthesis of a module declaration, it creates Verilog 2001 style, else uses Verilog 1995 style.
If any concatenation, or bit-subscripts are missing in the AUTOINSTant's instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
Typedefs must match
verilog-typedef-regexp, which is disabled by default.Signals matching
verilog-auto-inout-ignore-regexpare not included.
An example (see verilog-auto-inst for what else is going on here):
module ExampInout (ov,i) input i; /*AUTOINOUT*/ InstModule instName (/*AUTOINST*/); endmodule
Typing M-x verilog-auto will make this into:
module ExampInout (ov,i) input i; /*AUTOINOUT*/ // Beginning of automatic inouts (from unused autoinst inouts) inout [31:0] ov; // From inst of inst.v // End of automatics InstModule instName (/*AUTOINST*/ // Inouts .ov (ov[31:0]), // Inputs .i (i)); endmodule
You may also provide an optional regular expression, in which case only signals matching the regular expression will be included. For example the same expansion will result from only extracting inouts starting with i:
/*AUTOINOUT("^i")*/
verilog-auto-inout-comp (function)
Expand AUTOINOUTCOMP statements, as part of M-x verilog-auto.
Take input/output/inout statements from the specified module and
insert the inverse into the current module (inputs become outputs
and vice-versa.) This is useful for making test and stimulus
modules which need to have complementing I/O with another module.
Any I/O which are already defined in this module will not be
redefined. For the complement of this function, see
verilog-auto-inout-module.
Limitations:
-
If placed inside the parenthesis of a module declaration, it creates
Verilog 2001 style, else uses Verilog 1995 style.
Concatenation and outputting partial busses is not supported.
Module names must be resolvable to filenames. See
verilog-auto-inst.Signals are not inserted in the same order as in the original module, though they will appear to be in the same order to a AUTOINST instantiating either module.
An example:
module ExampShell (/*AUTOARG*/)
/*AUTOINOUTCOMP("ExampMain")*/
endmodule
module ExampMain (i,o,io)
input i;
output o;
inout io;
endmodule
Typing M-x verilog-auto will make this into:
module ExampShell (/*AUTOARG*/i,o,io)
/*AUTOINOUTCOMP("ExampMain")*/
// Beginning of automatic in/out/inouts (from specific module)
output i;
inout io;
input o;
// End of automatics
endmodule
You may also provide an optional regular expression, in which case only signals matching the regular expression will be included. For example the same expansion will result from only extracting signals starting with i:
/*AUTOINOUTCOMP("ExampMain","^i")*/
verilog-auto-inout-ignore-regexp (customizable variable)
If set, when creating AUTOINOUT list, ignore signals matching this regexp. See the M-x verilog-faq for examples on using this.
verilog-auto-inout-module (function)
Expand AUTOINOUTMODULE statements, as part of M-x verilog-auto.
Take input/output/inout statements from the specified module and insert
into the current module. This is useful for making null templates and
shell modules which need to have identical I/O with another module.
Any I/O which are already defined in this module will not be redefined.
For the complement of this function, see verilog-auto-inout-comp.
Limitations:
-
If placed inside the parenthesis of a module declaration, it creates
Verilog 2001 style, else uses Verilog 1995 style.
Concatenation and outputting partial busses is not supported.
Module names must be resolvable to filenames. See
verilog-auto-inst.Signals are not inserted in the same order as in the original module, though they will appear to be in the same order to a AUTOINST instantiating either module.
An example:
module ExampShell (/*AUTOARG*/)
/*AUTOINOUTMODULE("ExampMain")*/
endmodule
module ExampMain (i,o,io)
input i;
output o;
inout io;
endmodule
Typing M-x verilog-auto will make this into:
module ExampShell (/*AUTOARG*/i,o,io)
/*AUTOINOUTMODULE("ExampMain")*/
// Beginning of automatic in/out/inouts (from specific module)
output o;
inout io;
input i;
// End of automatics
endmodule
You may also provide an optional regular expression, in which case only signals matching the regular expression will be included. For example the same expansion will result from only extracting signals starting with i:
/*AUTOINOUTMODULE("ExampMain","^i")*/
You may also provide an optional second regular expression, in which case only signals which have that pin direction and data type will be included. This matches against everything before the signal name in the declaration, for example against "input" (single bit), "output logic" (direction and type) or "output [1:0]" (direction and implicit type). You also probably want to skip spaces in your regexp.
For example, the below will result in matching the output "o" against the previous example's module:
/*AUTOINOUTMODULE("ExampMain","","^output.*")*/
verilog-auto-input (function)
Expand AUTOINPUT statements, as part of M-x verilog-auto. Make input statements for any input signal into an /*AUTOINST*/ that isn't declared elsewhere inside the module. This is useful for modules which only instantiate other modules.
Limitations:
-
This ONLY detects outputs of AUTOINSTants (see
verilog-read-sub-decls).If placed inside the parenthesis of a module declaration, it creates Verilog 2001 style, else uses Verilog 1995 style.
If any concatenation, or bit-subscripts are missing in the AUTOINSTant's instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
Typedefs must match
verilog-typedef-regexp, which is disabled by default.Signals matching
verilog-auto-input-ignore-regexpare not included.
An example (see verilog-auto-inst for what else is going on here):
module ExampInput (ov,i) output [31:0] ov; /*AUTOINPUT*/ InstModule instName (/*AUTOINST*/); endmodule
Typing M-x verilog-auto will make this into:
module ExampInput (ov,i) output [31:0] ov; /*AUTOINPUT*/ // Beginning of automatic inputs (from unused autoinst inputs) input i; // From inst of inst.v // End of automatics InstModule instName (/*AUTOINST*/ // Outputs .ov (ov[31:0]), // Inputs .i (i)); endmodule
You may also provide an optional regular expression, in which case only signals matching the regular expression will be included. For example the same expansion will result from only extracting inputs starting with i:
/*AUTOINPUT("^i")*/
verilog-auto-input-ignore-regexp (customizable variable)
If set, when creating AUTOINPUT list, ignore signals matching this regexp. See the M-x verilog-faq for examples on using this.
verilog-auto-insert-lisp (function)
Expand AUTOINSERTLISP statements, as part of M-x verilog-auto. The Lisp code provided is called, and the Lisp code calls `insert` to insert text into the current file beginning on the line after the AUTOINSERTLISP.
See also AUTO_LISP, which takes a Lisp expression and evaluates
it during verilog-auto-inst but does not insert any text.
An example:
module ExampInsertLisp; /*AUTOINSERTLISP(my-verilog-insert-hello "world")*/ endmodule// For this example we declare the function in the // module's file itself. Often you'd define it instead // in a site-start.el or .emacs file. /* Local Variables: eval: (defun my-verilog-insert-hello (who) (insert (concat "initial $write(\"hello " who "\");\n"))) End: */
Typing M-x verilog-auto will call my-verilog-insert-hello and expand the above into:
// Beginning of automatic insert lisp
initial $write("hello world");
// End of automatics
You can also call an external program and insert the returned text:
/*AUTOINSERTLISP(insert (shell-command-to-string "echo //hello"))*/ // Beginning of automatic insert lisp //hello // End of automatics
verilog-auto-inst (function)
Expand AUTOINST statements, as part of M-x verilog-auto. Replace the pin connections to an instantiation or interface declaration with ones automatically derived from the module or interface header of the instantiated item.
If verilog-auto-star-expand is set, also expand SystemVerilog .* ports,
and delete them before saving unless verilog-auto-star-save is set.
See verilog-auto-star for more information.
Limitations:
-
Module names must be resolvable to filenames by adding a
verilog-library-extensions, and being found in the same directory, or by changing the variableverilog-library-flagsorverilog-library-directories. Macros `modname are translated through the vh-{name} Emacs variable, if that is not found, it just ignores the `.In templates you must have one signal per line, ending in a ), or ));, and have proper () nesting, including a final ); to end the template.
Typedefs must match
verilog-typedef-regexp, which is disabled by default.SystemVerilog multidimensional input/output has only experimental support.
SystemVerilog .name syntax is used if
verilog-auto-inst-dot-nameis set.Parameters referenced by the instantiation will remain symbolic, unless
verilog-auto-inst-param-valueis set.
For example, first take the submodule InstModule.v:
module InstModule (o,i)
output [31:0] o;
input i;
wire [31:0] o = {32{i}};
endmodule
This is then used in a upper level module:
module ExampInst (o,i) output o; input i; InstModule instName (/*AUTOINST*/); endmodule
Typing M-x verilog-auto will make this into:
module ExampInst (o,i) output o; input i; InstModule instName (/*AUTOINST*/ // Outputs .ov (ov[31:0]), // Inputs .i (i)); endmodule
Where the list of inputs and outputs came from the inst module.
Exceptions:
-
Unless you are instantiating a module multiple times, or the module is
something trivial like an adder, DO NOT CHANGE SIGNAL NAMES ACROSS HIERARCHY.
It just makes for unmaintainable code. To sanitize signal names, try
vrename from URL `http://www.veripool.org'.
When you need to violate this suggestion there are two ways to list exceptions, placing them before the AUTOINST, or using templates.
Any ports defined before the /*AUTOINST*/ are not included in the list of automatics. This is similar to making a template as described below, but is restricted to simple connections just like you normally make. Also note that any signals before the AUTOINST will only be picked up by AUTOWIRE if you have the appropriate // Input or // Output comment, and exactly the same line formatting as AUTOINST itself uses.
InstModule instName
(// Inputs
.i (my_i_dont_mess_with_it),
/*AUTOINST*/
// Outputs
.ov (ov[31:0]));
Templates:
- For multiple instantiations based upon a single template, create a commented out template:
/* InstModule AUTO_TEMPLATE ( .sig3 (sigz[]), ); */
-
Templates go ABOVE the instantiation(s). When an instantiation is
expanded
verilog-modesimply searches up for the closest template. Thus you can have multiple templates for the same module, just alternate between the template for an instantiation and the instantiation itself.The module name must be the same as the name of the module in the instantiation name, and the code "AUTO_TEMPLATE" must be in these exact words and capitalized. Only signals that must be different for each instantiation need to be listed.
Inside a template, a [] in a connection name (with nothing else inside the brackets) will be replaced by the same bus subscript as it is being connected to, or the [] will be removed if it is a single bit signal. Generally it is a good idea to do this for all connections in a template, as then they will work for any width signal, and with AUTOWIRE. See PTL_BUS becoming PTL_BUSNEW below.
If you have a complicated template, set
verilog-auto-inst-template-numbersto see which regexps are matching. Don't leave that mode set after debugging is completed though, it will result in lots of extra differences and merge conflicts.For example:
/* InstModule AUTO_TEMPLATE ( .ptl_bus (ptl_busnew[]), ); */ InstModule ms2m (/*AUTOINST*/);
- Typing M-x verilog-auto will make this into:
InstModule ms2m (/*AUTOINST*/ // Outputs .NotInTemplate (NotInTemplate), .ptl_bus (ptl_busnew[3:0]), // Templated ....
@ Templates:
- It is common to instantiate a cell multiple times, so templates make it trivial to substitute part of the cell name into the connection name.
/* InstName AUTO_TEMPLATE <optional "REGEXP"> ( .sig1 (sigx[@]), .sig2 (sigy[@"(% (+ 1 @) 4)"]), ); */
-
If no regular expression is provided immediately after the AUTO_TEMPLATE
keyword, then the @ character in any connection names will be replaced
with the instantiation number; the first digits found in the cell's
instantiation name.
If a regular expression is provided, the @ character will be replaced with the first () grouping that matches against the cell name. Using a regexp of "\([0-9]+\)" provides identical values for @ as when no regexp is provided. If you use multiple layers of parenthesis, "test\([^0-9]+\)_\([0-9]+\)" would replace @ with non-number characters after test and before _, whereas "\(test\([a-z]+\)_\([0-9]+\)\)" would replace @ with the entire match.
For example:
/* InstModule AUTO_TEMPLATE ( .ptl_mapvalidx (ptl_mapvalid[@]), .ptl_mapvalidp1x (ptl_mapvalid[@"(% (+ 1 @) 4)"]), ); */ InstModule ms2m (/*AUTOINST*/);
- Typing M-x verilog-auto will make this into:
InstModule ms2m (/*AUTOINST*/ // Outputs .ptl_mapvalidx (ptl_mapvalid[2]), .ptl_mapvalidp1x (ptl_mapvalid[3]));
-
Note the @ character was replaced with the 2 from "ms2m".
Alternatively, using a regular expression for @:
/* InstModule AUTO_TEMPLATE "_\([a-z]+\)" ( .ptl_mapvalidx (@_ptl_mapvalid), .ptl_mapvalidp1x (ptl_mapvalid_@), ); */ InstModule ms2_FOO (/*AUTOINST*/); InstModule ms2_BAR (/*AUTOINST*/);
- Typing M-x verilog-auto will make this into:
InstModule ms2_FOO (/*AUTOINST*/ // Outputs .ptl_mapvalidx (FOO_ptl_mapvalid), .ptl_mapvalidp1x (ptl_mapvalid_FOO)); InstModule ms2_BAR (/*AUTOINST*/ // Outputs .ptl_mapvalidx (BAR_ptl_mapvalid), .ptl_mapvalidp1x (ptl_mapvalid_BAR));
Regexp Templates:
- A template entry of the form
.pci_req\([0-9]+\)_l (pci_req_jtag_[\1]),
-
will apply an Emacs style regular expression search for any port beginning
in pci_req followed by numbers and ending in _l and connecting that to
the pci_req_jtag_[] net, with the bus subscript coming from what matches
inside the first set of \( \). Thus pci_req2_l becomes pci_req_jtag_[2].
Since \([0-9]+\) is so common and ugly to read, a @ in the port name does the same thing. (Note a @ in the connection/replacement text is completely different -- still use \1 there!) Thus this is the same as the above template:
.pci_req@_l (pci_req_jtag_[\1]),
- Here's another example to remove the _l, useful when naming conventions specify _ alone to mean active low. Note the use of [] to keep the bus subscript:
.\(.*\)_l (\1_[]),
Lisp Templates:
-
First any regular expression template is expanded.
If the syntax @"( ... )" is found in a connection, the expression in quotes will be evaluated as a Lisp expression, with @ replaced by the instantiation number. The MAPVALIDP1X example above would put @+1 modulo 4 into the brackets. Quote all double-quotes inside the expression with a leading backslash (\"...\"); or if the Lisp template is also a regexp template backslash the backslash quote (\\"...\\").
There are special variables defined that are useful in these Lisp functions:
vl-name Name portion of the input/output port.
vl-bits Bus bits portion of the input/output port ('[2:0]').
vl-mbits Multidimensional array bits for port ('[2:0][3:0]').
vl-width Width of the input/output port ('3' for [2:0]).
May be a (...) expression if bits isn't a constant.
vl-dir Direction of the pin input/output/inout/interface.
vl-modport The modport, if an interface with a modport.
vl-cell-type Module name/type of the cell ('InstModule').
vl-cell-name Instance name of the cell ('instName').
-
Normal Lisp variables may be used in expressions. See
verilog-read-defineswhich can set vh-{definename} variables for use here. Also, any comments of the form:
/*AUTO_LISP(setq foo 1)*/
-
will evaluate any Lisp expression inside the parenthesis between the
beginning of the buffer and the point of the AUTOINST. This allows
functions to be defined or variables to be changed between instantiations.
(See also
verilog-auto-insert-lispif you want the output from your lisp function to be inserted.)Note that when using lisp expressions errors may occur when @ is not a number; you may need to use the standard Emacs Lisp functions `number-to-string' and `string-to-number'.
After the evaluation is completed, @ substitution and [] substitution occur.
For more information see the M-x verilog-faq and forums at URL `http://www.veripool.org'.
verilog-auto-inst-dot-name (customizable variable)
If true, when creating ports with AUTOINST, use .name syntax.
This will use ".port" instead of ".port(port)" when possible.
This is only legal in SystemVerilog files, and will confuse older
simulators. Setting verilog-auto-inst-vector to nil may also
be desirable to increase how often .name will be used.
verilog-auto-inst-param (function)
Expand AUTOINSTPARAM statements, as part of M-x verilog-auto. Replace the parameter connections to an instantiation with ones automatically derived from the module header of the instantiated netlist.
See M-x verilog-auto-inst for limitations, and templates to customize the output.
For example, first take the submodule InstModule.v:
module InstModule (o,i) parameter PAR; endmodule
This is then used in a upper level module:
module ExampInst (o,i) parameter PAR; InstModule #(/*AUTOINSTPARAM*/) instName (/*AUTOINST*/); endmodule
Typing M-x verilog-auto will make this into:
module ExampInst (o,i) output o; input i; InstModule #(/*AUTOINSTPARAM*/ // Parameters .PAR (PAR)); instName (/*AUTOINST*/); endmodule
Where the list of parameter connections come from the inst module.
Templates:
- You can customize the parameter connections using AUTO_TEMPLATEs, just as you would with M-x verilog-auto-inst.
verilog-auto-inst-param-value (customizable variable)
If set, AUTOINST will replace parameters with the parameter value. If nil, leave parameters as symbolic names.
Parameters must be in Verilog 2001 format #(...), and if a parameter is not listed as such there (as when the default value is acceptable), it will not be replaced, and will remain symbolic.
For example, imagine a submodule uses parameters to declare the size of its inputs. This is then used by a upper module:
module InstModule (o,i) parameter WIDTH; input [WIDTH-1:0] i; endmodule#(PARAM(10))module ExampInst; InstModule
instName (/*AUTOINST*/ .i (i[PARAM-1:0]));
Note even though PARAM=10, the AUTOINST has left the parameter as a
symbolic name. If verilog-auto-inst-param-value is set, this will
instead expand to:
module ExampInst; InstModule#(PARAM(10))
instName (/*AUTOINST*/ .i (i[9:0]));
verilog-auto-inst-template-numbers (customizable variable)
If true, when creating templated ports with AUTOINST, add a comment. The comment will add the line number of the template that was used for that port declaration. Setting this aids in debugging, but nil is suggested for regular use to prevent large numbers of merge conflicts.
verilog-auto-inst-vector (customizable variable)
If true, when creating default ports with AUTOINST, use bus subscripts. If nil, skip the subscript when it matches the entire bus as declared in the module (AUTOWIRE signals always are subscripted, you must manually declare the wire to have the subscripts removed.) Setting this to nil may speed up some simulators, but is less general and harder to read, so avoid.
verilog-auto-lineup (customizable variable)
Type of statements to lineup across multiple lines. If 'all' is selected, then all line ups described below are done.
If 'declaration', then just declarations are lined up with any preceding declarations, taking into account widths and the like, so or example the code: reg [31:0] a; reg b; would become reg [31:0] a; reg b;
If 'assignment', then assignments are lined up with any preceding assignments, so for example the code
a_long_variable <= b + c; d = e + f;would become
a_long_variable <= b + c; d = e + f;
In order to speed up editing, large blocks of statements are lined up only when a M-x verilog-pretty-expr is typed; and large blocks of declarations are lineup only when M-x verilog-pretty-declarations is typed.
verilog-auto-newline (customizable variable)
True means automatically newline after semicolons.
verilog-auto-output (function)
Expand AUTOOUTPUT statements, as part of M-x verilog-auto. Make output statements for any output signal from an /*AUTOINST*/ that isn't a input to another AUTOINST. This is useful for modules which only instantiate other modules.
Limitations:
-
This ONLY detects outputs of AUTOINSTants (see
verilog-read-sub-decls).If placed inside the parenthesis of a module declaration, it creates Verilog 2001 style, else uses Verilog 1995 style.
If any concatenation, or bit-subscripts are missing in the AUTOINSTant's instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
Typedefs must match
verilog-typedef-regexp, which is disabled by default.Signals matching
verilog-auto-output-ignore-regexpare not included.
An example (see verilog-auto-inst for what else is going on here):
module ExampOutput (ov,i) input i; /*AUTOOUTPUT*/ InstModule instName (/*AUTOINST*/); endmodule
Typing M-x verilog-auto will make this into:
module ExampOutput (ov,i) input i; /*AUTOOUTPUT*/ // Beginning of automatic outputs (from unused autoinst outputs) output [31:0] ov; // From inst of inst.v // End of automatics InstModule instName (/*AUTOINST*/ // Outputs .ov (ov[31:0]), // Inputs .i (i)); endmodule
You may also provide an optional regular expression, in which case only signals matching the regular expression will be included. For example the same expansion will result from only extracting outputs starting with ov:
/*AUTOOUTPUT("^ov")*/
verilog-auto-output-every (function)
Expand AUTOOUTPUTEVERY statements, as part of M-x verilog-auto. Make output statements for any signals that aren't primary inputs or outputs already. This makes every signal in the design a output. This is useful to get Synopsys to preserve every signal in the design, since it won't optimize away the outputs.
An example:
module ExampOutputEvery (o,i,tempa,tempb) output o; input i; /*AUTOOUTPUTEVERY*/ wire tempa = i; wire tempb = tempa; wire o = tempb; endmodule
Typing M-x verilog-auto will make this into:
module ExampOutputEvery (o,i,tempa,tempb) output o; input i; /*AUTOOUTPUTEVERY*/ // Beginning of automatic outputs (every signal) output tempb; output tempa; // End of automatics wire tempa = i; wire tempb = tempa; wire o = tempb; endmodule
verilog-auto-output-ignore-regexp (customizable variable)
If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. See the M-x verilog-faq for examples on using this.
verilog-auto-reg (function)
Expand AUTOREG statements, as part of M-x verilog-auto. Make reg statements for any output that isn't already declared, and isn't a wire output from a block.
Limitations:
-
This ONLY detects outputs of AUTOINSTants (see
verilog-read-sub-decls).This does NOT work on memories, declare those yourself.
An example:
module ExampReg (o,i) output o; input i; /*AUTOREG*/ always o = i; endmodule
Typing M-x verilog-auto will make this into:
module ExampReg (o,i) output o; input i; /*AUTOREG*/ // Beginning of automatic regs (for this module's undeclared outputs) reg o; // End of automatics always o = i; endmodule
verilog-auto-reg-input (function)
Expand AUTOREGINPUT statements, as part of M-x verilog-auto. Make reg statements instantiation inputs that aren't already declared. This is useful for making a top level shell for testing the module that is to be instantiated.
Limitations:
-
This ONLY detects inputs of AUTOINSTants (see
verilog-read-sub-decls).This does NOT work on memories, declare those yourself.
An example (see verilog-auto-inst for what else is going on here):
module ExampRegInput (o,i)
output o;
input i;
/*AUTOREGINPUT*/
InstModule instName
(/*AUTOINST*/);
endmodule
Typing M-x verilog-auto will make this into:
module ExampRegInput (o,i)
output o;
input i;
/*AUTOREGINPUT*/
// Beginning of automatic reg inputs (for undeclared ...
reg [31:0] iv; // From inst of inst.v
// End of automatics
InstModule instName
(/*AUTOINST*/
// Outputs
.o (o[31:0]),
// Inputs
.iv (iv));
endmodule
verilog-auto-reset (function)
Expand AUTORESET statements, as part of M-x verilog-auto. Replace the /*AUTORESET*/ comment with code to initialize all registers set elsewhere in the always block.
Limitations:
-
AUTORESET will not clear memories.
AUTORESET uses <= if there are any <= assignments in the block, else it uses =.
/*AUTORESET*/ presumes that any signals mentioned between the previous begin/case/if statement and the AUTORESET comment are being reset manually and should not be automatically reset. This includes omitting any signals used on the right hand side of assignments.
By default, AUTORESET will include the width of the signal in the autos,
this is a recent change. To control this behavior, see
verilog-auto-reset-widths.
AUTORESET ties signals to deasserted, which is presumed to be zero.
Signals that match verilog-active-low-regexp will be deasserted by tieing
them to a one.
An example:
always @(posedge clk or negedge reset_l) begin
if (!reset_l) begin
c <= 1;
/*AUTORESET*/
end
else begin
a <= in_a;
b <= in_b;
c <= in_c;
end
end
Typing M-x verilog-auto will make this into:
always @(posedge core_clk or negedge reset_l) begin
if (!reset_l) begin
c <= 1;
/*AUTORESET*/
// Beginning of autoreset for uninitialized flops
a <= 0;
b <= 0;
// End of automatics
end
else begin
a <= in_a;
b <= in_b;
c <= in_c;
end
end
verilog-auto-reset-widths (customizable variable)
If true, AUTORESET should determine the width of signals. This is then used to set the width of the zero (32'h0 for example). This is required by some lint tools that aren't smart enough to ignore widths of the constant zero. This may result in ugly code when parameters determine the MSB or LSB of a signal inside an AUTORESET.
verilog-auto-save-compile (function)
Update automatics with M-x verilog-auto, save the buffer, and compile.
verilog-auto-sense (function)
Expand AUTOSENSE statements, as part of M-x verilog-auto.
Replace the always (/*AUTOSENSE*/) sensitivity list (/*AS*/ for short)
with one automatically derived from all inputs declared in the always
statement. Signals that are generated within the same always block are NOT
placed into the sensitivity list (see verilog-auto-sense-include-inputs).
Long lines are split based on the `fill-column', see M-x set-fill-column.
Limitations:
- Verilog does not allow memories (multidimensional arrays) in sensitivity lists. AUTOSENSE will thus exclude them, and add a /*memory or*/ comment.
Constant signals:
- AUTOSENSE cannot always determine if a `define is a constant or a signal (it could be in a include file for example). If a `define or other signal is put into the AUTOSENSE list and is not desired, use the AUTO_CONSTANT declaration anywhere in the module (parenthesis are required):
/* AUTO_CONSTANT ( `this_is_really_constant_dont_autosense_it ) */
- Better yet, use a parameter, which will be understood to be constant automatically.
OOps!
- If AUTOSENSE makes a mistake, please report it. (First try putting a begin/end after your always!) As a workaround, if a signal that shouldn't be in the sensitivity list was, use the AUTO_CONSTANT above. If a signal should be in the sensitivity list wasn't, placing it before the /*AUTOSENSE*/ comment will prevent it from being deleted when the autos are updated (or added if it occurs there already).
An example:
always @ (/*AS*/) begin /* AUTO_CONSTANT (`constant) */ outin = ina | inb | `constant; out = outin; end
Typing M-x verilog-auto will make this into:
always @ (/*AS*/ina or inb) begin /* AUTO_CONSTANT (`constant) */ outin = ina | inb | `constant; out = outin; end
Note in Verilog 2001, you can often get the same result from the new @* operator. (This was added to the language in part due to AUTOSENSE!)
always @* begin outin = ina | inb | `constant; out = outin; end
verilog-auto-sense-include-inputs (customizable variable)
If true, AUTOSENSE should include all inputs. If nil, only inputs that are NOT output signals in the same block are included.
verilog-auto-star (function)
Expand SystemVerilog .* pins, as part of M-x verilog-auto.
If verilog-auto-star-expand is set, .* pins are treated if they were
AUTOINST statements, otherwise they are ignored. For safety, Verilog mode
will also ignore any .* that are not last in your pin list (this prevents
it from deleting pins following the .* when it expands the AUTOINST.)
On writing your file, unless verilog-auto-star-save is set, any
non-templated expanded pins will be removed. You may do this at any time
with M-x verilog-delete-auto-star-implicit.
If you are converting a module to use .* for the first time, you may wish to use M-x verilog-inject-auto and then replace the created AUTOINST with .*.
See verilog-auto-inst for examples, templates, and more information.
verilog-auto-star-expand (customizable variable)
Non-nil indicates to expand a SystemVerilog .* instance ports.
They will be expanded in the same way as if there was a AUTOINST in the
instantiation. See also verilog-auto-star and verilog-auto-star-save.
verilog-auto-star-save (customizable variable)
Non-nil indicates to save to disk SystemVerilog .* instance expansions.
A nil value indicates direct connections will be removed before saving.
Only meaningful to those created due to verilog-auto-star-expand being set.
Instead of setting this, you may want to use /*AUTOINST*/, which will always be saved.
verilog-auto-tieoff (function)
Expand AUTOTIEOFF statements, as part of M-x verilog-auto. Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output signals to deasserted.
/*AUTOTIEOFF*/ is used to make stub modules; modules that have the same input/output list as another module, but no internals. Specifically, it finds all outputs in the module, and if that input is not otherwise declared as a register or wire, creates a tieoff.
AUTORESET ties signals to deasserted, which is presumed to be zero.
Signals that match verilog-active-low-regexp will be deasserted by tieing
them to a one.
You can add signals you do not want included in AUTOTIEOFF with
verilog-auto-tieoff-ignore-regexp.
An example of making a stub for another module:
module ExampStub (/*AUTOINST*/);
/*AUTOINOUTMODULE("Foo")*/
/*AUTOTIEOFF*/
// verilator lint_off UNUSED
wire _unused_ok = &{1'b0,
/*AUTOUNUSED*/
1'b0};
// verilator lint_on UNUSED
endmodule
Typing M-x verilog-auto will make this into:
module ExampStub (/*AUTOINST*/...);
/*AUTOINOUTMODULE("Foo")*/
// Beginning of autotieoff
output [2:0] foo;
// End of automatics
/*AUTOTIEOFF*/
// Beginning of autotieoff
wire [2:0] foo = 3'b0;
// End of automatics
...
endmodule
verilog-auto-tieoff-ignore-regexp (customizable variable)
If set, when creating AUTOTIEOFF list, ignore signals matching this regexp. See the M-x verilog-faq for examples on using this.
verilog-auto-unused (function)
Expand AUTOUNUSED statements, as part of M-x verilog-auto. Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused input and inout signals.
/*AUTOUNUSED*/ is used to make stub modules; modules that have the same input/output list as another module, but no internals. Specifically, it finds all inputs and inouts in the module, and if that input is not otherwise used, adds it to a comma separated list.
The comma separated list is intended to be used to create a _unused_ok signal. Using the exact name "_unused_ok" for name of the temporary signal is recommended as it will insure maximum forward compatibility, it also makes lint warnings easy to understand; ignore any unused warnings with "unused" in the signal name.
To reduce simulation time, the _unused_ok signal should be forced to a constant to prevent wiggling. The easiest thing to do is use a reduction-and with 1'b0 as shown.
This way all unused signals are in one place, making it convenient to add your tool's specific pragmas around the assignment to disable any unused warnings.
You can add signals you do not want included in AUTOUNUSED with
verilog-auto-unused-ignore-regexp.
An example of making a stub for another module:
module ExampStub (/*AUTOINST*/);
/*AUTOINOUTMODULE("Examp")*/
/*AUTOTIEOFF*/
// verilator lint_off UNUSED
wire _unused_ok = &{1'b0,
/*AUTOUNUSED*/
1'b0};
// verilator lint_on UNUSED
endmodule
Typing M-x verilog-auto will make this into:
...
// verilator lint_off UNUSED
wire _unused_ok = &{1'b0,
/*AUTOUNUSED*/
// Beginning of automatics
unused_input_a,
unused_input_b,
unused_input_c,
// End of automatics
1'b0};
// verilator lint_on UNUSED
endmodule
verilog-auto-unused-ignore-regexp (customizable variable)
If set, when creating AUTOUNUSED list, ignore signals matching this regexp. See the M-x verilog-faq for examples on using this.
verilog-auto-wire (function)
Expand AUTOWIRE statements, as part of M-x verilog-auto. Make wire statements for instantiations outputs that aren't already declared.
Limitations:
-
This ONLY detects outputs of AUTOINSTants (see
verilog-read-sub-decls), and all busses must have widths, such as those from AUTOINST, or using [] in AUTO_TEMPLATEs.This does NOT work on memories or SystemVerilog .name connections, declare those yourself.
Verilog mode will add "Couldn't Merge" comments to signals it cannot determine how to bus together. This occurs when you have ports with non-numeric or non-sequential bus subscripts. If Verilog mode mis-guessed, you'll have to declare them yourself.
An example (see verilog-auto-inst for what else is going on here):
module ExampWire (o,i)
output o;
input i;
/*AUTOWIRE*/
InstModule instName
(/*AUTOINST*/);
endmodule
Typing M-x verilog-auto will make this into:
module ExampWire (o,i) output o; input i; /*AUTOWIRE*/ // Beginning of automatic wires wire [31:0] ov; // From inst of inst.v // End of automatics InstModule instName (/*AUTOINST*/ // Outputs .ov (ov[31:0]), // Inputs .i (i)); wire o = | ov; endmodule
verilog-before-auto-hook (customizable variable)
Hook run before verilog-mode updates AUTOs.
verilog-before-delete-auto-hook (customizable variable)
Hook run before verilog-mode deletes AUTOs.
verilog-beg-of-defun (function)
Move backward to the beginning of the current function or procedure.
verilog-case-indent (customizable variable)
Indentation for case statements.
verilog-cexp-indent (customizable variable)
Indentation of Verilog statements split across lines.
verilog-comment-region (function)
Put the region into a Verilog comment. The comments that are in this area are "deformed": `*)' becomes `!(*' and `}' becomes `!{'. These deformed comments are returned to normal if you use M-x verilog-uncomment-region to undo the commenting.
The commented area starts with verilog-exclude-str-start, and ends with
verilog-exclude-str-end. But if you change these variables,
M-x verilog-uncomment-region won't recognize the comments.
verilog-compiler (customizable variable)
Program and arguments to use to compile Verilog source.
Depending on the verilog-set-compile-command, this may be invoked when
you type M-x compile. When the compile completes, M-x next-error will take
you to the next lint error.
verilog-complete-word (function)
Complete word at current point.
(See also verilog-toggle-completions, verilog-type-keywords,
and verilog-separator-keywords.)
verilog-coverage (customizable variable)
Program and arguments to use to annotate for coverage Verilog source.
Depending on the verilog-set-compile-command, this may be invoked when
you type M-x compile. When the compile completes, M-x next-error will take
you to the next lint error.
verilog-current-flags (function)
Convert verilog-library-flags and similar variables to command line.
Used for __FLAGS__ in verilog-expand-command.
verilog-delete-auto (function)
Delete the automatic outputs, regs, and wires created by M-x verilog-auto. Use M-x verilog-auto to re-insert the updated AUTOs.
The hooks verilog-before-delete-auto-hook and verilog-delete-auto-hook are
called before and after this function, respectively.
verilog-delete-auto-hook (customizable variable)
Hook run after verilog-mode deletes AUTOs.
verilog-delete-auto-star-implicit (function)
Delete all .* implicit connections created by verilog-auto-star.
This function will be called automatically at save unless
verilog-auto-star-save is set, any non-templated expanded pins will be
removed.
verilog-end-of-defun (function)
Move forward to the end of the current function or procedure.
verilog-expand-command (function)
Replace meta-information in COMMAND and return it.
Where __FLAGS__ appears in the string verilog-current-flags
will be substituted. Where __FILE__ appears in the string, the
current buffer's file-name, without the directory portion, will
be substituted.
verilog-faq (function)
Tell the user their current version, and where to get the FAQ etc.
verilog-header (function)
Insert a standard Verilog file header.
See also verilog-sk-header for an alternative format.
verilog-indent-begin-after-if (customizable variable)
If true, indent begin statements following if, else, while, for and repeat. Otherwise, line them up.
verilog-indent-level (customizable variable)
Indentation of Verilog statements with respect to containing block.
verilog-indent-level-behavioral (customizable variable)
Absolute indentation of first begin in a task or function block. Set to 0 to get such code to start at the left side of the screen.
verilog-indent-level-declaration (customizable variable)
Indentation of declarations with respect to containing block. Set to 0 to get them list right under containing block.
verilog-indent-level-directive (customizable variable)
Indentation to add to each level of `ifdef declarations. Set to 0 to have all directives start at the left side of the screen.
verilog-indent-level-module (customizable variable)
Indentation of Module level Verilog statements (eg always, initial). Set to 0 to get initial and always statements lined up on the left side of your screen.
verilog-inject-auto (function)
Examine legacy non-AUTO code and insert AUTOs in appropriate places.
Any always @ blocks with sensitivity lists that match computed lists will be replaced with /*AS*/ comments.
Any cells will get /*AUTOINST*/ added to the end of the pin list. Pins with have identical names will be deleted.
Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to support adding new ports. You may wish to delete older ports yourself.
For example:
module ExampInject (i, o);
input i;
input j;
output o;
always @ (i or j)
o = i | j;
InstModule instName
(.foobar(baz),
j(j));
endmodule
Typing M-x verilog-inject-auto will make this into:
module ExampInject (i, o/*AUTOARG*/
// Inputs
j);
input i;
output o;
always @ (/*AS*/i or j)
o = i | j;
InstModule instName
(.foobar(baz),
/*AUTOINST*/
// Outputs
j(j));
endmodule
verilog-insert-block (function)
Insert Verilog begin ... end; block in the code with right indentation.
verilog-label-be (function)
Label matching begin ... end, fork ... join and case ... endcase statements. With ARG, first kill any existing labels.
verilog-library-directories (customizable variable)
List of directories when looking for files for /*AUTOINST*/. The directory may be relative to the current file, or absolute. Environment variables are also expanded in the directory names. Having at least the current directory is a good idea.
You might want these defined in each file; put at the *END* of your file something like:
// Local Variables:
// verilog-library-directories:("." "subdir" "subdir2")
// End:
Verilog-mode attempts to detect changes to this local variable, but they are only insured to be correct when the file is first visited. Thus if you have problems, use M-x find-alternate-file RET to have these take effect.
See also verilog-library-flags, verilog-library-files
and verilog-library-extensions.
verilog-library-extensions (customizable variable)
List of extensions to use when looking for files for /*AUTOINST*/.
See also verilog-library-flags, verilog-library-directories.
verilog-library-files (customizable variable)
List of files to search for modules. AUTOINST will use this when it needs to resolve a module name. This is a complete path, usually to a technology file with many standard cells defined in it.
You might want these defined in each file; put at the *END* of your file something like:
// Local Variables:
// verilog-library-files:("/some/path/technology.v" "/some/path/tech2.v")
// End:
Verilog-mode attempts to detect changes to this local variable, but they are only insured to be correct when the file is first visited. Thus if you have problems, use M-x find-alternate-file RET to have these take effect.
See also verilog-library-flags, verilog-library-directories.
verilog-library-flags (customizable variable)
List of standard Verilog arguments to use for /*AUTOINST*/.
These arguments are used to find files for verilog-auto, and match
the flags accepted by a standard Verilog-XL simulator.
-f filename Reads more verilog-library-flags from the filename.
+incdir+dir Adds the directory to verilog-library-directories.
-Idir Adds the directory to verilog-library-directories.
-y dir Adds the directory to verilog-library-directories.
+libext+.v Adds the extensions to verilog-library-extensions.
-v filename Adds the filename to verilog-library-files.
filename Adds the filename to verilog-library-files.
This is not recommended, -v is a better choice.
You might want these defined in each file; put at the *END* of your file something like:
// Local Variables:
// verilog-library-flags:("-y dir -y otherdir")
// End:
Verilog-mode attempts to detect changes to this local variable, but they are only insured to be correct when the file is first visited. Thus if you have problems, use M-x find-alternate-file RET to have these take effect.
See also the variables mentioned above.
verilog-linter (customizable variable)
Unix program and arguments to call to run a lint checker on Verilog source.
Depending on the verilog-set-compile-command, this may be invoked when
you type M-x compile. When the compile completes, M-x next-error will take
you to the next lint error.
verilog-mark-defun (function)
Mark the current Verilog function (or procedure). This puts the mark at the end, and point at the beginning.
verilog-minimum-comment-distance (customizable variable)
Minimum distance (in lines) between begin and end required before a comment. Setting this variable to zero results in every end acquiring a comment; the default avoids too many redundant comments in tight quarters.
verilog-mode-hook (customizable variable)
Hook run after Verilog mode is loaded.
verilog-mode-map (variable)
Keymap used in Verilog mode.
verilog-preprocessor (customizable variable)
vppreproc __FLAGS__ __FILE__
verilog-pretty-declarations (function)
Line up declarations around point. Be verbose about progress unless optional QUIET set.
verilog-pretty-expr (function)
Line up expressions around point, optionally QUIET with regexp MYRE.
verilog-read-defines (function)
Read `defines and parameters for the current file, or optional FILENAME.
If the filename is provided, verilog-library-flags will be used to
resolve it. If optional RECURSE is non-nil, recurse through `includes.
Parameters must be simple assignments to constants, or have their own "parameter" label rather than a list of parameters. Thus:
parameter X = 5, Y = 10; // Ok
parameter X = {1'b1, 2'h2}; // Ok
parameter X = {1'b1, 2'h2}, Y = 10; // Bad, make into 2 parameter lines
Defines must be simple text substitutions, one on a line, starting at the beginning of the line. Any ifdefs or multiline comments around the define are ignored.
Defines are stored inside Emacs variables using the name vh-{definename}.
This function is useful for setting vh-* variables. The file variables
feature can be used to set defines that verilog-mode can see; put at the
*END* of your file something like:
// Local Variables:
// vh-macro:"macro_definition"
// End:
If macros are defined earlier in the same file and you want their values, you can read them automatically (provided `enable-local-eval' is on):
// Local Variables:
// eval:(verilog-read-defines)
// eval:(verilog-read-defines "group_standard_includes.v")
// End:
Note these are only read when the file is first visited, you must use M-x find-alternate-file RET to have these take effect after editing them!
If you want to disable the "Process `eval' or hook local variables" warning message, you need to add to your .emacs file:
(setq enable-local-eval t)
verilog-read-includes (function)
Read `includes for the current file.
This will find all of the `includes which are at the beginning of lines,
ignoring any ifdefs or multiline comments around them.
verilog-read-defines is then performed on the current and each included
file.
It is often useful put at the *END* of your file something like:
// Local Variables:
// eval:(verilog-read-defines)
// eval:(verilog-read-includes)
// End:
Note includes are only read when the file is first visited, you must use M-x find-alternate-file RET to have these take effect after editing them!
It is good to get in the habit of including all needed files in each .v file that needs it, rather than waiting for compile time. This will aid this process, Verilint, and readability. To prevent defining the same variable over and over when many modules are compiled together, put a test around the inside each include file:
foo.v (a include):
`ifdef _FOO_V // include if not already included `else `define _FOO_V ... contents of file `endif // _FOO_V
verilog-read-sub-decls (function)
Internally parse signals going to modules under this module. Return a array of [ outputs inouts inputs ] signals for modules that are instantiated in this module. For example if declare A A (.B(SIG)) and SIG is a output, then SIG will be included in the list.
This only works on instantiations created with /*AUTOINST*/ converted by M-x verilog-auto-inst. Otherwise, it would have to read in the whole component library to determine connectivity of the design.
One work around for this problem is to manually create // Inputs and // Outputs comments above subcell signals, for example:
module ModuleName ( // Outputs .out (out), // Inputs .in (in));
verilog-set-compile-command (function)
Function to compute shell command to compile Verilog.
This reads verilog-tool and sets `compile-command'. This specifies the
program that executes when you type M-x compile or
M-x verilog-auto-save-compile.
By default verilog-tool uses a Makefile if one exists in the
current directory. If not, it is set to the verilog-linter,
verilog-compiler, verilog-coverage, verilog-preprocessor,
or verilog-simulator variables, as selected with the Verilog ->
"Choose Compilation Action" menu.
You should set verilog-tool or the other variables to the path and
arguments for your Verilog simulator. For example:
"vcs -p123 -O"
or a string like:
"(cd /tmp; surecov %s)".
In the former case, the path to the current buffer is concat'ed to the
value of verilog-tool; in the later, the path to the current buffer is
substituted for the %s.
Where __FLAGS__ appears in the string verilog-current-flags
will be substituted.
Where __FILE__ appears in the string, the variable `buffer-file-name' of the current buffer, without the directory portion, will be substituted.
verilog-simulator (customizable variable)
Program and arguments to use to interpret Verilog source.
Depending on the verilog-set-compile-command, this may be invoked when
you type M-x compile. When the compile completes, M-x next-error will take
you to the next lint error.
verilog-sk-define-signal (function)
Insert a definition of signal under point at top of module.
verilog-sk-header (function)
Insert a descriptive header at the top of the file.
See also verilog-header for an alternative format.
verilog-star-comment (function)
Insert Verilog star comment at point.
verilog-tab-always-indent (customizable variable)
True means TAB should always re-indent the current line. A nil value means TAB will only reindent when at the beginning of the line.
verilog-toggle-completions (variable)
True means M-x verilog-complete-word should try all possible completions one by one. Repeated use of M-x verilog-complete-word will show you all of them. Normally, when there is more than one possible completion, it displays a list of all possible completions.
verilog-tool (variable)
Which tool to use for building compiler-command.
Either nil, `verilog-linter, `verilog-compiler,
`verilog-coverage, `verilog-preprocessor, or `verilog-simulator.
Alternatively use the "Choose Compilation Action" menu. See
verilog-set-compile-command for more information.
verilog-typedef-regexp (customizable variable)
If non-nil, regular expression that matches Verilog-2001 typedef names. For example, "_t$" matches typedefs named with _t, as in the C language.
verilog-uncomment-region (function)
Uncomment a commented area; change deformed comments back to normal.
This command does nothing if the pointer is not in a commented
area. See also verilog-comment-region.
![[logo]](/img/veripool_small.png)