ecp5: First BRAM type maps successfully

Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
David Shah 2018-10-10 16:35:19 +01:00
parent 2ef1af8b58
commit 983fb7ff88
8 changed files with 76 additions and 10 deletions

View File

@ -6,3 +6,4 @@ bram_conn_2.vh
bram_conn_4.vh
bram_conn_9.vh
bram_conn_18.vh
brams_connect.mk

View File

@ -5,19 +5,38 @@ $(eval $(call add_share_file,share/ecp5,techlibs/ecp5/cells_map.v))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/cells_sim.v))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/drams_map.v))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/dram.txt))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/brams_map.v))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/bram.txt))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/arith_map.v))
EXTRA_OBJS += techlibs/ecp5/brams_init.mk
.SECONDARY: techlibs/ecp5/brams_init.mk
EXTRA_OBJS += techlibs/ecp5/brams_init.mk techlibs/ecp5/brams_connect.mk
.SECONDARY: techlibs/ecp5/brams_init.mk techlibs/ecp5/brams_connect.mk
techlibs/ecp5/brams_init.mk: techlibs/ecp5/brams_init.py
$(Q) mkdir -p techlibs/ecp5
$(P) python3 $<
$(Q) touch $@
techlibs/ecp5/brams_connect.mk: techlibs/ecp5/brams_connect.py
$(Q) mkdir -p techlibs/ecp5
$(P) python3 $<
$(Q) touch $@
techlibs/ecp5/bram_init_1_2_4.vh: techlibs/ecp5/brams_init.mk
techlibs/ecp5/bram_init_9_18_36.vh: techlibs/ecp5/brams_init.mk
techlibs/ecp5/bram_conn_1.vh: techlibs/ecp5/brams_connect.mk
techlibs/ecp5/bram_conn_2.vh: techlibs/ecp5/brams_connect.mk
techlibs/ecp5/bram_conn_4.vh: techlibs/ecp5/brams_connect.mk
techlibs/ecp5/bram_conn_9.vh: techlibs/ecp5/brams_connect.mk
techlibs/ecp5/bram_conn_18.vh: techlibs/ecp5/brams_connect.mk
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/bram_init_1_2_4.vh))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/bram_init_9_18_36.vh))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/bram_conn_1.vh))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/bram_conn_2.vh))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/bram_conn_4.vh))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/bram_conn_9.vh))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/bram_conn_18.vh))

View File

@ -18,8 +18,8 @@ bram $__ECP5_DP16KD
enable 2 1 @a10d18
enable 1 1 @a11d9 @a12d4 @a13d2 @a14d1
transp 0 2
clocks 1 2
clkpol 2 2
clocks 2 3
clkpol 2 3
endbram
match $__ECP5_DP16KD

View File

@ -8,7 +8,7 @@ with open("techlibs/ecp5/bram_init_1_2_4.vh", "w") as f:
init_snippets = list(reversed(init_snippets))
for k in range(8, 64, 8):
init_snippets[k] = "\n " + init_snippets[k]
print(".INIT_%02X({%s})," % (i, ", ".join(init_snippets)), file=f)
print(".INITVAL_%02X({%s})," % (i, ", ".join(init_snippets)), file=f)
with open("techlibs/ecp5/bram_init_9_18_36.vh", "w") as f:
for i in range(0, 0x40):
@ -19,4 +19,4 @@ with open("techlibs/ecp5/bram_init_9_18_36.vh", "w") as f:
init_snippets = list(reversed(init_snippets))
for k in range(8, 32, 8):
init_snippets[k] = "\n " + init_snippets[k]
print(".INIT_%02X({%s})," % (i, ", ".join(init_snippets)), file=f)
print(".INITVAL_%02X({%s})," % (i, ", ".join(init_snippets)), file=f)

47
techlibs/ecp5/brams_map.v Normal file
View File

@ -0,0 +1,47 @@
module \$__ECP5_DP16KD (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);
parameter CFG_ABITS = 10;
parameter CFG_DBITS = 18;
parameter CFG_ENABLE_A = 2;
parameter CLKPOL2 = 1;
parameter CLKPOL3 = 1;
parameter [18431:0] INIT = 18432'bx;
parameter TRANSP2 = 0;
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;
localparam CLKAMUX = CLKPOL2 ? "CLKA" : "INV";
localparam CLKBMUX = CLKPOL3 ? "CLKB" : "INV";
localparam WRITEMODE_A = TRANSP2 ? "WRITETHROUGH" : "NORMAL";
generate if (CFG_DBITS == 1) begin
DP16KD #(
`include "bram_init_1_2_4.vh"
.DATA_WIDTH_A(1),
.DATA_WIDTH_B(1),
.CLKAMUX(CLKAMUX),
.CLKBMUX(CLKBMUX),
.WRITEMODE_A(WRITEMODE_A),
.GSR("DISABLED")
) _TECHMAP_REPLACE_ (
`include "bram_conn_1.vh"
.CLKA(CLK2), .CLKB(CLK3),
.WEA(1'b1), .CEA(|A1EN), .OCEA(1'b1),
.WEB(1'b0), .CEB(B1EN), .OCEB(1'b1),
.RSTA(1'b0), .RSTB(1'b0)
);
end else begin
wire TECHMAP_FAIL = 1'b1;
end endgenerate
endmodule

View File

@ -475,6 +475,8 @@ module DP16KD(
parameter WRITEMODE_A = "NORMAL";
parameter WRITEMODE_B = "NORMAL";
parameter CLKAMUX = "CLKA";
parameter CLKBMUX = "CLKB";
parameter GSR = "ENABLED";

View File

@ -222,11 +222,8 @@ struct SynthEcp5Pass : public ScriptPass
if (!nobram && check_label("bram", "(skip if -nobram)"))
{
//TODO
#if 0
run("memory_bram -rules +/ecp5/brams.txt");
run("memory_bram -rules +/ecp5/bram.txt");
run("techmap -map +/ecp5/brams_map.v");
#endif
}
if (!nodram && check_label("dram", "(skip if -nodram)"))