aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/gowin/brams_map.v
blob: fbebc4af88c89ca4465a91aa10b183ae2ef7a93f (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* Semi Dual Port (SDP) memory have the following configurations:
 * Memory Config    RAM(BIT)   Port Mode   Memory Depth   Data Depth
 * ----------------|---------| ----------|--------------|------------|
 * B-SRAM_16K_SD1      16K      16Kx1       16,384           1
 * B-SRAM_8K_SD2       16K       8Kx2        8,192           2
 * B-SRAM_4K_SD4       16K       4Kx2        4,096           4
 */
module \$__GW1NR_SDP (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);
	parameter CFG_ABITS = 10;
	parameter CFG_DBITS = 16;
	parameter CFG_ENABLE_A = 1;
	parameter [16383:0] INIT = 16384'hx;
	parameter CLKPOL2 = 1;
	parameter CLKPOL3 = 1;

	input CLK2;
	input CLK3;

	input [CFG_ABITS-1:0] A1ADDR;
	input [CFG_DBITS-1:0] A1DATA;   
	input [CFG_ENABLE_A-1:0] A1EN;

	input [CFG_ABITS-1:0] B1ADDR;
	output [CFG_DBITS-1:0] B1DATA;
	input B1EN;

	wire [31-CFG_DBITS:0] open;

	
	generate if (CFG_DBITS == 1) begin
		SDP   #(
      `include "bram_init_16.vh"
			.READ_MODE(0),
			.BIT_WIDTH_0(1),
			.BIT_WIDTH_1(1),
			.BLK_SEL(3'b000),
			.RESET_MODE("SYNC")
		) _TECHMAP_REPLACE_ (
			.CLKA(CLK2),   .CLKB(CLK3),
			.WREA(A1EN),   .OCE(1'b0), .CEA(1'b1),
			.WREB(1'b0),   .CEB(B1EN),
			.RESETA(1'b0), .RESETB(1'b0), .BLKSEL(3'b000),
			.DI({{(32-CFG_DBITS){1'b0}}, A1DATA}),
			.DO({open, B1DATA}),
			.ADA({A1ADDR, {(14-CFG_ABITS){1'b0}}}),
			.ADB({B1ADDR, {(14-CFG_ABITS){1'b0}}})
		);
	end else if (CFG_DBITS == 2) begin
		SDP    #(
      `include "bram_init_16.vh"
			.READ_MODE(0),
			.BIT_WIDTH_0(2),
			.BIT_WIDTH_1(2),
			.BLK_SEL(3'b000),
			.RESET_MODE("SYNC")
		) _TECHMAP_REPLACE_ (
			.CLKA(CLK2),   .CLKB(CLK3),
			.WREA(A1EN),   .OCE(1'b0), .CEA(1'b1),
			.WREB(1'b0),   .CEB(B1EN),
			.RESETA(1'b0), .RESETB(1'b0), .BLKSEL(3'b000),
			.DI({{(32-CFG_DBITS){1'b0}}, A1DATA}),
			.DO({open, B1DATA}),
			.ADA({A1ADDR, {(14-CFG_ABITS){1'b0}}}),
			.ADB({B1ADDR, {(14-CFG_ABITS){1'b0}}})
		);
	end else if (CFG_DBITS <= 4) begin
		SDP    #(
      `include "bram_init_16.vh"
			.READ_MODE(0),
			.BIT_WIDTH_0(4),
			.BIT_WIDTH_1(4),
			.BLK_SEL(3'b000),
			.RESET_MODE("SYNC")
		) _TECHMAP_REPLACE_ (
			.CLKA(CLK2),   .CLKB(CLK3),
			.WREA(A1EN),   .OCE(1'b0),
			.WREB(1'b0),   .CEB(B1EN), .CEA(1'b1),
			.RESETA(1'b0), .RESETB(1'b0), .BLKSEL(3'b000),
			.DI({{(32-CFG_DBITS){1'b0}}, A1DATA}),
			.DO({open, B1DATA}),
			.ADA({A1ADDR, {(14-CFG_ABITS){1'b0}}}),
			.ADB({B1ADDR, {(14-CFG_ABITS){1'b0}}})
		);
	end else if (CFG_DBITS <= 8) begin
		SDP    #(
      `include "bram_init_16.vh"
			.READ_MODE(0),
			.BIT_WIDTH_0(8),
			.BIT_WIDTH_1(8),
			.BLK_SEL(3'b000),
			.RESET_MODE("SYNC")
		) _TECHMAP_REPLACE_ (
			.CLKA(CLK2),   .CLKB(CLK3),
			.WREA(A1EN),   .OCE(1'b0), .CEA(1'b1),
			.WREB(1'b0),   .CEB(B1EN),
			.RESETA(1'b0), .RESETB(1'b0), .BLKSEL(3'b000),
			.DI({{(32-CFG_DBITS){1'b0}}, A1DATA}),
			.DO({open, B1DATA}),
			.ADA({A1ADDR, {(14-CFG_ABITS){1'b0}}}),
			.ADB({B1ADDR, {(14-CFG_ABITS){1'b0}}})
		);
	end else if (CFG_DBITS <= 16) begin
		SDP    #(
      `include "bram_init_16.vh"
			.READ_MODE(0),
			.BIT_WIDTH_0(16),
			.BIT_WIDTH_1(16),
			.BLK_SEL(3'b000),
			.RESET_MODE("SYNC")
		) _TECHMAP_REPLACE_ (
			.CLKA(CLK2),   .CLKB(CLK3),
			.WREA(|A1EN),   .OCE(1'b0),
			.WREB(1'b0),   .CEB(B1EN), .CEA(1'b1),
			.RESETA(1'b0), .RESETB(1'b0), .BLKSEL(3'b000),
			.DI({{(32-CFG_DBITS){1'b0}}, A1DATA}),
			.DO({open, B1DATA}),
			.ADA({A1ADDR, {(12-CFG_ABITS){1'b0}}, A1EN}),
			.ADB({B1ADDR, {(14-CFG_ABITS){1'b0}}})
		);
	end else if (CFG_DBITS <= 32) begin
		SDP    #(
      `include "bram_init_16.vh"
			.READ_MODE(0),
			.BIT_WIDTH_0(32),
			.BIT_WIDTH_1(32),
			.BLK_SEL(3'b000),
			.RESET_MODE("SYNC")
		) _TECHMAP_REPLACE_ (
			.CLKA(CLK2),   .CLKB(CLK3),
			.WREA(|A1EN),   .OCE(1'b0),
			.WREB(1'b0),   .CEB(B1EN), .CEA(1'b1),
			.RESETA(1'b0), .RESETB(1'b0), .BLKSEL(3'b000),
			.DI(A1DATA),
			.DO(B1DATA),
			.ADA({A1ADDR, {(10-CFG_ABITS){1'b0}}, A1EN}),
			.ADB({B1ADDR, {(14-CFG_ABITS){1'b0}}})
		);
	end else begin
		wire TECHMAP_FAIL = 1'b1;
	end endgenerate
	
endmodule