-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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>
- Loading branch information
Showing
6 changed files
with
73 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright lowRISC contributors. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/** | ||
* Generic Counter Flop | ||
* | ||
* Counter flop implementation for non-Xilinx targets | ||
*/ | ||
module ibex_counter_flop_xilinx #( | ||
parameter int CounterWidth = 32, | ||
parameter logic [CounterWidth-1:0] ResetValue = 0 | ||
) ( | ||
input logic clk_i, | ||
input logic rst_ni, | ||
input logic [CounterWidth-1:0] d_i, | ||
output logic [CounterWidth-1:0] q_o | ||
); | ||
// On Xilinx FPGAs, 48-bit DSPs are available that can be used for the | ||
// counter. When using a DSP, a sync. reset is needed for the flop. | ||
localparam string ResetType = CounterWidth < 49 ? "SYNC" : "ASYNC"; | ||
|
||
generate | ||
if(ResetType == "ASYNC") begin : g_async_reset_ff | ||
always_ff @(posedge clk_i or negedge rst_ni) begin | ||
if (!rst_ni) begin | ||
q_o <= ResetValue; | ||
end else begin | ||
q_o <= d_i; | ||
end | ||
end | ||
end else begin : g_sync_reset_ff | ||
always_ff @(posedge clk_i) begin | ||
if (!rst_ni) begin | ||
q_o <= ResetValue; | ||
end else begin | ||
q_o <= d_i; | ||
end | ||
end | ||
end | ||
endgenerate | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters