ecp5: First BRAM type maps successfully
authorDavid Shah <dave@ds0.me>
Wed, 10 Oct 2018 15:35:19 +0000 (16:35 +0100)
committerDavid Shah <dave@ds0.me>
Wed, 10 Oct 2018 15:35:19 +0000 (16:35 +0100)
Signed-off-by: David Shah <dave@ds0.me>
techlibs/ecp5/.gitignore
techlibs/ecp5/Makefile.inc
techlibs/ecp5/bram.txt
techlibs/ecp5/bram_map.v [deleted file]
techlibs/ecp5/brams_init.py
techlibs/ecp5/brams_map.v [new file with mode: 0644]
techlibs/ecp5/cells_sim.v
techlibs/ecp5/synth_ecp5.cc

index 3f66045f8be990e7fb397f5fb6f23d71b677494f..54c3297356bc3bfcff4146af93bc968dd283d59f 100644 (file)
@@ -6,3 +6,4 @@ bram_conn_2.vh
 bram_conn_4.vh
 bram_conn_9.vh
 bram_conn_18.vh
+brams_connect.mk
index 95d40fccf7d952e1f6d24a1f6ce91baa2f078abd..f4585939260585eeef7bc04424bb483a857baab3 100644 (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))
index 9d22e4afed7d627b1e0c3f10213b59fb30071150..f223a42b823d17695163004a85ff3d73d3d07d3a 100644 (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
diff --git a/techlibs/ecp5/bram_map.v b/techlibs/ecp5/bram_map.v
deleted file mode 100644 (file)
index e69de29..0000000
index 6f650b2a9c8c2c869c2e7ee69d17e7bca86d4621..96a47bdcddcc3fa3d7a1806246945b8793416ca4 100755 (executable)
@@ -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)
diff --git a/techlibs/ecp5/brams_map.v b/techlibs/ecp5/brams_map.v
new file mode 100644 (file)
index 0000000..894f5c4
--- /dev/null
@@ -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
index 4732381caf4a9f1481ab955b82860b04526b1e4a..e43632c640f4937f3f5266115a8b0fd0a77d0609 100644 (file)
@@ -475,6 +475,8 @@ module DP16KD(
   parameter WRITEMODE_A = "NORMAL";
   parameter WRITEMODE_B = "NORMAL";
 
+  parameter CLKAMUX = "CLKA";
+  parameter CLKBMUX = "CLKB";
 
   parameter GSR = "ENABLED";
 
index a13dd8d411d31df6a06cd6d009e90fcc56ba52c7..ab56a94442c8f8d5479cd91f5e40e4b1172b937f 100644 (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)"))