Skip to content

Commit e606895

Browse files
committed
Dual-ported, buffered interface to HyperBus Memory Controller
- Migrate TL-UL logic into a submodule to support multiple ports. - Separated I and D ports for increased performance. - Implemented read buffering on each port. - Write coalescing on D port, to form burst writes. - Routing of write notifications from D port to I port. - Updating of read buffers in response to write notifications. - Introduce a single-entry, zero-latency FIFO on each TL-UL connection to avoid a combinatorial loop that would otherwise exist between the LSU and Instruction fetch ports of the Ibex when the HyperRAM is presented to both ports. - Use a single SRAM model of the HyperRAM for simulation purposes (when requested) and for the Sonata XL synthesis target. - SRAM model is dual-ported on the TL-UL bus, increasing performance on the Sonata XL target too. - Support simulation of Sonata XL (with TARGET_XL_BOARD defined).
1 parent ed86a2e commit e606895

File tree

14 files changed

+1470
-321
lines changed

14 files changed

+1470
-321
lines changed

dv/verilator/sonata_system.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
SonataSystem::SonataSystem(const char *ram_hier_path, int ram_size_words,
1717
const char *hyperram_hier_path, int hyperram_size_words)
1818
: _ram(ram_hier_path, ram_size_words, 4),
19-
#ifdef USE_HYPERRAM_SIM_MODEL
19+
#ifdef USE_HYPERRAM_SRAM_MODEL
20+
// The SRAM model within the `hyperram` IP block is 32 bits wide to
21+
// match the TL-UL bus.
2022
_hyperram(hyperram_hier_path, hyperram_size_words, 4) {}
2123
#else
24+
// The simulation model of the W956 HyperRAM chip employs a memory
25+
// that is 16 bits wide, as per the HyperBus protocol.
2226
_hyperram(hyperram_hier_path, hyperram_size_words / 2, 2) {}
2327
#endif
2428

dv/verilator/sonata_system_main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ int main(int argc, char **argv) {
88
SonataSystem sonata_system(
99
"TOP.top_verilator.u_sonata_system.u_sram_top.u_ram.gen_generic.u_impl_generic",
1010
32 * 1024, // 32k words = 128 KiB
11-
#ifdef USE_HYPERRAM_SIM_MODEL
11+
#ifdef USE_HYPERRAM_SRAM_MODEL
1212
// Simple SRAM model used within the Sonata System for faster simulations.
13-
"TOP.top_verilator.u_sonata_system.u_hyperram.u_hyperram_model.u_ram.gen_generic.u_impl_generic",
13+
"TOP.top_verilator.u_sonata_system.u_hyperram.gen_dual_port.u_hyperram_model.u_ram.gen_generic.u_impl_generic",
1414
#else
1515
// HyperRAM simulation model external to the Sonata System; driven by HBMC.
1616
"TOP.top_verilator.u_hyperram_W956.u_ram.gen_generic.u_impl_generic",

dv/verilator/sonata_verilator_lint.vlt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ lint_off -rule WIDTHTRUNC -file "*hbmc_iobuf.v"
106106
lint_off -rule UNUSED -file "*hbmc_clk_obuf.v"
107107
lint_off -rule UNUSED -file "*hbmc_iobuf.v"
108108

109-
lint_off -rule UNOPTFLAT -file "*hbmc_tl_top.sv"
109+
lint_off -rule UNOPTFLAT -file "*hbmc_tl_port.sv"
110110
lint_off -rule UNUSED -file "*hbmc_tl_top.sv"
111111

112+
lint_off -rule MULTIDRIVEN -file "*prim_arbiter_fixed.sv"
113+
112114
// Disable warnings in models of FPGA primitives.
113115
lint_off -rule UNUSED -file "*IOBUF.v"
114116
lint_off -rule UNUSED -file "*ISERDESE2.v"

dv/verilator/top_verilator.sv

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ module top_verilator #(
177177
wire unused_io_ = ^{mb1, ah_tmpio10, rph_g18, rph_g17,
178178
rph_g16_ce2, rph_g8_ce0, rph_g7_ce1,
179179
usrLed};
180-
180+
`ifndef TARGET_XL_BOARD
181181
// HyperRAM interface.
182182
wire [7:0] hyperram_dq;
183183
wire hyperram_rwds;
184184
wire hyperram_ckp;
185185
wire hyperram_ckn;
186186
wire hyperram_nrst;
187187
wire hyperram_cs;
188-
188+
`endif
189189
// Reporting of CHERI enable/disable and any exceptions that occur.
190190
wire [CheriErrWidth-1:0] cheri_err;
191191
logic [CheriErrWidth-1:0] cheri_errored;
@@ -356,11 +356,16 @@ module top_verilator #(
356356
.clk_usb_i (clk_usb),
357357
.rst_usb_ni (rst_usb_n),
358358

359+
// HyperRAM clocks and reset
360+
`ifdef TARGET_XL_BOARD
361+
// No HyperRAM on Sonata XL
362+
`else
359363
// Hyperram clocks
360364
.clk_hr_i (clk_hr),
361365
.clk_hr90p_i (clk_hr90p),
362366
.clk_hr3x_i (clk_hr3x),
363367
.rst_hr_ni (rst_hr_n),
368+
`endif
364369

365370
.gp_i ({
366371
15'b0,
@@ -430,12 +435,16 @@ module top_verilator #(
430435

431436
.rgbled_dout_o (),
432437

438+
`ifdef TARGET_XL_BOARD
439+
// No HyperRAM on Sonata XL
440+
`else
433441
.hyperram_dq (hyperram_dq),
434442
.hyperram_rwds (hyperram_rwds),
435443
.hyperram_ckp (hyperram_ckp),
436444
.hyperram_ckn (hyperram_ckn),
437445
.hyperram_nrst (hyperram_nrst),
438446
.hyperram_cs (hyperram_cs),
447+
`endif
439448

440449
.rs485_tx_enable_o(rs485_tx_enable),
441450
.rs485_rx_enable_o(rs485_rx_enable),
@@ -663,6 +672,11 @@ module top_verilator #(
663672
.rx_i (rs485_uartdpi_rx)
664673
);
665674

675+
`ifdef TARGET_XL_BOARD
676+
// No HyperRAM on Sonata XL
677+
logic unused_hr;
678+
assign unused_hr = ^{clk_hr, clk_hr90p, clk_hr3x, rst_hr_n};
679+
`else
666680
// HyperRAM model (based on W956D8MBYA5I).
667681
hyperram_W956 u_hyperram_W956 (
668682
// Asynchronous reset signal.
@@ -677,6 +691,7 @@ module top_verilator #(
677691
// Bidirectional data bus.
678692
.dq (hyperram_dq)
679693
);
694+
`endif
680695

681696
export "DPI-C" function mhpmcounter_get;
682697

rtl/ip/hyperram/hyperram.core

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ filesets:
1111
- open_hbmc:hyperram:controller
1212
files:
1313
- rtl/hyperram.sv
14+
- rtl/hyperram_rdbuf.sv
15+
- rtl/hyperram_wrbuf.sv
16+
- rtl/hbmc_tl_port.sv
1417
- rtl/hbmc_tl_top.sv
1518
file_type: systemVerilogSource
1619

rtl/ip/hyperram/rtl/hbmc_dfifo.sv

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
33
// SPDX-License-Identifier: Apache-2.0
44

5-
// Reimplementation of hbmc_dfifo using OpenTitan primitives, only works for DATA_WIDTH == 32
6-
module hbmc_dfifo #
7-
(
8-
parameter integer DATA_WIDTH = 32
9-
)
10-
(
5+
// Reimplementation of hbmc_dfifo using OpenTitan primitives, only works for DataWidth == 32
6+
7+
module hbmc_dfifo #(
8+
parameter int unsigned DataWidth = 32, // Width of data words, bits.
9+
parameter int unsigned FIFODepth = 8 // Depth of FIFO, entries.
10+
) (
1111
input wire fifo_wr_clk,
1212
input wire fifo_wr_nrst,
13-
input wire [DATA_WIDTH - 1:0] fifo_wr_din,
14-
input wire [DATA_WIDTH/8 - 1:0] fifo_wr_strb,
13+
input wire [DataWidth - 1:0] fifo_wr_din,
14+
input wire [DataWidth/8 - 1:0] fifo_wr_strb,
1515
input wire fifo_wr_ena,
1616
output wire fifo_wr_full,
1717

@@ -22,8 +22,8 @@ module hbmc_dfifo #
2222
input wire fifo_rd_ena,
2323
output wire fifo_rd_empty
2424
);
25-
// FIFO contains 32-bit data word and 4-bit strobes
26-
localparam int unsigned FIFOWidth = DATA_WIDTH + 4;
25+
// FIFO contains 32-bit data word and 4 bit strobes
26+
localparam int unsigned FIFOWidth = DataWidth + (DataWidth / 8);
2727

2828
logic [FIFOWidth-1:0] fifo_wdata, fifo_rdata;
2929
logic fifo_wready, fifo_rvalid, fifo_rready;
@@ -35,7 +35,7 @@ module hbmc_dfifo #
3535

3636
prim_fifo_async #(
3737
.Width(FIFOWidth),
38-
.Depth(4)
38+
.Depth(FIFODepth)
3939
) u_fifo (
4040
.clk_wr_i(fifo_wr_clk),
4141
.rst_wr_ni(fifo_wr_nrst),
@@ -65,8 +65,8 @@ module hbmc_dfifo #
6565
end
6666

6767
initial begin
68-
if (DATA_WIDTH != 32) begin
69-
$fatal("hbmc_dfifo only supports DATA_WIDTH of 32");
68+
if (DataWidth != 32) begin
69+
$fatal("hbmc_dfifo only supports DataWidth of 32");
7070
end
7171
end
7272
endmodule

0 commit comments

Comments
 (0)