Parameters in Verilog code is usually declared with a default value, like:
parameter UP = 1;
But if the parameters is always to be overridden at module instantiation, then I have also seen declaration without default value, like:
parameter UP;
This parameter declaration without default value can compile in ModelSim, but fails compilation in Riviera-PRO.
The Verilog IEEE Std 1365-2005 section "4.10.1 Module parameters" shows that default value is required (not optional), as:
So either ModelSim is forgiving by accepting a parameter without default value if default value is required, or Riviera-PRO lacks support for parameters without default value if default value is optional.
Thus: Is default value required for a Verilog parameter declaration?
A counter module is included below, including parameter declaration without default value, for reference.
module counter
(
input clk,
input rst,
output reg [3:0] cntr
);
parameter UP;
// Counter
always @(posedge clk or posedge rst)
begin
if (rst)
cntr <= 4'd0;
else
if (UP)
cntr <= cntr + 1;
else
cntr <= cntr - 1;
end
endmodule
A testbench with using the counter is also included below for reference:
module testbench();
// Declarations
reg clk;
reg rst;
wire [3:0] cntr;
// Clock generation
initial begin
clk = 0;
forever #5 clk = ~ clk;
end
// Reset generation
initial begin
rst = 1;
#100;
rst = 0;
end
// DUT counter
counter #(.UP(1)) dut (clk, rst, cntr);
endmodule