Skip to content

Commit b9671b1

Browse files
Set up tdpram
1 parent 2e55e31 commit b9671b1

File tree

3 files changed

+192
-0
lines changed

3 files changed

+192
-0
lines changed
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: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
genvar i;
60+
61+
/* verilator lint_off MULTIDRIVEN */
62+
generate
63+
for (i = 0; i < DW; i = i + 1) begin
64+
// Port A write
65+
always @(posedge clk_a) begin
66+
if (ce_a && we_a && wmask_a[i]) begin
67+
ram[addr_a][i] <= din_a[i];
68+
end
69+
end
70+
// Port B write
71+
always @(posedge clk_b) begin
72+
if (ce_b && we_b && wmask_b[i]) begin
73+
ram[addr_b][i] <= din_b[i];
74+
end
75+
end
76+
77+
end
78+
endgenerate
79+
/* verilator lint_on MULTIDRIVEN */
80+
81+
// Port A read
82+
always @(posedge clk_a) begin
83+
if (ce_a && ~we_a) begin
84+
dout_a <= ram[addr_a];
85+
end
86+
end
87+
88+
// Port B read
89+
always @(posedge clk_b) begin
90+
if (ce_b && ~we_b) begin
91+
dout_b <= ram[addr_b];
92+
end
93+
end
94+
95+
endmodule

0 commit comments

Comments
 (0)