Ahmed Ghazy | 2517fa8 | 2020-11-08 23:34:41 +0200 | [diff] [blame] | 1 | `ifndef USE_CUSTOM_DFFRAM |
| 2 | |
Manar | 68e0363 | 2020-11-09 13:25:13 +0200 | [diff] [blame] | 3 | module DFFRAM( |
| 4 | `ifdef LVS |
| 5 | 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 Ghazy | 2517fa8 | 2020-11-08 23:34:41 +0200 | [diff] [blame] | 16 | |
| 17 | reg [31:0] mem [0:`MEM_WORDS-1]; |
| 18 | |
| 19 | always @(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 |
| 27 | end |
| 28 | endmodule |
| 29 | |
Ahmed Ghazy | 2517fa8 | 2020-11-08 23:34:41 +0200 | [diff] [blame] | 30 | `else |
Manar | 68e0363 | 2020-11-09 13:25:13 +0200 | [diff] [blame] | 31 | |
| 32 | module DFFRAM #( parameter COLS=1, parameter ROWS=4) |
| 33 | ( |
| 34 | CLK, |
| 35 | WE, |
| 36 | EN, |
| 37 | Di, |
| 38 | Do, |
| 39 | A, |
| 40 | VPWR, |
| 41 | VGND |
| 42 | ); |
| 43 | |
| 44 | input CLK; |
| 45 | input [3:0] WE; |
| 46 | input EN; |
| 47 | input [31:0] Di; |
| 48 | output [31:0] Do; |
| 49 | input [7:0] A; |
| 50 | |
| 51 | input VPWR; |
| 52 | input VGND; |
| 53 | |
| 54 | wire [31:0] Di_buf; |
| 55 | wire [31:0] Do_pre; |
| 56 | wire CLK_buf; |
| 57 | wire [3:0] WE_buf; |
| 58 | |
| 59 | wire [31:0] Do_B_0_0; |
| 60 | wire [31:0] Do_B_0_1; |
| 61 | wire [31:0] Do_B_0_2; |
| 62 | wire [31:0] Do_B_0_3; |
| 63 | |
| 64 | wire [3:0] row_sel; |
| 65 | |
| 66 | sky130_fd_sc_hd__clkbuf_8 CLKBUF ( .VPWR(VPWR), .VGND(VGND), .VPB(VPWR), .VNB(VGND), .X(CLK_buf), .A(CLK)); |
| 67 | sky130_fd_sc_hd__clkbuf_8 WEBUF[3:0] ( .VPWR(VPWR), .VGND(VGND), .VPB(VPWR), .VNB(VGND), .X(WE_buf), .A(WE)); |
| 68 | sky130_fd_sc_hd__clkbuf_8 DIBUF[31:0] ( .VPWR(VPWR), .VGND(VGND), .VPB(VPWR), .VNB(VGND), .X(Di_buf), .A(Di)); |
| 69 | |
| 70 | DEC2x4 DEC ( .VPWR(VPWR), .VGND(VGND), .EN(EN), .A(A[7:6]), .SEL(row_sel) ); |
| 71 | |
| 72 | SRAM64x32 B_0_0 ( .VPWR(VPWR), .VGND(VGND), .CLK(CLK_buf), .WE(WE_buf), .EN(row_sel[0]), .Di(Di_buf), .Do(Do_B_0_0), .A(A[5:0]) ); |
| 73 | SRAM64x32 B_0_1 ( .VPWR(VPWR), .VGND(VGND), .CLK(CLK_buf), .WE(WE_buf), .EN(row_sel[1]), .Di(Di_buf), .Do(Do_B_0_1), .A(A[5:0]) ); |
| 74 | SRAM64x32 B_0_2 ( .VPWR(VPWR), .VGND(VGND), .CLK(CLK_buf), .WE(WE_buf), .EN(row_sel[2]), .Di(Di_buf), .Do(Do_B_0_2), .A(A[5:0]) ); |
| 75 | SRAM64x32 B_0_3 ( .VPWR(VPWR), .VGND(VGND), .CLK(CLK_buf), .WE(WE_buf), .EN(row_sel[3]), .Di(Di_buf), .Do(Do_B_0_3), .A(A[5:0]) ); |
| 76 | |
| 77 | MUX4x1_32 MUX1 ( .VPWR(VPWR), .VGND(VGND), .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) ); |
| 78 | |
| 79 | sky130_fd_sc_hd__clkbuf_4 DOBUF[31:0] ( .VPWR(VPWR), .VGND(VGND), .VPB(VPWR), .VNB(VGND), .X(Do), .A(Do_pre)); |
| 80 | |
Ahmed Ghazy | 5586f1b | 2020-11-06 21:34:43 +0200 | [diff] [blame] | 81 | endmodule |
Manar | 68e0363 | 2020-11-09 13:25:13 +0200 | [diff] [blame] | 82 | |
| 83 | `endif |