mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-22 04:47:25 -04:00
Update code from upstream repository https://github.com/lowRISC/opentitan to revision 1ae03937f0bb4b146bb6e736bccb4821bfda556b * [prim/fifo_async] Add assertions on pointers (Tom Roberts) * [prim/fifo_async] Add support for Depth <= 2 (Tom Roberts) * [prim/fifo_async] Code tidy-up (Tom Roberts) * [top / ast] Continued ast integration (Timothy Chen) * [dvsim] Use bash when running make underneath (Srikrishna Iyer) * [prim] Increase maximum width for prim_util_memload to 312 (Greg Chadwick) * [sram_ctrl] Fix potential back-to-back partial write bug (Michael Schaffner) * [dvsim] Fix for lowRISC/opentitan#5527 (Srikrishna Iyer) * [lint] Waive Verilator UNUSED warnings for packages (Rupert Swarbrick) * [uvmdvgen] Update DV doc path and terminology (Srikrishna Iyer) * [clkmgr] Fix dft issues (Timothy Chen) * [util] add `dec` types to prim_secded_pkg (Udi Jonnalagadda) * [util] minor updates to secded_gen (Udi Jonnalagadda) * [lint] Fix a bunch of lint warnings related to long lines (>100 chars) (Michael Schaffner) * [dv] Update common intr_test seq (Weicai Yang) * [util] Slight refactor of secded_gen.py (Timothy Chen) * [tlul] Add memory transmission integrity checks (Timothy Chen) * [dvsim] Move clean_odirs to `util.py` (Srikrishna Iyer) * [dvsim] Split Deploy into Deploy and Launcher (Srikrishna Iyer) * [dvsim] Add utils.TS_FORMAT* vars (Srikrishna Iyer) * [dv/lock_reg] Update IPs to adopt the lock_reg changes (Cindy Chen) * [dv/enable_regs] Support enable registers have more than one field (Cindy Chen) * [dv/base_reg] use m_field instead of accessing field (Cindy Chen) * [dv/sram] add SRAM scrambling model for DV (Udi Jonnalagadda) * [dv/tools] Updated Coverage flow for xcelium (Rasmus Madsen) Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
69 lines
1.7 KiB
Systemverilog
69 lines
1.7 KiB
Systemverilog
// Copyright lowRISC contributors.
|
|
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
/**
|
|
* Single-port RAM with 1 cycle read/write delay, 32 bit words
|
|
*/
|
|
|
|
`include "prim_assert.sv"
|
|
|
|
module ram_1p #(
|
|
parameter int Depth = 128,
|
|
parameter MemInitFile = ""
|
|
) (
|
|
input clk_i,
|
|
input rst_ni,
|
|
|
|
input req_i,
|
|
input we_i,
|
|
input [ 3:0] be_i,
|
|
input [31:0] addr_i,
|
|
input [31:0] wdata_i,
|
|
output logic rvalid_o,
|
|
output logic [31:0] rdata_o
|
|
);
|
|
|
|
localparam int Aw = $clog2(Depth);
|
|
|
|
logic [Aw-1:0] addr_idx;
|
|
assign addr_idx = addr_i[Aw-1+2:2];
|
|
logic [31-Aw:0] unused_addr_parts;
|
|
assign unused_addr_parts = {addr_i[31:Aw+2], addr_i[1:0]};
|
|
|
|
// Convert byte mask to SRAM bit mask.
|
|
logic [31:0] wmask;
|
|
always_comb begin
|
|
for (int i = 0 ; i < 4 ; i++) begin
|
|
// mask for read data
|
|
wmask[8*i+:8] = {8{be_i[i]}};
|
|
end
|
|
end
|
|
|
|
// |rvalid| in the bus module is an "ack" (which is a different meaning than
|
|
// in the prim_ram_*_adv modules). prim_ram_1p is guaranteed to return data
|
|
// in the next cycle.
|
|
always_ff @(posedge clk_i, negedge rst_ni) begin
|
|
if (!rst_ni) begin
|
|
rvalid_o <= 1'b0;
|
|
end else begin
|
|
rvalid_o <= req_i;
|
|
end
|
|
end
|
|
|
|
prim_ram_1p #(
|
|
.Width(32),
|
|
.DataBitsPerMask(8),
|
|
.Depth(Depth),
|
|
.MemInitFile(MemInitFile)
|
|
) u_ram (
|
|
.clk_i (clk_i),
|
|
.cfg_i ('0),
|
|
.req_i (req_i),
|
|
.write_i (we_i),
|
|
.wmask_i (wmask),
|
|
.addr_i (addr_idx),
|
|
.wdata_i (wdata_i),
|
|
.rdata_o (rdata_o)
|
|
);
|
|
endmodule
|