blob: 0607a186efc6468bd9a2242e0b1c2b7213b44a37 [file] [log] [blame]
Ahmed Ghazy2517fa82020-11-08 23:34:41 +02001`ifndef USE_CUSTOM_DFFRAM
2
Manar68e03632020-11-09 13:25:13 +02003module DFFRAM(
Manar61dce922020-11-10 19:26:28 +02004`ifdef USE_POWER_PINS
Manar68e03632020-11-09 13:25:13 +02005 input VPWR,
6 input VGND,
7`endif
8 input CLK,
9 input [3:0] WE,
10 input EN,
11 input [31:0] Di,
12 output reg [31:0] Do,
13 input [7:0] A
14);
15
Ahmed Ghazy2517fa82020-11-08 23:34:41 +020016
17reg [31:0] mem [0:`MEM_WORDS-1];
18
19always @(posedge CLK) begin
20 if (EN == 1'b1) begin
21 Do <= mem[A];
22 if (WE[0]) mem[A][ 7: 0] <= Di[ 7: 0];
23 if (WE[1]) mem[A][15: 8] <= Di[15: 8];
24 if (WE[2]) mem[A][23:16] <= Di[23:16];
25 if (WE[3]) mem[A][31:24] <= Di[31:24];
26 end
27end
28endmodule
29
Ahmed Ghazy2517fa82020-11-08 23:34:41 +020030`else
Manar68e03632020-11-09 13:25:13 +020031
32module DFFRAM #( parameter COLS=1, parameter ROWS=4)
33(
Manar61dce922020-11-10 19:26:28 +020034`ifdef USE_POWER_PINS
35 VPWR,
36 VGND,
37`endif
Manar68e03632020-11-09 13:25:13 +020038 CLK,
39 WE,
40 EN,
41 Di,
42 Do,
Manar61dce922020-11-10 19:26:28 +020043 A
Manar68e03632020-11-09 13:25:13 +020044);
45
46 input CLK;
47 input [3:0] WE;
48 input EN;
49 input [31:0] Di;
50 output [31:0] Do;
51 input [7:0] A;
52
Manar61dce922020-11-10 19:26:28 +020053`ifdef USE_POWER_PINS
Manar68e03632020-11-09 13:25:13 +020054 input VPWR;
55 input VGND;
Manar61dce922020-11-10 19:26:28 +020056`endif
57
Manar68e03632020-11-09 13:25:13 +020058 wire [31:0] Di_buf;
59 wire [31:0] Do_pre;
60 wire CLK_buf;
61 wire [3:0] WE_buf;
62
63 wire [31:0] Do_B_0_0;
64 wire [31:0] Do_B_0_1;
65 wire [31:0] Do_B_0_2;
66 wire [31:0] Do_B_0_3;
67
68 wire [3:0] row_sel;
69
Manar61dce922020-11-10 19:26:28 +020070 sky130_fd_sc_hd__clkbuf_8 CLKBUF (
71 `ifdef USE_POWER_PINS
72 .VPWR(VPWR),
73 .VGND(VGND),
74 .VPB(VPWR),
75 .VNB(VGND),
76 `endif
77 .X(CLK_buf),
78 .A(CLK)
79 );
Manar68e03632020-11-09 13:25:13 +020080
Manar61dce922020-11-10 19:26:28 +020081 sky130_fd_sc_hd__clkbuf_8 WEBUF[3:0] (
82 `ifdef USE_POWER_PINS
83 .VPWR(VPWR),
84 .VGND(VGND),
85 .VPB(VPWR),
86 .VNB(VGND),
87 `endif
88 .X(WE_buf),
89 .A(WE)
90 );
Manar68e03632020-11-09 13:25:13 +020091
Manar61dce922020-11-10 19:26:28 +020092 sky130_fd_sc_hd__clkbuf_8 DIBUF[31:0] (
93 `ifdef USE_POWER_PINS
94 .VPWR(VPWR),
95 .VGND(VGND),
96 .VPB(VPWR),
97 .VNB(VGND),
98 `endif
99 .X(Di_buf),
100 .A(Di)
101 );
Manar68e03632020-11-09 13:25:13 +0200102
Manar61dce922020-11-10 19:26:28 +0200103 DEC2x4 DEC (
104 `ifdef USE_POWER_PINS
105 .VPWR(VPWR), .VGND(VGND),
106 `endif
107 .EN(EN), .A(A[7:6]), .SEL(row_sel) );
Manar68e03632020-11-09 13:25:13 +0200108
Manar61dce922020-11-10 19:26:28 +0200109 SRAM64x32 B_0_0 (
110 `ifdef USE_POWER_PINS
111 .VPWR(VPWR), .VGND(VGND),
112 `endif
113 .CLK(CLK_buf), .WE(WE_buf), .EN(row_sel[0]), .Di(Di_buf), .Do(Do_B_0_0), .A(A[5:0]) );
114 SRAM64x32 B_0_1 (
115 `ifdef USE_POWER_PINS
116 .VPWR(VPWR), .VGND(VGND),
117 `endif
118 .CLK(CLK_buf), .WE(WE_buf), .EN(row_sel[1]), .Di(Di_buf), .Do(Do_B_0_1), .A(A[5:0]) );
119 SRAM64x32 B_0_2 (
120 `ifdef USE_POWER_PINS
121 .VPWR(VPWR), .VGND(VGND),
122 `endif
123 .CLK(CLK_buf), .WE(WE_buf), .EN(row_sel[2]), .Di(Di_buf), .Do(Do_B_0_2), .A(A[5:0]) );
124 SRAM64x32 B_0_3 (
125 `ifdef USE_POWER_PINS
126 .VPWR(VPWR), .VGND(VGND),
127 `endif
128 .CLK(CLK_buf), .WE(WE_buf), .EN(row_sel[3]), .Di(Di_buf), .Do(Do_B_0_3), .A(A[5:0]) );
129
130 MUX4x1_32 MUX1 (
131 `ifdef USE_POWER_PINS
132 .VPWR(VPWR), .VGND(VGND),
133 `endif
134 .A0(Do_B_0_0), .A1(Do_B_0_1), .A2(Do_B_0_2), .A3(Do_B_0_3), .S(A[7:6]), .X(Do_pre) );
135
136 sky130_fd_sc_hd__clkbuf_4 DOBUF[31:0] (
137 `ifdef USE_POWER_PINS
138 .VPWR(VPWR),
139 .VGND(VGND),
140 .VPB(VPWR),
141 .VNB(VGND),
142 `endif
143 .X(Do), .A(Do_pre));
Manar68e03632020-11-09 13:25:13 +0200144
Ahmed Ghazy5586f1b2020-11-06 21:34:43 +0200145endmodule
Manar68e03632020-11-09 13:25:13 +0200146
147`endif