-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[prim,earlgrey,fpga] Add specialized ram_1p prim
Add a specialized ram_1p prim for the prim_xilinx library. This prim adds some prim_xilinx-specific parameters to enable selecting particular layouts for embedded memories. The intention is to have the top-level override the parameters with hierarchical assignment. This feature is intended for use with memories that are too wide to fit in updatemem's capabilities (where splicing is required). The flash info pages are one such type, since updatemem can only handle up to 64-bit wide items, and the info page array is 76 bits wide. Synthesis chooses the most efficient layout of the memories, but the layout is awkward for handling splices. Force earlgrey's flash info data and metadata into separate arrays for the FPGA. Signed-off-by: Alexander Williams <[email protected]>
- Loading branch information
Showing
14 changed files
with
381 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CAPI=2: | ||
# Copyright lowRISC contributors (OpenTitan project). | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: "lowrisc:prim_xilinx:prim_xilinx_default_pkg" | ||
description: "Single port RAM" | ||
virtual: | ||
- lowrisc:prim_xilinx:prim_xilinx_pkg | ||
filesets: | ||
files_rtl: | ||
files: | ||
- rtl/prim_xilinx_pkg.sv | ||
file_type: systemVerilogSource | ||
|
||
targets: | ||
default: &default_target | ||
filesets: | ||
- files_rtl |
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,44 @@ | ||
CAPI=2: | ||
# Copyright lowRISC contributors (OpenTitan project). | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: "lowrisc:prim_xilinx:ram_1p" | ||
description: "Single port RAM" | ||
filesets: | ||
files_rtl: | ||
depend: | ||
- lowrisc:prim:assert | ||
- lowrisc:prim:ram_1p_pkg | ||
# Note that prim_xilinx_pkg is a virtual core that the top should provide. | ||
# It maps parameters to instructions for how to split memories into | ||
# logical groups of bits. See prim_xilinx_default_pkg for an example. | ||
- lowrisc:prim_xilinx:prim_xilinx_pkg | ||
- lowrisc:prim_generic:ram_1p | ||
- lowrisc:prim:util_memload | ||
files: | ||
- rtl/prim_xilinx_ram_1p.sv | ||
file_type: systemVerilogSource | ||
|
||
files_verilator_waiver: | ||
depend: | ||
# common waivers | ||
- lowrisc:lint:common | ||
|
||
files_ascentlint_waiver: | ||
depend: | ||
# common waivers | ||
- lowrisc:lint:common | ||
|
||
files_veriblelint_waiver: | ||
depend: | ||
# common waivers | ||
- lowrisc:lint:common | ||
|
||
targets: | ||
default: | ||
filesets: | ||
- tool_verilator ? (files_verilator_waiver) | ||
- tool_ascentlint ? (files_ascentlint_waiver) | ||
- tool_veriblelint ? (files_veriblelint_waiver) | ||
- files_rtl |
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,16 @@ | ||
// Copyright lowRISC contributors (OpenTitan project). | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package prim_xilinx_pkg; | ||
|
||
// Returns the maximum width of an individual xpm memory. Note that this API | ||
// may evolve over time, but currently it uses the width and depth | ||
// parameters to identify memories that may need to be broken up into | ||
// separate groups. This can help work around updatemem's maximum width for | ||
// words, which is 64 bits at the time of writing. | ||
function automatic int get_ram_max_width(int width, int depth); | ||
return 0; | ||
endfunction | ||
|
||
endpackage : prim_xilinx_pkg |
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,77 @@ | ||
// Copyright lowRISC contributors (OpenTitan project). | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Synchronous single-port SRAM model | ||
|
||
`include "prim_assert.sv" | ||
|
||
module prim_xilinx_ram_1p import prim_ram_1p_pkg::*; #( | ||
parameter int Width = 32, // bit | ||
parameter int Depth = 128, | ||
parameter int DataBitsPerMask = 1, // Number of data bits per bit of write mask | ||
parameter MemInitFile = "", // VMEM file to initialize the memory with | ||
|
||
localparam int Aw = $clog2(Depth) // derived parameter | ||
) ( | ||
input logic clk_i, | ||
|
||
input logic req_i, | ||
input logic write_i, | ||
input logic [Aw-1:0] addr_i, | ||
input logic [Width-1:0] wdata_i, | ||
input logic [Width-1:0] wmask_i, | ||
output logic [Width-1:0] rdata_o, // Read data. Data is returned one cycle after req_i is high. | ||
input ram_1p_cfg_t cfg_i | ||
); | ||
|
||
localparam int PrimMaxWidth = prim_xilinx_pkg::get_ram_max_width(Width, Depth); | ||
|
||
if (PrimMaxWidth <= 0) begin : gen_generic | ||
prim_generic_ram_1p #( | ||
.Width(Width), | ||
.Depth(Depth), | ||
.DataBitsPerMask(DataBitsPerMask), | ||
.MemInitFile(MemInitFile) | ||
) u_ram_1p ( | ||
.* | ||
); | ||
end else begin : gen_xpm | ||
logic wr_en; | ||
assign wr_en = write_i & wmask_i[0]; | ||
|
||
logic unused_cfg_i; | ||
assign unused_cfg_i = cfg_i; | ||
|
||
for (genvar k = 0; k < Width; k = k + PrimMaxWidth) begin : gen_split | ||
localparam int PrimWidth = ((Width - k) > PrimMaxWidth) ? PrimMaxWidth : Width - k; | ||
localparam string PrimMemoryInitFile = (MemInitFile != "") ? MemInitFile : "none"; | ||
|
||
xpm_memory_spram #( | ||
.ADDR_WIDTH_A(Aw), | ||
.BYTE_WRITE_WIDTH_A(PrimWidth), // Masks are not supported | ||
.MEMORY_INIT_FILE(PrimMemoryInitFile), | ||
.MEMORY_SIZE(Depth * PrimWidth), | ||
.READ_DATA_WIDTH_A(PrimWidth), | ||
.READ_LATENCY_A(1), | ||
.USE_MEM_INIT_MMI(1), | ||
.WRITE_DATA_WIDTH_A(PrimWidth) | ||
) u_ram_1p ( | ||
.clka(clk_i), | ||
.addra(addr_i), | ||
.dbiterra(), | ||
.dina(wdata_i[k +: PrimWidth]), | ||
.douta(rdata_o[k +: PrimWidth]), | ||
.ena(req_i), | ||
.injectdbiterra(1'b0), | ||
.injectsbiterra(1'b0), | ||
.regcea(1'b1), | ||
.rsta(1'b0), | ||
.sbiterra(), | ||
.sleep(1'b0), | ||
.wea(wr_en) | ||
); | ||
end | ||
end | ||
|
||
endmodule |
19 changes: 19 additions & 0 deletions
19
hw/ip/prim_xilinx_ultrascale/prim_xilinx_ultrascale_ram_1p.core
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,19 @@ | ||
CAPI=2: | ||
# Copyright lowRISC contributors (OpenTitan project). | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: "lowrisc:prim_xilinx_ultrascale:ram_1p" | ||
description: "Single port RAM" | ||
filesets: | ||
files_rtl: | ||
depend: | ||
- lowrisc:prim_xilinx:ram_1p | ||
files: | ||
- rtl/prim_xilinx_ultrascale_ram_1p.sv | ||
file_type: systemVerilogSource | ||
|
||
targets: | ||
default: | ||
filesets: | ||
- files_rtl |
35 changes: 35 additions & 0 deletions
35
hw/ip/prim_xilinx_ultrascale/rtl/prim_xilinx_ultrascale_ram_1p.sv
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,35 @@ | ||
// Copyright lowRISC contributors (OpenTitan project). | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Synchronous single-port SRAM model | ||
|
||
`include "prim_assert.sv" | ||
|
||
module prim_xilinx_ultrascale_ram_1p import prim_ram_1p_pkg::*; #( | ||
parameter int Width = 32, // bit | ||
parameter int Depth = 128, | ||
parameter int DataBitsPerMask = 1, // Number of data bits per bit of write mask | ||
parameter MemInitFile = "", // VMEM file to initialize the memory with | ||
|
||
localparam int Aw = $clog2(Depth) // derived parameter | ||
) ( | ||
input logic clk_i, | ||
|
||
input logic req_i, | ||
input logic write_i, | ||
input logic [Aw-1:0] addr_i, | ||
input logic [Width-1:0] wdata_i, | ||
input logic [Width-1:0] wmask_i, | ||
output logic [Width-1:0] rdata_o, // Read data. Data is returned one cycle after req_i is high. | ||
input ram_1p_cfg_t cfg_i | ||
); | ||
|
||
prim_xilinx_ram_1p #( | ||
.Width(Width), | ||
.Depth(Depth), | ||
.DataBitsPerMask(DataBitsPerMask), | ||
.MemInitFile(MemInitFile) | ||
) u_inst (.*); | ||
|
||
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
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 was deleted.
Oops, something went wrong.
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,19 @@ | ||
CAPI=2: | ||
# Copyright lowRISC contributors (OpenTitan project). | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: "lowrisc:prim_xilinx:earlgrey_xilinx_prim_pkg" | ||
description: "Single port RAM" | ||
virtual: | ||
- lowrisc:prim_xilinx:prim_xilinx_pkg | ||
filesets: | ||
files_rtl: | ||
files: | ||
- rtl/prim_xilinx_pkg.sv | ||
file_type: systemVerilogSource | ||
|
||
targets: | ||
default: &default_target | ||
filesets: | ||
- files_rtl |
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,20 @@ | ||
// Copyright lowRISC contributors (OpenTitan project). | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package prim_xilinx_pkg; | ||
|
||
// Accommodates updatemem by breaking up flash info arrays into data and | ||
// metadata subarrays. The 76-bit width and 1 BRAM depth identifies these | ||
// memories in earlgrey, and we limit the subarray size to 64 bits, which is | ||
// the size of the data portion. The leftover 12 bits get placed into their | ||
// own memory with a unique hierarchical path. See prim_xilinx_ram_1p.sv to | ||
// see how this works. | ||
function automatic int get_ram_max_width(int width, int depth); | ||
if (width == 76 && depth < 4096) begin | ||
return 64; | ||
end | ||
return 0; | ||
endfunction | ||
|
||
endpackage : prim_xilinx_pkg |
Oops, something went wrong.