mirror of
https://github.com/lowRISC/ibex.git
synced 2025-06-27 17:00:41 -04:00
[rtl] Fix non-DSP reset in ibex_counter
When targeting Xilinx FPGAs, we utilize a DSP for counters with a width of less than 49-bit. In this case, a sync. reset is needed. However, currently, there is a bug in the RTL where also a sync. reset is used for the non-DSP counters on the FPGA. Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
This commit is contained in:
parent
0945aa84c6
commit
667fd20d2e
1 changed files with 25 additions and 17 deletions
|
@ -51,27 +51,38 @@ module ibex_counter #(
|
||||||
end
|
end
|
||||||
|
|
||||||
`ifdef FPGA_XILINX
|
`ifdef FPGA_XILINX
|
||||||
// Set DSP pragma for supported xilinx FPGAs
|
// On Xilinx FPGAs, 48-bit DSPs are available that can be used for the
|
||||||
localparam int DspPragma = CounterWidth < 49 ? "yes" : "no";
|
// counter. Hence, use Xilinx specific flop implementation. The datatype for
|
||||||
(* use_dsp = DspPragma *) logic [CounterWidth-1:0] counter_q;
|
// UseDsp is on purpose int as with string Xilinx throws an error for the
|
||||||
|
// use_dsp pragma.
|
||||||
// DSP output register requires synchronous reset.
|
localparam int UseDsp = CounterWidth < 49 ? "yes" : "no";
|
||||||
`define COUNTER_FLOP_RST posedge clk_i
|
(* use_dsp = UseDsp *) logic [CounterWidth-1:0] counter_q;
|
||||||
`else
|
`else
|
||||||
|
localparam int UseDsp = "no";
|
||||||
logic [CounterWidth-1:0] counter_q;
|
logic [CounterWidth-1:0] counter_q;
|
||||||
|
|
||||||
`define COUNTER_FLOP_RST posedge clk_i or negedge rst_ni
|
|
||||||
`endif
|
`endif
|
||||||
|
|
||||||
// Counter flop
|
if (UseDsp == "yes") begin : g_cnt_dsp
|
||||||
always_ff @(`COUNTER_FLOP_RST) begin
|
// Use sync. reset for DSP.
|
||||||
if (!rst_ni) begin
|
always_ff @(posedge clk_i) begin
|
||||||
counter_q <= '0;
|
if (!rst_ni) begin
|
||||||
end else begin
|
counter_q <= '0;
|
||||||
counter_q <= counter_d;
|
end else begin
|
||||||
|
counter_q <= counter_d;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end else begin : g_cnt_no_dsp
|
||||||
|
// Use async. reset for flop.
|
||||||
|
always_ff @(posedge clk_i or negedge rst_ni) begin
|
||||||
|
if (!rst_ni) begin
|
||||||
|
counter_q <= '0;
|
||||||
|
end else begin
|
||||||
|
counter_q <= counter_d;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if (CounterWidth < 64) begin : g_counter_narrow
|
if (CounterWidth < 64) begin : g_counter_narrow
|
||||||
logic [63:CounterWidth] unused_counter_load;
|
logic [63:CounterWidth] unused_counter_load;
|
||||||
|
|
||||||
|
@ -98,6 +109,3 @@ module ibex_counter #(
|
||||||
assign counter_val_o = counter;
|
assign counter_val_o = counter;
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
// Keep helper defines file-local.
|
|
||||||
`undef COUNTER_FLOP_RST
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue