From 4262e13a095ff6b1d9738bf3eef7098cefcf3958 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 15 Jun 2019 08:16:05 -0400 Subject: [PATCH] Clean up verilog-mode.el documentation examples to match behavior. * verilog-mode.el (verilog-auto, verilog-auto-arg) (verilog-auto-ascii-enum, verilog-auto-inout) (verilog-auto-inout-comp, verilog-auto-inout-in) (verilog-auto-inout-modport, verilog-auto-inout-module) (verilog-auto-inout-param, verilog-auto-input) (verilog-auto-insert-lisp, verilog-auto-inst) (verilog-auto-inst-param, verilog-auto-inst-param-value) (verilog-auto-output, verilog-auto-output-every, verilog-auto-reg) (verilog-auto-reg-input, verilog-auto-reset, verilog-auto-sense) (verilog-auto-tieoff, verilog-auto-undef, verilog-auto-unused) (verilog-auto-wire, verilog-inject-auto, verilog-read-sub-decls): Clean up documentation examples to match behavior. --- lisp/progmodes/verilog-mode.el | 1035 ++++++++++++++++---------------- 1 file changed, 517 insertions(+), 518 deletions(-) diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index eeed4c0d7c8..8ddd262af3e 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el @@ -1171,7 +1171,7 @@ inputs. This is then used by an upper module: output OUT_t o; endmodule - module ExampInst; + module ExampParamVal1; /*AUTOOUTPUT*/ // Beginning of automatic outputs output OUT_t o; @@ -1182,8 +1182,13 @@ inputs. This is then used by an upper module: ,.OUT_t(upper_t)) instName (/*AUTOINST*/ - .i (i[WIDTH-1:0]), - .o (o)); + .o (o), + .i (i[WIDTH-1:0])); + endmodule + + // Local Variables: + // verilog-typedef-regexp: \"_t$\" + // End: Note even though WIDTH=10, the AUTOINST has left the parameter as a symbolic name. Likewise the OUT_t is preserved as the name @@ -1192,7 +1197,7 @@ from the instantiated module. If `verilog-auto-inst-param-value' is set, this will instead expand to: - module ExampInst; + module ExampParamVal1; /*AUTOOUTPUT*/ // Beginning of automatic outputs output upper_t o; @@ -1203,8 +1208,8 @@ instead expand to: ,.OUT_t(upper_t)) instName (/*AUTOINST*/ - .i (i[9:0]), - .o (o)); + .o (o), + .i (i[9:0])); Note that the instantiation now has \"i[9:0]\" as the WIDTH was expanded. Likewise the data type of \"o\" in the AUTOOUTPUT @@ -8977,11 +8982,11 @@ 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));" + submod SubModuleName ( + // Outputs + .out (out), + // Inputs + .in (in));" (save-excursion (let ((end-mod-point (verilog-get-end-of-defun)) st-point end-inst-point par-values @@ -10848,32 +10853,33 @@ 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 + 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 \\[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 + .j(j)); + endmodule + +Typing \\[verilog-inject-auto] (with an appropriate submodule not +shown) 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" + /*AUTOINST*/ + // Outputs + j(j)); + endmodule" (interactive) (verilog-auto t)) @@ -11184,22 +11190,21 @@ Limitations: For example: - module ExampArg (/*AUTOARG*/); - input i; - output o; - endmodule + module ExampArg (/*AUTOARG*/); + input i; + output o; + endmodule Typing \\[verilog-auto] will make this into: - module ExampArg (/*AUTOARG*/ - // Outputs - o, - // Inputs - i - ); - input i; - output o; - endmodule + 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 @@ -11548,33 +11553,33 @@ Limitations: 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 + module InstModule (o,i); + output [31:0] o; + input i; + wire [31:0] o = {32{i}}; + endmodule This is then used in an upper level module: - module ExampInst (o,i); - output o; - input i; - InstModule instName - (/*AUTOINST*/); - endmodule + module ExampInst (o,i); + output o; + input i; + InstModule instName + (/*AUTOINST*/); + endmodule Typing \\[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 + module ExampInst (o,i); + output o; + input i; + InstModule instName + (/*AUTOINST*/ + // Outputs + .o (o[31:0]), + // Inputs + .i (i)); + endmodule Where the list of inputs and outputs came from the inst module. @@ -11595,12 +11600,12 @@ Exceptions: you have the appropriate // Input or // Output comment, and exactly the same line formatting as AUTOINST itself uses. - InstModule instName + InstModule instName (// Inputs - .i (my_i_dont_mess_with_it), - /*AUTOINST*/ - // Outputs - .ov (ov[31:0])); + .i (my_i_dont_mess_with_it), + /*AUTOINST*/ + // Outputs + .o (o[31:0])); Templates: @@ -11608,10 +11613,10 @@ Templates: For multiple instantiations based upon a single template, create a commented out template: - /* InstModule AUTO_TEMPLATE ( - .sig3 (sigz[]), - ); - */ + /* InstModule AUTO_TEMPLATE ( + .sig3 (sigz[]), + ); + */ Templates go ABOVE the instantiation(s). When an instantiation is expanded `verilog-mode' simply searches up for the closest template. @@ -11655,19 +11660,19 @@ Templates: For example: - /* InstModule AUTO_TEMPLATE ( - .ptl_bus (ptl_busnew[]), - ); - */ - InstModule ms2m (/*AUTOINST*/); + /* InstModule AUTO_TEMPLATE ( + .ptl_bus (ptl_busnew[]), + ); + */ + InstModule ms2m (/*AUTOINST*/); Typing \\[verilog-auto] will make this into: - InstModule ms2m (/*AUTOINST*/ - // Outputs - .NotInTemplate (NotInTemplate), - .ptl_bus (ptl_busnew[3:0]), // Templated - .... + InstModule ms2m (/*AUTOINST*/ + // Outputs + .NotInTemplate (NotInTemplate), + .ptl_bus (ptl_busnew[3:0]), // Templated + .... Multiple Module Templates: @@ -11675,13 +11680,13 @@ Multiple Module Templates: The same template lines can be applied to multiple modules with the syntax as follows: - /* InstModuleA AUTO_TEMPLATE - InstModuleB AUTO_TEMPLATE - InstModuleC AUTO_TEMPLATE - InstModuleD AUTO_TEMPLATE ( - .ptl_bus (ptl_busnew[]), - ); - */ + /* InstModuleA AUTO_TEMPLATE + InstModuleB AUTO_TEMPLATE + InstModuleC AUTO_TEMPLATE + InstModuleD AUTO_TEMPLATE ( + .ptl_bus (ptl_busnew[]), + ); + */ Note there is only one AUTO_TEMPLATE opening parenthesis. @@ -11690,11 +11695,11 @@ Multiple Module 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 ( - .sig1 (sigx[@]), - .sig2 (sigy[@\"(% (+ 1 @) 4)\"]), - ); - */ + /* InstName AUTO_TEMPLATE ( + .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 @@ -11712,49 +11717,49 @@ Multiple Module Templates: For example: - /* InstModule AUTO_TEMPLATE ( - .ptl_mapvalidx (ptl_mapvalid[@]), - .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]), - ); - */ - InstModule ms2m (/*AUTOINST*/); + /* InstModule AUTO_TEMPLATE ( + .ptl_mapvalidx (ptl_mapvalid[@]), + .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]), + ); + */ + InstModule ms2m (/*AUTOINST*/); Typing \\[verilog-auto] will make this into: - InstModule ms2m (/*AUTOINST*/ - // Outputs - .ptl_mapvalidx (ptl_mapvalid[2]), - .ptl_mapvalidp1x (ptl_mapvalid[3])); + 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*/); + /* InstModule AUTO_TEMPLATE \"_\\([a-z]+\\)\" ( + .ptl_mapvalidx (@_ptl_mapvalid), + .ptl_mapvalidp1x (ptl_mapvalid_@), + ); + */ + InstModule ms2_FOO (/*AUTOINST*/); + InstModule ms2_BAR (/*AUTOINST*/); Typing \\[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)); + 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]), + .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 @@ -11766,13 +11771,13 @@ Regexp Templates: completely different -- still use \\1 there!) Thus this is the same as the above template: - .pci_req@_l (pci_req_jtag_[\\1]), + .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_[]), + .\\(.*\\)_l (\\1_[]), Lisp Templates: @@ -11788,21 +11793,21 @@ Lisp Templates: 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]). + 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'). + 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-defines' which can set vh-{definename} variables for use here. Also, any comments of the form: - /*AUTO_LISP(setq foo 1)*/ + /*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 @@ -11932,28 +11937,27 @@ output. For example, first take the submodule InstModule.v: - module InstModule (o,i); - parameter PAR; - endmodule + module InstModule (o,i); + parameter PAR; + endmodule This is then used in an upper level module: - module ExampInst (o,i); - parameter PAR; - InstModule #(/*AUTOINSTPARAM*/) - instName (/*AUTOINST*/); - endmodule + module ExampInstParam (o,i); + parameter PAR; + InstModule #(/*AUTOINSTPARAM*/) + instName (/*AUTOINST*/); + endmodule Typing \\[verilog-auto] will make this into: - module ExampInst (o,i); - output o; - input i; - InstModule #(/*AUTOINSTPARAM*/ - // Parameters - .PAR (PAR)); - instName (/*AUTOINST*/); - endmodule + module ExampInstParam (o,i); + parameter PAR; + InstModule #(/*AUTOINSTPARAM*/ + // Parameters + .PAR (PAR)) + instName (/*AUTOINST*/); + endmodule Where the list of parameter connections come from the inst module. @@ -12035,24 +12039,24 @@ Limitations: An example: - module ExampReg (o,i); - output o; - input i; - /*AUTOREG*/ - always o = i; - endmodule + module ExampReg (o,i); + output o; + input i; + /*AUTOREG*/ + always o = i; + endmodule Typing \\[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" + module ExampReg (o,i); + output o; + input i; + /*AUTOREG*/ + // Beginning of automatic regs + reg o; + // End of automatics + always o = i; + endmodule" (save-excursion ;; Point must be at insertion point. (let* ((indent-pt (current-indentation)) @@ -12093,30 +12097,27 @@ Limitations: An example (see `verilog-auto-inst' for what else is going on here): - module ExampRegInput (o,i); - output o; - input i; - /*AUTOREGINPUT*/ + module InstModule (input i); + endmodule + + module ExampRegInput (); + /*AUTOREGINPUT*/ InstModule instName (/*AUTOINST*/); - endmodule + endmodule Typing \\[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 + module ExampRegInput (); + /*AUTOREGINPUT*/ + // Beginning of automatic reg inputs + reg i; // To instName of InstModule.v + // End of automatics + InstModule instName (/*AUTOINST*/ - // Outputs - .o (o[31:0]), - // Inputs - .iv (iv)); - endmodule" + // Inputs + .i (i)); + endmodule" (save-excursion ;; Point must be at insertion point. (let* ((indent-pt (current-indentation)) @@ -12183,31 +12184,29 @@ Limitations: An example (see `verilog-auto-inst' for what else is going on here): - module ExampWire (o,i); - output o; - input i; - /*AUTOWIRE*/ + module ExampWire (i); + input i; + /*AUTOWIRE*/ InstModule instName - (/*AUTOINST*/); - endmodule + (/*AUTOINST*/); + endmodule Typing \\[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" + module ExampWire (i); + input i; + /*AUTOWIRE*/ + // Beginning of automatic wires + wire [31:0] o; // From instName of InstModule.v + // End of automatics + InstModule instName + (/*AUTOINST*/ + // Outputs + .o (o[31:0]), + // Inputs + .i (i)); + wire o = | ov; + endmodule" (save-excursion ;; Point must be at insertion point. (let* ((indent-pt (current-indentation)) @@ -12254,28 +12253,29 @@ Limitations: An example (see `verilog-auto-inst' for what else is going on here): - module ExampOutput (ov,i); - input i; - /*AUTOOUTPUT*/ - InstModule instName - (/*AUTOINST*/); - endmodule + module InstModule (output o); + endmodule + + module ExampOutput + (/*AUTOOUTPUT*/ + ); + InstModule instName + (/*AUTOINST*/); + endmodule Typing \\[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 + module ExampOutput + (/*AUTOOUTPUT*/ + // Beginning of automatic outputs + output o // From instName of InstModule.v + // End of automatics + ); + InstModule instName + (/*AUTOINST*/ + // Outputs + .o (o)); + endmodule You may also provide an optional regular expression, in which case only signals matching the regular expression will be included. For example the @@ -12320,35 +12320,36 @@ 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 + module ExampOutputEvery (o,i,tempa,tempb); + output o; + input i; + /*AUTOOUTPUTEVERY*/ + wire tempa = i; + wire tempb = tempa; + wire o = tempb; + endmodule Typing \\[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 + module ExampOutputEvery ( + /*AUTOOUTPUTEVERY*/ + // Beginning of automatic outputs (every signal) + output o, + output tempa, + output tempb, + // End of automatics + input i + ); + wire tempa = i; + wire tempb = tempa; + wire o = tempb; + 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: - /*AUTOOUTPUTEVERY(\"^ov\")*/" + /*AUTOOUTPUTEVERY(\"^ov\")*/" (save-excursion ;;Point must be at insertion point (let* ((indent-pt (current-indentation)) @@ -12398,28 +12399,29 @@ Limitations: 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 + module InstModule (input i); + endmodule + + module ExampInput ( + /*AUTOINPUT*/ + ); + InstModule instName + (/*AUTOINST*/); + endmodule Typing \\[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 + module ExampInput ( + /*AUTOINPUT*/ + // Beginning of automatic inputs (from unused autoinst inputs) + input i // To instName of InstModule.v + // End of automatics + ); + InstModule instName + (/*AUTOINST*/ + // 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 @@ -12481,34 +12483,35 @@ Limitations: An example (see `verilog-auto-inst' for what else is going on here): - module ExampInout (ov,i); - input i; - /*AUTOINOUT*/ - InstModule instName - (/*AUTOINST*/); - endmodule + module InstModule (inout io); + endmodule + + module ExampInout ( + /*AUTOINOUT*/ + ); + InstModule instName + (/*AUTOINST*/); + endmodule Typing \\[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 + module ExampInout ( + /*AUTOINOUT*/ + // Beginning of automatic inouts + inout io // To/From instName of InstModule.v + // End of automatics + ); + InstModule instName + (/*AUTOINST*/ + // Inouts + .io (io)); + 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\")*/" + /*AUTOINOUT(\"^i\")*/" (save-excursion ;; Point must be at insertion point. (let* ((indent-pt (current-indentation)) @@ -12566,32 +12569,32 @@ Limitations: An example: - module ExampShell (/*AUTOARG*/); - /*AUTOINOUTMODULE(\"ExampMain\")*/ - endmodule + module ExampMain + (input i, + output o, + inout io); + endmodule - module ExampMain (i,o,io); - input i; - output o; - inout io; + module ExampShell (/*AUTOARG*/); + /*AUTOINOUTMODULE(\"ExampMain\")*/ endmodule Typing \\[verilog-auto] will make this into: - module ExampShell (/*AUTOARG*/i,o,io); - /*AUTOINOUTMODULE(\"ExampMain\")*/ - // Beginning of automatic in/out/inouts (from specific module) + module ExampShell (/*AUTOARG*/o, io, o); + /*AUTOINOUTMODULE(\"ExampMain\")*/ + // Beginning of automatic in/out/inouts output o; inout io; input i; - // End of automatics - endmodule + // 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\")*/ + /*AUTOINOUTMODULE(\"ExampMain\",\"^i\")*/ You may also provide an optional third argument regular expression, in which case only signals which have that pin @@ -12605,7 +12608,7 @@ 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.*\")*/ + /*AUTOINOUTMODULE(\"ExampMain\",\"\",\"^output.*\")*/ You may also provide an optional fourth argument regular expression, which if not \"\" only signals which do NOT match @@ -12704,32 +12707,32 @@ Limitations: An example: - module ExampShell (/*AUTOARG*/); - /*AUTOINOUTCOMP(\"ExampMain\")*/ - endmodule + module ExampMain + (input i, + output o, + inout io); + endmodule - module ExampMain (i,o,io); - input i; - output o; - inout io; + module ExampBench (/*AUTOARG*/); + /*AUTOINOUTCOMP(\"ExampMain\")*/ endmodule Typing \\[verilog-auto] will make this into: - module ExampShell (/*AUTOARG*/i,o,io); - /*AUTOINOUTCOMP(\"ExampMain\")*/ - // Beginning of automatic in/out/inouts (from specific module) + module ExampShell (/*AUTOARG*/i, io, o); + /*AUTOINOUTCOMP(\"ExampMain\")*/ + // Beginning of automatic in/out/inouts output i; inout io; input o; - // End of automatics - endmodule + // 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\")*/ + /*AUTOINOUTCOMP(\"ExampMain\",\"^i\")*/ You may also provide an optional third argument regular expression, in which case only signals which have that pin @@ -12743,7 +12746,7 @@ 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: - /*AUTOINOUTCOMP(\"ExampMain\",\"\",\"^output.*\")*/ + /*AUTOINOUTCOMP(\"ExampMain\",\"\",\"^output.*\")*/ You may also provide an optional fourth argument regular expression, which if not \"\" only signals which do NOT match @@ -12774,32 +12777,32 @@ Limitations: An example: - module ExampShell (/*AUTOARG*/); - /*AUTOINOUTIN(\"ExampMain\")*/ - endmodule + module ExampMain + (input i, + output o, + inout io); + endmodule - module ExampMain (i,o,io); - input i; - output o; - inout io; + module ExampInoutIn (/*AUTOARG*/); + /*AUTOINOUTIN(\"ExampMain\")*/ endmodule Typing \\[verilog-auto] will make this into: - module ExampShell (/*AUTOARG*/i,o,io); - /*AUTOINOUTIN(\"ExampMain\")*/ - // Beginning of automatic in/out/inouts (from specific module) + module ExampInoutIn (/*AUTOARG*/i, io, o); + /*AUTOINOUTIN(\"ExampMain\")*/ + // Beginning of automatic in/out/inouts input i; input io; input o; - // End of automatics - endmodule + // 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: - /*AUTOINOUTIN(\"ExampMain\",\"^i\")*/" + /*AUTOINOUTIN(\"ExampMain\",\"^i\")*/" (verilog-auto-inout-module nil t)) (defun verilog-auto-inout-param () @@ -12823,28 +12826,28 @@ Limitations: An example: - module ExampShell (); - /*AUTOINOUTPARAM(\"ExampMain\")*/ - endmodule - - module ExampMain (); + module ExampMain (); parameter PARAM = 22; endmodule + module ExampInoutParam (); + /*AUTOINOUTPARAM(\"ExampMain\")*/ + endmodule + Typing \\[verilog-auto] will make this into: - module ExampShell (/*AUTOARG*/i,o,io); - /*AUTOINOUTPARAM(\"ExampMain\")*/ + module ExampInoutParam (); + /*AUTOINOUTPARAM(\"ExampMain\")*/ // Beginning of automatic parameters (from specific module) - parameter PARAM; - // End of automatics - endmodule + parameter PARAM; + // End of automatics + endmodule You may also provide an optional regular expression, in which case only parameters matching the regular expression will be included. For example the same expansion will result from only extracting parameters starting with i: - /*AUTOINOUTPARAM(\"ExampMain\",\"^i\")*/" + /*AUTOINOUTPARAM(\"ExampMain\",\"^i\")*/" (save-excursion (let* ((params (verilog-read-auto-params 1 2)) (submod (nth 0 params)) @@ -12897,39 +12900,34 @@ the same name. An example: - interface ExampIf - ( input logic clk ); - logic req_val; - logic [7:0] req_dat; - clocking mon_clkblk @(posedge clk); - input req_val; - input req_dat; - endclocking - modport mp(clocking mon_clkblk); - endinterface - - module ExampMain - ( input clk, - /*AUTOINOUTMODPORT(\"ExampIf\" \"mp\")*/ - // Beginning of automatic in/out/inouts (from modport) - input [7:0] req_dat, - input req_val - // End of automatics - ); - /*AUTOASSIGNMODPORT(\"ExampIf\" \"mp\")*/ - endmodule + interface ExampIf + ( input logic clk ); + logic req_val; + logic [7:0] req_dat; + clocking mon_clkblk @(posedge clk); + input req_val; + input req_dat; + endclocking + modport mp(clocking mon_clkblk); + endinterface + + module ExampMain + ( input clk, + /*AUTOINOUTMODPORT(\"ExampIf\", \"mp\")*/ + ); + endmodule Typing \\[verilog-auto] will make this into: - ... - module ExampMain - ( input clk, - /*AUTOINOUTMODPORT(\"ExampIf\" \"mp\")*/ - // Beginning of automatic in/out/inouts (from modport) - input req_dat, - input req_val - // End of automatics - ); + module ExampMain + ( input clk, + /*AUTOINOUTMODPORT(\"ExampIf\", \"mp\")*/ + // Beginning of automatic in/out/inouts (from modport) + input req_val, + input [7:0] req_dat + // End of automatics + ); + endmodule If the modport is part of a UVM monitor/driver class, this creates a wrapper module that may be used to instantiate the @@ -13005,35 +13003,36 @@ 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 init file. - /* - Local Variables: - eval: - (defun my-verilog-insert-hello (who) - (insert (concat \"initial $write(\\\"hello \" who \"\\\");\\n\"))) - End: - */ + 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 init file. + /* + Local Variables: + eval: + (defun my-verilog-insert-hello (who) + (insert (concat \"initial $write(\\\"hello \" who \"\\\");\\n\"))) + End: + */ Typing \\[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 + /*AUTOINSERTLISP(my-verilog-insert-hello \"world\")*/ + // 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" + /*AUTOINSERTLISP(insert (shell-command-to-string \"echo //hello\"))*/ + // Beginning of automatic insert lisp + //hello + // End of automatics" (save-excursion ;; Point is at end of /*AUTO...*/ (let* ((indent-pt (current-indentation)) @@ -13119,27 +13118,27 @@ OOps! An example: - always @ (/*AS*/) begin - /* AUTO_CONSTANT (\\=`constant) */ - outin = ina | inb | \\=`constant; - out = outin; - end + always @ (/*AS*/) begin + /*AUTO_CONSTANT (\\=`constant) */ + outin = ina | inb | \\=`constant; + out = outin; + end Typing \\[verilog-auto] will make this into: - always @ (/*AS*/ina or inb) begin - /* AUTO_CONSTANT (\\=`constant) */ - outin = ina | inb | \\=`constant; - out = outin; - end + 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" + always @* begin + outin = ina | inb | \\=`constant; + out = outin; + end" (save-excursion ;; Find beginning (let* ((start-pt (save-excursion @@ -13220,35 +13219,30 @@ signals manually (or put them into a \"\\=`ifdef NEVER signal<=\\=`0; 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 + module ExampReset (); + 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 + endmodule Typing \\[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; // if `verilog-auto-reset-blocking-in-non' true - // End of automatics - end - else begin - a <= in_a; - b = in_b; - c <= in_c; - end - end" + ... + c <= 1; + /*AUTORESET*/ + // Beginning of autoreset for uninitialized flops + a <= 1'h0; + b <= 1'h0; + // End of automatics + ..." (interactive) (save-excursion @@ -13324,32 +13318,32 @@ value's width is generated. An example of making a stub for another module: - module ExampStub (/*AUTOINST*/); - /*AUTOINOUTPARAM(\"Foo\")*/ - /*AUTOINOUTMODULE(\"Foo\")*/ - /*AUTOTIEOFF*/ - // verilator lint_off UNUSED - wire _unused_ok = &{1\\='b0, - /*AUTOUNUSED*/ - 1\\='b0}; - // verilator lint_on UNUSED - endmodule + module ExampMain + #(parameter P) + (input i, output o, inout io); + endmodule -Typing \\[verilog-auto] will make this into: + module ExampStub (/*AUTOARG*/); + /*AUTOINOUTPARAM(\"ExampMain\")*/ + /*AUTOINOUTMODULE(\"ExampMain\")*/ - module ExampStub (/*AUTOINST*/...); - /*AUTOINOUTPARAM(\"Foo\")*/ - /*AUTOINOUTMODULE(\"Foo\")*/ - // Beginning of autotieoff - output [2:0] foo; - // End of automatics + /*AUTOTIEOFF*/ + + // verilator lint_off UNUSED + wire _unused_ok = &{1\\='b0, + /*AUTOUNUSED*/ + 1\\='b0}; + // verilator lint_on UNUSED + endmodule + +Typing \\[verilog-auto] will make this into: + ... /*AUTOTIEOFF*/ - // Beginning of autotieoff - wire [2:0] foo = 3\\='b0; + // Beginning of automatic tieoffs + wire [2:0] o = 3\\='b0; // End of automatics - ... - endmodule" + ..." (interactive) (save-excursion ;; Find beginning @@ -13402,24 +13396,24 @@ Limitations: An example: - \\=`define XX_FOO - \\=`define M_BAR(x) - \\=`define M_BAZ - ... - \\=`ifdef NEVER - \\=`undef M_BAZ // Emacs will see this and not \\=`undef M_BAZ - \\=`endif - ... - /*AUTOUNDEF*/ + \\=`define XX_FOO + \\=`define M_BAR(x) + \\=`define M_BAZ + ... + \\=`ifdef NEVER + \\=`undef M_BAZ // Emacs will see this and not \\=`undef M_BAZ + \\=`endif + ... + /*AUTOUNDEF*/ Typing \\[verilog-auto] will make this into: - ... - /*AUTOUNDEF*/ - // Beginning of automatic undefs - \\=`undef XX_FOO - \\=`undef M_BAR - // End of automatics + ... + /*AUTOUNDEF*/ + // Beginning of automatic undefs + \\=`undef M_BAR + \\=`undef XX_FOO + // End of automatics You may also provide an optional regular expression, in which case only defines the regular expression will be undefed." @@ -13482,31 +13476,36 @@ You can add signals you do not want included in AUTOUNUSED with An example of making a stub for another module: - module ExampStub (/*AUTOINST*/); - /*AUTOINOUTPARAM(\"Examp\")*/ - /*AUTOINOUTMODULE(\"Examp\")*/ - /*AUTOTIEOFF*/ - // verilator lint_off UNUSED - wire _unused_ok = &{1\\='b0, - /*AUTOUNUSED*/ - 1\\='b0}; - // verilator lint_on UNUSED - endmodule + module ExampMain + (input unused_input_a, input unused_input_b); + endmodule + + module ExampStub2 (/*AUTOARG*/); + /*AUTOINOUTPARAM(\"ExampMain\")*/ + /*AUTOINOUTMODULE(\"ExampMain\")*/ + + /*AUTOTIEOFF*/ + + // verilator lint_off UNUSED + wire _unused_ok = &{1\\='b0, + /*AUTOUNUSED*/ + 1\\='b0}; + // verilator lint_on UNUSED + endmodule Typing \\[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" + ... + // verilator lint_off UNUSED + wire _unused_ok = &{1\\='b0, + /*AUTOUNUSED*/ + // Beginning of automatics + unused_input_a, + unused_input_b + // End of automatics + 1\\='b0}; + // verilator lint_on UNUSED + endmodule" (interactive) (save-excursion ;; Find beginning @@ -13577,35 +13576,34 @@ Finally, an AUTOASCIIENUM command is used. An example: - //== State enumeration - parameter [2:0] // auto enum state_info - SM_IDLE = 3\\='b000, - SM_SEND = 3\\='b001, - SM_WAIT1 = 3\\='b010; - //== State variables - reg [2:0] /* auto enum state_info */ - state_r; /* auto state_vector state_r */ - reg [2:0] /* auto enum state_info */ - state_e1; + //== State enumeration + parameter [2:0] // auto enum state_info + SM_IDLE = 3\\='b000, + SM_SEND = 3\\='b001, + SM_WAIT1 = 3\\='b010; + //== State variables + reg [2:0] /* auto enum state_info */ + state_r; /* auto state_vector state_r */ + reg [2:0] /* auto enum state_info */ + state_e1; - /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ + /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ Typing \\[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" + ... + /*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" (save-excursion (let* ((params (verilog-read-auto-params 2 4)) (undecode-name (nth 0 params)) @@ -13776,12 +13774,13 @@ 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*/); + module ExampModule (/*AUTOARG*/); + /*AUTOINPUT*/ + /*AUTOOUTPUT*/ + /*AUTOWIRE*/ + /*AUTOREG*/ + InstMod instName #(/*AUTOINSTPARAM*/) (/*AUTOINST*/); + endmodule You can also update the AUTOs from the shell using: emacs --batch -f verilog-batch-auto -- 2.39.5