forked from lowRISC/ibex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a register file designed to be synthesized into FPGA synchronous-write / asynchronous-read design elements. For the artya7-100 example, the register file is implemented by 12 RAM32M primitives, conserving approximately 600 Logic LUTs and 1000 flip-flops at the expense of 48 LUTRAMs. Signed-off-by: ganoam <[email protected]>
- Loading branch information
Showing
4 changed files
with
74 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright lowRISC contributors. | ||
// Copyright 2018 ETH Zurich and University of Bologna, see also CREDITS.md. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/** | ||
* RISC-V register file | ||
* | ||
* Register file with 31 or 15x 32 bit wide registers. Register 0 is fixed to 0. | ||
* | ||
* This register file is designed to make FPGA synthesis tools infer RAM primitives. For Xilinx | ||
* FPGA architectures, it will produce RAM32M primitives. Other vendors have not yet been tested. | ||
*/ | ||
module ibex_register_file #( | ||
parameter bit RV32E = 0, | ||
parameter int unsigned DataWidth = 32 | ||
) ( | ||
// Clock and Reset | ||
input logic clk_i, | ||
input logic rst_ni, | ||
|
||
input logic test_en_i, | ||
|
||
//Read port R1 | ||
input logic [ 4:0] raddr_a_i, | ||
output logic [DataWidth-1:0] rdata_a_o, | ||
//Read port R2 | ||
input logic [ 4:0] raddr_b_i, | ||
output logic [DataWidth-1:0] rdata_b_o, | ||
// Write port W1 | ||
input logic [ 4:0] waddr_a_i, | ||
input logic [DataWidth-1:0] wdata_a_i, | ||
input logic we_a_i | ||
); | ||
|
||
localparam int ADDR_WIDTH = RV32E ? 4 : 5; | ||
localparam int NUM_WORDS = 2**ADDR_WIDTH; | ||
|
||
logic [DataWidth-1:0] mem[NUM_WORDS]; | ||
logic we; // write enable if writing to any register other than R0 | ||
|
||
// async_read a | ||
assign rdata_a_o = (raddr_a_i == '0) ? '0 : mem[raddr_a_i]; | ||
|
||
// async_read b | ||
assign rdata_b_o = (raddr_b_i == '0) ? '0 : mem[baddr_b_i]; | ||
|
||
// we select | ||
assign we = (waddr_a_i == '0) ? 1'b0 : we_a_i; | ||
|
||
always_ff @(posedge clk_i) begin : sync_write | ||
if (we == 1'b1) begin | ||
mem[waddr_a_i] <= wdata_a_i; | ||
end | ||
end : sync_write | ||
|
||
endmodule : ibex_register_file |