Altera_Forum
Honored Contributor
12 years agoVerilog with ANSI-style regs, non-zero initial value is not synthesised correctly!
Hi,
We raised this with Altera and had it confirmed in Quartus V13, but the issue is not fixed in 13.sp1 so I thought I would raise awareness here in the hope it might save anyone else debugging time. If you have a Verilog module with 'ANSI-style' port lists, any 'reg' output ports that are initialised in line to be non-zero will incorrectly initialise to zero after synthesis. Value of y also has to be modified, ie. not reducible to a constant expression.module mux8 (
output reg y = 8'd4,
input wire a,
input wire b,
input wire clk);
...
always @(posedge clk)
y <= a ? y : y + 1;
endmodule We debugged this from a hardware mismatch, and luckily, if you simulate the post-synthesis netlist with vendor part library you can spot the difference against the same module under HDL simulation! Altera stated that in-line initialisation/default value is not a supported V2001 language feature, and added a feature request. We argued this should be a bug fix for the service pack cycle, since you get a simulation/synthesis mismatch with zero warnings. Tools should either synthesise correctly or fail! Modelsim etc. follows V2001 correctly. The obvious workaround is to convert the port to a wire, then use an explicit assign from a register declared internally. module mux8 (
output wire y,
input wire a,
input wire b,
input wire clk);
...
reg yreg = 8'd4;
assign y = yreg;
...
always @(posedge clk)
yreg <= a ? yreg : yreg + 1;
endmodule Happy debugging! Chris (Updated to indicate the process is clocked)