Generate was the first thing I tried a 2 days ago.
Here was my code:
generate
if (BHG_EXTRA_SPEED) begin
(*preserve*) logic [PORT_VECTOR_SIZE-1:0] OUT_RD_VECTOR_int = 0 ; // This prevents inferred block ram for the read vector FIFO offering greater FMAX.
end else begin
logic [PORT_VECTOR_SIZE-1:0] OUT_RD_VECTOR_int = 0 ; // This allows inferred block ram for the read vector FIFO offering a much smaller LC/LUT count.
end
endgenerate
Here is the error later-on when I used the logic cell:
# -- Compiling module BrianHG_DDR3_CMD_SEQUENCER
# ** Error: BrianHG_DDR3_CMD_SEQUENCER.sv(251): (vlog-2730) Undefined variable: 'OUT_RD_VECTOR_int'.
However, weirdly, I just tried again with an odd addition, this:
generate
if (BHG_EXTRA_SPEED) begin
(*preserve*) logic [PORT_VECTOR_SIZE-1:0] OUT_RD_VECTOR_int = 0 ; // This prevents inferred block ram for the read vector FIFO offering greater FMAX.
always_ff @(posedge CLK) begin
OUT_RD_VECTOR_int <= vector_pipe_mem[vrpos] ; // Add a DFF latch stage so that when Quartus infers a ram block for the read vector FIFO, it sees a second DFF on the output to improve FMAX performance.
if (IN_READ_RDY_t != IN_READ_RDY_tdl) OUT_RD_VECTOR <= OUT_RD_VECTOR_int ;
end
end else begin
logic [PORT_VECTOR_SIZE-1:0] OUT_RD_VECTOR_int = 0 ; // This allows inferred block ram for the read vector FIFO offering a much smaller LC/LUT count.
always_ff @(posedge CLK) begin
OUT_RD_VECTOR_int <= vector_pipe_mem[vrpos] ; // Add a DFF latch stage so that when Quartus infers a ram block for the read vector FIFO, it sees a second DFF on the output to improve FMAX performance.
if (IN_READ_RDY_t != IN_READ_RDY_tdl) OUT_RD_VECTOR <= OUT_RD_VECTOR_int ;
end
end
endgenerate
And this time it worked. I do not know why, but for the rest of my code to make use of the 'OUT_RD_VECTOR_int', it must be defined, set and used, all 3, inside each generate IF for it to work.
Just placing the 'set', or just placing the 'read' outside the generate's ifs simplifies out the LC all together even in Modelsim simulations.