Skip to content

Commit e0d5d1c

Browse files
authored
Merge pull request #119 from siliconcompiler/add_tdp_ram2
Set up tdpram
2 parents 7086a94 + b4c27b8 commit e0d5d1c

File tree

4 files changed

+194
-1
lines changed

4 files changed

+194
-1
lines changed

lambdalib/ramlib/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
from .la_syncfifo.la_syncfifo import Syncfifo
55
from .la_dpram.la_dpram import Dpram
66
from .la_spram.la_spram import Spram
7+
from .la_tdpram.la_tdpram import Tdpram
78

89
__all__ = ['Asyncfifo',
910
'Syncfifo',
1011
'Dpram',
11-
'Spram']
12+
'Spram',
13+
'Tdpram']
1214

1315

1416
class RAMLib(Design):
@@ -20,3 +22,4 @@ def __init__(self):
2022
self.add_depfileset(Syncfifo(), depfileset="rtl")
2123
self.add_depfileset(Dpram(), depfileset="rtl")
2224
self.add_depfileset(Spram(), depfileset="rtl")
25+
self.add_depfileset(Tdpram(), depfileset="rtl")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from lambdalib.lambdalib import Lambda
2+
3+
4+
class Tdpram(Lambda):
5+
def __init__(self):
6+
name = 'la_tdpram'
7+
super().__init__(name, __file__, extrasources=['rtl/la_tdpram_impl.v'])
8+
9+
10+
if __name__ == "__main__":
11+
d = Tdpram()
12+
d.write_fileset(f"{d.name}.f", fileset="rtl")
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*****************************************************************************
2+
* Function:
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+
* Technology specific implementations of "la_tdpram" 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_tdpram #(
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+
) ( // A port
30+
input clk_a, // write clock
31+
input ce_a, // write chip-enable
32+
input we_a, // write enable
33+
input [DW-1:0] wmask_a, // write mask
34+
input [AW-1:0] addr_a, // write address
35+
input [DW-1:0] din_a, // write data in
36+
output [DW-1:0] dout_a, // read data out
37+
// B port
38+
input clk_b, // write clock
39+
input ce_b, // write chip-enable
40+
input we_b, // write enable
41+
input [DW-1:0] wmask_b, // write mask
42+
input [AW-1:0] addr_b, // write address
43+
input [DW-1:0] din_b, // write data in
44+
output [DW-1:0] dout_b, // read data out
45+
// Power signal
46+
input vss, // ground signal
47+
input vdd, // memory core array power
48+
input vddio, // periphery/io power
49+
// Generic interfaces
50+
input [CTRLW-1:0] ctrl, // pass through ASIC control interface
51+
input [TESTW-1:0] test // pass through ASIC test interface
52+
);
53+
54+
la_tdpram_impl #(
55+
.DW (DW),
56+
.AW (AW),
57+
.PROP (PROP),
58+
.CTRLW (CTRLW),
59+
.TESTW (TESTW)
60+
) memory (
61+
.clk_a (clk_a),
62+
.ce_a (ce_a),
63+
.we_a (we_a),
64+
.wmask_a (wmask_a),
65+
.addr_a (addr_a),
66+
.din_a (din_a),
67+
.dout_a (dout_a),
68+
69+
.clk_b (clk_b),
70+
.ce_b (ce_b),
71+
.we_b (we_b),
72+
.wmask_b (wmask_b),
73+
.addr_b (addr_b),
74+
.din_b (din_b),
75+
.dout_b (dout_b),
76+
77+
.vss (vss),
78+
.vdd (vdd),
79+
.vddio (vddio),
80+
81+
.ctrl (ctrl),
82+
.test (test)
83+
);
84+
85+
endmodule
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*****************************************************************************
2+
* Function: True Dual Port RAM (Two write + read ports)
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+
* Technology specific implementations of "la_tdpram" 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_tdpram_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 clk_a, // write clock
31+
input ce_a, // write chip-enable
32+
input we_a, // write enable
33+
input [DW-1:0] wmask_a, // write mask
34+
input [AW-1:0] addr_a, // write address
35+
input [DW-1:0] din_a, // write data in
36+
output reg [DW-1:0] dout_a, // read data out
37+
// B port
38+
input clk_b, // write clock
39+
input ce_b, // write chip-enable
40+
input we_b, // write enable
41+
input [DW-1:0] wmask_b, // write mask
42+
input [AW-1:0] addr_b, // write address
43+
input [DW-1:0] din_b, // write data in
44+
output reg [DW-1:0] dout_b, // read data out
45+
// Power signal
46+
input vss, // ground signal
47+
input vdd, // memory core array power
48+
input vddio, // periphery/io power
49+
// Generic interfaces
50+
input [CTRLW-1:0] ctrl, // pass through ASIC control interface
51+
input [TESTW-1:0] test // pass through ASIC test interface
52+
);
53+
54+
// Generic RTL RAM
55+
/* verilator lint_off MULTIDRIVEN */
56+
reg [DW-1:0] ram[(2**AW)-1:0];
57+
/* verilator lint_on MULTIDRIVEN */
58+
59+
integer i;
60+
61+
// Port A write
62+
always @(posedge clk_a) begin
63+
for (i = 0; i < DW; i = i + 1) begin
64+
if (ce_a && we_a && wmask_a[i]) begin
65+
ram[addr_a][i] <= din_a[i];
66+
end
67+
end
68+
end
69+
70+
// Port B write
71+
always @(posedge clk_b) begin
72+
for (i = 0; i < DW; i = i + 1) begin
73+
if (ce_b && we_b && wmask_b[i]) begin
74+
ram[addr_b][i] <= din_b[i];
75+
end
76+
end
77+
end
78+
79+
// Port A read
80+
always @(posedge clk_a) begin
81+
if (ce_a && ~we_a) begin
82+
dout_a <= ram[addr_a];
83+
end
84+
end
85+
86+
// Port B read
87+
always @(posedge clk_b) begin
88+
if (ce_b && ~we_b) begin
89+
dout_b <= ram[addr_b];
90+
end
91+
end
92+
93+
endmodule

0 commit comments

Comments
 (0)