I have two memory banks A & B and a flag called "epoch" that tells my design to write to bank A and read from bank B if epoch=1 and to read from bank A and write to bank B if epoch=0. Epoch changes from 0 to 1 or vice versa when a counter hits a certain threshold.
I have tried implementing this by just using an if-else statement in an always_ff block:
logic [15:0] counter;
logic epoch;
always_ff @(posedge clk)
begin
if(counter[15]) epoch<=1;
else epoch<=0;
if(epoch)
begin:write_A_read_B
wr_en_A<=1'b1;
wr_en_B<=1'b0;
end
else
begin:read_A_write_B
wr_en_B<=1'b1;
wr_en_A<=1'b0;
end
counter<=counter+1'b1;
end
This synthesizes just fine, and the elaborated design looks the way it should, but it complains at the implementation step because I am using a net as a clock pin or something like that.
So instead I instantiate a BUFGCE and use counter[15] as the input and clock enable pin and epoch as the output so that epoch goes high when counter[15]=1 and LOW when counter[15]=0:
logic epoch;
logic [15:0] counter;
BUFGCE epoch_buffer
(
I(counter[15]),
CE(counter[15]),
O(epoch)
);
always_ff @(posedge clk)
begin
if(epoch)
begin:write_A_read_B
wr_en_A<=1'b1;
wr_en_B<=1'b0;
end
else
begin:read_A_write_B
wr_en_B<=1'b1;
wr_en_A<=1'b0;
end
counter<=counter+1'b1;
end
This synthesizes just fine, the elaborated model works great, and it even obeys timing closure, but I get a critical warning in the Methodology section from Vivado with the following text "TIMING #1 Critical Warning The clock pin epoch_buffer/I is not reached by a timing clock ". What does this mean? Is there a better way of implementing my design that either doesn't need BUFGCE or uses it in a way that doesn't create this critical warning?
***EDIT*** Fixed the blocking assignment in the counter net, should written non-blocking. It is implemented as non-blocking in my design. whoops