1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
module $__GOWIN_LUTRAM_(...);
parameter INIT = 64'bx;
parameter BITS_USED = 0;
input PORT_W_CLK;
input [3:0] PORT_W_ADDR;
input PORT_W_WR_EN;
input [3:0] PORT_W_WR_DATA;
input [3:0] PORT_R_ADDR;
output [3:0] PORT_R_RD_DATA;
function [15:0] init_slice;
input integer idx;
integer i;
for (i = 0; i < 16; i = i + 1)
init_slice[i] = INIT[4*i+idx];
endfunction
generate
casez(BITS_USED)
4'b000z:
RAM16SDP1 #(
.INIT_0(init_slice(0)),
) _TECHMAP_REPLACE_ (
.WAD(PORT_W_ADDR),
.RAD(PORT_R_ADDR),
.DI(PORT_W_WR_DATA[0]),
.DO(PORT_R_RD_DATA[0]),
.CLK(PORT_W_CLK),
.WRE(PORT_W_WR_EN)
);
4'b00zz:
RAM16SDP2 #(
.INIT_0(init_slice(0)),
.INIT_1(init_slice(1)),
) _TECHMAP_REPLACE_ (
.WAD(PORT_W_ADDR),
.RAD(PORT_R_ADDR),
.DI(PORT_W_WR_DATA[1:0]),
.DO(PORT_R_RD_DATA[1:0]),
.CLK(PORT_W_CLK),
.WRE(PORT_W_WR_EN)
);
default:
RAM16SDP4 #(
.INIT_0(init_slice(0)),
.INIT_1(init_slice(1)),
.INIT_2(init_slice(2)),
.INIT_3(init_slice(3)),
) _TECHMAP_REPLACE_ (
.WAD(PORT_W_ADDR),
.RAD(PORT_R_ADDR),
.DI(PORT_W_WR_DATA),
.DO(PORT_R_RD_DATA),
.CLK(PORT_W_CLK),
.WRE(PORT_W_WR_EN)
);
endcase
endgenerate
endmodule
|