comparison lisp/progmodes/verilog-mode.el @ 93340:971b85f6050d

* progmodes/verilog-mode.el (verilog-auto-inout-module): Add optional regular expression to AUTOINOUTMODULE. (verilog-inject-auto, verilog-auto-arg, verilog-auto-inst) (verilog-auto-inst-param, verilog-auto-reg) (verilog-auto-reg-input, verilog-auto-wire, verilog-auto-output) (verilog-auto-output-every, verilog-auto-input) (verilog-auto-inout, verilog-auto-sense, verilog-auto-tieoff) (verilog-auto-unused, verilog-auto): Update documentation to use more obvious instance module names versus cell names.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 28 Mar 2008 15:47:25 +0000
parents 096de5eb1d54
children 842d446b22d9
comparison
equal deleted inserted replaced
93339:ed66b85b0c05 93340:971b85f6050d
6352 component library to determine connectivity of the design. 6352 component library to determine connectivity of the design.
6353 6353
6354 One work around for this problem is to manually create // Inputs and // 6354 One work around for this problem is to manually create // Inputs and //
6355 Outputs comments above subcell signals, for example: 6355 Outputs comments above subcell signals, for example:
6356 6356
6357 module1 instance1x ( 6357 module ModuleName (
6358 // Outputs 6358 // Outputs
6359 .out (out), 6359 .out (out),
6360 // Inputs 6360 // Inputs
6361 .in (in));" 6361 .in (in));"
6362 (save-excursion 6362 (save-excursion
7703 Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to 7703 Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to
7704 support adding new ports. You may wish to delete older ports yourself. 7704 support adding new ports. You may wish to delete older ports yourself.
7705 7705
7706 For example: 7706 For example:
7707 7707
7708 module ex_inject (i, o); 7708 module ExampInject (i, o);
7709 input i; 7709 input i;
7710 input j; 7710 input j;
7711 output o; 7711 output o;
7712 always @ (i or j) 7712 always @ (i or j)
7713 o = i | j; 7713 o = i | j;
7714 cell cell (.foobar(baz), 7714 InstModule instName
7715 .j(j)); 7715 (.foobar(baz),
7716 j(j));
7716 endmodule 7717 endmodule
7717 7718
7718 Typing \\[verilog-inject-auto] will make this into: 7719 Typing \\[verilog-inject-auto] will make this into:
7719 7720
7720 module ex_inject (i, o/*AUTOARG*/ 7721 module ExampInject (i, o/*AUTOARG*/
7721 // Inputs 7722 // Inputs
7722 j); 7723 j);
7723 input i; 7724 input i;
7724 output o; 7725 output o;
7725 always @ (/*AS*/i or j) 7726 always @ (/*AS*/i or j)
7726 o = i | j; 7727 o = i | j;
7727 cell cell (.foobar(baz), 7728 InstModule instName
7728 /*AUTOINST*/ 7729 (.foobar(baz),
7729 // Outputs 7730 /*AUTOINST*/
7730 .j(j)); 7731 // Outputs
7732 j(j));
7731 endmodule" 7733 endmodule"
7732 (interactive) 7734 (interactive)
7733 (verilog-auto t)) 7735 (verilog-auto t))
7734 7736
7735 (defun verilog-inject-arg () 7737 (defun verilog-inject-arg ()
7891 7893
7892 Typedefs must match `verilog-typedef-regexp', which is disabled by default. 7894 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
7893 7895
7894 For example: 7896 For example:
7895 7897
7896 module ex_arg (/*AUTOARG*/); 7898 module ExampArg (/*AUTOARG*/);
7897 input i; 7899 input i;
7898 output o; 7900 output o;
7899 endmodule 7901 endmodule
7900 7902
7901 Typing \\[verilog-auto] will make this into: 7903 Typing \\[verilog-auto] will make this into:
7902 7904
7903 module ex_arg (/*AUTOARG*/ 7905 module ExampArg (/*AUTOARG*/
7904 // Outputs 7906 // Outputs
7905 o, 7907 o,
7906 // Inputs 7908 // Inputs
7907 i 7909 i
7908 ); 7910 );
8080 8082
8081 Typedefs must match `verilog-typedef-regexp', which is disabled by default. 8083 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
8082 8084
8083 SystemVerilog multidimensional input/output has only experimental support. 8085 SystemVerilog multidimensional input/output has only experimental support.
8084 8086
8085 For example, first take the submodule inst.v: 8087 For example, first take the submodule InstModule.v:
8086 8088
8087 module inst (o,i) 8089 module InstModule (o,i)
8088 output [31:0] o; 8090 output [31:0] o;
8089 input i; 8091 input i;
8090 wire [31:0] o = {32{i}}; 8092 wire [31:0] o = {32{i}};
8091 endmodule 8093 endmodule
8092 8094
8093 This is then used in a upper level module: 8095 This is then used in a upper level module:
8094 8096
8095 module ex_inst (o,i) 8097 module ExampInst (o,i)
8096 output o; 8098 output o;
8097 input i; 8099 input i;
8098 inst inst (/*AUTOINST*/); 8100 InstModule instName
8101 (/*AUTOINST*/);
8099 endmodule 8102 endmodule
8100 8103
8101 Typing \\[verilog-auto] will make this into: 8104 Typing \\[verilog-auto] will make this into:
8102 8105
8103 module ex_inst (o,i) 8106 module ExampInst (o,i)
8104 output o; 8107 output o;
8105 input i; 8108 input i;
8106 inst inst (/*AUTOINST*/ 8109 InstModule instName
8107 // Outputs 8110 (/*AUTOINST*/
8108 .ov (ov[31:0]), 8111 // Outputs
8109 // Inputs 8112 .ov (ov[31:0]),
8110 .i (i)); 8113 // Inputs
8114 .i (i));
8111 endmodule 8115 endmodule
8112 8116
8113 Where the list of inputs and outputs came from the inst module. 8117 Where the list of inputs and outputs came from the inst module.
8114 8118
8115 Exceptions: 8119 Exceptions:
8127 is restricted to simple connections just like you normally make. Also note 8131 is restricted to simple connections just like you normally make. Also note
8128 that any signals before the AUTOINST will only be picked up by AUTOWIRE if 8132 that any signals before the AUTOINST will only be picked up by AUTOWIRE if
8129 you have the appropriate // Input or // Output comment, and exactly the 8133 you have the appropriate // Input or // Output comment, and exactly the
8130 same line formatting as AUTOINST itself uses. 8134 same line formatting as AUTOINST itself uses.
8131 8135
8132 inst inst (// Inputs 8136 InstModule instName
8133 .i (my_i_dont_mess_with_it), 8137 (// Inputs
8134 /*AUTOINST*/ 8138 .i (my_i_dont_mess_with_it),
8135 // Outputs 8139 /*AUTOINST*/
8136 .ov (ov[31:0])); 8140 // Outputs
8141 .ov (ov[31:0]));
8137 8142
8138 8143
8139 Templates: 8144 Templates:
8140 8145
8141 For multiple instantiations based upon a single template, create a 8146 For multiple instantiations based upon a single template, create a
8142 commented out template: 8147 commented out template:
8143 8148
8144 /* instantiating_module_name AUTO_TEMPLATE ( 8149 /* InstModule AUTO_TEMPLATE (
8145 .sig3 (sigz[]), 8150 .sig3 (sigz[]),
8146 ); 8151 );
8147 */ 8152 */
8148 8153
8149 Templates go ABOVE the instantiation(s). When an instantiation is 8154 Templates go ABOVE the instantiation(s). When an instantiation is
8168 debugging is completed though, it will result in lots of extra differences 8173 debugging is completed though, it will result in lots of extra differences
8169 and merge conflicts. 8174 and merge conflicts.
8170 8175
8171 For example: 8176 For example:
8172 8177
8173 /* psm_mas AUTO_TEMPLATE ( 8178 /* InstModule AUTO_TEMPLATE (
8174 .ptl_bus (ptl_busnew[]), 8179 .ptl_bus (ptl_busnew[]),
8175 ); 8180 );
8176 */ 8181 */
8177 psm_mas ms2m (/*AUTOINST*/); 8182 InstModule ms2m (/*AUTOINST*/);
8178 8183
8179 Typing \\[verilog-auto] will make this into: 8184 Typing \\[verilog-auto] will make this into:
8180 8185
8181 psm_mas ms2m (/*AUTOINST*/ 8186 InstModule ms2m (/*AUTOINST*/
8182 // Outputs 8187 // Outputs
8183 .NotInTemplate (NotInTemplate), 8188 .NotInTemplate (NotInTemplate),
8184 .ptl_bus (ptl_busnew[3:0]), // Templated 8189 .ptl_bus (ptl_busnew[3:0]), // Templated
8185 .... 8190 ....
8186 8191
8187 @ Templates: 8192 @ Templates:
8188 8193
8189 It is common to instantiate a cell multiple times, so templates make it 8194 It is common to instantiate a cell multiple times, so templates make it
8190 trivial to substitute part of the cell name into the connection name. 8195 trivial to substitute part of the cell name into the connection name.
8191 8196
8192 /* cell_type AUTO_TEMPLATE <optional \"REGEXP\"> ( 8197 /* InstName AUTO_TEMPLATE <optional \"REGEXP\"> (
8193 .sig1 (sigx[@]), 8198 .sig1 (sigx[@]),
8194 .sig2 (sigy[@\"(% (+ 1 @) 4)\"]), 8199 .sig2 (sigy[@\"(% (+ 1 @) 4)\"]),
8195 ); 8200 );
8196 */ 8201 */
8197 8202
8209 \"\\(test\\([a-z]+\\)_\\([0-9]+\\)\\)\" would replace @ with the entire 8214 \"\\(test\\([a-z]+\\)_\\([0-9]+\\)\\)\" would replace @ with the entire
8210 match. 8215 match.
8211 8216
8212 For example: 8217 For example:
8213 8218
8214 /* psm_mas AUTO_TEMPLATE ( 8219 /* InstModule AUTO_TEMPLATE (
8215 .ptl_mapvalidx (ptl_mapvalid[@]), 8220 .ptl_mapvalidx (ptl_mapvalid[@]),
8216 .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]), 8221 .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]),
8217 ); 8222 );
8218 */ 8223 */
8219 psm_mas ms2m (/*AUTOINST*/); 8224 InstModule ms2m (/*AUTOINST*/);
8220 8225
8221 Typing \\[verilog-auto] will make this into: 8226 Typing \\[verilog-auto] will make this into:
8222 8227
8223 psm_mas ms2m (/*AUTOINST*/ 8228 InstModule ms2m (/*AUTOINST*/
8224 // Outputs 8229 // Outputs
8225 .ptl_mapvalidx (ptl_mapvalid[2]), 8230 .ptl_mapvalidx (ptl_mapvalid[2]),
8226 .ptl_mapvalidp1x (ptl_mapvalid[3])); 8231 .ptl_mapvalidp1x (ptl_mapvalid[3]));
8227 8232
8228 Note the @ character was replaced with the 2 from \"ms2m\". 8233 Note the @ character was replaced with the 2 from \"ms2m\".
8229 8234
8230 Alternatively, using a regular expression for @: 8235 Alternatively, using a regular expression for @:
8231 8236
8232 /* psm_mas AUTO_TEMPLATE \"_\\([a-z]+\\)\" ( 8237 /* InstModule AUTO_TEMPLATE \"_\\([a-z]+\\)\" (
8233 .ptl_mapvalidx (@_ptl_mapvalid), 8238 .ptl_mapvalidx (@_ptl_mapvalid),
8234 .ptl_mapvalidp1x (ptl_mapvalid_@), 8239 .ptl_mapvalidp1x (ptl_mapvalid_@),
8235 ); 8240 );
8236 */ 8241 */
8237 psm_mas ms2_FOO (/*AUTOINST*/); 8242 InstModule ms2_FOO (/*AUTOINST*/);
8238 psm_mas ms2_BAR (/*AUTOINST*/); 8243 InstModule ms2_BAR (/*AUTOINST*/);
8239 8244
8240 Typing \\[verilog-auto] will make this into: 8245 Typing \\[verilog-auto] will make this into:
8241 8246
8242 psm_mas ms2_FOO (/*AUTOINST*/ 8247 InstModule ms2_FOO (/*AUTOINST*/
8243 // Outputs 8248 // Outputs
8244 .ptl_mapvalidx (FOO_ptl_mapvalid), 8249 .ptl_mapvalidx (FOO_ptl_mapvalid),
8245 .ptl_mapvalidp1x (ptl_mapvalid_FOO)); 8250 .ptl_mapvalidp1x (ptl_mapvalid_FOO));
8246 psm_mas ms2_BAR (/*AUTOINST*/ 8251 InstModule ms2_BAR (/*AUTOINST*/
8247 // Outputs 8252 // Outputs
8248 .ptl_mapvalidx (BAR_ptl_mapvalid), 8253 .ptl_mapvalidx (BAR_ptl_mapvalid),
8249 .ptl_mapvalidp1x (ptl_mapvalid_BAR)); 8254 .ptl_mapvalidp1x (ptl_mapvalid_BAR));
8250 8255
8251 8256
8287 vl-name Name portion of the input/output port. 8292 vl-name Name portion of the input/output port.
8288 vl-bits Bus bits portion of the input/output port ('[2:0]'). 8293 vl-bits Bus bits portion of the input/output port ('[2:0]').
8289 vl-width Width of the input/output port ('3' for [2:0]). 8294 vl-width Width of the input/output port ('3' for [2:0]).
8290 May be a (...) expression if bits isn't a constant. 8295 May be a (...) expression if bits isn't a constant.
8291 vl-dir Direction of the pin input/output/inout. 8296 vl-dir Direction of the pin input/output/inout.
8292 vl-cell-type Module name/type of the cell ('psm_mas'). 8297 vl-cell-type Module name/type of the cell ('InstModule').
8293 vl-cell-name Instance name of the cell ('ms2m'). 8298 vl-cell-name Instance name of the cell ('instName').
8294 8299
8295 Normal Lisp variables may be used in expressions. See 8300 Normal Lisp variables may be used in expressions. See
8296 `verilog-read-defines' which can set vh-{definename} variables for use 8301 `verilog-read-defines' which can set vh-{definename} variables for use
8297 here. Also, any comments of the form: 8302 here. Also, any comments of the form:
8298 8303
8398 automatically derived from the module header of the instantiated netlist. 8403 automatically derived from the module header of the instantiated netlist.
8399 8404
8400 See \\[verilog-auto-inst] for limitations, and templates to customize the 8405 See \\[verilog-auto-inst] for limitations, and templates to customize the
8401 output. 8406 output.
8402 8407
8403 For example, first take the submodule inst.v: 8408 For example, first take the submodule InstModule.v:
8404 8409
8405 module inst (o,i) 8410 module InstModule (o,i)
8406 parameter PAR; 8411 parameter PAR;
8407 endmodule 8412 endmodule
8408 8413
8409 This is then used in a upper level module: 8414 This is then used in a upper level module:
8410 8415
8411 module ex_inst (o,i) 8416 module ExampInst (o,i)
8412 parameter PAR; 8417 parameter PAR;
8413 inst #(/*AUTOINSTPARAM*/) 8418 InstModule #(/*AUTOINSTPARAM*/)
8414 inst (/*AUTOINST*/); 8419 instName (/*AUTOINST*/);
8415 endmodule 8420 endmodule
8416 8421
8417 Typing \\[verilog-auto] will make this into: 8422 Typing \\[verilog-auto] will make this into:
8418 8423
8419 module ex_inst (o,i) 8424 module ExampInst (o,i)
8420 output o; 8425 output o;
8421 input i; 8426 input i;
8422 inst (/*AUTOINSTPARAM*/ 8427 InstModule #(/*AUTOINSTPARAM*/
8423 // Parameters 8428 // Parameters
8424 .PAR (PAR)); 8429 .PAR (PAR));
8425 inst (/*AUTOINST*/); 8430 instName (/*AUTOINST*/);
8426 endmodule 8431 endmodule
8427 8432
8428 Where the list of parameter connections come from the inst module. 8433 Where the list of parameter connections come from the inst module.
8429 8434
8430 Templates: 8435 Templates:
8504 8509
8505 This does NOT work on memories, declare those yourself. 8510 This does NOT work on memories, declare those yourself.
8506 8511
8507 An example: 8512 An example:
8508 8513
8509 module ex_reg (o,i) 8514 module ExampReg (o,i)
8510 output o; 8515 output o;
8511 input i; 8516 input i;
8512 /*AUTOREG*/ 8517 /*AUTOREG*/
8513 always o = i; 8518 always o = i;
8514 endmodule 8519 endmodule
8515 8520
8516 Typing \\[verilog-auto] will make this into: 8521 Typing \\[verilog-auto] will make this into:
8517 8522
8518 module ex_reg (o,i) 8523 module ExampReg (o,i)
8519 output o; 8524 output o;
8520 input i; 8525 input i;
8521 /*AUTOREG*/ 8526 /*AUTOREG*/
8522 // Beginning of automatic regs (for this module's undeclared outputs) 8527 // Beginning of automatic regs (for this module's undeclared outputs)
8523 reg o; 8528 reg o;
8524 // End of automatics 8529 // End of automatics
8525 always o = i; 8530 always o = i;
8526 endmodule" 8531 endmodule"
8527 (save-excursion 8532 (save-excursion
8528 ;; Point must be at insertion point. 8533 ;; Point must be at insertion point.
8555 8560
8556 This does NOT work on memories, declare those yourself. 8561 This does NOT work on memories, declare those yourself.
8557 8562
8558 An example (see `verilog-auto-inst' for what else is going on here): 8563 An example (see `verilog-auto-inst' for what else is going on here):
8559 8564
8560 module ex_reg_input (o,i) 8565 module ExampRegInput (o,i)
8561 output o; 8566 output o;
8562 input i; 8567 input i;
8563 /*AUTOREGINPUT*/ 8568 /*AUTOREGINPUT*/
8564 inst inst (/*AUTOINST*/); 8569 InstModule instName
8570 (/*AUTOINST*/);
8565 endmodule 8571 endmodule
8566 8572
8567 Typing \\[verilog-auto] will make this into: 8573 Typing \\[verilog-auto] will make this into:
8568 8574
8569 module ex_reg_input (o,i) 8575 module ExampRegInput (o,i)
8570 output o; 8576 output o;
8571 input i; 8577 input i;
8572 /*AUTOREGINPUT*/ 8578 /*AUTOREGINPUT*/
8573 // Beginning of automatic reg inputs (for undeclared ... 8579 // Beginning of automatic reg inputs (for undeclared ...
8574 reg [31:0] iv; // From inst of inst.v 8580 reg [31:0] iv; // From inst of inst.v
8575 // End of automatics 8581 // End of automatics
8576 inst inst (/*AUTOINST*/ 8582 InstModule instName
8577 // Outputs 8583 (/*AUTOINST*/
8578 .o (o[31:0]), 8584 // Outputs
8579 // Inputs 8585 .o (o[31:0]),
8580 .iv (iv)); 8586 // Inputs
8587 .iv (iv));
8581 endmodule" 8588 endmodule"
8582 (save-excursion 8589 (save-excursion
8583 ;; Point must be at insertion point. 8590 ;; Point must be at insertion point.
8584 (let* ((indent-pt (current-indentation)) 8591 (let* ((indent-pt (current-indentation))
8585 (modi (verilog-modi-current)) 8592 (modi (verilog-modi-current))
8613 non-numeric or non-sequential bus subscripts. If Verilog mode 8620 non-numeric or non-sequential bus subscripts. If Verilog mode
8614 mis-guessed, you'll have to declare them yourself. 8621 mis-guessed, you'll have to declare them yourself.
8615 8622
8616 An example (see `verilog-auto-inst' for what else is going on here): 8623 An example (see `verilog-auto-inst' for what else is going on here):
8617 8624
8618 module ex_wire (o,i) 8625 module ExampWire (o,i)
8619 output o; 8626 output o;
8620 input i; 8627 input i;
8621 /*AUTOWIRE*/ 8628 /*AUTOWIRE*/
8622 inst inst (/*AUTOINST*/); 8629 InstModule instName
8630 (/*AUTOINST*/);
8623 endmodule 8631 endmodule
8624 8632
8625 Typing \\[verilog-auto] will make this into: 8633 Typing \\[verilog-auto] will make this into:
8626 8634
8627 module ex_wire (o,i) 8635 module ExampWire (o,i)
8628 output o; 8636 output o;
8629 input i; 8637 input i;
8630 /*AUTOWIRE*/ 8638 /*AUTOWIRE*/
8631 // Beginning of automatic wires 8639 // Beginning of automatic wires
8632 wire [31:0] ov; // From inst of inst.v 8640 wire [31:0] ov; // From inst of inst.v
8633 // End of automatics 8641 // End of automatics
8634 inst inst (/*AUTOINST*/ 8642 InstModule instName
8635 // Outputs 8643 (/*AUTOINST*/
8636 .ov (ov[31:0]), 8644 // Outputs
8637 // Inputs 8645 .ov (ov[31:0]),
8638 .i (i)); 8646 // Inputs
8647 .i (i));
8639 wire o = | ov; 8648 wire o = | ov;
8640 endmodule" 8649 endmodule"
8641 (save-excursion 8650 (save-excursion
8642 ;; Point must be at insertion point. 8651 ;; Point must be at insertion point.
8643 (let* ((indent-pt (current-indentation)) 8652 (let* ((indent-pt (current-indentation))
8679 8688
8680 Signals matching `verilog-auto-output-ignore-regexp' are not included. 8689 Signals matching `verilog-auto-output-ignore-regexp' are not included.
8681 8690
8682 An example (see `verilog-auto-inst' for what else is going on here): 8691 An example (see `verilog-auto-inst' for what else is going on here):
8683 8692
8684 module ex_output (ov,i) 8693 module ExampOutput (ov,i)
8685 input i; 8694 input i;
8686 /*AUTOOUTPUT*/ 8695 /*AUTOOUTPUT*/
8687 inst inst (/*AUTOINST*/); 8696 InstModule instName
8697 (/*AUTOINST*/);
8688 endmodule 8698 endmodule
8689 8699
8690 Typing \\[verilog-auto] will make this into: 8700 Typing \\[verilog-auto] will make this into:
8691 8701
8692 module ex_output (ov,i) 8702 module ExampOutput (ov,i)
8693 input i; 8703 input i;
8694 /*AUTOOUTPUT*/ 8704 /*AUTOOUTPUT*/
8695 // Beginning of automatic outputs (from unused autoinst outputs) 8705 // Beginning of automatic outputs (from unused autoinst outputs)
8696 output [31:0] ov; // From inst of inst.v 8706 output [31:0] ov; // From inst of inst.v
8697 // End of automatics 8707 // End of automatics
8698 inst inst (/*AUTOINST*/ 8708 InstModule instName
8699 // Outputs 8709 (/*AUTOINST*/
8700 .ov (ov[31:0]), 8710 // Outputs
8701 // Inputs 8711 .ov (ov[31:0]),
8702 .i (i)); 8712 // Inputs
8713 .i (i));
8703 endmodule 8714 endmodule
8704 8715
8705 You may also provide an optional regular expression, in which case only 8716 You may also provide an optional regular expression, in which case only
8706 signals matching the regular expression will be included. For example the 8717 signals matching the regular expression will be included. For example the
8707 same expansion will result from only extracting outputs starting with ov: 8718 same expansion will result from only extracting outputs starting with ov:
8741 useful to get Synopsys to preserve every signal in the design, since it 8752 useful to get Synopsys to preserve every signal in the design, since it
8742 won't optimize away the outputs. 8753 won't optimize away the outputs.
8743 8754
8744 An example: 8755 An example:
8745 8756
8746 module ex_output_every (o,i,tempa,tempb) 8757 module ExampOutputEvery (o,i,tempa,tempb)
8747 output o; 8758 output o;
8748 input i; 8759 input i;
8749 /*AUTOOUTPUTEVERY*/ 8760 /*AUTOOUTPUTEVERY*/
8750 wire tempa = i; 8761 wire tempa = i;
8751 wire tempb = tempa; 8762 wire tempb = tempa;
8752 wire o = tempb; 8763 wire o = tempb;
8753 endmodule 8764 endmodule
8754 8765
8755 Typing \\[verilog-auto] will make this into: 8766 Typing \\[verilog-auto] will make this into:
8756 8767
8757 module ex_output_every (o,i,tempa,tempb) 8768 module ExampOutputEvery (o,i,tempa,tempb)
8758 output o; 8769 output o;
8759 input i; 8770 input i;
8760 /*AUTOOUTPUTEVERY*/ 8771 /*AUTOOUTPUTEVERY*/
8761 // Beginning of automatic outputs (every signal) 8772 // Beginning of automatic outputs (every signal)
8762 output tempb; 8773 output tempb;
8763 output tempa; 8774 output tempa;
8764 // End of automatics 8775 // End of automatics
8765 wire tempa = i; 8776 wire tempa = i;
8766 wire tempb = tempa; 8777 wire tempb = tempa;
8767 wire o = tempb; 8778 wire o = tempb;
8768 endmodule" 8779 endmodule"
8803 8814
8804 Signals matching `verilog-auto-input-ignore-regexp' are not included. 8815 Signals matching `verilog-auto-input-ignore-regexp' are not included.
8805 8816
8806 An example (see `verilog-auto-inst' for what else is going on here): 8817 An example (see `verilog-auto-inst' for what else is going on here):
8807 8818
8808 module ex_input (ov,i) 8819 module ExampInput (ov,i)
8809 output [31:0] ov; 8820 output [31:0] ov;
8810 /*AUTOINPUT*/ 8821 /*AUTOINPUT*/
8811 inst inst (/*AUTOINST*/); 8822 InstModule instName
8823 (/*AUTOINST*/);
8812 endmodule 8824 endmodule
8813 8825
8814 Typing \\[verilog-auto] will make this into: 8826 Typing \\[verilog-auto] will make this into:
8815 8827
8816 module ex_input (ov,i) 8828 module ExampInput (ov,i)
8817 output [31:0] ov; 8829 output [31:0] ov;
8818 /*AUTOINPUT*/ 8830 /*AUTOINPUT*/
8819 // Beginning of automatic inputs (from unused autoinst inputs) 8831 // Beginning of automatic inputs (from unused autoinst inputs)
8820 input i; // From inst of inst.v 8832 input i; // From inst of inst.v
8821 // End of automatics 8833 // End of automatics
8822 inst inst (/*AUTOINST*/ 8834 InstModule instName
8823 // Outputs 8835 (/*AUTOINST*/
8824 .ov (ov[31:0]), 8836 // Outputs
8825 // Inputs 8837 .ov (ov[31:0]),
8826 .i (i)); 8838 // Inputs
8839 .i (i));
8827 endmodule 8840 endmodule
8828 8841
8829 You may also provide an optional regular expression, in which case only 8842 You may also provide an optional regular expression, in which case only
8830 signals matching the regular expression will be included. For example the 8843 signals matching the regular expression will be included. For example the
8831 same expansion will result from only extracting inputs starting with i: 8844 same expansion will result from only extracting inputs starting with i:
8879 8892
8880 Signals matching `verilog-auto-inout-ignore-regexp' are not included. 8893 Signals matching `verilog-auto-inout-ignore-regexp' are not included.
8881 8894
8882 An example (see `verilog-auto-inst' for what else is going on here): 8895 An example (see `verilog-auto-inst' for what else is going on here):
8883 8896
8884 module ex_inout (ov,i) 8897 module ExampInout (ov,i)
8885 input i; 8898 input i;
8886 /*AUTOINOUT*/ 8899 /*AUTOINOUT*/
8887 inst inst (/*AUTOINST*/); 8900 InstModule instName
8901 (/*AUTOINST*/);
8888 endmodule 8902 endmodule
8889 8903
8890 Typing \\[verilog-auto] will make this into: 8904 Typing \\[verilog-auto] will make this into:
8891 8905
8892 module ex_inout (ov,i) 8906 module ExampInout (ov,i)
8893 input i; 8907 input i;
8894 /*AUTOINOUT*/ 8908 /*AUTOINOUT*/
8895 // Beginning of automatic inouts (from unused autoinst inouts) 8909 // Beginning of automatic inouts (from unused autoinst inouts)
8896 inout [31:0] ov; // From inst of inst.v 8910 inout [31:0] ov; // From inst of inst.v
8897 // End of automatics 8911 // End of automatics
8898 inst inst (/*AUTOINST*/ 8912 InstModule instName
8899 // Inouts 8913 (/*AUTOINST*/
8900 .ov (ov[31:0]), 8914 // Inouts
8901 // Inputs 8915 .ov (ov[31:0]),
8902 .i (i)); 8916 // Inputs
8917 .i (i));
8903 endmodule 8918 endmodule
8904 8919
8905 You may also provide an optional regular expression, in which case only 8920 You may also provide an optional regular expression, in which case only
8906 signals matching the regular expression will be included. For example the 8921 signals matching the regular expression will be included. For example the
8907 same expansion will result from only extracting inouts starting with i: 8922 same expansion will result from only extracting inouts starting with i:
8954 though they will appear to be in the same order to a AUTOINST 8969 though they will appear to be in the same order to a AUTOINST
8955 instantiating either module. 8970 instantiating either module.
8956 8971
8957 An example: 8972 An example:
8958 8973
8959 module ex_shell (/*AUTOARG*/) 8974 module ExampShell (/*AUTOARG*/)
8960 /*AUTOINOUTMODULE(\"ex_main\")*/ 8975 /*AUTOINOUTMODULE(\"ExampMain\")*/
8961 endmodule 8976 endmodule
8962 8977
8963 module ex_main (i,o,io) 8978 module ExampMain (i,o,io)
8964 input i; 8979 input i;
8965 output o; 8980 output o;
8966 inout io; 8981 inout io;
8967 endmodule 8982 endmodule
8968 8983
8969 Typing \\[verilog-auto] will make this into: 8984 Typing \\[verilog-auto] will make this into:
8970 8985
8971 module ex_shell (/*AUTOARG*/i,o,io) 8986 module ExampShell (/*AUTOARG*/i,o,io)
8972 /*AUTOINOUTMODULE(\"ex_main\")*/ 8987 /*AUTOINOUTMODULE(\"ExampMain\")*/
8973 // Beginning of automatic in/out/inouts (from specific module) 8988 // Beginning of automatic in/out/inouts (from specific module)
8974 input i; 8989 input i;
8975 output o; 8990 output o;
8976 inout io; 8991 inout io;
8977 // End of automatics 8992 // End of automatics
8978 endmodule" 8993 endmodule
8994
8995 You may also provide an optional regular expression, in which case only
8996 signals matching the regular expression will be included. For example the
8997 same expansion will result from only extracting signals starting with i:
8998
8999 /*AUTOINOUTMODULE(\"ExampMain\",\"^i\")*/"
8979 (save-excursion 9000 (save-excursion
8980 (let* ((submod (car (verilog-read-auto-params 1))) submodi) 9001 (let* ((params (verilog-read-auto-params 1 2))
9002 (submod (nth 0 params))
9003 (regexp (nth 1 params))
9004 submodi)
8981 ;; Lookup position, etc of co-module 9005 ;; Lookup position, etc of co-module
8982 ;; Note this may raise an error 9006 ;; Note this may raise an error
8983 (when (setq submodi (verilog-modi-lookup submod t)) 9007 (when (setq submodi (verilog-modi-lookup submod t))
8984 (let* ((indent-pt (current-indentation)) 9008 (let* ((indent-pt (current-indentation))
8985 (v2k (verilog-in-paren)) 9009 (v2k (verilog-in-paren))
8992 (append (verilog-modi-get-outputs modi)))) 9016 (append (verilog-modi-get-outputs modi))))
8993 (sig-list-io (verilog-signals-not-in 9017 (sig-list-io (verilog-signals-not-in
8994 (verilog-modi-get-inouts submodi) 9018 (verilog-modi-get-inouts submodi)
8995 (append (verilog-modi-get-inouts modi))))) 9019 (append (verilog-modi-get-inouts modi)))))
8996 (forward-line 1) 9020 (forward-line 1)
9021 (when regexp
9022 (setq sig-list-i (verilog-signals-matching-regexp
9023 sig-list-i regexp)
9024 sig-list-o (verilog-signals-matching-regexp
9025 sig-list-o regexp)
9026 sig-list-io (verilog-signals-matching-regexp
9027 sig-list-io regexp)))
8997 (when v2k (verilog-repair-open-comma)) 9028 (when v2k (verilog-repair-open-comma))
8998 (when (or sig-list-i sig-list-o sig-list-io) 9029 (when (or sig-list-i sig-list-o sig-list-io)
8999 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n") 9030 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n")
9000 ;; Don't sort them so a upper AUTOINST will match the main module 9031 ;; Don't sort them so a upper AUTOINST will match the main module
9001 (verilog-insert-definition sig-list-o "output" indent-pt v2k t) 9032 (verilog-insert-definition sig-list-o "output" indent-pt v2k t)
9050 the /*AUTOSENSE*/ comment will prevent it from being deleted when the 9081 the /*AUTOSENSE*/ comment will prevent it from being deleted when the
9051 autos are updated (or added if it occurs there already). 9082 autos are updated (or added if it occurs there already).
9052 9083
9053 An example: 9084 An example:
9054 9085
9055 always @ (/*AUTOSENSE*/) begin 9086 always @ (/*AS*/) begin
9056 /* AUTO_CONSTANT (`constant) */ 9087 /* AUTO_CONSTANT (`constant) */
9057 outin = ina | inb | `constant; 9088 outin = ina | inb | `constant;
9058 out = outin; 9089 out = outin;
9059 end 9090 end
9060 9091
9061 Typing \\[verilog-auto] will make this into: 9092 Typing \\[verilog-auto] will make this into:
9062 9093
9063 always @ (/*AUTOSENSE*/ina or inb) begin 9094 always @ (/*AS*/ina or inb) begin
9064 /* AUTO_CONSTANT (`constant) */ 9095 /* AUTO_CONSTANT (`constant) */
9096 outin = ina | inb | `constant;
9097 out = outin;
9098 end
9099
9100 Note in Verilog 2001, you can often get the same result from the new @*
9101 operator. (This was added to the language in part due to AUTOSENSE!)
9102
9103 always @* begin
9065 outin = ina | inb | `constant; 9104 outin = ina | inb | `constant;
9066 out = outin; 9105 out = outin;
9067 end" 9106 end"
9068 (save-excursion 9107 (save-excursion
9069 ;; Find beginning 9108 ;; Find beginning
9217 Signals that match `verilog-active-low-regexp' will be deasserted by tieing 9256 Signals that match `verilog-active-low-regexp' will be deasserted by tieing
9218 them to a one. 9257 them to a one.
9219 9258
9220 An example of making a stub for another module: 9259 An example of making a stub for another module:
9221 9260
9222 module FooStub (/*AUTOINST*/); 9261 module ExampStub (/*AUTOINST*/);
9223 /*AUTOINOUTMODULE(\"Foo\")*/ 9262 /*AUTOINOUTMODULE(\"Foo\")*/
9224 /*AUTOTIEOFF*/ 9263 /*AUTOTIEOFF*/
9225 // verilator lint_off UNUSED 9264 // verilator lint_off UNUSED
9226 wire _unused_ok = &{1'b0, 9265 wire _unused_ok = &{1'b0,
9227 /*AUTOUNUSED*/ 9266 /*AUTOUNUSED*/
9229 // verilator lint_on UNUSED 9268 // verilator lint_on UNUSED
9230 endmodule 9269 endmodule
9231 9270
9232 Typing \\[verilog-auto] will make this into: 9271 Typing \\[verilog-auto] will make this into:
9233 9272
9234 module FooStub (/*AUTOINST*/...); 9273 module ExampStub (/*AUTOINST*/...);
9235 /*AUTOINOUTMODULE(\"Foo\")*/ 9274 /*AUTOINOUTMODULE(\"Foo\")*/
9236 // Beginning of autotieoff 9275 // Beginning of autotieoff
9237 output [2:0] foo; 9276 output [2:0] foo;
9238 // End of automatics 9277 // End of automatics
9239 9278
9298 You can add signals you do not want included in AUTOUNUSED with 9337 You can add signals you do not want included in AUTOUNUSED with
9299 `verilog-auto-unused-ignore-regexp'. 9338 `verilog-auto-unused-ignore-regexp'.
9300 9339
9301 An example of making a stub for another module: 9340 An example of making a stub for another module:
9302 9341
9303 module FooStub (/*AUTOINST*/); 9342 module ExampStub (/*AUTOINST*/);
9304 /*AUTOINOUTMODULE(\"Foo\")*/ 9343 /*AUTOINOUTMODULE(\"Examp\")*/
9305 /*AUTOTIEOFF*/ 9344 /*AUTOTIEOFF*/
9306 // verilator lint_off UNUSED 9345 // verilator lint_off UNUSED
9307 wire _unused_ok = &{1'b0, 9346 wire _unused_ok = &{1'b0,
9308 /*AUTOUNUSED*/ 9347 /*AUTOUNUSED*/
9309 1'b0}; 9348 1'b0};
9522 9561
9523 The hooks `verilog-before-auto-hook' and `verilog-auto-hook' are 9562 The hooks `verilog-before-auto-hook' and `verilog-auto-hook' are
9524 called before and after this function, respectively. 9563 called before and after this function, respectively.
9525 9564
9526 For example: 9565 For example:
9527 module (/*AUTOARG*/) 9566 module ModuleName (/*AUTOARG*/)
9528 /*AUTOINPUT*/ 9567 /*AUTOINPUT*/
9529 /*AUTOOUTPUT*/ 9568 /*AUTOOUTPUT*/
9530 /*AUTOWIRE*/ 9569 /*AUTOWIRE*/
9531 /*AUTOREG*/ 9570 /*AUTOREG*/
9532 somesub sub #(/*AUTOINSTPARAM*/) (/*AUTOINST*/); 9571 InstMod instName #(/*AUTOINSTPARAM*/) (/*AUTOINST*/);
9533 9572
9534 You can also update the AUTOs from the shell using: 9573 You can also update the AUTOs from the shell using:
9535 emacs --batch <filenames.v> -f verilog-batch-auto 9574 emacs --batch <filenames.v> -f verilog-batch-auto
9536 Or fix indentation with: 9575 Or fix indentation with:
9537 emacs --batch <filenames.v> -f verilog-batch-indent 9576 emacs --batch <filenames.v> -f verilog-batch-indent