Altera_Forum
Honored Contributor
11 years agoDefault port values in SystemVerilog
I am trying unsuccessfully to define a default value for an input port in a module definition, so that if an instantiation of it does not pass a value to that port, the default value is used without any error. According to Altera, Quartus 13 supports section 23.2.2 of the IEE standard 1800-2009 for SystemVerilog. On the Internet I found this reproduction of section 23.2.2.4 of the aforementioned standard, which I have included at the end of this posting.
When I try the syntax suggested below, I get a compiler error, even though I have chosen "SystemVerilog" as the version under Assignment: Settings. At first, I just assumed that this feature was not implemented by Altera, until I saw their page where they state that section 23.2.2 is supported by Quartus 13. Any thoughts? (I am a Verilog newbie, so be gentle.) 23.2.2.4 Default port values A module declaration may specify a default value for each singular input port. These default values shall be constant expressions evaluated in the scope of the module where they are defined, not in the scope of the instantiating module. The informal syntax to declare a default input port value in a module is as follows: module module_name ( ..., [ input ] [ type ] port_identifier = constant_expression, ... ) ; Defaults can be specified only for input ports and only in ANSI style declarations. When the module is instantiated, input ports with default values can be omitted from the instantiation, and the compiler shall insert the corresponding default values. If a connection is not specified for an input port and the port does not have a default value, then, depending on the connection style (ordered list, named connections, implicit named connections, or implicit .* connections), the port shall either be left unconnected or result in an error, as discussed in 23.3.2.1 through 23.3.2.4.