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

AUTO_TEMPLATE that applies only to a specific instance #1739

Closed imgod2u closed 2 years ago

imgod2u commented 2 years ago

I have multiple instances of the same module, for example:

/* my_module AUTO_TEMPLATE "^\(.*\)" (
.\(.*\) (@_\1),
);
*/
my_module u0(
  /*AUTOINST*/
);
my_module u1(
  /*AUTOINST*/
);
my_module u2(
  /*AUTOINST*/
);

However, instance u2 needs more specific connections that's different than the others. For example, I want port2 of u2 tied to 1'b0 but u0 and u1 to tie it to u0_port2 and u1_port2 respectively.

Is there a way to make specific template rules based on instance name?

wsnyder commented 2 years ago

For your case it sounds like you can just list the exceptions.

/* my_module AUTO_TEMPLATE "^\(.*\)" (
.\(.*\) (@_\1),
);
*/
my_module u0(
  /*AUTOINST*/
);
my_module u1(
  // Outputs
  .port2('0),
  /*AUTOINST*/
);

Another alternative is to put a template for each (and repeat the identical rules)

/* my_module AUTO_TEMPLATE "^\(.*\)" (
.\(.*\) (@_\1),
);
*/
my_module u0(
  /*AUTOINST*/
);
/* my_module AUTO_TEMPLATE "^\(.*\)" (
.port2('0),
.\(.*\) (@_\1),
);
*/
my_module u1(
  /*AUTOINST*/
);