-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rtl] Dedicated ibex_counter_flop modules
Depending on whether we are targeting a Xilinx FPGA or a generic target, we use a Xilinx specifc flop implementation for the Ibex counters. To increase readability, this commit creates a new module containing a Xilinx specific flop implementation. For generic targets, the existing prim_flop is used. In the Xilinx specific version, a DSP is used when the CounterWidth is below 49-bits. Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
- Loading branch information
Showing
6 changed files
with
68 additions
and
22 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