gatemate: Use `memory_libmap` pass.
authorMarcelina Kościelnicka <mwk@0x04.net>
Sun, 6 Mar 2022 05:49:18 +0000 (06:49 +0100)
committerMarcelina Kościelnicka <mwk@0x04.net>
Wed, 18 May 2022 15:32:56 +0000 (17:32 +0200)
techlibs/gatemate/brams.txt
techlibs/gatemate/brams_map.v
techlibs/gatemate/synth_gatemate.cc

index 9e0bebba66d571fa9c9524f913de00d69f70f5b6..a0b500060a7fb83eb368661766e5fc4e1869057a 100644 (file)
-bram $__CC_BRAM_CASCADE
-  init 1
-  abits 16 @a16d1
-  dbits 1  @a16d1
-  groups 2
-  ports 1 1
-  wrmode 1 0
-  enable 1 1 @a16d1
-  transp 0 0
-  clocks 2 3
-  clkpol 2 3
-endbram
-
-bram $__CC_BRAM_40K_SDP
-  init 1
-  abits 9  @a9d80
-  dbits 80 @a9d80
-  groups 2
-  ports 1 1
-  wrmode 1 0
-  enable 80 1 @a9d80
-  transp 0 0
-  clocks 2 3
-  clkpol 2 3
-endbram
-
-bram $__CC_BRAM_20K_SDP
-  init 1
-  abits 9  @a9d40
-  dbits 40 @a9d40
-  groups 2
-  ports 1 1
-  wrmode 1 0
-  enable 40 1 @a9d40
-  transp 0 0
-  clocks 2 3
-  clkpol 2 3
-endbram
-
-bram $__CC_BRAM_40K_TDP
-  init 1
-  abits 10 @a10d40
-  dbits 40 @a10d40
-  abits 11 @a11d20
-  dbits 20 @a11d20
-  abits 12 @a12d10
-  dbits 10 @a12d10
-  abits 13 @a13d5
-  dbits 5  @a13d5
-  abits 14 @a14d2
-  dbits 2  @a14d2
-  abits 15 @a15d1
-  dbits 1  @a15d1
-  groups 2
-  ports 1 1
-  wrmode 1 0
-  enable 40 1 @a10d40
-  enable 20 1 @a11d20
-  enable 10 1 @a12d10
-  enable 5 1  @a13d5
-  enable 2 1  @a14d2
-  enable 1 1  @a15d1
-  transp 0 0
-  clocks 2 3
-  clkpol 2 3
-endbram
-
-bram $__CC_BRAM_20K_TDP
-  init 1
-  abits 10 @a10d20
-  dbits 20 @a10d20
-  abits 11 @a11d10
-  dbits 10 @a11d10
-  abits 12 @a12d5
-  dbits 5  @a12d5
-  abits 13 @a13d2
-  dbits 2  @a13d2
-  abits 14 @a14d1
-  dbits 1  @a14d1
-  groups 2
-  ports 1 1
-  wrmode 1 0
-  enable 20 1 @a10d20
-  enable 10 1 @a11d10
-  enable 5 1  @a12d5
-  enable 2 1  @a13d2
-  enable 1 1  @a14d1
-  transp 0 0
-  clocks 2 3
-  clkpol 2 3
-endbram
-
-match $__CC_BRAM_CASCADE
-  # implicitly requested RAM or ROM
-  attribute !syn_ramstyle syn_ramstyle=auto
-  attribute !syn_romstyle syn_romstyle=auto
-  attribute !ram_block
-  attribute !rom_block
-  attribute !logic_block
-  min bits 512
-  min efficiency 5
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_CASCADE
-  # explicitly requested RAM
-  attribute syn_ramstyle=block_ram ram_block
-  attribute !syn_romstyle
-  attribute !rom_block
-  attribute !logic_block
-  min wports 1
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_CASCADE
-  # explicitly requested ROM
-  attribute syn_romstyle=ebr rom_block
-  attribute !syn_ramstyle
-  attribute !ram_block
-  attribute !logic_block
-  max wports 0
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_40K_SDP
-  # implicitly requested RAM or ROM
-  attribute !syn_ramstyle syn_ramstyle=auto
-  attribute !syn_romstyle syn_romstyle=auto
-  attribute !ram_block
-  attribute !rom_block
-  attribute !logic_block
-  min bits 512
-  min efficiency 5
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_40K_SDP
-  # explicitly requested RAM
-  attribute syn_ramstyle=block_ram ram_block
-  attribute !syn_romstyle
-  attribute !rom_block
-  attribute !logic_block
-  min wports 1
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_40K_SDP
-  # explicitly requested ROM
-  attribute syn_romstyle=ebr rom_block
-  attribute !syn_ramstyle
-  attribute !ram_block
-  attribute !logic_block
-  max wports 0
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_20K_SDP
-  # implicitly requested RAM or ROM
-  attribute !syn_ramstyle syn_ramstyle=auto
-  attribute !syn_romstyle syn_romstyle=auto
-  attribute !ram_block
-  attribute !rom_block
-  attribute !logic_block
-  min bits 512
-  min efficiency 5
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_20K_SDP
-  # explicitly requested RAM
-  attribute syn_ramstyle=block_ram ram_block
-  attribute !syn_romstyle
-  attribute !rom_block
-  attribute !logic_block
-  min wports 1
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_20K_SDP
-  # explicitly requested ROM
-  attribute syn_romstyle=ebr rom_block
-  attribute !syn_ramstyle
-  attribute !ram_block
-  attribute !logic_block
-  max wports 0
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_40K_TDP
-  # implicitly requested RAM or ROM
-  attribute !syn_ramstyle syn_ramstyle=auto
-  attribute !syn_romstyle syn_romstyle=auto
-  attribute !ram_block
-  attribute !rom_block
-  attribute !logic_block
-  min bits 512
-  min efficiency 5
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_40K_TDP
-  # explicitly requested RAM
-  attribute syn_ramstyle=block_ram ram_block
-  attribute !syn_romstyle
-  attribute !rom_block
-  attribute !logic_block
-  min wports 1
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_40K_TDP
-  # explicitly requested ROM
-  attribute syn_romstyle=ebr rom_block
-  attribute !syn_ramstyle
-  attribute !ram_block
-  attribute !logic_block
-  max wports 0
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_20K_TDP
-  # implicitly requested RAM or ROM
-  attribute !syn_ramstyle syn_ramstyle=auto
-  attribute !syn_romstyle syn_romstyle=auto
-  attribute !ram_block
-  attribute !rom_block
-  attribute !logic_block
-  min bits 512
-  min efficiency 5
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_20K_TDP
-  # explicitly requested RAM
-  attribute syn_ramstyle=block_ram ram_block
-  attribute !syn_romstyle
-  attribute !rom_block
-  attribute !logic_block
-  min wports 1
-  shuffle_enable A
-  make_transp
-  or_next_if_better
-endmatch
-
-match $__CC_BRAM_20K_TDP
-  # explicitly requested ROM
-  attribute syn_romstyle=ebr rom_block
-  attribute !syn_ramstyle
-  attribute !ram_block
-  attribute !logic_block
-  max wports 0
-  shuffle_enable A
-  make_transp
-endmatch
+ram block $__CC_BRAM_TDP_ {
+       option "MODE" "20K" {
+               abits 14;
+               widths 1 2 5 10 20 per_port;
+               cost 129;
+       }
+       option "MODE" "40K" {
+               abits 15;
+               widths 1 2 5 10 20 40 per_port;
+               cost 257;
+       }
+       option "MODE" "CASCADE" {
+               abits 16;
+               # hack to enforce same INIT layout as in the other modes
+               widths 1 2 5 per_port;
+               cost 513;
+       }
+       byte 1;
+       init no_undef;
+       port srsw "A" "B" {
+               clock anyedge;
+               clken;
+               option "MODE" "20K" {
+                       width mix;
+               }
+               option "MODE" "40K" {
+                       width mix;
+               }
+               option "MODE" "CASCADE" {
+                       width mix 1;
+               }
+               portoption "WR_MODE" "NO_CHANGE" {
+                       rdwr no_change;
+               }
+               portoption "WR_MODE" "WRITE_THROUGH" {
+                       rdwr new;
+               }
+               wrbe_separate;
+       }
+}
+
+ram block $__CC_BRAM_SDP_ {
+       option "MODE" "20K" {
+               abits 14;
+               widths 1 2 5 10 20 40 per_port;
+               cost 129;
+       }
+       option "MODE" "40K" {
+               abits 15;
+               widths 1 2 5 10 20 40 80 per_port;
+               cost 257;
+       }
+       byte 1;
+       init no_undef;
+       port sr "R" {
+               option "MODE" "20K" {
+                       width 40;
+               }
+               option "MODE" "40K" {
+                       width 80;
+               }
+               clock anyedge;
+               clken;
+       }
+       port sw "W" {
+               option "MODE" "20K" {
+                       width 40;
+               }
+               option "MODE" "40K" {
+                       width 80;
+               }
+               clock anyedge;
+               clken;
+               wrbe_separate;
+       }
+}
index f36f05212d3f0b3425283241311794d1ffd4b6f1..7023f5ef29e793b054b7960efe6d45b8f03c502b 100644 (file)
-/*\r
- *  yosys -- Yosys Open SYnthesis Suite\r
- *\r
- *  Copyright (C) 2021  Cologne Chip AG <support@colognechip.com>\r
- *\r
- *  Permission to use, copy, modify, and/or distribute this software for any\r
- *  purpose with or without fee is hereby granted, provided that the above\r
- *  copyright notice and this permission notice appear in all copies.\r
- *\r
- *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\r
- *  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\r
- *  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\r
- *  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\r
- *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\r
- *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\r
- *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\r
- *\r
- */\r
-\r
-module \$__CC_BRAM_20K_SDP (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);\r
-\r
-       parameter CFG_ABITS = 14;\r
-       parameter CFG_DBITS = 40;\r
-       parameter CFG_ENABLE_A = 1;\r
-       parameter CFG_ENABLE_B = 1;\r
-\r
-       parameter CLKPOL2 = 1;\r
-       parameter CLKPOL3 = 1;\r
-\r
-       // 512 x 40 bit\r
-       parameter [20479:0] INIT = 20480'b0;\r
-\r
-       input CLK2;\r
-       input CLK3;\r
-\r
-       // write side of the memory\r
-       input [15:0] A1ADDR;\r
-       input [39:0] A1DATA;\r
-       input [39:0] A1EN;\r
-\r
-       // read side of the memory\r
-       input [15:0] B1ADDR;\r
-       output [39:0] B1DATA;\r
-       input [0:0] B1EN;\r
-\r
-       // unconnected signals\r
-       wire ECC_1B_ERR, ECC_2B_ERR;\r
-\r
-       // internal signals\r
-       wire [15:0] ADDRA = {A1ADDR, 7'b0};\r
-       wire [15:0] ADDRB = {B1ADDR, 7'b0};\r
-\r
-       localparam INIT_CHUNK_SIZE = 320;\r
-\r
-       function [319:0] permute_init;\r
-               input [INIT_CHUNK_SIZE-1:0] chunk;\r
-               integer i;\r
-               begin\r
-                       permute_init = chunk;\r
-               end\r
-       endfunction\r
-\r
-       CC_BRAM_20K #(\r
-               `include "brams_init_20.vh"\r
-               .LOC("UNPLACED"),\r
-               .A_RD_WIDTH(0), .B_RD_WIDTH(CFG_DBITS),\r
-               .A_WR_WIDTH(CFG_DBITS), .B_WR_WIDTH(0),\r
-               .RAM_MODE("SDP"),\r
-               .A_WR_MODE("NO_CHANGE"), .B_WR_MODE("NO_CHANGE"),\r
-               .A_CLK_INV(!CLKPOL2), .B_CLK_INV(!CLKPOL3),\r
-               .A_EN_INV(1'b0), .B_EN_INV(1'b0),\r
-               .A_WE_INV(1'b0), .B_WE_INV(1'b0),\r
-               .A_DO_REG(1'b0), .B_DO_REG(1'b0),\r
-               .ECC_EN(1'b0)\r
-       ) _TECHMAP_REPLACE_ (\r
-               .A_DO(B1DATA[19:0]),\r
-               .B_DO(B1DATA[39:20]),\r
-               .ECC_1B_ERR(ECC_1B_ERR),\r
-               .ECC_2B_ERR(ECC_2B_ERR),\r
-               .A_CLK(CLK2),\r
-               .B_CLK(CLK3),\r
-               .A_EN(1'b1),\r
-               .B_EN(B1EN),\r
-               .A_WE(|A1EN),\r
-               .B_WE(1'b0),\r
-               .A_ADDR(ADDRA),\r
-               .B_ADDR(ADDRB),\r
-               .A_DI(A1DATA[19:0]),\r
-               .B_DI(A1DATA[39:20]),\r
-               .A_BM(A1EN[19:0]),\r
-               .B_BM(A1EN[39:20])\r
-       );\r
-\r
-endmodule\r
-\r
-\r
-module \$__CC_BRAM_40K_SDP (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);\r
-\r
-       parameter CFG_ABITS = 15;\r
-       parameter CFG_DBITS = 80;\r
-       parameter CFG_ENABLE_A = 1;\r
-       parameter CFG_ENABLE_B = 1;\r
-\r
-       parameter CLKPOL2 = 1;\r
-       parameter CLKPOL3 = 1;\r
-\r
-       // 512 x 80 bit\r
-       parameter [40959:0] INIT = 40960'b0;\r
-\r
-       input CLK2;\r
-       input CLK3;\r
-\r
-       // write side of the memory\r
-       input [15:0] A1ADDR;\r
-       input [79:0] A1DATA;\r
-       input [79:0] A1EN;\r
-\r
-       // read side of the memory\r
-       input [15:0] B1ADDR;\r
-       output [79:0] B1DATA;\r
-       input [0:0] B1EN;\r
-\r
-       // unconnected signals\r
-       wire A_ECC_1B_ERR, B_ECC_1B_ERR, A_ECC_2B_ERR, B_ECC_2B_ERR;\r
-\r
-       // internal signals\r
-       wire [15:0] ADDRA = {A1ADDR, 7'b0};\r
-       wire [15:0] ADDRB = {B1ADDR, 7'b0};\r
-\r
-       localparam INIT_CHUNK_SIZE = 320;\r
-\r
-       function [319:0] permute_init;\r
-               input [INIT_CHUNK_SIZE-1:0] chunk;\r
-               integer i;\r
-               begin\r
-                       permute_init = chunk;\r
-               end\r
-       endfunction\r
-\r
-       CC_BRAM_40K #(\r
-               `define INIT_LOWER\r
-               `include "brams_init_40.vh"\r
-               `undef INIT_LOWER\r
-               .LOC("UNPLACED"),\r
-               .CAS("NONE"),\r
-               .A_RD_WIDTH(0), .B_RD_WIDTH(CFG_DBITS),\r
-               .A_WR_WIDTH(CFG_DBITS), .B_WR_WIDTH(0),\r
-               .RAM_MODE("SDP"),\r
-               .A_WR_MODE("NO_CHANGE"), .B_WR_MODE("NO_CHANGE"),\r
-               .A_CLK_INV(!CLKPOL2), .B_CLK_INV(!CLKPOL3),\r
-               .A_EN_INV(1'b0), .B_EN_INV(1'b0),\r
-               .A_WE_INV(1'b0), .B_WE_INV(1'b0),\r
-               .A_DO_REG(1'b0), .B_DO_REG(1'b0),\r
-               .A_ECC_EN(1'b0), .B_ECC_EN(1'b0)\r
-       ) _TECHMAP_REPLACE_ (\r
-               .A_DO(B1DATA[39:0]),\r
-               .B_DO(B1DATA[79:40]),\r
-               .A_ECC_1B_ERR(A_ECC_1B_ERR),\r
-               .B_ECC_1B_ERR(B_ECC_1B_ERR),\r
-               .A_ECC_2B_ERR(A_ECC_2B_ERR),\r
-               .B_ECC_2B_ERR(B_ECC_2B_ERR),\r
-               .A_CLK(CLK2),\r
-               .B_CLK(CLK3),\r
-               .A_EN(1'b1),\r
-               .B_EN(B1EN),\r
-               .A_WE(|A1EN),\r
-               .B_WE(1'b0),\r
-               .A_ADDR(ADDRA),\r
-               .B_ADDR(ADDRB),\r
-               .A_DI(A1DATA[39:0]),\r
-               .B_DI(A1DATA[79:40]),\r
-               .A_BM(A1EN[39:0]),\r
-               .B_BM(A1EN[79:40])\r
-       );\r
-\r
-endmodule\r
-\r
-\r
-module \$__CC_BRAM_20K_TDP (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);\r
-\r
-       parameter CFG_ABITS = 14;\r
-       parameter CFG_DBITS = 20;\r
-       parameter CFG_ENABLE_A = 1;\r
-       parameter CFG_ENABLE_B = 1;\r
-\r
-       parameter CLKPOL2 = 1;\r
-       parameter CLKPOL3 = 1;\r
-\r
-       // 512 x 40 bit\r
-       parameter [20479:0] INIT = 20480'b0;\r
-\r
-       input CLK2;\r
-       input CLK3;\r
-\r
-       // write side of the memory\r
-       input [15:0] A1ADDR;\r
-       input [19:0] A1DATA;\r
-       input [19:0] A1EN;\r
-\r
-       // read side of the memory\r
-       input [15:0] B1ADDR;\r
-       output [19:0] B1DATA;\r
-       input [0:0] B1EN;\r
-\r
-       // unconnected signals\r
-       wire [19:0] A_DO;\r
-       wire ECC_1B_ERR, ECC_2B_ERR;\r
-\r
-       localparam INIT_CHUNK_SIZE = (CFG_DBITS <= 2) ? 256 : 320;\r
-\r
-       function [319:0] permute_init;\r
-               input [INIT_CHUNK_SIZE-1:0] chunk;\r
-               integer i;\r
-               begin\r
-                       if (CFG_DBITS <= 2) begin\r
-                               for (i = 0; i < 64; i = i + 1) begin\r
-                                       permute_init[i * 5 +: 5] = {1'b0, chunk[i * 4 +: 4]};\r
-                               end\r
-                       end else begin\r
-                               permute_init = chunk;\r
-                       end\r
-               end\r
-       endfunction\r
-\r
-       // internal signals\r
-       generate\r
-               wire [15:0] ADDRA;\r
-               wire [15:0] ADDRB;\r
-\r
-               if (CFG_DBITS == 1) begin: blk\r
-                       assign ADDRA = {A1ADDR[13:5], 1'b0, A1ADDR[4:0], 1'b0};\r
-                       assign ADDRB = {B1ADDR[13:5], 1'b0, B1ADDR[4:0], 1'b0};\r
-               end\r
-               else if (CFG_DBITS == 2) begin: blk\r
-                       assign ADDRA = {A1ADDR[12:4], 1'b0, A1ADDR[3:0], 2'b0};\r
-                       assign ADDRB = {B1ADDR[12:4], 1'b0, B1ADDR[3:0], 2'b0};\r
-               end\r
-               else if (CFG_DBITS == 5) begin: blk\r
-                       assign ADDRA = {A1ADDR[11:3], 1'b0, A1ADDR[2:0], 3'b0};\r
-                       assign ADDRB = {B1ADDR[11:3], 1'b0, B1ADDR[2:0], 3'b0};\r
-               end\r
-               else if (CFG_DBITS == 10) begin: blk\r
-                       assign ADDRA = {A1ADDR[10:2], 1'b0, A1ADDR[1:0], 4'b0};\r
-                       assign ADDRB = {B1ADDR[10:2], 1'b0, B1ADDR[1:0], 4'b0};\r
-               end\r
-               else if (CFG_DBITS == 20) begin: blk\r
-                       assign ADDRA = {A1ADDR[9:1], 1'b0, A1ADDR[0], 5'b0};\r
-                       assign ADDRB = {B1ADDR[9:1], 1'b0, B1ADDR[0], 5'b0};\r
-               end\r
-\r
+module $__CC_BRAM_TDP_(...);\r
+\r
+parameter INIT = 0;\r
+parameter OPTION_MODE = "20K";\r
+\r
+parameter PORT_A_CLK_POL = 1;\r
+parameter PORT_A_RD_WIDTH = 1;\r
+parameter PORT_A_WR_WIDTH = 1;\r
+parameter PORT_A_WR_BE_WIDTH = 1;\r
+parameter PORT_A_OPTION_WR_MODE = "NO_CHANGE";\r
+\r
+parameter PORT_B_CLK_POL = 1;\r
+parameter PORT_B_RD_WIDTH = 1;\r
+parameter PORT_B_WR_WIDTH = 1;\r
+parameter PORT_B_WR_BE_WIDTH = 1;\r
+parameter PORT_B_OPTION_WR_MODE = "NO_CHANGE";\r
+\r
+input PORT_A_CLK;\r
+input PORT_A_CLK_EN;\r
+input PORT_A_WR_EN;\r
+input [15:0] PORT_A_ADDR;\r
+input [PORT_A_WR_BE_WIDTH-1:0] PORT_A_WR_BE;\r
+input [PORT_A_WR_WIDTH-1:0] PORT_A_WR_DATA;\r
+output [PORT_A_RD_WIDTH-1:0] PORT_A_RD_DATA;\r
+\r
+input PORT_B_CLK;\r
+input PORT_B_CLK_EN;\r
+input PORT_B_WR_EN;\r
+input [15:0] PORT_B_ADDR;\r
+input [PORT_B_WR_BE_WIDTH-1:0] PORT_B_WR_BE;\r
+input [PORT_B_WR_WIDTH-1:0] PORT_B_WR_DATA;\r
+output [PORT_B_RD_WIDTH-1:0] PORT_B_RD_DATA;\r
+\r
+generate\r
+       if (OPTION_MODE == "20K") begin\r
                CC_BRAM_20K #(\r
-                       `include "brams_init_20.vh"\r
-                       .LOC("UNPLACED"),\r
-                       .A_RD_WIDTH(0), .B_RD_WIDTH(CFG_DBITS),\r
-                       .A_WR_WIDTH(CFG_DBITS), .B_WR_WIDTH(0),\r
+                       .INIT_00(INIT['h00*320+:320]),\r
+                       .INIT_01(INIT['h01*320+:320]),\r
+                       .INIT_02(INIT['h02*320+:320]),\r
+                       .INIT_03(INIT['h03*320+:320]),\r
+                       .INIT_04(INIT['h04*320+:320]),\r
+                       .INIT_05(INIT['h05*320+:320]),\r
+                       .INIT_06(INIT['h06*320+:320]),\r
+                       .INIT_07(INIT['h07*320+:320]),\r
+                       .INIT_08(INIT['h08*320+:320]),\r
+                       .INIT_09(INIT['h09*320+:320]),\r
+                       .INIT_0A(INIT['h0a*320+:320]),\r
+                       .INIT_0B(INIT['h0b*320+:320]),\r
+                       .INIT_0C(INIT['h0c*320+:320]),\r
+                       .INIT_0D(INIT['h0d*320+:320]),\r
+                       .INIT_0E(INIT['h0e*320+:320]),\r
+                       .INIT_0F(INIT['h0f*320+:320]),\r
+                       .INIT_10(INIT['h10*320+:320]),\r
+                       .INIT_11(INIT['h11*320+:320]),\r
+                       .INIT_12(INIT['h12*320+:320]),\r
+                       .INIT_13(INIT['h13*320+:320]),\r
+                       .INIT_14(INIT['h14*320+:320]),\r
+                       .INIT_15(INIT['h15*320+:320]),\r
+                       .INIT_16(INIT['h16*320+:320]),\r
+                       .INIT_17(INIT['h17*320+:320]),\r
+                       .INIT_18(INIT['h18*320+:320]),\r
+                       .INIT_19(INIT['h19*320+:320]),\r
+                       .INIT_1A(INIT['h1a*320+:320]),\r
+                       .INIT_1B(INIT['h1b*320+:320]),\r
+                       .INIT_1C(INIT['h1c*320+:320]),\r
+                       .INIT_1D(INIT['h1d*320+:320]),\r
+                       .INIT_1E(INIT['h1e*320+:320]),\r
+                       .INIT_1F(INIT['h1f*320+:320]),\r
+                       .INIT_20(INIT['h20*320+:320]),\r
+                       .INIT_21(INIT['h21*320+:320]),\r
+                       .INIT_22(INIT['h22*320+:320]),\r
+                       .INIT_23(INIT['h23*320+:320]),\r
+                       .INIT_24(INIT['h24*320+:320]),\r
+                       .INIT_25(INIT['h25*320+:320]),\r
+                       .INIT_26(INIT['h26*320+:320]),\r
+                       .INIT_27(INIT['h27*320+:320]),\r
+                       .INIT_28(INIT['h28*320+:320]),\r
+                       .INIT_29(INIT['h29*320+:320]),\r
+                       .INIT_2A(INIT['h2a*320+:320]),\r
+                       .INIT_2B(INIT['h2b*320+:320]),\r
+                       .INIT_2C(INIT['h2c*320+:320]),\r
+                       .INIT_2D(INIT['h2d*320+:320]),\r
+                       .INIT_2E(INIT['h2e*320+:320]),\r
+                       .INIT_2F(INIT['h2f*320+:320]),\r
+                       .INIT_30(INIT['h30*320+:320]),\r
+                       .INIT_31(INIT['h31*320+:320]),\r
+                       .INIT_32(INIT['h32*320+:320]),\r
+                       .INIT_33(INIT['h33*320+:320]),\r
+                       .INIT_34(INIT['h34*320+:320]),\r
+                       .INIT_35(INIT['h35*320+:320]),\r
+                       .INIT_36(INIT['h36*320+:320]),\r
+                       .INIT_37(INIT['h37*320+:320]),\r
+                       .INIT_38(INIT['h38*320+:320]),\r
+                       .INIT_39(INIT['h39*320+:320]),\r
+                       .INIT_3A(INIT['h3a*320+:320]),\r
+                       .INIT_3B(INIT['h3b*320+:320]),\r
+                       .INIT_3C(INIT['h3c*320+:320]),\r
+                       .INIT_3D(INIT['h3d*320+:320]),\r
+                       .INIT_3E(INIT['h3e*320+:320]),\r
+                       .INIT_3F(INIT['h3f*320+:320]),\r
+                       .A_RD_WIDTH(PORT_A_RD_WIDTH),\r
+                       .A_WR_WIDTH(PORT_A_WR_WIDTH),\r
+                       .B_RD_WIDTH(PORT_B_RD_WIDTH),\r
+                       .B_WR_WIDTH(PORT_B_WR_WIDTH),\r
                        .RAM_MODE("TDP"),\r
-                       .A_WR_MODE("NO_CHANGE"), .B_WR_MODE("NO_CHANGE"),\r
-                       .A_CLK_INV(!CLKPOL2), .B_CLK_INV(!CLKPOL3),\r
-                       .A_EN_INV(1'b0), .B_EN_INV(1'b0),\r
-                       .A_WE_INV(1'b0), .B_WE_INV(1'b0),\r
-                       .A_DO_REG(1'b0), .B_DO_REG(1'b0),\r
-                       .ECC_EN(1'b0)\r
+                       .A_WR_MODE(PORT_A_OPTION_WR_MODE),\r
+                       .B_WR_MODE(PORT_B_OPTION_WR_MODE),\r
+                       .A_CLK_INV(!PORT_A_CLK_POL),\r
+                       .B_CLK_INV(!PORT_B_CLK_POL),\r
                ) _TECHMAP_REPLACE_ (\r
-                       .A_DO(A_DO),\r
-                       .B_DO(B1DATA),\r
-                       .ECC_1B_ERR(ECC_1B_ERR),\r
-                       .ECC_2B_ERR(ECC_2B_ERR),\r
-                       .A_CLK(CLK2),\r
-                       .B_CLK(CLK3),\r
-                       .A_EN(1'b1),\r
-                       .B_EN(B1EN),\r
-                       .A_WE(|A1EN),\r
-                       .B_WE(1'b0),\r
-                       .A_ADDR(ADDRA),\r
-                       .B_ADDR(ADDRB),\r
-                       .A_DI(A1DATA),\r
-                       .B_DI(20'b0),\r
-                       .A_BM(A1EN),\r
-                       .B_BM(20'b0)\r
+                       .A_CLK(PORT_A_CLK),\r
+                       .A_EN(PORT_A_CLK_EN),\r
+                       .A_WE(PORT_A_WR_EN),\r
+                       .A_BM(PORT_A_WR_BE),\r
+                       .A_DI(PORT_A_WR_DATA),\r
+                       .A_ADDR({PORT_A_ADDR[13:5], 1'b0, PORT_A_ADDR[4:0], 1'b0}),\r
+                       .A_DO(PORT_A_RD_DATA),\r
+                       .B_CLK(PORT_B_CLK),\r
+                       .B_EN(PORT_B_CLK_EN),\r
+                       .B_WE(PORT_B_WR_EN),\r
+                       .B_BM(PORT_B_WR_BE),\r
+                       .B_DI(PORT_A_WR_DATA),\r
+                       .B_ADDR({PORT_B_ADDR[13:5], 1'b0, PORT_B_ADDR[4:0], 1'b0}),\r
+                       .B_DO(PORT_B_RD_DATA),\r
                );\r
-       endgenerate\r
-\r
-endmodule\r
-\r
-\r
-module \$__CC_BRAM_40K_TDP (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);\r
-\r
-       parameter CFG_ABITS = 15;\r
-       parameter CFG_DBITS = 40;\r
-       parameter CFG_ENABLE_A = 1;\r
-       parameter CFG_ENABLE_B = 1;\r
-\r
-       parameter CLKPOL2 = 1;\r
-       parameter CLKPOL3 = 1;\r
-\r
-       // 512 x 80 bit\r
-       parameter [40959:0] INIT = 40960'b0;\r
-\r
-       input CLK2;\r
-       input CLK3;\r
-\r
-       // write side of the memory\r
-       input [15:0] A1ADDR;\r
-       input [39:0] A1DATA;\r
-       input [39:0] A1EN;\r
-\r
-       // read side of the memory\r
-       input [15:0] B1ADDR;\r
-       output [39:0] B1DATA;\r
-       input [0:0] B1EN;\r
-\r
-       // unconnected signals\r
-       wire [39:0] A_DO;\r
-       wire A_ECC_1B_ERR, B_ECC_1B_ERR, A_ECC_2B_ERR, B_ECC_2B_ERR;\r
-\r
-       localparam INIT_CHUNK_SIZE = (CFG_DBITS <= 2) ? 256 : 320;\r
-\r
-       function [319:0] permute_init;\r
-               input [INIT_CHUNK_SIZE-1:0] chunk;\r
-               integer i;\r
-               begin\r
-                       if (CFG_DBITS <= 2) begin\r
-                               for (i = 0; i < 64; i = i + 1) begin\r
-                                       permute_init[i * 5 +: 5] = {1'b0, chunk[i * 4 +: 4]};\r
-                               end\r
-                       end else begin\r
-                               permute_init = chunk;\r
-                       end\r
-               end\r
-       endfunction\r
-\r
-       generate\r
-               wire [15:0] ADDRA;\r
-               wire [15:0] ADDRB;\r
-\r
-               if (CFG_DBITS == 1) begin\r
-                       assign ADDRA = {A1ADDR, 1'b0};\r
-                       assign ADDRB = {B1ADDR, 1'b0};\r
-               end\r
-               else if (CFG_DBITS == 2) begin\r
-                       assign ADDRA = {A1ADDR, 2'b0};\r
-                       assign ADDRB = {B1ADDR, 2'b0};\r
-               end\r
-               else if (CFG_DBITS == 5) begin\r
-                       assign ADDRA = {A1ADDR, 3'b0};\r
-                       assign ADDRB = {B1ADDR, 3'b0};\r
-               end\r
-               else if (CFG_DBITS == 10) begin\r
-                       assign ADDRA = {A1ADDR, 4'b0};\r
-                       assign ADDRB = {B1ADDR, 4'b0};\r
-               end\r
-               else if (CFG_DBITS == 20) begin\r
-                       assign ADDRA = {A1ADDR, 5'b0};\r
-                       assign ADDRB = {B1ADDR, 5'b0};\r
-               end\r
-               else if (CFG_DBITS == 40) begin\r
-                       assign ADDRA = {A1ADDR, 6'b0};\r
-                       assign ADDRB = {B1ADDR, 6'b0};\r
-               end\r
-\r
+       end else if (OPTION_MODE == "40K") begin\r
                CC_BRAM_40K #(\r
-                       `define INIT_LOWER\r
-                       `include "brams_init_40.vh"\r
-                       `undef INIT_LOWER\r
-                       .LOC("UNPLACED"),\r
-                       .CAS("NONE"),\r
-                       .A_RD_WIDTH(0), .B_RD_WIDTH(CFG_DBITS),\r
-                       .A_WR_WIDTH(CFG_DBITS), .B_WR_WIDTH(0),\r
+                       .INIT_00(INIT['h00*320+:320]),\r
+                       .INIT_01(INIT['h01*320+:320]),\r
+                       .INIT_02(INIT['h02*320+:320]),\r
+                       .INIT_03(INIT['h03*320+:320]),\r
+                       .INIT_04(INIT['h04*320+:320]),\r
+                       .INIT_05(INIT['h05*320+:320]),\r
+                       .INIT_06(INIT['h06*320+:320]),\r
+                       .INIT_07(INIT['h07*320+:320]),\r
+                       .INIT_08(INIT['h08*320+:320]),\r
+                       .INIT_09(INIT['h09*320+:320]),\r
+                       .INIT_0A(INIT['h0a*320+:320]),\r
+                       .INIT_0B(INIT['h0b*320+:320]),\r
+                       .INIT_0C(INIT['h0c*320+:320]),\r
+                       .INIT_0D(INIT['h0d*320+:320]),\r
+                       .INIT_0E(INIT['h0e*320+:320]),\r
+                       .INIT_0F(INIT['h0f*320+:320]),\r
+                       .INIT_10(INIT['h10*320+:320]),\r
+                       .INIT_11(INIT['h11*320+:320]),\r
+                       .INIT_12(INIT['h12*320+:320]),\r
+                       .INIT_13(INIT['h13*320+:320]),\r
+                       .INIT_14(INIT['h14*320+:320]),\r
+                       .INIT_15(INIT['h15*320+:320]),\r
+                       .INIT_16(INIT['h16*320+:320]),\r
+                       .INIT_17(INIT['h17*320+:320]),\r
+                       .INIT_18(INIT['h18*320+:320]),\r
+                       .INIT_19(INIT['h19*320+:320]),\r
+                       .INIT_1A(INIT['h1a*320+:320]),\r
+                       .INIT_1B(INIT['h1b*320+:320]),\r
+                       .INIT_1C(INIT['h1c*320+:320]),\r
+                       .INIT_1D(INIT['h1d*320+:320]),\r
+                       .INIT_1E(INIT['h1e*320+:320]),\r
+                       .INIT_1F(INIT['h1f*320+:320]),\r
+                       .INIT_20(INIT['h20*320+:320]),\r
+                       .INIT_21(INIT['h21*320+:320]),\r
+                       .INIT_22(INIT['h22*320+:320]),\r
+                       .INIT_23(INIT['h23*320+:320]),\r
+                       .INIT_24(INIT['h24*320+:320]),\r
+                       .INIT_25(INIT['h25*320+:320]),\r
+                       .INIT_26(INIT['h26*320+:320]),\r
+                       .INIT_27(INIT['h27*320+:320]),\r
+                       .INIT_28(INIT['h28*320+:320]),\r
+                       .INIT_29(INIT['h29*320+:320]),\r
+                       .INIT_2A(INIT['h2a*320+:320]),\r
+                       .INIT_2B(INIT['h2b*320+:320]),\r
+                       .INIT_2C(INIT['h2c*320+:320]),\r
+                       .INIT_2D(INIT['h2d*320+:320]),\r
+                       .INIT_2E(INIT['h2e*320+:320]),\r
+                       .INIT_2F(INIT['h2f*320+:320]),\r
+                       .INIT_30(INIT['h30*320+:320]),\r
+                       .INIT_31(INIT['h31*320+:320]),\r
+                       .INIT_32(INIT['h32*320+:320]),\r
+                       .INIT_33(INIT['h33*320+:320]),\r
+                       .INIT_34(INIT['h34*320+:320]),\r
+                       .INIT_35(INIT['h35*320+:320]),\r
+                       .INIT_36(INIT['h36*320+:320]),\r
+                       .INIT_37(INIT['h37*320+:320]),\r
+                       .INIT_38(INIT['h38*320+:320]),\r
+                       .INIT_39(INIT['h39*320+:320]),\r
+                       .INIT_3A(INIT['h3a*320+:320]),\r
+                       .INIT_3B(INIT['h3b*320+:320]),\r
+                       .INIT_3C(INIT['h3c*320+:320]),\r
+                       .INIT_3D(INIT['h3d*320+:320]),\r
+                       .INIT_3E(INIT['h3e*320+:320]),\r
+                       .INIT_3F(INIT['h3f*320+:320]),\r
+                       .INIT_40(INIT['h40*320+:320]),\r
+                       .INIT_41(INIT['h41*320+:320]),\r
+                       .INIT_42(INIT['h42*320+:320]),\r
+                       .INIT_43(INIT['h43*320+:320]),\r
+                       .INIT_44(INIT['h44*320+:320]),\r
+                       .INIT_45(INIT['h45*320+:320]),\r
+                       .INIT_46(INIT['h46*320+:320]),\r
+                       .INIT_47(INIT['h47*320+:320]),\r
+                       .INIT_48(INIT['h48*320+:320]),\r
+                       .INIT_49(INIT['h49*320+:320]),\r
+                       .INIT_4A(INIT['h4a*320+:320]),\r
+                       .INIT_4B(INIT['h4b*320+:320]),\r
+                       .INIT_4C(INIT['h4c*320+:320]),\r
+                       .INIT_4D(INIT['h4d*320+:320]),\r
+                       .INIT_4E(INIT['h4e*320+:320]),\r
+                       .INIT_4F(INIT['h4f*320+:320]),\r
+                       .INIT_50(INIT['h50*320+:320]),\r
+                       .INIT_51(INIT['h51*320+:320]),\r
+                       .INIT_52(INIT['h52*320+:320]),\r
+                       .INIT_53(INIT['h53*320+:320]),\r
+                       .INIT_54(INIT['h54*320+:320]),\r
+                       .INIT_55(INIT['h55*320+:320]),\r
+                       .INIT_56(INIT['h56*320+:320]),\r
+                       .INIT_57(INIT['h57*320+:320]),\r
+                       .INIT_58(INIT['h58*320+:320]),\r
+                       .INIT_59(INIT['h59*320+:320]),\r
+                       .INIT_5A(INIT['h5a*320+:320]),\r
+                       .INIT_5B(INIT['h5b*320+:320]),\r
+                       .INIT_5C(INIT['h5c*320+:320]),\r
+                       .INIT_5D(INIT['h5d*320+:320]),\r
+                       .INIT_5E(INIT['h5e*320+:320]),\r
+                       .INIT_5F(INIT['h5f*320+:320]),\r
+                       .INIT_60(INIT['h60*320+:320]),\r
+                       .INIT_61(INIT['h61*320+:320]),\r
+                       .INIT_62(INIT['h62*320+:320]),\r
+                       .INIT_63(INIT['h63*320+:320]),\r
+                       .INIT_64(INIT['h64*320+:320]),\r
+                       .INIT_65(INIT['h65*320+:320]),\r
+                       .INIT_66(INIT['h66*320+:320]),\r
+                       .INIT_67(INIT['h67*320+:320]),\r
+                       .INIT_68(INIT['h68*320+:320]),\r
+                       .INIT_69(INIT['h69*320+:320]),\r
+                       .INIT_6A(INIT['h6a*320+:320]),\r
+                       .INIT_6B(INIT['h6b*320+:320]),\r
+                       .INIT_6C(INIT['h6c*320+:320]),\r
+                       .INIT_6D(INIT['h6d*320+:320]),\r
+                       .INIT_6E(INIT['h6e*320+:320]),\r
+                       .INIT_6F(INIT['h6f*320+:320]),\r
+                       .INIT_70(INIT['h70*320+:320]),\r
+                       .INIT_71(INIT['h71*320+:320]),\r
+                       .INIT_72(INIT['h72*320+:320]),\r
+                       .INIT_73(INIT['h73*320+:320]),\r
+                       .INIT_74(INIT['h74*320+:320]),\r
+                       .INIT_75(INIT['h75*320+:320]),\r
+                       .INIT_76(INIT['h76*320+:320]),\r
+                       .INIT_77(INIT['h77*320+:320]),\r
+                       .INIT_78(INIT['h78*320+:320]),\r
+                       .INIT_79(INIT['h79*320+:320]),\r
+                       .INIT_7A(INIT['h7a*320+:320]),\r
+                       .INIT_7B(INIT['h7b*320+:320]),\r
+                       .INIT_7C(INIT['h7c*320+:320]),\r
+                       .INIT_7D(INIT['h7d*320+:320]),\r
+                       .INIT_7E(INIT['h7e*320+:320]),\r
+                       .INIT_7F(INIT['h7f*320+:320]),\r
+                       .A_RD_WIDTH(PORT_A_RD_WIDTH),\r
+                       .A_WR_WIDTH(PORT_A_WR_WIDTH),\r
+                       .B_RD_WIDTH(PORT_B_RD_WIDTH),\r
+                       .B_WR_WIDTH(PORT_B_WR_WIDTH),\r
                        .RAM_MODE("TDP"),\r
-                       .A_WR_MODE("NO_CHANGE"), .B_WR_MODE("NO_CHANGE"),\r
-                       .A_CLK_INV(!CLKPOL2), .B_CLK_INV(!CLKPOL3),\r
-                       .A_EN_INV(1'b0), .B_EN_INV(1'b0),\r
-                       .A_WE_INV(1'b0), .B_WE_INV(1'b0),\r
-                       .A_DO_REG(1'b0), .B_DO_REG(1'b0),\r
-                       .A_ECC_EN(1'b0), .B_ECC_EN(1'b0)\r
+                       .A_WR_MODE(PORT_A_OPTION_WR_MODE),\r
+                       .B_WR_MODE(PORT_B_OPTION_WR_MODE),\r
+                       .A_CLK_INV(!PORT_A_CLK_POL),\r
+                       .B_CLK_INV(!PORT_B_CLK_POL),\r
                ) _TECHMAP_REPLACE_ (\r
-                       .A_DO(A_DO),\r
-                       .B_DO(B1DATA),\r
-                       .A_ECC_1B_ERR(A_ECC_1B_ERR),\r
-                       .B_ECC_1B_ERR(B_ECC_1B_ERR),\r
-                       .A_ECC_2B_ERR(A_ECC_2B_ERR),\r
-                       .B_ECC_2B_ERR(B_ECC_2B_ERR),\r
-                       .A_CLK(CLK2),\r
-                       .B_CLK(CLK3),\r
-                       .A_EN(1'b1),\r
-                       .B_EN(B1EN),\r
-                       .A_WE(|A1EN),\r
-                       .B_WE(1'b0),\r
-                       .A_ADDR(ADDRA),\r
-                       .B_ADDR(ADDRB),\r
-                       .A_DI(A1DATA),\r
-                       .B_DI(40'b0),\r
-                       .A_BM(A1EN),\r
-                       .B_BM(40'b0)\r
+                       .A_CLK(PORT_A_CLK),\r
+                       .A_EN(PORT_A_CLK_EN),\r
+                       .A_WE(PORT_A_WR_EN),\r
+                       .A_BM(PORT_A_WR_BE),\r
+                       .A_DI(PORT_A_WR_DATA),\r
+                       .A_ADDR({PORT_A_ADDR[14:0], 1'b0}),\r
+                       .A_DO(PORT_A_RD_DATA),\r
+                       .B_CLK(PORT_B_CLK),\r
+                       .B_EN(PORT_B_CLK_EN),\r
+                       .B_WE(PORT_B_WR_EN),\r
+                       .B_BM(PORT_B_WR_BE),\r
+                       .B_DI(PORT_A_WR_DATA),\r
+                       .B_ADDR({PORT_B_ADDR[14:0], 1'b0}),\r
+                       .B_DO(PORT_B_RD_DATA),\r
                );\r
-       endgenerate\r
+       end else begin\r
+               wire CAS_A, CAS_B;\r
+               CC_BRAM_40K #(\r
+                       .INIT_00(INIT['h00*320+:320]),\r
+                       .INIT_01(INIT['h01*320+:320]),\r
+                       .INIT_02(INIT['h02*320+:320]),\r
+                       .INIT_03(INIT['h03*320+:320]),\r
+                       .INIT_04(INIT['h04*320+:320]),\r
+                       .INIT_05(INIT['h05*320+:320]),\r
+                       .INIT_06(INIT['h06*320+:320]),\r
+                       .INIT_07(INIT['h07*320+:320]),\r
+                       .INIT_08(INIT['h08*320+:320]),\r
+                       .INIT_09(INIT['h09*320+:320]),\r
+                       .INIT_0A(INIT['h0a*320+:320]),\r
+                       .INIT_0B(INIT['h0b*320+:320]),\r
+                       .INIT_0C(INIT['h0c*320+:320]),\r
+                       .INIT_0D(INIT['h0d*320+:320]),\r
+                       .INIT_0E(INIT['h0e*320+:320]),\r
+                       .INIT_0F(INIT['h0f*320+:320]),\r
+                       .INIT_10(INIT['h10*320+:320]),\r
+                       .INIT_11(INIT['h11*320+:320]),\r
+                       .INIT_12(INIT['h12*320+:320]),\r
+                       .INIT_13(INIT['h13*320+:320]),\r
+                       .INIT_14(INIT['h14*320+:320]),\r
+                       .INIT_15(INIT['h15*320+:320]),\r
+                       .INIT_16(INIT['h16*320+:320]),\r
+                       .INIT_17(INIT['h17*320+:320]),\r
+                       .INIT_18(INIT['h18*320+:320]),\r
+                       .INIT_19(INIT['h19*320+:320]),\r
+                       .INIT_1A(INIT['h1a*320+:320]),\r
+                       .INIT_1B(INIT['h1b*320+:320]),\r
+                       .INIT_1C(INIT['h1c*320+:320]),\r
+                       .INIT_1D(INIT['h1d*320+:320]),\r
+                       .INIT_1E(INIT['h1e*320+:320]),\r
+                       .INIT_1F(INIT['h1f*320+:320]),\r
+                       .INIT_20(INIT['h20*320+:320]),\r
+                       .INIT_21(INIT['h21*320+:320]),\r
+                       .INIT_22(INIT['h22*320+:320]),\r
+                       .INIT_23(INIT['h23*320+:320]),\r
+                       .INIT_24(INIT['h24*320+:320]),\r
+                       .INIT_25(INIT['h25*320+:320]),\r
+                       .INIT_26(INIT['h26*320+:320]),\r
+                       .INIT_27(INIT['h27*320+:320]),\r
+                       .INIT_28(INIT['h28*320+:320]),\r
+                       .INIT_29(INIT['h29*320+:320]),\r
+                       .INIT_2A(INIT['h2a*320+:320]),\r
+                       .INIT_2B(INIT['h2b*320+:320]),\r
+                       .INIT_2C(INIT['h2c*320+:320]),\r
+                       .INIT_2D(INIT['h2d*320+:320]),\r
+                       .INIT_2E(INIT['h2e*320+:320]),\r
+                       .INIT_2F(INIT['h2f*320+:320]),\r
+                       .INIT_30(INIT['h30*320+:320]),\r
+                       .INIT_31(INIT['h31*320+:320]),\r
+                       .INIT_32(INIT['h32*320+:320]),\r
+                       .INIT_33(INIT['h33*320+:320]),\r
+                       .INIT_34(INIT['h34*320+:320]),\r
+                       .INIT_35(INIT['h35*320+:320]),\r
+                       .INIT_36(INIT['h36*320+:320]),\r
+                       .INIT_37(INIT['h37*320+:320]),\r
+                       .INIT_38(INIT['h38*320+:320]),\r
+                       .INIT_39(INIT['h39*320+:320]),\r
+                       .INIT_3A(INIT['h3a*320+:320]),\r
+                       .INIT_3B(INIT['h3b*320+:320]),\r
+                       .INIT_3C(INIT['h3c*320+:320]),\r
+                       .INIT_3D(INIT['h3d*320+:320]),\r
+                       .INIT_3E(INIT['h3e*320+:320]),\r
+                       .INIT_3F(INIT['h3f*320+:320]),\r
+                       .INIT_40(INIT['h40*320+:320]),\r
+                       .INIT_41(INIT['h41*320+:320]),\r
+                       .INIT_42(INIT['h42*320+:320]),\r
+                       .INIT_43(INIT['h43*320+:320]),\r
+                       .INIT_44(INIT['h44*320+:320]),\r
+                       .INIT_45(INIT['h45*320+:320]),\r
+                       .INIT_46(INIT['h46*320+:320]),\r
+                       .INIT_47(INIT['h47*320+:320]),\r
+                       .INIT_48(INIT['h48*320+:320]),\r
+                       .INIT_49(INIT['h49*320+:320]),\r
+                       .INIT_4A(INIT['h4a*320+:320]),\r
+                       .INIT_4B(INIT['h4b*320+:320]),\r
+                       .INIT_4C(INIT['h4c*320+:320]),\r
+                       .INIT_4D(INIT['h4d*320+:320]),\r
+                       .INIT_4E(INIT['h4e*320+:320]),\r
+                       .INIT_4F(INIT['h4f*320+:320]),\r
+                       .INIT_50(INIT['h50*320+:320]),\r
+                       .INIT_51(INIT['h51*320+:320]),\r
+                       .INIT_52(INIT['h52*320+:320]),\r
+                       .INIT_53(INIT['h53*320+:320]),\r
+                       .INIT_54(INIT['h54*320+:320]),\r
+                       .INIT_55(INIT['h55*320+:320]),\r
+                       .INIT_56(INIT['h56*320+:320]),\r
+                       .INIT_57(INIT['h57*320+:320]),\r
+                       .INIT_58(INIT['h58*320+:320]),\r
+                       .INIT_59(INIT['h59*320+:320]),\r
+                       .INIT_5A(INIT['h5a*320+:320]),\r
+                       .INIT_5B(INIT['h5b*320+:320]),\r
+                       .INIT_5C(INIT['h5c*320+:320]),\r
+                       .INIT_5D(INIT['h5d*320+:320]),\r
+                       .INIT_5E(INIT['h5e*320+:320]),\r
+                       .INIT_5F(INIT['h5f*320+:320]),\r
+                       .INIT_60(INIT['h60*320+:320]),\r
+                       .INIT_61(INIT['h61*320+:320]),\r
+                       .INIT_62(INIT['h62*320+:320]),\r
+                       .INIT_63(INIT['h63*320+:320]),\r
+                       .INIT_64(INIT['h64*320+:320]),\r
+                       .INIT_65(INIT['h65*320+:320]),\r
+                       .INIT_66(INIT['h66*320+:320]),\r
+                       .INIT_67(INIT['h67*320+:320]),\r
+                       .INIT_68(INIT['h68*320+:320]),\r
+                       .INIT_69(INIT['h69*320+:320]),\r
+                       .INIT_6A(INIT['h6a*320+:320]),\r
+                       .INIT_6B(INIT['h6b*320+:320]),\r
+                       .INIT_6C(INIT['h6c*320+:320]),\r
+                       .INIT_6D(INIT['h6d*320+:320]),\r
+                       .INIT_6E(INIT['h6e*320+:320]),\r
+                       .INIT_6F(INIT['h6f*320+:320]),\r
+                       .INIT_70(INIT['h70*320+:320]),\r
+                       .INIT_71(INIT['h71*320+:320]),\r
+                       .INIT_72(INIT['h72*320+:320]),\r
+                       .INIT_73(INIT['h73*320+:320]),\r
+                       .INIT_74(INIT['h74*320+:320]),\r
+                       .INIT_75(INIT['h75*320+:320]),\r
+                       .INIT_76(INIT['h76*320+:320]),\r
+                       .INIT_77(INIT['h77*320+:320]),\r
+                       .INIT_78(INIT['h78*320+:320]),\r
+                       .INIT_79(INIT['h79*320+:320]),\r
+                       .INIT_7A(INIT['h7a*320+:320]),\r
+                       .INIT_7B(INIT['h7b*320+:320]),\r
+                       .INIT_7C(INIT['h7c*320+:320]),\r
+                       .INIT_7D(INIT['h7d*320+:320]),\r
+                       .INIT_7E(INIT['h7e*320+:320]),\r
+                       .INIT_7F(INIT['h7f*320+:320]),\r
+                       .A_RD_WIDTH(PORT_A_RD_WIDTH),\r
+                       .A_WR_WIDTH(PORT_A_WR_WIDTH),\r
+                       .B_RD_WIDTH(PORT_B_RD_WIDTH),\r
+                       .B_WR_WIDTH(PORT_B_WR_WIDTH),\r
+                       .RAM_MODE("TDP"),\r
+                       .A_WR_MODE(PORT_A_OPTION_WR_MODE),\r
+                       .B_WR_MODE(PORT_B_OPTION_WR_MODE),\r
+                       .A_CLK_INV(!PORT_A_CLK_POL),\r
+                       .B_CLK_INV(!PORT_B_CLK_POL),\r
+                       .CAS("LOWER"),\r
+               ) lower (\r
+                       .A_CO(CAS_A),\r
+                       .B_CO(CAS_B),\r
+                       .A_CLK(PORT_A_CLK),\r
+                       .A_EN(PORT_A_CLK_EN),\r
+                       .A_WE(PORT_A_WR_EN),\r
+                       .A_BM(PORT_A_WR_BE),\r
+                       .A_DI(PORT_A_WR_DATA),\r
+                       .A_ADDR({PORT_A_ADDR[14:0], PORT_A_ADDR[15]}),\r
+                       .B_CLK(PORT_B_CLK),\r
+                       .B_EN(PORT_B_CLK_EN),\r
+                       .B_WE(PORT_B_WR_EN),\r
+                       .B_BM(PORT_B_WR_BE),\r
+                       .B_DI(PORT_A_WR_DATA),\r
+                       .B_ADDR({PORT_B_ADDR[14:0], PORT_B_ADDR[15]}),\r
+               );\r
+               CC_BRAM_40K #(\r
+                       .INIT_00(INIT['h80*320+:320]),\r
+                       .INIT_01(INIT['h81*320+:320]),\r
+                       .INIT_02(INIT['h82*320+:320]),\r
+                       .INIT_03(INIT['h83*320+:320]),\r
+                       .INIT_04(INIT['h84*320+:320]),\r
+                       .INIT_05(INIT['h85*320+:320]),\r
+                       .INIT_06(INIT['h86*320+:320]),\r
+                       .INIT_07(INIT['h87*320+:320]),\r
+                       .INIT_08(INIT['h88*320+:320]),\r
+                       .INIT_09(INIT['h89*320+:320]),\r
+                       .INIT_0A(INIT['h8a*320+:320]),\r
+                       .INIT_0B(INIT['h8b*320+:320]),\r
+                       .INIT_0C(INIT['h8c*320+:320]),\r
+                       .INIT_0D(INIT['h8d*320+:320]),\r
+                       .INIT_0E(INIT['h8e*320+:320]),\r
+                       .INIT_0F(INIT['h8f*320+:320]),\r
+                       .INIT_10(INIT['h90*320+:320]),\r
+                       .INIT_11(INIT['h91*320+:320]),\r
+                       .INIT_12(INIT['h92*320+:320]),\r
+                       .INIT_13(INIT['h93*320+:320]),\r
+                       .INIT_14(INIT['h94*320+:320]),\r
+                       .INIT_15(INIT['h95*320+:320]),\r
+                       .INIT_16(INIT['h96*320+:320]),\r
+                       .INIT_17(INIT['h97*320+:320]),\r
+                       .INIT_18(INIT['h98*320+:320]),\r
+                       .INIT_19(INIT['h99*320+:320]),\r
+                       .INIT_1A(INIT['h9a*320+:320]),\r
+                       .INIT_1B(INIT['h9b*320+:320]),\r
+                       .INIT_1C(INIT['h9c*320+:320]),\r
+                       .INIT_1D(INIT['h9d*320+:320]),\r
+                       .INIT_1E(INIT['h9e*320+:320]),\r
+                       .INIT_1F(INIT['h9f*320+:320]),\r
+                       .INIT_20(INIT['ha0*320+:320]),\r
+                       .INIT_21(INIT['ha1*320+:320]),\r
+                       .INIT_22(INIT['ha2*320+:320]),\r
+                       .INIT_23(INIT['ha3*320+:320]),\r
+                       .INIT_24(INIT['ha4*320+:320]),\r
+                       .INIT_25(INIT['ha5*320+:320]),\r
+                       .INIT_26(INIT['ha6*320+:320]),\r
+                       .INIT_27(INIT['ha7*320+:320]),\r
+                       .INIT_28(INIT['ha8*320+:320]),\r
+                       .INIT_29(INIT['ha9*320+:320]),\r
+                       .INIT_2A(INIT['haa*320+:320]),\r
+                       .INIT_2B(INIT['hab*320+:320]),\r
+                       .INIT_2C(INIT['hac*320+:320]),\r
+                       .INIT_2D(INIT['had*320+:320]),\r
+                       .INIT_2E(INIT['hae*320+:320]),\r
+                       .INIT_2F(INIT['haf*320+:320]),\r
+                       .INIT_30(INIT['hb0*320+:320]),\r
+                       .INIT_31(INIT['hb1*320+:320]),\r
+                       .INIT_32(INIT['hb2*320+:320]),\r
+                       .INIT_33(INIT['hb3*320+:320]),\r
+                       .INIT_34(INIT['hb4*320+:320]),\r
+                       .INIT_35(INIT['hb5*320+:320]),\r
+                       .INIT_36(INIT['hb6*320+:320]),\r
+                       .INIT_37(INIT['hb7*320+:320]),\r
+                       .INIT_38(INIT['hb8*320+:320]),\r
+                       .INIT_39(INIT['hb9*320+:320]),\r
+                       .INIT_3A(INIT['hba*320+:320]),\r
+                       .INIT_3B(INIT['hbb*320+:320]),\r
+                       .INIT_3C(INIT['hbc*320+:320]),\r
+                       .INIT_3D(INIT['hbd*320+:320]),\r
+                       .INIT_3E(INIT['hbe*320+:320]),\r
+                       .INIT_3F(INIT['hbf*320+:320]),\r
+                       .INIT_40(INIT['hc0*320+:320]),\r
+                       .INIT_41(INIT['hc1*320+:320]),\r
+                       .INIT_42(INIT['hc2*320+:320]),\r
+                       .INIT_43(INIT['hc3*320+:320]),\r
+                       .INIT_44(INIT['hc4*320+:320]),\r
+                       .INIT_45(INIT['hc5*320+:320]),\r
+                       .INIT_46(INIT['hc6*320+:320]),\r
+                       .INIT_47(INIT['hc7*320+:320]),\r
+                       .INIT_48(INIT['hc8*320+:320]),\r
+                       .INIT_49(INIT['hc9*320+:320]),\r
+                       .INIT_4A(INIT['hca*320+:320]),\r
+                       .INIT_4B(INIT['hcb*320+:320]),\r
+                       .INIT_4C(INIT['hcc*320+:320]),\r
+                       .INIT_4D(INIT['hcd*320+:320]),\r
+                       .INIT_4E(INIT['hce*320+:320]),\r
+                       .INIT_4F(INIT['hcf*320+:320]),\r
+                       .INIT_50(INIT['hd0*320+:320]),\r
+                       .INIT_51(INIT['hd1*320+:320]),\r
+                       .INIT_52(INIT['hd2*320+:320]),\r
+                       .INIT_53(INIT['hd3*320+:320]),\r
+                       .INIT_54(INIT['hd4*320+:320]),\r
+                       .INIT_55(INIT['hd5*320+:320]),\r
+                       .INIT_56(INIT['hd6*320+:320]),\r
+                       .INIT_57(INIT['hd7*320+:320]),\r
+                       .INIT_58(INIT['hd8*320+:320]),\r
+                       .INIT_59(INIT['hd9*320+:320]),\r
+                       .INIT_5A(INIT['hda*320+:320]),\r
+                       .INIT_5B(INIT['hdb*320+:320]),\r
+                       .INIT_5C(INIT['hdc*320+:320]),\r
+                       .INIT_5D(INIT['hdd*320+:320]),\r
+                       .INIT_5E(INIT['hde*320+:320]),\r
+                       .INIT_5F(INIT['hdf*320+:320]),\r
+                       .INIT_60(INIT['he0*320+:320]),\r
+                       .INIT_61(INIT['he1*320+:320]),\r
+                       .INIT_62(INIT['he2*320+:320]),\r
+                       .INIT_63(INIT['he3*320+:320]),\r
+                       .INIT_64(INIT['he4*320+:320]),\r
+                       .INIT_65(INIT['he5*320+:320]),\r
+                       .INIT_66(INIT['he6*320+:320]),\r
+                       .INIT_67(INIT['he7*320+:320]),\r
+                       .INIT_68(INIT['he8*320+:320]),\r
+                       .INIT_69(INIT['he9*320+:320]),\r
+                       .INIT_6A(INIT['hea*320+:320]),\r
+                       .INIT_6B(INIT['heb*320+:320]),\r
+                       .INIT_6C(INIT['hec*320+:320]),\r
+                       .INIT_6D(INIT['hed*320+:320]),\r
+                       .INIT_6E(INIT['hee*320+:320]),\r
+                       .INIT_6F(INIT['hef*320+:320]),\r
+                       .INIT_70(INIT['hf0*320+:320]),\r
+                       .INIT_71(INIT['hf1*320+:320]),\r
+                       .INIT_72(INIT['hf2*320+:320]),\r
+                       .INIT_73(INIT['hf3*320+:320]),\r
+                       .INIT_74(INIT['hf4*320+:320]),\r
+                       .INIT_75(INIT['hf5*320+:320]),\r
+                       .INIT_76(INIT['hf6*320+:320]),\r
+                       .INIT_77(INIT['hf7*320+:320]),\r
+                       .INIT_78(INIT['hf8*320+:320]),\r
+                       .INIT_79(INIT['hf9*320+:320]),\r
+                       .INIT_7A(INIT['hfa*320+:320]),\r
+                       .INIT_7B(INIT['hfb*320+:320]),\r
+                       .INIT_7C(INIT['hfc*320+:320]),\r
+                       .INIT_7D(INIT['hfd*320+:320]),\r
+                       .INIT_7E(INIT['hfe*320+:320]),\r
+                       .INIT_7F(INIT['hff*320+:320]),\r
+                       .A_RD_WIDTH(PORT_A_RD_WIDTH),\r
+                       .A_WR_WIDTH(PORT_A_WR_WIDTH),\r
+                       .B_RD_WIDTH(PORT_B_RD_WIDTH),\r
+                       .B_WR_WIDTH(PORT_B_WR_WIDTH),\r
+                       .RAM_MODE("TDP"),\r
+                       .A_WR_MODE(PORT_A_OPTION_WR_MODE),\r
+                       .B_WR_MODE(PORT_B_OPTION_WR_MODE),\r
+                       .A_CLK_INV(!PORT_A_CLK_POL),\r
+                       .B_CLK_INV(!PORT_B_CLK_POL),\r
+                       .CAS("UPPER"),\r
+               ) upper (\r
+                       .A_CI(CAS_A),\r
+                       .B_CI(CAS_B),\r
+                       .A_CLK(PORT_A_CLK),\r
+                       .A_EN(PORT_A_CLK_EN),\r
+                       .A_WE(PORT_A_WR_EN),\r
+                       .A_BM(PORT_A_WR_BE),\r
+                       .A_DI(PORT_A_WR_DATA),\r
+                       .A_DO(PORT_A_RD_DATA),\r
+                       .A_ADDR({PORT_A_ADDR[14:0], PORT_A_ADDR[15]}),\r
+                       .B_CLK(PORT_B_CLK),\r
+                       .B_EN(PORT_B_CLK_EN),\r
+                       .B_WE(PORT_B_WR_EN),\r
+                       .B_BM(PORT_B_WR_BE),\r
+                       .B_DI(PORT_A_WR_DATA),\r
+                       .B_DO(PORT_B_RD_DATA),\r
+                       .B_ADDR({PORT_B_ADDR[14:0], PORT_B_ADDR[15]}),\r
+               );\r
+       end\r
+endgenerate\r
 \r
 endmodule\r
 \r
 \r
-module \$__CC_BRAM_CASCADE (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);\r
-\r
-       parameter CFG_ABITS = 16;\r
-       parameter CFG_DBITS = 1;\r
-       parameter CFG_ENABLE_A = 1;\r
-       parameter CFG_ENABLE_B = 1;\r
-\r
-       parameter CLKPOL2 = 1;\r
-       parameter CLKPOL3 = 1;\r
-\r
-       // 64K x 1\r
-       parameter [65535:0] INIT = 65535'b0;\r
-\r
-       input CLK2;\r
-       input CLK3;\r
+module $__CC_BRAM_SDP_(...);\r
 \r
-       // write side of the memory\r
-       input [15:0] A1ADDR;\r
-       input [39:0] A1DATA;\r
-       input [39:0] A1EN;\r
+parameter INIT = 0;\r
+parameter OPTION_MODE = "20K";\r
 \r
-       // read side of the memory\r
-       input [15:0] B1ADDR;\r
-       output [39:0] B1DATA;\r
-       input [0:0] B1EN;\r
+parameter PORT_W_CLK_POL = 1;\r
+parameter PORT_W_WIDTH = 40;\r
+parameter PORT_W_WR_BE_WIDTH = 40;\r
 \r
-       // cascade signals\r
-       wire A_CAS, B_CAS;\r
+parameter PORT_R_CLK_POL = 1;\r
+parameter PORT_R_WIDTH = 40;\r
 \r
-       // unconnected signals\r
-       wire [39:0] A_UP_DO;\r
-       wire A_ECC_1B_ERR, B_ECC_1B_ERR, A_ECC_2B_ERR, B_ECC_2B_ERR;\r
+input PORT_W_CLK;\r
+input PORT_W_CLK_EN;\r
+input PORT_W_WR_EN;\r
+input [15:0] PORT_W_ADDR;\r
+input [PORT_W_WR_BE_WIDTH-1:0] PORT_W_WR_BE;\r
+input [PORT_W_WIDTH-1:0] PORT_W_WR_DATA;\r
 \r
-       localparam INIT_CHUNK_SIZE = 256;\r
+input PORT_R_CLK;\r
+input PORT_R_CLK_EN;\r
+input [15:0] PORT_R_ADDR;\r
+output [PORT_R_WIDTH-1:0] PORT_R_RD_DATA;\r
 \r
-       function [319:0] permute_init;\r
-               input [INIT_CHUNK_SIZE-1:0] chunk;\r
-               integer i;\r
-               begin\r
-                       for (i = 0; i < 64; i = i + 1) begin\r
-                               permute_init[i * 5 +: 5] = {1'b0, chunk[i * 4 +: 4]};\r
-                       end\r
-               end\r
-       endfunction\r
-\r
-       generate\r
-               CC_BRAM_40K #(\r
-                       `define INIT_UPPER\r
-                       `include "brams_init_40.vh" // INIT_80 .. INIT_FF\r
-                       `undef INIT_UPPER\r
-                       .LOC("UNPLACED"),\r
-                       .CAS("UPPER"),\r
-                       .A_RD_WIDTH(0), .B_RD_WIDTH(CFG_DBITS),\r
-                       .A_WR_WIDTH(CFG_DBITS), .B_WR_WIDTH(0),\r
-                       .RAM_MODE("TDP"),\r
-                       .A_WR_MODE("NO_CHANGE"), .B_WR_MODE("NO_CHANGE"),\r
-                       .A_CLK_INV(!CLKPOL2), .B_CLK_INV(!CLKPOL3),\r
-                       .A_EN_INV(1'b0), .B_EN_INV(1'b0),\r
-                       .A_WE_INV(1'b0), .B_WE_INV(1'b0),\r
-                       .A_DO_REG(1'b0), .B_DO_REG(1'b0),\r
-                       .A_ECC_EN(1'b0), .B_ECC_EN(1'b0)\r
-               ) upper_cell (\r
-                       .A_CI(A_CAS),\r
-                       .B_CI(B_CAS),\r
-                       .A_DO(A_UP_DO),\r
-                       .B_DO(B1DATA),\r
-                       .A_ECC_1B_ERR(A_ECC_1B_ERR),\r
-                       .B_ECC_1B_ERR(B_ECC_1B_ERR),\r
-                       .A_ECC_2B_ERR(A_ECC_2B_ERR),\r
-                       .B_ECC_2B_ERR(B_ECC_2B_ERR),\r
-                       .A_CLK(CLK2),\r
-                       .B_CLK(CLK3),\r
-                       .A_EN(1'b1),\r
-                       .B_EN(B1EN),\r
-                       .A_WE(|A1EN),\r
+generate\r
+       if (OPTION_MODE == "20K") begin\r
+               CC_BRAM_20K #(\r
+                       .INIT_00(INIT['h00*320+:320]),\r
+                       .INIT_01(INIT['h01*320+:320]),\r
+                       .INIT_02(INIT['h02*320+:320]),\r
+                       .INIT_03(INIT['h03*320+:320]),\r
+                       .INIT_04(INIT['h04*320+:320]),\r
+                       .INIT_05(INIT['h05*320+:320]),\r
+                       .INIT_06(INIT['h06*320+:320]),\r
+                       .INIT_07(INIT['h07*320+:320]),\r
+                       .INIT_08(INIT['h08*320+:320]),\r
+                       .INIT_09(INIT['h09*320+:320]),\r
+                       .INIT_0A(INIT['h0a*320+:320]),\r
+                       .INIT_0B(INIT['h0b*320+:320]),\r
+                       .INIT_0C(INIT['h0c*320+:320]),\r
+                       .INIT_0D(INIT['h0d*320+:320]),\r
+                       .INIT_0E(INIT['h0e*320+:320]),\r
+                       .INIT_0F(INIT['h0f*320+:320]),\r
+                       .INIT_10(INIT['h10*320+:320]),\r
+                       .INIT_11(INIT['h11*320+:320]),\r
+                       .INIT_12(INIT['h12*320+:320]),\r
+                       .INIT_13(INIT['h13*320+:320]),\r
+                       .INIT_14(INIT['h14*320+:320]),\r
+                       .INIT_15(INIT['h15*320+:320]),\r
+                       .INIT_16(INIT['h16*320+:320]),\r
+                       .INIT_17(INIT['h17*320+:320]),\r
+                       .INIT_18(INIT['h18*320+:320]),\r
+                       .INIT_19(INIT['h19*320+:320]),\r
+                       .INIT_1A(INIT['h1a*320+:320]),\r
+                       .INIT_1B(INIT['h1b*320+:320]),\r
+                       .INIT_1C(INIT['h1c*320+:320]),\r
+                       .INIT_1D(INIT['h1d*320+:320]),\r
+                       .INIT_1E(INIT['h1e*320+:320]),\r
+                       .INIT_1F(INIT['h1f*320+:320]),\r
+                       .INIT_20(INIT['h20*320+:320]),\r
+                       .INIT_21(INIT['h21*320+:320]),\r
+                       .INIT_22(INIT['h22*320+:320]),\r
+                       .INIT_23(INIT['h23*320+:320]),\r
+                       .INIT_24(INIT['h24*320+:320]),\r
+                       .INIT_25(INIT['h25*320+:320]),\r
+                       .INIT_26(INIT['h26*320+:320]),\r
+                       .INIT_27(INIT['h27*320+:320]),\r
+                       .INIT_28(INIT['h28*320+:320]),\r
+                       .INIT_29(INIT['h29*320+:320]),\r
+                       .INIT_2A(INIT['h2a*320+:320]),\r
+                       .INIT_2B(INIT['h2b*320+:320]),\r
+                       .INIT_2C(INIT['h2c*320+:320]),\r
+                       .INIT_2D(INIT['h2d*320+:320]),\r
+                       .INIT_2E(INIT['h2e*320+:320]),\r
+                       .INIT_2F(INIT['h2f*320+:320]),\r
+                       .INIT_30(INIT['h30*320+:320]),\r
+                       .INIT_31(INIT['h31*320+:320]),\r
+                       .INIT_32(INIT['h32*320+:320]),\r
+                       .INIT_33(INIT['h33*320+:320]),\r
+                       .INIT_34(INIT['h34*320+:320]),\r
+                       .INIT_35(INIT['h35*320+:320]),\r
+                       .INIT_36(INIT['h36*320+:320]),\r
+                       .INIT_37(INIT['h37*320+:320]),\r
+                       .INIT_38(INIT['h38*320+:320]),\r
+                       .INIT_39(INIT['h39*320+:320]),\r
+                       .INIT_3A(INIT['h3a*320+:320]),\r
+                       .INIT_3B(INIT['h3b*320+:320]),\r
+                       .INIT_3C(INIT['h3c*320+:320]),\r
+                       .INIT_3D(INIT['h3d*320+:320]),\r
+                       .INIT_3E(INIT['h3e*320+:320]),\r
+                       .INIT_3F(INIT['h3f*320+:320]),\r
+                       .A_RD_WIDTH(0),\r
+                       .A_WR_WIDTH(PORT_W_WIDTH),\r
+                       .B_RD_WIDTH(PORT_R_WIDTH),\r
+                       .B_WR_WIDTH(0),\r
+                       .RAM_MODE("SDP"),\r
+                       .A_WR_MODE("NO_CHANGE"),\r
+                       .B_WR_MODE("NO_CHANGE"),\r
+                       .A_CLK_INV(!PORT_W_CLK_POL),\r
+                       .B_CLK_INV(!PORT_R_CLK_POL),\r
+               ) _TECHMAP_REPLACE_ (\r
+                       .A_CLK(PORT_W_CLK),\r
+                       .A_EN(PORT_W_CLK_EN),\r
+                       .A_WE(PORT_W_WR_EN),\r
+                       .A_BM(PORT_W_WR_BE[19:0]),\r
+                       .B_BM(PORT_W_WR_BE[39:20]),\r
+                       .A_DI(PORT_W_WR_DATA[19:0]),\r
+                       .B_DI(PORT_W_WR_DATA[39:20]),\r
+                       .A_ADDR({PORT_W_ADDR[13:5], 1'b0, PORT_W_ADDR[4:0], 1'b0}),\r
+                       .B_CLK(PORT_R_CLK),\r
+                       .B_EN(PORT_R_CLK_EN),\r
                        .B_WE(1'b0),\r
-                       .A_ADDR(A1ADDR),\r
-                       .B_ADDR(B1ADDR),\r
-                       .A_DI(A1DATA),\r
-                       .B_DI(40'b0),\r
-                       .A_BM(A1EN),\r
-                       .B_BM(40'b0)\r
+                       .B_ADDR({PORT_R_ADDR[13:5], 1'b0, PORT_R_ADDR[4:0], 1'b0}),\r
+                       .A_DO(PORT_R_RD_DATA[19:0]),\r
+                       .B_DO(PORT_R_RD_DATA[39:20]),\r
                );\r
-\r
+       end else if (OPTION_MODE == "40K") begin\r
                CC_BRAM_40K #(\r
-                       `define INIT_LOWER\r
-                       `include "brams_init_40.vh" // INIT_00 .. INIT_7F\r
-                       `undef INIT_LOWER\r
-                       .LOC("UNPLACED"),\r
-                       .CAS("LOWER"),\r
-                       .A_RD_WIDTH(0), .B_RD_WIDTH(CFG_DBITS),\r
-                       .A_WR_WIDTH(CFG_DBITS), .B_WR_WIDTH(0),\r
-                       .RAM_MODE("TDP"),\r
-                       .A_WR_MODE("NO_CHANGE"), .B_WR_MODE("NO_CHANGE"),\r
-                       .A_CLK_INV(!CLKPOL2), .B_CLK_INV(!CLKPOL3),\r
-                       .A_EN_INV(1'b0), .B_EN_INV(1'b0),\r
-                       .A_WE_INV(1'b0), .B_WE_INV(1'b0),\r
-                       .A_DO_REG(1'b0), .B_DO_REG(1'b0),\r
-                       .A_ECC_EN(1'b0), .B_ECC_EN(1'b0)\r
-               ) lower_cell (\r
-                       .A_CI(),\r
-                       .B_CI(),\r
-                       .A_CO(A_CAS),\r
-                       .B_CO(B_CAS),\r
-                       .A_CLK(CLK2),\r
-                       .B_CLK(CLK3),\r
-                       .A_EN(1'b1),\r
-                       .B_EN(B1EN),\r
-                       .A_WE(|A1EN),\r
+                       .INIT_00(INIT['h00*320+:320]),\r
+                       .INIT_01(INIT['h01*320+:320]),\r
+                       .INIT_02(INIT['h02*320+:320]),\r
+                       .INIT_03(INIT['h03*320+:320]),\r
+                       .INIT_04(INIT['h04*320+:320]),\r
+                       .INIT_05(INIT['h05*320+:320]),\r
+                       .INIT_06(INIT['h06*320+:320]),\r
+                       .INIT_07(INIT['h07*320+:320]),\r
+                       .INIT_08(INIT['h08*320+:320]),\r
+                       .INIT_09(INIT['h09*320+:320]),\r
+                       .INIT_0A(INIT['h0a*320+:320]),\r
+                       .INIT_0B(INIT['h0b*320+:320]),\r
+                       .INIT_0C(INIT['h0c*320+:320]),\r
+                       .INIT_0D(INIT['h0d*320+:320]),\r
+                       .INIT_0E(INIT['h0e*320+:320]),\r
+                       .INIT_0F(INIT['h0f*320+:320]),\r
+                       .INIT_10(INIT['h10*320+:320]),\r
+                       .INIT_11(INIT['h11*320+:320]),\r
+                       .INIT_12(INIT['h12*320+:320]),\r
+                       .INIT_13(INIT['h13*320+:320]),\r
+                       .INIT_14(INIT['h14*320+:320]),\r
+                       .INIT_15(INIT['h15*320+:320]),\r
+                       .INIT_16(INIT['h16*320+:320]),\r
+                       .INIT_17(INIT['h17*320+:320]),\r
+                       .INIT_18(INIT['h18*320+:320]),\r
+                       .INIT_19(INIT['h19*320+:320]),\r
+                       .INIT_1A(INIT['h1a*320+:320]),\r
+                       .INIT_1B(INIT['h1b*320+:320]),\r
+                       .INIT_1C(INIT['h1c*320+:320]),\r
+                       .INIT_1D(INIT['h1d*320+:320]),\r
+                       .INIT_1E(INIT['h1e*320+:320]),\r
+                       .INIT_1F(INIT['h1f*320+:320]),\r
+                       .INIT_20(INIT['h20*320+:320]),\r
+                       .INIT_21(INIT['h21*320+:320]),\r
+                       .INIT_22(INIT['h22*320+:320]),\r
+                       .INIT_23(INIT['h23*320+:320]),\r
+                       .INIT_24(INIT['h24*320+:320]),\r
+                       .INIT_25(INIT['h25*320+:320]),\r
+                       .INIT_26(INIT['h26*320+:320]),\r
+                       .INIT_27(INIT['h27*320+:320]),\r
+                       .INIT_28(INIT['h28*320+:320]),\r
+                       .INIT_29(INIT['h29*320+:320]),\r
+                       .INIT_2A(INIT['h2a*320+:320]),\r
+                       .INIT_2B(INIT['h2b*320+:320]),\r
+                       .INIT_2C(INIT['h2c*320+:320]),\r
+                       .INIT_2D(INIT['h2d*320+:320]),\r
+                       .INIT_2E(INIT['h2e*320+:320]),\r
+                       .INIT_2F(INIT['h2f*320+:320]),\r
+                       .INIT_30(INIT['h30*320+:320]),\r
+                       .INIT_31(INIT['h31*320+:320]),\r
+                       .INIT_32(INIT['h32*320+:320]),\r
+                       .INIT_33(INIT['h33*320+:320]),\r
+                       .INIT_34(INIT['h34*320+:320]),\r
+                       .INIT_35(INIT['h35*320+:320]),\r
+                       .INIT_36(INIT['h36*320+:320]),\r
+                       .INIT_37(INIT['h37*320+:320]),\r
+                       .INIT_38(INIT['h38*320+:320]),\r
+                       .INIT_39(INIT['h39*320+:320]),\r
+                       .INIT_3A(INIT['h3a*320+:320]),\r
+                       .INIT_3B(INIT['h3b*320+:320]),\r
+                       .INIT_3C(INIT['h3c*320+:320]),\r
+                       .INIT_3D(INIT['h3d*320+:320]),\r
+                       .INIT_3E(INIT['h3e*320+:320]),\r
+                       .INIT_3F(INIT['h3f*320+:320]),\r
+                       .INIT_40(INIT['h40*320+:320]),\r
+                       .INIT_41(INIT['h41*320+:320]),\r
+                       .INIT_42(INIT['h42*320+:320]),\r
+                       .INIT_43(INIT['h43*320+:320]),\r
+                       .INIT_44(INIT['h44*320+:320]),\r
+                       .INIT_45(INIT['h45*320+:320]),\r
+                       .INIT_46(INIT['h46*320+:320]),\r
+                       .INIT_47(INIT['h47*320+:320]),\r
+                       .INIT_48(INIT['h48*320+:320]),\r
+                       .INIT_49(INIT['h49*320+:320]),\r
+                       .INIT_4A(INIT['h4a*320+:320]),\r
+                       .INIT_4B(INIT['h4b*320+:320]),\r
+                       .INIT_4C(INIT['h4c*320+:320]),\r
+                       .INIT_4D(INIT['h4d*320+:320]),\r
+                       .INIT_4E(INIT['h4e*320+:320]),\r
+                       .INIT_4F(INIT['h4f*320+:320]),\r
+                       .INIT_50(INIT['h50*320+:320]),\r
+                       .INIT_51(INIT['h51*320+:320]),\r
+                       .INIT_52(INIT['h52*320+:320]),\r
+                       .INIT_53(INIT['h53*320+:320]),\r
+                       .INIT_54(INIT['h54*320+:320]),\r
+                       .INIT_55(INIT['h55*320+:320]),\r
+                       .INIT_56(INIT['h56*320+:320]),\r
+                       .INIT_57(INIT['h57*320+:320]),\r
+                       .INIT_58(INIT['h58*320+:320]),\r
+                       .INIT_59(INIT['h59*320+:320]),\r
+                       .INIT_5A(INIT['h5a*320+:320]),\r
+                       .INIT_5B(INIT['h5b*320+:320]),\r
+                       .INIT_5C(INIT['h5c*320+:320]),\r
+                       .INIT_5D(INIT['h5d*320+:320]),\r
+                       .INIT_5E(INIT['h5e*320+:320]),\r
+                       .INIT_5F(INIT['h5f*320+:320]),\r
+                       .INIT_60(INIT['h60*320+:320]),\r
+                       .INIT_61(INIT['h61*320+:320]),\r
+                       .INIT_62(INIT['h62*320+:320]),\r
+                       .INIT_63(INIT['h63*320+:320]),\r
+                       .INIT_64(INIT['h64*320+:320]),\r
+                       .INIT_65(INIT['h65*320+:320]),\r
+                       .INIT_66(INIT['h66*320+:320]),\r
+                       .INIT_67(INIT['h67*320+:320]),\r
+                       .INIT_68(INIT['h68*320+:320]),\r
+                       .INIT_69(INIT['h69*320+:320]),\r
+                       .INIT_6A(INIT['h6a*320+:320]),\r
+                       .INIT_6B(INIT['h6b*320+:320]),\r
+                       .INIT_6C(INIT['h6c*320+:320]),\r
+                       .INIT_6D(INIT['h6d*320+:320]),\r
+                       .INIT_6E(INIT['h6e*320+:320]),\r
+                       .INIT_6F(INIT['h6f*320+:320]),\r
+                       .INIT_70(INIT['h70*320+:320]),\r
+                       .INIT_71(INIT['h71*320+:320]),\r
+                       .INIT_72(INIT['h72*320+:320]),\r
+                       .INIT_73(INIT['h73*320+:320]),\r
+                       .INIT_74(INIT['h74*320+:320]),\r
+                       .INIT_75(INIT['h75*320+:320]),\r
+                       .INIT_76(INIT['h76*320+:320]),\r
+                       .INIT_77(INIT['h77*320+:320]),\r
+                       .INIT_78(INIT['h78*320+:320]),\r
+                       .INIT_79(INIT['h79*320+:320]),\r
+                       .INIT_7A(INIT['h7a*320+:320]),\r
+                       .INIT_7B(INIT['h7b*320+:320]),\r
+                       .INIT_7C(INIT['h7c*320+:320]),\r
+                       .INIT_7D(INIT['h7d*320+:320]),\r
+                       .INIT_7E(INIT['h7e*320+:320]),\r
+                       .INIT_7F(INIT['h7f*320+:320]),\r
+                       .A_RD_WIDTH(0),\r
+                       .A_WR_WIDTH(PORT_W_WIDTH),\r
+                       .B_RD_WIDTH(PORT_R_WIDTH),\r
+                       .B_WR_WIDTH(0),\r
+                       .RAM_MODE("SDP"),\r
+                       .A_WR_MODE("NO_CHANGE"),\r
+                       .B_WR_MODE("NO_CHANGE"),\r
+                       .A_CLK_INV(!PORT_W_CLK_POL),\r
+                       .B_CLK_INV(!PORT_R_CLK_POL),\r
+               ) _TECHMAP_REPLACE_ (\r
+                       .A_CLK(PORT_W_CLK),\r
+                       .A_EN(PORT_W_CLK_EN),\r
+                       .A_WE(PORT_W_WR_EN),\r
+                       .A_BM(PORT_W_WR_BE[39:0]),\r
+                       .B_BM(PORT_W_WR_BE[79:40]),\r
+                       .A_DI(PORT_W_WR_DATA[39:0]),\r
+                       .B_DI(PORT_W_WR_DATA[79:40]),\r
+                       .A_ADDR({PORT_W_ADDR[14:0], 1'b0}),\r
+                       .B_CLK(PORT_R_CLK),\r
+                       .B_EN(PORT_R_CLK_EN),\r
                        .B_WE(1'b0),\r
-                       .A_ADDR(A1ADDR),\r
-                       .B_ADDR(B1ADDR),\r
-                       .A_DI(A1DATA),\r
-                       .B_DI(40'b0),\r
-                       .A_BM(A1EN),\r
-                       .B_BM(40'b0)\r
+                       .B_ADDR({PORT_R_ADDR[14:0], 1'b0}),\r
+                       .A_DO(PORT_R_RD_DATA[39:0]),\r
+                       .B_DO(PORT_R_RD_DATA[79:40]),\r
                );\r
-       endgenerate\r
+       end\r
+endgenerate\r
 \r
 endmodule\r
index 0131cdcdfbf5aaf4192fa646068b089403c9237e..93b16b2e074457b606aab261fb9dcf24487729f9 100644 (file)
@@ -237,12 +237,7 @@ struct SynthGateMatePass : public ScriptPass
 \r
                if (check_label("map_bram", "(skip if '-nobram')") && !nobram)\r
                {\r
-                       run("memory_bram -rules +/gatemate/brams.txt");\r
-                       run("setundef -zero -params "\r
-                               "t:$__CC_BRAM_CASCADE "\r
-                               "t:$__CC_BRAM_40K_SDP t:$__CC_BRAM_20K_SDP "\r
-                               "t:$__CC_BRAM_20K_TDP t:$__CC_BRAM_40K_TDP "\r
-                       );\r
+                       run("memory_libmap -lib +/gatemate/brams.txt");\r
                        run("techmap -map +/gatemate/brams_map.v");\r
                }\r
 \r