veripool / verilog-mode

Verilog-Mode for Emacs with Indentation, Hightlighting and AUTOs. Master repository for pushing to GNU, verilog.com and veripool.org.
http://veripool.org/verilog-mode
GNU General Public License v3.0
247 stars 90 forks source link

Fixed AUTONOHOOKUP case where the port is the last input. #1729

Closed udif closed 3 years ago

udif commented 3 years ago

This PR fixes an issue in #1526 . When a NOHOOKUP comment is added to an input port which is the last input port in the instantiated module, then each invocation of verilog-mode would append yet another "Templated AUTONOHOOKUP" comment over and over.

For example: a3.v

module a3(
/*AUTOINPUT*/
/*AUTOOUTPUT*/
);
/* a2 AUTO_TEMPLATE (
  .i1(i1), // AUTONOHOOKUP
  .o1(o1),
) */
a2 a2( /*AUTOINST*/ );
endmodule

module a2 (
  input i1,
  output o1
);
endmodule

After 3 consecutive invocations would yield (please notice you have to right-scroll to see the issue):

module a3(
/*AUTOINPUT*/
/*AUTOOUTPUT*/
// Beginning of automatic outputs (from unused autoinst outputs)
output                  o1                      // From a2 of a2.v
// End of automatics
);
/* a2 AUTO_TEMPLATE (
  .i1(i1), // AUTONOHOOKUP
  .o1(o1),
) */
a2 a2( /*AUTOINST*/
      // Outputs
      .o1                               (o1),                    // Templated
      // Inputs
      .i1                               (i1));                   // Templated AUTONOHOOKUP                       // Templated AUTONOHOOKUP                       // Templated AUTONOHOOKUP
endmodule

module a2 (
  input i1,
  output o1
);
endmodule

After this fix, any number of invocations would always yield:

module a3(
/*AUTOINPUT*/
/*AUTOOUTPUT*/
// Beginning of automatic outputs (from unused autoinst outputs)
output                  o1                      // From a2 of a2.v
// End of automatics
);
/* a2 AUTO_TEMPLATE (
  .i1(i1), // AUTONOHOOKUP
  .o1(o1),
) */
a2 a2( /*AUTOINST*/
      // Outputs
      .o1                               (o1),                    // Templated
      // Inputs
      .i1                               (i1));                   // Templated AUTONOHOOKUP
endmodule

module a2 (
  input i1,
  output o1
);
endmodule
udif commented 3 years ago

I made sure the test fails on master, but passes on the pr branch