Are you allowed to have a module identifier be the same as the module type in Verilog?

StackOverflow https://stackoverflow.com/questions/2321565

  •  22-09-2019
  •  | 
  •  

Question

For example

module top
    debouncer debouncer(...);
endmodule

module debouncer
...
endmodule

Can I instantiate a debouncer as "debouncer" in the top module, or is that illegal?

Was it helpful?

Solution

Yes, it is legal for a module instance name to match the module name in Verilog, and it is quite common to do so when you only need one instance of a module. But, you could have quickly verified that for yourself by simply compiling your file with your favorite simulator. The following is legal syntax and compiles for me:

module top;
    debouncer debouncer();
endmodule

module debouncer;
endmodule
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top