Skip to content

Commit c0c6c85

Browse files
author
azaidy
committed
Split rams into impl and wrappers
1 parent f81fbff commit c0c6c85

File tree

4 files changed

+170
-24
lines changed

4 files changed

+170
-24
lines changed

lambdalib/ramlib/rtl/la_dpram.v

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,31 @@ module la_dpram #(
4747
input [TESTW-1:0] test // pass through ASIC test interface
4848
);
4949

50-
// Generic RTL RAM
51-
reg [DW-1:0] ram[(2**AW)-1:0];
52-
integer i;
50+
la_dpram_impl #(
51+
.DW (DW),
52+
.AW (AW),
53+
.PROP (PROP),
54+
.CTRLW (CTRLW),
55+
.TESTW (TESTW)
56+
) ram (
57+
.wr_clk (wr_clk),
58+
.wr_ce (wr_ce),
59+
.wr_we (wr_we),
60+
.wr_wmask (wr_wmask),
61+
.wr_addr (wr_addr),
62+
.wr_din (wr_din),
5363

54-
// Write port
55-
always @(posedge wr_clk)
56-
for (i = 0; i < DW; i = i + 1)
57-
if (wr_ce & wr_we & wr_wmask[i]) ram[wr_addr[AW-1:0]][i] <= wr_din[i];
64+
.rd_clk (rd_clk),
65+
.rd_ce (rd_ce),
66+
.rd_addr (rd_addr),
67+
.rd_dout (rd_dout),
5868

59-
// Read Port
60-
always @(posedge rd_clk) if (rd_ce) rd_dout[DW-1:0] <= ram[rd_addr[AW-1:0]];
69+
.vss (vss),
70+
.vdd (vdd),
71+
.vddio (vddio),
72+
73+
.ctrl (ctrl),
74+
.test (test)
75+
);
6176

6277
endmodule
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*****************************************************************************
2+
* Function: Dual Port RAM (One write port + One read port)
3+
* Copyright: Lambda Project Authors. All rights Reserved.
4+
* License: MIT (see LICENSE file in Lambda repository)
5+
*
6+
* Docs:
7+
*
8+
* This is a wrapper for selecting from a set of hardened memory macros.
9+
*
10+
* A synthesizable reference model is used when the PROP is DEFAULT. The
11+
* synthesizable model does not implement the cfg and test interface and should
12+
* only be used for basic testing and for synthesizing for FPGA devices.
13+
* Advanced ASIC development should rely on complete functional models
14+
* supplied on a per macro basis.
15+
*
16+
* Technologoy specific implementations of "la_dpram" would generally include
17+
* one or more hardcoded instantiations of RAM modules with a generate
18+
* statement relying on the "PROP" to select between the list of modules
19+
* at build time.
20+
*
21+
****************************************************************************/
22+
23+
module la_dpram_impl #(
24+
parameter DW = 32, // Memory width
25+
parameter AW = 10, // address width (derived)
26+
parameter PROP = "DEFAULT", // pass through variable for hard macro
27+
parameter CTRLW = 128, // width of asic ctrl interface
28+
parameter TESTW = 128 // width of asic test interface
29+
) ( // Write port
30+
input wr_clk, // write clock
31+
input wr_ce, // write chip-enable
32+
input wr_we, // write enable
33+
input [DW-1:0] wr_wmask, // write mask
34+
input [AW-1:0] wr_addr, // write address
35+
input [DW-1:0] wr_din, //write data in
36+
// Read port
37+
input rd_clk, // read clock
38+
input rd_ce, // read chip-enable
39+
input [AW-1:0] rd_addr, // read address
40+
output reg [DW-1:0] rd_dout, //read data out
41+
// Power signal
42+
input vss, // ground signal
43+
input vdd, // memory core array power
44+
input vddio, // periphery/io power
45+
// Generic interfaces
46+
input [CTRLW-1:0] ctrl, // pass through ASIC control interface
47+
input [TESTW-1:0] test // pass through ASIC test interface
48+
);
49+
50+
// Generic RTL RAM
51+
reg [DW-1:0] ram[(2**AW)-1:0];
52+
integer i;
53+
54+
// Write port
55+
always @(posedge wr_clk)
56+
for (i = 0; i < DW; i = i + 1)
57+
if (wr_ce & wr_we & wr_wmask[i]) ram[wr_addr[AW-1:0]][i] <= wr_din[i];
58+
59+
// Read Port
60+
always @(posedge rd_clk) if (rd_ce) rd_dout[DW-1:0] <= ram[rd_addr[AW-1:0]];
61+
62+
endmodule

lambdalib/ramlib/rtl/la_spram.v

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,27 @@ module la_spram #(
4343
input [TESTW-1:0] test // pass through ASIC test interface
4444
);
4545

46-
// Generic RTL RAM
47-
reg [DW-1:0] ram[(2**AW)-1:0];
48-
integer i;
46+
la_spram_impl #(
47+
.DW (DW),
48+
.AW (AW),
49+
.PROP (PROP),
50+
.CTRLW (CTRLW),
51+
.TESTW (TESTW),
52+
) ram (
53+
.clk (clk),
54+
.ce (ce),
55+
.we (we),
56+
.wmask (wmask),
57+
.addr (addr),
58+
.din (din),
59+
.dout (dout),
4960

50-
// Write port
51-
// always @(posedge clk)
52-
// for (i=0;i<DW;i=i+1)
53-
// if (ce & we & wmask[i])
54-
// ram[addr[AW-1:0]][i] <= din[i];
61+
.vss (vss),
62+
.vdd (vdd),
63+
.vddio (vddio),
5564

56-
// Re-writing as a mux for verilator
57-
always @(posedge clk)
58-
if (ce & we)
59-
ram[addr[AW-1:0]] <= din[DW-1:0] & wmask[DW-1:0] | ram[addr[AW-1:0]] & ~wmask[DW-1:0];
60-
61-
// Read Port
62-
always @(posedge clk) if (ce) dout[DW-1:0] <= ram[addr[AW-1:0]];
65+
.ctrl (ctrl),
66+
.test (test)
67+
);
6368

6469
endmodule
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*****************************************************************************
2+
* Function: Single Port RAM
3+
* Copyright: Lambda Project Authors. All rights Reserved.
4+
* License: MIT (see LICENSE file in Lambda repository)
5+
*
6+
* Docs:
7+
*
8+
* This is a wrapper for selecting from a set of hardened memory macros.
9+
*
10+
* A synthesizable reference model is used when the PROP is DEFAULT. The
11+
* synthesizable model does not implement the cfg and test interface and should
12+
* only be used for basic testing and for synthesizing for FPGA devices.
13+
* Advanced ASIC development should rely on complete functional models
14+
* supplied on a per macro basis.
15+
*
16+
* Technologoy specific implementations of "la_spram" would generally include
17+
* one or more hardcoded instantiations of RAM modules with a generate
18+
* statement relying on the "PROP" to select between the list of modules
19+
* at build time.
20+
*
21+
****************************************************************************/
22+
23+
module la_spram_impl #(
24+
parameter DW = 32, // Memory width
25+
parameter AW = 10, // Address width (derived)
26+
parameter PROP = "DEFAULT", // Pass through variable for hard macro
27+
parameter CTRLW = 1, // Width of asic ctrl interface
28+
parameter TESTW = 1 // Width of asic test interface
29+
) ( // Memory interface
30+
input clk, // write clock
31+
input ce, // chip enable
32+
input we, // write enable
33+
input [DW-1:0] wmask, //per bit write mask
34+
input [AW-1:0] addr, //write address
35+
input [DW-1:0] din, //write data
36+
output reg [DW-1:0] dout, //read output data
37+
// Power signals
38+
input vss, // ground signal
39+
input vdd, // memory core array power
40+
input vddio, // periphery/io power
41+
// Generic interfaces
42+
input [CTRLW-1:0] ctrl, // pass through ASIC control interface
43+
input [TESTW-1:0] test // pass through ASIC test interface
44+
);
45+
46+
// Generic RTL RAM
47+
reg [DW-1:0] ram[(2**AW)-1:0];
48+
integer i;
49+
50+
// Write port
51+
// always @(posedge clk)
52+
// for (i=0;i<DW;i=i+1)
53+
// if (ce & we & wmask[i])
54+
// ram[addr[AW-1:0]][i] <= din[i];
55+
56+
// Re-writing as a mux for verilator
57+
always @(posedge clk)
58+
if (ce & we)
59+
ram[addr[AW-1:0]] <= din[DW-1:0] & wmask[DW-1:0] | ram[addr[AW-1:0]] & ~wmask[DW-1:0];
60+
61+
// Read Port
62+
always @(posedge clk) if (ce) dout[DW-1:0] <= ram[addr[AW-1:0]];
63+
64+
endmodule

0 commit comments

Comments
 (0)