From 0a8eaca322a622610efe5a0d33d1cda83e4afa8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marcelina=20Ko=C5=9Bcielnicka?= Date: Tue, 8 Feb 2022 03:52:50 +0100 Subject: [PATCH] nexus: Use `memory_libmap` pass. --- techlibs/nexus/Makefile.inc | 2 - techlibs/nexus/brams.txt | 108 ++++---- techlibs/nexus/brams_init.vh | 64 ----- techlibs/nexus/brams_map.v | 493 ++++++++++++++++++++++++++-------- techlibs/nexus/lrams.txt | 43 ++- techlibs/nexus/lrams_init.vh | 128 --------- techlibs/nexus/lrams_map.v | 246 +++++++++++++---- techlibs/nexus/lutrams.txt | 38 +-- techlibs/nexus/lutrams_map.v | 39 +-- techlibs/nexus/synth_nexus.cc | 33 +-- tests/arch/nexus/blockram.ys | 4 +- 11 files changed, 679 insertions(+), 519 deletions(-) delete mode 100644 techlibs/nexus/brams_init.vh delete mode 100644 techlibs/nexus/lrams_init.vh diff --git a/techlibs/nexus/Makefile.inc b/techlibs/nexus/Makefile.inc index 9828d32c1..8121d1d8a 100644 --- a/techlibs/nexus/Makefile.inc +++ b/techlibs/nexus/Makefile.inc @@ -6,10 +6,8 @@ $(eval $(call add_share_file,share/nexus,techlibs/nexus/parse_init.vh)) $(eval $(call add_share_file,share/nexus,techlibs/nexus/cells_xtra.v)) $(eval $(call add_share_file,share/nexus,techlibs/nexus/lutrams_map.v)) $(eval $(call add_share_file,share/nexus,techlibs/nexus/lutrams.txt)) -$(eval $(call add_share_file,share/nexus,techlibs/nexus/brams_init.vh)) $(eval $(call add_share_file,share/nexus,techlibs/nexus/brams_map.v)) $(eval $(call add_share_file,share/nexus,techlibs/nexus/brams.txt)) -$(eval $(call add_share_file,share/nexus,techlibs/nexus/lrams_init.vh)) $(eval $(call add_share_file,share/nexus,techlibs/nexus/lrams_map.v)) $(eval $(call add_share_file,share/nexus,techlibs/nexus/lrams.txt)) $(eval $(call add_share_file,share/nexus,techlibs/nexus/arith_map.v)) diff --git a/techlibs/nexus/brams.txt b/techlibs/nexus/brams.txt index 086afe8bf..975a8d227 100644 --- a/techlibs/nexus/brams.txt +++ b/techlibs/nexus/brams.txt @@ -1,63 +1,47 @@ -bram $__NX_PDP16K - init 1 +ram block $__NX_DP16K_ { + abits 14; + widths 1 2 4 9 18 per_port; + byte 9; + cost 129; + init no_undef; + port srsw "A" "B" { + clock posedge; + clken; + wrbe_separate; + rdwr no_change; + portoption "RESETMODE" "SYNC" { + rdsrst zero gated_clken; + } + portoption "RESETMODE" "ASYNC" { + rdarst zero; + } + rdinit zero; + } +} - abits 9 @a9d36 - dbits 36 @a9d36 - abits 10 @a10d18 - dbits 18 @a10d18 - abits 11 @a11d9 - dbits 9 @a11d9 - abits 12 @a12d4 - dbits 4 @a12d4 - abits 13 @a13d2 - dbits 2 @a13d2 - abits 14 @a14d1 - dbits 1 @a14d1 - - groups 2 - ports 1 1 - wrmode 1 0 - enable 4 1 @a9d36 - enable 2 1 @a10d18 - enable 1 1 @a11d9 @a12d4 @a13d2 @a14d1 - transp 0 0 - clocks 2 3 - clkpol 2 3 -endbram - -match $__NX_PDP16K - # 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 2048 - min efficiency 5 - shuffle_enable A - make_transp - or_next_if_better -endmatch - -match $__NX_PDP16K - # 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 $__NX_PDP16K - # explicitly requested ROM - attribute syn_romstyle=ebr rom_block - attribute !syn_ramstyle - attribute !ram_block - attribute !logic_block - max wports 0 - make_transp - shuffle_enable A -endmatch +ram block $__NX_PDP16K_ { + abits 14; + widths 1 2 4 9 18 36 per_port; + byte 9; + option "SAME_CLOCK" 1 cost 128; + option "SAME_CLOCK" 0 cost 129; + init no_undef; + port sr "R" { + option "SAME_CLOCK" 1 clock posedge "C"; + option "SAME_CLOCK" 0 clock posedge; + clken; + portoption "RESETMODE" "SYNC" { + rdsrst zero gated_clken; + } + portoption "RESETMODE" "ASYNC" { + rdarst zero; + } + rdinit zero; + } + port sw "W" { + option "SAME_CLOCK" 1 clock posedge "C"; + option "SAME_CLOCK" 0 clock posedge; + clken; + option "SAME_CLOCK" 1 wrtrans all old; + } +} diff --git a/techlibs/nexus/brams_init.vh b/techlibs/nexus/brams_init.vh deleted file mode 100644 index 5b1d0188a..000000000 --- a/techlibs/nexus/brams_init.vh +++ /dev/null @@ -1,64 +0,0 @@ -.INITVAL_00($sformatf("0x%080x", permute_init(INIT[0 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_01($sformatf("0x%080x", permute_init(INIT[1 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_02($sformatf("0x%080x", permute_init(INIT[2 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_03($sformatf("0x%080x", permute_init(INIT[3 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_04($sformatf("0x%080x", permute_init(INIT[4 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_05($sformatf("0x%080x", permute_init(INIT[5 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_06($sformatf("0x%080x", permute_init(INIT[6 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_07($sformatf("0x%080x", permute_init(INIT[7 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_08($sformatf("0x%080x", permute_init(INIT[8 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_09($sformatf("0x%080x", permute_init(INIT[9 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0A($sformatf("0x%080x", permute_init(INIT[10 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0B($sformatf("0x%080x", permute_init(INIT[11 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0C($sformatf("0x%080x", permute_init(INIT[12 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0D($sformatf("0x%080x", permute_init(INIT[13 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0E($sformatf("0x%080x", permute_init(INIT[14 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0F($sformatf("0x%080x", permute_init(INIT[15 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_10($sformatf("0x%080x", permute_init(INIT[16 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_11($sformatf("0x%080x", permute_init(INIT[17 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_12($sformatf("0x%080x", permute_init(INIT[18 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_13($sformatf("0x%080x", permute_init(INIT[19 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_14($sformatf("0x%080x", permute_init(INIT[20 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_15($sformatf("0x%080x", permute_init(INIT[21 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_16($sformatf("0x%080x", permute_init(INIT[22 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_17($sformatf("0x%080x", permute_init(INIT[23 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_18($sformatf("0x%080x", permute_init(INIT[24 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_19($sformatf("0x%080x", permute_init(INIT[25 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1A($sformatf("0x%080x", permute_init(INIT[26 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1B($sformatf("0x%080x", permute_init(INIT[27 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1C($sformatf("0x%080x", permute_init(INIT[28 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1D($sformatf("0x%080x", permute_init(INIT[29 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1E($sformatf("0x%080x", permute_init(INIT[30 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1F($sformatf("0x%080x", permute_init(INIT[31 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_20($sformatf("0x%080x", permute_init(INIT[32 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_21($sformatf("0x%080x", permute_init(INIT[33 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_22($sformatf("0x%080x", permute_init(INIT[34 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_23($sformatf("0x%080x", permute_init(INIT[35 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_24($sformatf("0x%080x", permute_init(INIT[36 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_25($sformatf("0x%080x", permute_init(INIT[37 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_26($sformatf("0x%080x", permute_init(INIT[38 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_27($sformatf("0x%080x", permute_init(INIT[39 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_28($sformatf("0x%080x", permute_init(INIT[40 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_29($sformatf("0x%080x", permute_init(INIT[41 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2A($sformatf("0x%080x", permute_init(INIT[42 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2B($sformatf("0x%080x", permute_init(INIT[43 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2C($sformatf("0x%080x", permute_init(INIT[44 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2D($sformatf("0x%080x", permute_init(INIT[45 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2E($sformatf("0x%080x", permute_init(INIT[46 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2F($sformatf("0x%080x", permute_init(INIT[47 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_30($sformatf("0x%080x", permute_init(INIT[48 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_31($sformatf("0x%080x", permute_init(INIT[49 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_32($sformatf("0x%080x", permute_init(INIT[50 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_33($sformatf("0x%080x", permute_init(INIT[51 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_34($sformatf("0x%080x", permute_init(INIT[52 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_35($sformatf("0x%080x", permute_init(INIT[53 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_36($sformatf("0x%080x", permute_init(INIT[54 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_37($sformatf("0x%080x", permute_init(INIT[55 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_38($sformatf("0x%080x", permute_init(INIT[56 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_39($sformatf("0x%080x", permute_init(INIT[57 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3A($sformatf("0x%080x", permute_init(INIT[58 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3B($sformatf("0x%080x", permute_init(INIT[59 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3C($sformatf("0x%080x", permute_init(INIT[60 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3D($sformatf("0x%080x", permute_init(INIT[61 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3E($sformatf("0x%080x", permute_init(INIT[62 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3F($sformatf("0x%080x", permute_init(INIT[63 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))) diff --git a/techlibs/nexus/brams_map.v b/techlibs/nexus/brams_map.v index 214da4326..3cada2414 100644 --- a/techlibs/nexus/brams_map.v +++ b/techlibs/nexus/brams_map.v @@ -1,115 +1,382 @@ -module \$__NX_PDP16K (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN); - parameter CFG_ABITS = 9; - parameter CFG_DBITS = 36; - parameter CFG_ENABLE_A = 4; - - parameter CLKPOL2 = 1; - parameter CLKPOL3 = 1; - parameter [18431:0] INIT = 18432'b0; - - parameter _TECHMAP_BITS_CONNMAP_ = 8; - parameter [_TECHMAP_BITS_CONNMAP_-1:0] _TECHMAP_CONNMAP_CLK2_ = 0; - parameter [_TECHMAP_BITS_CONNMAP_-1:0] _TECHMAP_CONNMAP_CLK3_ = 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; - - // Address is left justified, in x18 and above lower bits are byte enables - localparam A_SHIFT = - (CFG_DBITS == 36) ? 5 : - (CFG_DBITS == 18) ? 4 : - (CFG_DBITS == 9) ? 3 : - (CFG_DBITS == 4) ? 2 : - (CFG_DBITS == 2) ? 1 : - 0; - - // Different primitives needed for single vs dual clock case - localparam SINGLE_CLOCK = (_TECHMAP_CONNMAP_CLK2_ == _TECHMAP_CONNMAP_CLK3_); - - localparam WIDTH = $sformatf("X%d", CFG_DBITS); - - wire [13:0] ra, wa; - wire [35:0] rd, wd; - - assign ra = {B1ADDR, {A_SHIFT{1'b1}}}; - - generate - if (CFG_ENABLE_A > 1) - assign wa = {A1ADDR, {(A_SHIFT-CFG_ENABLE_A){1'b1}}, A1EN}; - else - assign wa = {A1ADDR, {A_SHIFT{1'b1}}}; - endgenerate - - assign wd = A1DATA; - assign B1DATA = rd[CFG_DBITS-1:0]; - - wire wck, rck; - - generate - if (CLKPOL2) - assign wck = CLK2; - else - INV wck_inv_i (.A(CLK2), .Z(wck)); - if (CLKPOL3) - assign rck = CLK3; - else - INV wck_inv_i (.A(CLK3), .Z(rck)); - endgenerate - - wire we = |A1EN; - - localparam INIT_CHUNK_SIZE = (CFG_DBITS <= 4) ? 256 : 288; - - function [319:0] permute_init; - input [INIT_CHUNK_SIZE-1:0] chunk; - integer i; - begin - if (CFG_DBITS <= 4) begin - for (i = 0; i < 32; i = i + 1'b1) - permute_init[i * 10 +: 10] = {2'b00, chunk[i * 8 +: 8]}; - end else begin - for (i = 0; i < 32; i = i + 1'b1) - permute_init[i * 10 +: 10] = {1'b0, chunk[i * 9 +: 9]}; - end - end - endfunction - - generate - if (SINGLE_CLOCK) begin - PDPSC16K #( - .DATA_WIDTH_W(WIDTH), - .DATA_WIDTH_R(WIDTH), - .OUTREG("BYPASSED"), - .ECC("DISABLED"), - .GSR("DISABLED"), -`include "brams_init.vh" - ) _TECHMAP_REPLACE_ ( - .CLK(wck), .RST(1'b0), - .DI(wd), .ADW(wa), .CEW(we), .CSW(3'b111), - .ADR(ra), .DO(rd), .CER(B1EN), .CSR(3'b111) - ); - end else begin - PDP16K #( - .DATA_WIDTH_W(WIDTH), - .DATA_WIDTH_R(WIDTH), - .OUTREG("BYPASSED"), - .ECC("DISABLED"), - .GSR("DISABLED"), -`include "brams_init.vh" - ) _TECHMAP_REPLACE_ ( - .CLKW(wck), .CLKR(rck), .RST(1'b0), - .DI(wd), .ADW(wa), .CEW(we), .CSW(3'b111), - .ADR(ra), .DO(rd), .CER(B1EN), .CSR(3'b111) - ); - end - endgenerate +module $__NX_DP16K_ (...); + +parameter INIT = 0; + +parameter PORT_A_OPTION_RESETMODE = "SYNC"; +parameter PORT_A_WIDTH = 18; +parameter PORT_A_WR_BE_WIDTH = 2; + +input PORT_A_CLK; +input PORT_A_CLK_EN; +input PORT_A_WR_EN; +input PORT_A_RD_SRST; +input PORT_A_RD_ARST; +input [13:0] PORT_A_ADDR; +input [PORT_A_WR_BE_WIDTH-1:0] PORT_A_WR_BE; +input [PORT_A_WIDTH-1:0] PORT_A_WR_DATA; +output [PORT_A_WIDTH-1:0] PORT_A_RD_DATA; + +parameter PORT_B_OPTION_RESETMODE = "SYNC"; +parameter PORT_B_WIDTH = 18; +parameter PORT_B_WR_BE_WIDTH = 2; + +input PORT_B_CLK; +input PORT_B_CLK_EN; +input PORT_B_WR_EN; +input PORT_B_RD_SRST; +input PORT_B_RD_ARST; +input [13:0] PORT_B_ADDR; +input [PORT_B_WR_BE_WIDTH-1:0] PORT_B_WR_BE; +input [PORT_B_WIDTH-1:0] PORT_B_WR_DATA; +output [PORT_B_WIDTH-1:0] PORT_B_RD_DATA; + +function [319:0] init_slice; + input integer idx; + integer i, j; + init_slice = 0; + for (i = 0; i < 16; i = i + 1) begin + init_slice[i*20+:18] = INIT[(idx * 16 + i) * 18+:18]; + end +endfunction + +wire [17:0] DOA; +wire [17:0] DOB; +wire [17:0] DIA = PORT_A_WR_DATA; +wire [17:0] DIB = PORT_B_WR_DATA; +wire [13:0] ADA = PORT_A_WIDTH == 18 ? {PORT_A_ADDR[13:2], PORT_A_WR_BE} : PORT_A_ADDR; +wire [13:0] ADB = PORT_B_WIDTH == 18 ? {PORT_B_ADDR[13:2], PORT_B_WR_BE} : PORT_B_ADDR; + +assign PORT_A_RD_DATA = DOA; +assign PORT_B_RD_DATA = DOB; + +DP16K #( + .INITVAL_00($sformatf("0x%080x", init_slice('h00))), + .INITVAL_01($sformatf("0x%080x", init_slice('h01))), + .INITVAL_02($sformatf("0x%080x", init_slice('h02))), + .INITVAL_03($sformatf("0x%080x", init_slice('h03))), + .INITVAL_04($sformatf("0x%080x", init_slice('h04))), + .INITVAL_05($sformatf("0x%080x", init_slice('h05))), + .INITVAL_06($sformatf("0x%080x", init_slice('h06))), + .INITVAL_07($sformatf("0x%080x", init_slice('h07))), + .INITVAL_08($sformatf("0x%080x", init_slice('h08))), + .INITVAL_09($sformatf("0x%080x", init_slice('h09))), + .INITVAL_0A($sformatf("0x%080x", init_slice('h0a))), + .INITVAL_0B($sformatf("0x%080x", init_slice('h0b))), + .INITVAL_0C($sformatf("0x%080x", init_slice('h0c))), + .INITVAL_0D($sformatf("0x%080x", init_slice('h0d))), + .INITVAL_0E($sformatf("0x%080x", init_slice('h0e))), + .INITVAL_0F($sformatf("0x%080x", init_slice('h0f))), + .INITVAL_10($sformatf("0x%080x", init_slice('h10))), + .INITVAL_11($sformatf("0x%080x", init_slice('h11))), + .INITVAL_12($sformatf("0x%080x", init_slice('h12))), + .INITVAL_13($sformatf("0x%080x", init_slice('h13))), + .INITVAL_14($sformatf("0x%080x", init_slice('h14))), + .INITVAL_15($sformatf("0x%080x", init_slice('h15))), + .INITVAL_16($sformatf("0x%080x", init_slice('h16))), + .INITVAL_17($sformatf("0x%080x", init_slice('h17))), + .INITVAL_18($sformatf("0x%080x", init_slice('h18))), + .INITVAL_19($sformatf("0x%080x", init_slice('h19))), + .INITVAL_1A($sformatf("0x%080x", init_slice('h1a))), + .INITVAL_1B($sformatf("0x%080x", init_slice('h1b))), + .INITVAL_1C($sformatf("0x%080x", init_slice('h1c))), + .INITVAL_1D($sformatf("0x%080x", init_slice('h1d))), + .INITVAL_1E($sformatf("0x%080x", init_slice('h1e))), + .INITVAL_1F($sformatf("0x%080x", init_slice('h1f))), + .INITVAL_20($sformatf("0x%080x", init_slice('h20))), + .INITVAL_21($sformatf("0x%080x", init_slice('h21))), + .INITVAL_22($sformatf("0x%080x", init_slice('h22))), + .INITVAL_23($sformatf("0x%080x", init_slice('h23))), + .INITVAL_24($sformatf("0x%080x", init_slice('h24))), + .INITVAL_25($sformatf("0x%080x", init_slice('h25))), + .INITVAL_26($sformatf("0x%080x", init_slice('h26))), + .INITVAL_27($sformatf("0x%080x", init_slice('h27))), + .INITVAL_28($sformatf("0x%080x", init_slice('h28))), + .INITVAL_29($sformatf("0x%080x", init_slice('h29))), + .INITVAL_2A($sformatf("0x%080x", init_slice('h2a))), + .INITVAL_2B($sformatf("0x%080x", init_slice('h2b))), + .INITVAL_2C($sformatf("0x%080x", init_slice('h2c))), + .INITVAL_2D($sformatf("0x%080x", init_slice('h2d))), + .INITVAL_2E($sformatf("0x%080x", init_slice('h2e))), + .INITVAL_2F($sformatf("0x%080x", init_slice('h2f))), + .INITVAL_30($sformatf("0x%080x", init_slice('h30))), + .INITVAL_31($sformatf("0x%080x", init_slice('h31))), + .INITVAL_32($sformatf("0x%080x", init_slice('h32))), + .INITVAL_33($sformatf("0x%080x", init_slice('h33))), + .INITVAL_34($sformatf("0x%080x", init_slice('h34))), + .INITVAL_35($sformatf("0x%080x", init_slice('h35))), + .INITVAL_36($sformatf("0x%080x", init_slice('h36))), + .INITVAL_37($sformatf("0x%080x", init_slice('h37))), + .INITVAL_38($sformatf("0x%080x", init_slice('h38))), + .INITVAL_39($sformatf("0x%080x", init_slice('h39))), + .INITVAL_3A($sformatf("0x%080x", init_slice('h3a))), + .INITVAL_3B($sformatf("0x%080x", init_slice('h3b))), + .INITVAL_3C($sformatf("0x%080x", init_slice('h3c))), + .INITVAL_3D($sformatf("0x%080x", init_slice('h3d))), + .INITVAL_3E($sformatf("0x%080x", init_slice('h3e))), + .INITVAL_3F($sformatf("0x%080x", init_slice('h3f))), + .DATA_WIDTH_A($sformatf("X%d", PORT_A_WIDTH)), + .DATA_WIDTH_B($sformatf("X%d", PORT_B_WIDTH)), + .OUTREG_A("BYPASSED"), + .OUTREG_B("BYPASSED"), + .RESETMODE_A(PORT_A_OPTION_RESETMODE), + .RESETMODE_B(PORT_B_OPTION_RESETMODE), + .ASYNC_RST_RELEASE_A(PORT_A_OPTION_RESETMODE), + .ASYNC_RST_RELEASE_B(PORT_B_OPTION_RESETMODE), + .CSDECODE_A("000"), + .CSDECODE_B("000"), + .GSR("DISABLED"), +) _TECHMAP_REPLACE_ ( + .CLKA(PORT_A_CLK), + .WEA(PORT_A_WIDTH == 18 ? PORT_A_WR_EN : (PORT_A_WR_EN | PORT_A_WR_BE[0])), + .CEA(PORT_A_CLK_EN), + .RSTA(PORT_A_OPTION_RESETMODE == "SYNC" ? PORT_A_RD_SRST : PORT_A_RD_ARST), + .CSA(3'b111), + .DIA(DIA), + .DOA(DOA), + .ADA(ADA), + + .CLKB(PORT_B_CLK), + .WEB(PORT_B_WIDTH == 18 ? PORT_B_WR_EN : (PORT_B_WR_EN | PORT_B_WR_BE[0])), + .CEB(PORT_B_CLK_EN), + .RSTB(PORT_B_OPTION_RESETMODE == "SYNC" ? PORT_B_RD_SRST : PORT_B_RD_ARST), + .CSB(3'b111), + .ADB(ADB), + .DIB(DIB), + .DOB(DOB), +); + +endmodule + + +module $__NX_PDP16K_ (...); + +parameter INIT = 0; +parameter OPTION_SAME_CLOCK = 1; + +parameter PORT_R_WIDTH = 36; +parameter PORT_R_OPTION_RESETMODE = "SYNC"; + +input CLK_C; + +input PORT_R_CLK; +input PORT_R_CLK_EN; +input PORT_R_RD_SRST; +input PORT_R_RD_ARST; +input [13:0] PORT_R_ADDR; +output [PORT_R_WIDTH-1:0] PORT_R_RD_DATA; + +parameter PORT_W_WIDTH = 36; +parameter PORT_W_WR_EN_WIDTH = 4; + +input PORT_W_CLK; +input PORT_W_CLK_EN; +input [13:0] PORT_W_ADDR; +input [PORT_W_WR_EN_WIDTH-1:0] PORT_W_WR_EN; +input [PORT_W_WIDTH-1:0] PORT_W_WR_DATA; + +function [319:0] init_slice; + input integer idx; + integer i, j; + init_slice = 0; + for (i = 0; i < 16; i = i + 1) begin + init_slice[i*20+:18] = INIT[(idx * 16 + i) * 18+:18]; + end +endfunction + +wire [35:0] DI = PORT_W_WR_DATA; +wire [35:0] DO; + +assign PORT_R_RD_DATA = DO; + +wire [13:0] ADW = PORT_W_WIDTH == 36 ? {PORT_W_ADDR[13:4], PORT_W_WR_EN} : + (PORT_W_WIDTH == 18 ? {PORT_W_ADDR[13:2], PORT_W_WR_EN} : PORT_W_ADDR); + +generate + +if (OPTION_SAME_CLOCK) begin + +PDPSC16K #( + .INITVAL_00($sformatf("0x%080x", init_slice('h00))), + .INITVAL_01($sformatf("0x%080x", init_slice('h01))), + .INITVAL_02($sformatf("0x%080x", init_slice('h02))), + .INITVAL_03($sformatf("0x%080x", init_slice('h03))), + .INITVAL_04($sformatf("0x%080x", init_slice('h04))), + .INITVAL_05($sformatf("0x%080x", init_slice('h05))), + .INITVAL_06($sformatf("0x%080x", init_slice('h06))), + .INITVAL_07($sformatf("0x%080x", init_slice('h07))), + .INITVAL_08($sformatf("0x%080x", init_slice('h08))), + .INITVAL_09($sformatf("0x%080x", init_slice('h09))), + .INITVAL_0A($sformatf("0x%080x", init_slice('h0a))), + .INITVAL_0B($sformatf("0x%080x", init_slice('h0b))), + .INITVAL_0C($sformatf("0x%080x", init_slice('h0c))), + .INITVAL_0D($sformatf("0x%080x", init_slice('h0d))), + .INITVAL_0E($sformatf("0x%080x", init_slice('h0e))), + .INITVAL_0F($sformatf("0x%080x", init_slice('h0f))), + .INITVAL_10($sformatf("0x%080x", init_slice('h10))), + .INITVAL_11($sformatf("0x%080x", init_slice('h11))), + .INITVAL_12($sformatf("0x%080x", init_slice('h12))), + .INITVAL_13($sformatf("0x%080x", init_slice('h13))), + .INITVAL_14($sformatf("0x%080x", init_slice('h14))), + .INITVAL_15($sformatf("0x%080x", init_slice('h15))), + .INITVAL_16($sformatf("0x%080x", init_slice('h16))), + .INITVAL_17($sformatf("0x%080x", init_slice('h17))), + .INITVAL_18($sformatf("0x%080x", init_slice('h18))), + .INITVAL_19($sformatf("0x%080x", init_slice('h19))), + .INITVAL_1A($sformatf("0x%080x", init_slice('h1a))), + .INITVAL_1B($sformatf("0x%080x", init_slice('h1b))), + .INITVAL_1C($sformatf("0x%080x", init_slice('h1c))), + .INITVAL_1D($sformatf("0x%080x", init_slice('h1d))), + .INITVAL_1E($sformatf("0x%080x", init_slice('h1e))), + .INITVAL_1F($sformatf("0x%080x", init_slice('h1f))), + .INITVAL_20($sformatf("0x%080x", init_slice('h20))), + .INITVAL_21($sformatf("0x%080x", init_slice('h21))), + .INITVAL_22($sformatf("0x%080x", init_slice('h22))), + .INITVAL_23($sformatf("0x%080x", init_slice('h23))), + .INITVAL_24($sformatf("0x%080x", init_slice('h24))), + .INITVAL_25($sformatf("0x%080x", init_slice('h25))), + .INITVAL_26($sformatf("0x%080x", init_slice('h26))), + .INITVAL_27($sformatf("0x%080x", init_slice('h27))), + .INITVAL_28($sformatf("0x%080x", init_slice('h28))), + .INITVAL_29($sformatf("0x%080x", init_slice('h29))), + .INITVAL_2A($sformatf("0x%080x", init_slice('h2a))), + .INITVAL_2B($sformatf("0x%080x", init_slice('h2b))), + .INITVAL_2C($sformatf("0x%080x", init_slice('h2c))), + .INITVAL_2D($sformatf("0x%080x", init_slice('h2d))), + .INITVAL_2E($sformatf("0x%080x", init_slice('h2e))), + .INITVAL_2F($sformatf("0x%080x", init_slice('h2f))), + .INITVAL_30($sformatf("0x%080x", init_slice('h30))), + .INITVAL_31($sformatf("0x%080x", init_slice('h31))), + .INITVAL_32($sformatf("0x%080x", init_slice('h32))), + .INITVAL_33($sformatf("0x%080x", init_slice('h33))), + .INITVAL_34($sformatf("0x%080x", init_slice('h34))), + .INITVAL_35($sformatf("0x%080x", init_slice('h35))), + .INITVAL_36($sformatf("0x%080x", init_slice('h36))), + .INITVAL_37($sformatf("0x%080x", init_slice('h37))), + .INITVAL_38($sformatf("0x%080x", init_slice('h38))), + .INITVAL_39($sformatf("0x%080x", init_slice('h39))), + .INITVAL_3A($sformatf("0x%080x", init_slice('h3a))), + .INITVAL_3B($sformatf("0x%080x", init_slice('h3b))), + .INITVAL_3C($sformatf("0x%080x", init_slice('h3c))), + .INITVAL_3D($sformatf("0x%080x", init_slice('h3d))), + .INITVAL_3E($sformatf("0x%080x", init_slice('h3e))), + .INITVAL_3F($sformatf("0x%080x", init_slice('h3f))), + .DATA_WIDTH_W($sformatf("X%d", PORT_W_WIDTH)), + .DATA_WIDTH_R($sformatf("X%d", PORT_R_WIDTH)), + .OUTREG("BYPASSED"), + .RESETMODE(PORT_R_OPTION_RESETMODE), + .ASYNC_RST_RELEASE(PORT_R_OPTION_RESETMODE), + .CSDECODE_W("000"), + .CSDECODE_R("000"), + .ECC("DISABLED"), + .GSR("DISABLED"), +) _TECHMAP_REPLACE_ ( + .CLK(CLK_C), + + .CEW(PORT_W_CLK_EN), + .CSW(3'b111), + .ADW(ADW), + .DI(DI), + + .CER(PORT_R_CLK_EN), + .RST(PORT_R_OPTION_RESETMODE == "SYNC" ? PORT_R_RD_SRST : PORT_R_RD_ARST), + .CSR(3'b111), + .ADR(PORT_R_ADDR), + .DO(DO), +); + +end else begin + +PDP16K #( + .INITVAL_00($sformatf("0x%080x", init_slice('h00))), + .INITVAL_01($sformatf("0x%080x", init_slice('h01))), + .INITVAL_02($sformatf("0x%080x", init_slice('h02))), + .INITVAL_03($sformatf("0x%080x", init_slice('h03))), + .INITVAL_04($sformatf("0x%080x", init_slice('h04))), + .INITVAL_05($sformatf("0x%080x", init_slice('h05))), + .INITVAL_06($sformatf("0x%080x", init_slice('h06))), + .INITVAL_07($sformatf("0x%080x", init_slice('h07))), + .INITVAL_08($sformatf("0x%080x", init_slice('h08))), + .INITVAL_09($sformatf("0x%080x", init_slice('h09))), + .INITVAL_0A($sformatf("0x%080x", init_slice('h0a))), + .INITVAL_0B($sformatf("0x%080x", init_slice('h0b))), + .INITVAL_0C($sformatf("0x%080x", init_slice('h0c))), + .INITVAL_0D($sformatf("0x%080x", init_slice('h0d))), + .INITVAL_0E($sformatf("0x%080x", init_slice('h0e))), + .INITVAL_0F($sformatf("0x%080x", init_slice('h0f))), + .INITVAL_10($sformatf("0x%080x", init_slice('h10))), + .INITVAL_11($sformatf("0x%080x", init_slice('h11))), + .INITVAL_12($sformatf("0x%080x", init_slice('h12))), + .INITVAL_13($sformatf("0x%080x", init_slice('h13))), + .INITVAL_14($sformatf("0x%080x", init_slice('h14))), + .INITVAL_15($sformatf("0x%080x", init_slice('h15))), + .INITVAL_16($sformatf("0x%080x", init_slice('h16))), + .INITVAL_17($sformatf("0x%080x", init_slice('h17))), + .INITVAL_18($sformatf("0x%080x", init_slice('h18))), + .INITVAL_19($sformatf("0x%080x", init_slice('h19))), + .INITVAL_1A($sformatf("0x%080x", init_slice('h1a))), + .INITVAL_1B($sformatf("0x%080x", init_slice('h1b))), + .INITVAL_1C($sformatf("0x%080x", init_slice('h1c))), + .INITVAL_1D($sformatf("0x%080x", init_slice('h1d))), + .INITVAL_1E($sformatf("0x%080x", init_slice('h1e))), + .INITVAL_1F($sformatf("0x%080x", init_slice('h1f))), + .INITVAL_20($sformatf("0x%080x", init_slice('h20))), + .INITVAL_21($sformatf("0x%080x", init_slice('h21))), + .INITVAL_22($sformatf("0x%080x", init_slice('h22))), + .INITVAL_23($sformatf("0x%080x", init_slice('h23))), + .INITVAL_24($sformatf("0x%080x", init_slice('h24))), + .INITVAL_25($sformatf("0x%080x", init_slice('h25))), + .INITVAL_26($sformatf("0x%080x", init_slice('h26))), + .INITVAL_27($sformatf("0x%080x", init_slice('h27))), + .INITVAL_28($sformatf("0x%080x", init_slice('h28))), + .INITVAL_29($sformatf("0x%080x", init_slice('h29))), + .INITVAL_2A($sformatf("0x%080x", init_slice('h2a))), + .INITVAL_2B($sformatf("0x%080x", init_slice('h2b))), + .INITVAL_2C($sformatf("0x%080x", init_slice('h2c))), + .INITVAL_2D($sformatf("0x%080x", init_slice('h2d))), + .INITVAL_2E($sformatf("0x%080x", init_slice('h2e))), + .INITVAL_2F($sformatf("0x%080x", init_slice('h2f))), + .INITVAL_30($sformatf("0x%080x", init_slice('h30))), + .INITVAL_31($sformatf("0x%080x", init_slice('h31))), + .INITVAL_32($sformatf("0x%080x", init_slice('h32))), + .INITVAL_33($sformatf("0x%080x", init_slice('h33))), + .INITVAL_34($sformatf("0x%080x", init_slice('h34))), + .INITVAL_35($sformatf("0x%080x", init_slice('h35))), + .INITVAL_36($sformatf("0x%080x", init_slice('h36))), + .INITVAL_37($sformatf("0x%080x", init_slice('h37))), + .INITVAL_38($sformatf("0x%080x", init_slice('h38))), + .INITVAL_39($sformatf("0x%080x", init_slice('h39))), + .INITVAL_3A($sformatf("0x%080x", init_slice('h3a))), + .INITVAL_3B($sformatf("0x%080x", init_slice('h3b))), + .INITVAL_3C($sformatf("0x%080x", init_slice('h3c))), + .INITVAL_3D($sformatf("0x%080x", init_slice('h3d))), + .INITVAL_3E($sformatf("0x%080x", init_slice('h3e))), + .INITVAL_3F($sformatf("0x%080x", init_slice('h3f))), + .DATA_WIDTH_W($sformatf("X%d", PORT_W_WIDTH)), + .DATA_WIDTH_R($sformatf("X%d", PORT_R_WIDTH)), + .OUTREG("BYPASSED"), + .RESETMODE(PORT_R_OPTION_RESETMODE), + .ASYNC_RST_RELEASE(PORT_R_OPTION_RESETMODE), + .CSDECODE_W("000"), + .CSDECODE_R("000"), + .ECC("DISABLED"), + .GSR("DISABLED"), +) _TECHMAP_REPLACE_ ( + .CLKW(PORT_W_CLK), + .CEW(PORT_W_CLK_EN), + .CSW(3'b111), + .ADW(ADW), + .DI(DI), + + .CLKR(PORT_R_CLK), + .CER(PORT_R_CLK_EN), + .RST(PORT_R_OPTION_RESETMODE == "SYNC" ? PORT_R_RD_SRST : PORT_R_RD_ARST), + .CSR(3'b111), + .ADR(PORT_R_ADDR), + .DO(DO), +); + +end + +endgenerate endmodule diff --git a/techlibs/nexus/lrams.txt b/techlibs/nexus/lrams.txt index 481629b98..ad2845783 100644 --- a/techlibs/nexus/lrams.txt +++ b/techlibs/nexus/lrams.txt @@ -1,22 +1,21 @@ -bram $__NX_PDPSC512K - init 1 - - abits 14 - dbits 32 - - groups 2 - ports 1 1 - wrmode 1 0 - enable 4 1 - transp 0 0 - clocks 2 2 - clkpol 2 2 -endbram - -match $__NX_PDPSC512K - # explicitly requested LRAM only, due to limited availability and - # slower Fmax - attribute lram - shuffle_enable A - make_transp -endmatch +ram huge $__NX_DPSC512K_ { + abits 14; + width 32; + byte 8; + cost 2048; + init no_undef; + port srsw "A" "B" { + clock posedge "C"; + clken; + wrbe_separate; + rdwr no_change; + option "RESETMODE" "SYNC" { + rdsrst zero gated_clken; + } + option "RESETMODE" "ASYNC" { + rdarst zero; + } + rdinit zero; + wrtrans all old; + } +} diff --git a/techlibs/nexus/lrams_init.vh b/techlibs/nexus/lrams_init.vh deleted file mode 100644 index 31a7ba4a8..000000000 --- a/techlibs/nexus/lrams_init.vh +++ /dev/null @@ -1,128 +0,0 @@ -.INITVAL_00($sformatf("0x%05120x", permute_init(INIT[0 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_01($sformatf("0x%05120x", permute_init(INIT[1 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_02($sformatf("0x%05120x", permute_init(INIT[2 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_03($sformatf("0x%05120x", permute_init(INIT[3 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_04($sformatf("0x%05120x", permute_init(INIT[4 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_05($sformatf("0x%05120x", permute_init(INIT[5 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_06($sformatf("0x%05120x", permute_init(INIT[6 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_07($sformatf("0x%05120x", permute_init(INIT[7 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_08($sformatf("0x%05120x", permute_init(INIT[8 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_09($sformatf("0x%05120x", permute_init(INIT[9 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0A($sformatf("0x%05120x", permute_init(INIT[10 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0B($sformatf("0x%05120x", permute_init(INIT[11 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0C($sformatf("0x%05120x", permute_init(INIT[12 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0D($sformatf("0x%05120x", permute_init(INIT[13 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0E($sformatf("0x%05120x", permute_init(INIT[14 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_0F($sformatf("0x%05120x", permute_init(INIT[15 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_10($sformatf("0x%05120x", permute_init(INIT[16 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_11($sformatf("0x%05120x", permute_init(INIT[17 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_12($sformatf("0x%05120x", permute_init(INIT[18 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_13($sformatf("0x%05120x", permute_init(INIT[19 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_14($sformatf("0x%05120x", permute_init(INIT[20 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_15($sformatf("0x%05120x", permute_init(INIT[21 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_16($sformatf("0x%05120x", permute_init(INIT[22 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_17($sformatf("0x%05120x", permute_init(INIT[23 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_18($sformatf("0x%05120x", permute_init(INIT[24 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_19($sformatf("0x%05120x", permute_init(INIT[25 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1A($sformatf("0x%05120x", permute_init(INIT[26 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1B($sformatf("0x%05120x", permute_init(INIT[27 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1C($sformatf("0x%05120x", permute_init(INIT[28 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1D($sformatf("0x%05120x", permute_init(INIT[29 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1E($sformatf("0x%05120x", permute_init(INIT[30 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_1F($sformatf("0x%05120x", permute_init(INIT[31 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_20($sformatf("0x%05120x", permute_init(INIT[32 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_21($sformatf("0x%05120x", permute_init(INIT[33 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_22($sformatf("0x%05120x", permute_init(INIT[34 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_23($sformatf("0x%05120x", permute_init(INIT[35 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_24($sformatf("0x%05120x", permute_init(INIT[36 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_25($sformatf("0x%05120x", permute_init(INIT[37 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_26($sformatf("0x%05120x", permute_init(INIT[38 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_27($sformatf("0x%05120x", permute_init(INIT[39 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_28($sformatf("0x%05120x", permute_init(INIT[40 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_29($sformatf("0x%05120x", permute_init(INIT[41 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2A($sformatf("0x%05120x", permute_init(INIT[42 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2B($sformatf("0x%05120x", permute_init(INIT[43 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2C($sformatf("0x%05120x", permute_init(INIT[44 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2D($sformatf("0x%05120x", permute_init(INIT[45 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2E($sformatf("0x%05120x", permute_init(INIT[46 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_2F($sformatf("0x%05120x", permute_init(INIT[47 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_30($sformatf("0x%05120x", permute_init(INIT[48 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_31($sformatf("0x%05120x", permute_init(INIT[49 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_32($sformatf("0x%05120x", permute_init(INIT[50 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_33($sformatf("0x%05120x", permute_init(INIT[51 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_34($sformatf("0x%05120x", permute_init(INIT[52 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_35($sformatf("0x%05120x", permute_init(INIT[53 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_36($sformatf("0x%05120x", permute_init(INIT[54 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_37($sformatf("0x%05120x", permute_init(INIT[55 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_38($sformatf("0x%05120x", permute_init(INIT[56 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_39($sformatf("0x%05120x", permute_init(INIT[57 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3A($sformatf("0x%05120x", permute_init(INIT[58 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3B($sformatf("0x%05120x", permute_init(INIT[59 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3C($sformatf("0x%05120x", permute_init(INIT[60 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3D($sformatf("0x%05120x", permute_init(INIT[61 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3E($sformatf("0x%05120x", permute_init(INIT[62 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_3F($sformatf("0x%05120x", permute_init(INIT[63 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_40($sformatf("0x%05120x", permute_init(INIT[64 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_41($sformatf("0x%05120x", permute_init(INIT[65 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_42($sformatf("0x%05120x", permute_init(INIT[66 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_43($sformatf("0x%05120x", permute_init(INIT[67 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_44($sformatf("0x%05120x", permute_init(INIT[68 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_45($sformatf("0x%05120x", permute_init(INIT[69 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_46($sformatf("0x%05120x", permute_init(INIT[70 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_47($sformatf("0x%05120x", permute_init(INIT[71 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_48($sformatf("0x%05120x", permute_init(INIT[72 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_49($sformatf("0x%05120x", permute_init(INIT[73 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_4A($sformatf("0x%05120x", permute_init(INIT[74 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_4B($sformatf("0x%05120x", permute_init(INIT[75 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_4C($sformatf("0x%05120x", permute_init(INIT[76 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_4D($sformatf("0x%05120x", permute_init(INIT[77 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_4E($sformatf("0x%05120x", permute_init(INIT[78 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_4F($sformatf("0x%05120x", permute_init(INIT[79 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_50($sformatf("0x%05120x", permute_init(INIT[80 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_51($sformatf("0x%05120x", permute_init(INIT[81 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_52($sformatf("0x%05120x", permute_init(INIT[82 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_53($sformatf("0x%05120x", permute_init(INIT[83 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_54($sformatf("0x%05120x", permute_init(INIT[84 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_55($sformatf("0x%05120x", permute_init(INIT[85 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_56($sformatf("0x%05120x", permute_init(INIT[86 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_57($sformatf("0x%05120x", permute_init(INIT[87 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_58($sformatf("0x%05120x", permute_init(INIT[88 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_59($sformatf("0x%05120x", permute_init(INIT[89 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_5A($sformatf("0x%05120x", permute_init(INIT[90 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_5B($sformatf("0x%05120x", permute_init(INIT[91 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_5C($sformatf("0x%05120x", permute_init(INIT[92 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_5D($sformatf("0x%05120x", permute_init(INIT[93 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_5E($sformatf("0x%05120x", permute_init(INIT[94 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_5F($sformatf("0x%05120x", permute_init(INIT[95 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_60($sformatf("0x%05120x", permute_init(INIT[96 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_61($sformatf("0x%05120x", permute_init(INIT[97 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_62($sformatf("0x%05120x", permute_init(INIT[98 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_63($sformatf("0x%05120x", permute_init(INIT[99 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_64($sformatf("0x%05120x", permute_init(INIT[100 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_65($sformatf("0x%05120x", permute_init(INIT[101 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_66($sformatf("0x%05120x", permute_init(INIT[102 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_67($sformatf("0x%05120x", permute_init(INIT[103 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_68($sformatf("0x%05120x", permute_init(INIT[104 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_69($sformatf("0x%05120x", permute_init(INIT[105 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_6A($sformatf("0x%05120x", permute_init(INIT[106 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_6B($sformatf("0x%05120x", permute_init(INIT[107 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_6C($sformatf("0x%05120x", permute_init(INIT[108 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_6D($sformatf("0x%05120x", permute_init(INIT[109 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_6E($sformatf("0x%05120x", permute_init(INIT[110 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_6F($sformatf("0x%05120x", permute_init(INIT[111 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_70($sformatf("0x%05120x", permute_init(INIT[112 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_71($sformatf("0x%05120x", permute_init(INIT[113 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_72($sformatf("0x%05120x", permute_init(INIT[114 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_73($sformatf("0x%05120x", permute_init(INIT[115 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_74($sformatf("0x%05120x", permute_init(INIT[116 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_75($sformatf("0x%05120x", permute_init(INIT[117 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_76($sformatf("0x%05120x", permute_init(INIT[118 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_77($sformatf("0x%05120x", permute_init(INIT[119 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_78($sformatf("0x%05120x", permute_init(INIT[120 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_79($sformatf("0x%05120x", permute_init(INIT[121 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_7A($sformatf("0x%05120x", permute_init(INIT[122 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_7B($sformatf("0x%05120x", permute_init(INIT[123 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_7C($sformatf("0x%05120x", permute_init(INIT[124 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_7D($sformatf("0x%05120x", permute_init(INIT[125 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_7E($sformatf("0x%05120x", permute_init(INIT[126 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), -.INITVAL_7F($sformatf("0x%05120x", permute_init(INIT[127 * INIT_CHUNK_SIZE +: INIT_CHUNK_SIZE]))), diff --git a/techlibs/nexus/lrams_map.v b/techlibs/nexus/lrams_map.v index 938a0e843..5db5ae8bf 100644 --- a/techlibs/nexus/lrams_map.v +++ b/techlibs/nexus/lrams_map.v @@ -1,56 +1,194 @@ -module \$__NX_PDPSC512K (CLK2, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN); - parameter CFG_ABITS = 14; - parameter CFG_DBITS = 32; - parameter CFG_ENABLE_A = 4; - - parameter CLKPOL2 = 1; - parameter [524287:0] INIT = 524287'b0; - - input CLK2; - - 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 clk; - wire [31:0] rd; - assign B1DATA = rd[CFG_DBITS-1:0]; - - generate - if (CLKPOL2) - assign clk = CLK2; - else - INV clk_inv_i (.A(CLK2), .Z(clk)); - endgenerate - - wire we = |A1EN; - - localparam INIT_CHUNK_SIZE = 4096; - - function [5119:0] permute_init; - input [INIT_CHUNK_SIZE-1:0] chunk; - integer i; - begin - for (i = 0; i < 128; i = i + 1'b1) - permute_init[i * 40 +: 40] = {8'b0, chunk[i * 32 +: 32]}; - end - endfunction - - generate - PDPSC512K #( - .OUTREG("NO_REG"), - .ECC_BYTE_SEL("BYTE_EN"), -`include "lrams_init.vh" - .GSR("DISABLED") - ) _TECHMAP_REPLACE_ ( - .CLK(clk), .RSTR(1'b0), - .DI(A1DATA), .ADW(A1ADDR), .CEW(we), .WE(we), .CSW(1'b1), - .ADR(B1ADDR), .DO(rd), .CER(B1EN), .CSR(1'b1), - ); - endgenerate +module $__NX_DPSC512K_ (...); + +parameter INIT = 0; +parameter OPTION_RESETMODE = "SYNC"; + +input CLK_C; + +input PORT_A_CLK; +input PORT_A_CLK_EN; +input PORT_A_WR_EN; +input PORT_A_RD_SRST; +input PORT_A_RD_ARST; +input [13:0] PORT_A_ADDR; +input [3:0] PORT_A_WR_BE; +input [31:0] PORT_A_WR_DATA; +output [31:0] PORT_A_RD_DATA; + +input PORT_B_CLK; +input PORT_B_CLK_EN; +input PORT_B_WR_EN; +input PORT_B_RD_SRST; +input PORT_B_RD_ARST; +input [13:0] PORT_B_ADDR; +input [3:0] PORT_B_WR_BE; +input [31:0] PORT_B_WR_DATA; +output [31:0] PORT_B_RD_DATA; + +function [5119:0] init_slice; + input integer idx; + integer i, j; + init_slice = 0; + for (i = 0; i < 128; i = i + 1) begin + init_slice[i*40+:32] = INIT[(idx * 128 + i) * 32+:32]; + end +endfunction + +DPSC512K #( + .INITVAL_00($sformatf("0x%01280x", init_slice('h00))), + .INITVAL_01($sformatf("0x%01280x", init_slice('h01))), + .INITVAL_02($sformatf("0x%01280x", init_slice('h02))), + .INITVAL_03($sformatf("0x%01280x", init_slice('h03))), + .INITVAL_04($sformatf("0x%01280x", init_slice('h04))), + .INITVAL_05($sformatf("0x%01280x", init_slice('h05))), + .INITVAL_06($sformatf("0x%01280x", init_slice('h06))), + .INITVAL_07($sformatf("0x%01280x", init_slice('h07))), + .INITVAL_08($sformatf("0x%01280x", init_slice('h08))), + .INITVAL_09($sformatf("0x%01280x", init_slice('h09))), + .INITVAL_0A($sformatf("0x%01280x", init_slice('h0a))), + .INITVAL_0B($sformatf("0x%01280x", init_slice('h0b))), + .INITVAL_0C($sformatf("0x%01280x", init_slice('h0c))), + .INITVAL_0D($sformatf("0x%01280x", init_slice('h0d))), + .INITVAL_0E($sformatf("0x%01280x", init_slice('h0e))), + .INITVAL_0F($sformatf("0x%01280x", init_slice('h0f))), + .INITVAL_10($sformatf("0x%01280x", init_slice('h10))), + .INITVAL_11($sformatf("0x%01280x", init_slice('h11))), + .INITVAL_12($sformatf("0x%01280x", init_slice('h12))), + .INITVAL_13($sformatf("0x%01280x", init_slice('h13))), + .INITVAL_14($sformatf("0x%01280x", init_slice('h14))), + .INITVAL_15($sformatf("0x%01280x", init_slice('h15))), + .INITVAL_16($sformatf("0x%01280x", init_slice('h16))), + .INITVAL_17($sformatf("0x%01280x", init_slice('h17))), + .INITVAL_18($sformatf("0x%01280x", init_slice('h18))), + .INITVAL_19($sformatf("0x%01280x", init_slice('h19))), + .INITVAL_1A($sformatf("0x%01280x", init_slice('h1a))), + .INITVAL_1B($sformatf("0x%01280x", init_slice('h1b))), + .INITVAL_1C($sformatf("0x%01280x", init_slice('h1c))), + .INITVAL_1D($sformatf("0x%01280x", init_slice('h1d))), + .INITVAL_1E($sformatf("0x%01280x", init_slice('h1e))), + .INITVAL_1F($sformatf("0x%01280x", init_slice('h1f))), + .INITVAL_20($sformatf("0x%01280x", init_slice('h20))), + .INITVAL_21($sformatf("0x%01280x", init_slice('h21))), + .INITVAL_22($sformatf("0x%01280x", init_slice('h22))), + .INITVAL_23($sformatf("0x%01280x", init_slice('h23))), + .INITVAL_24($sformatf("0x%01280x", init_slice('h24))), + .INITVAL_25($sformatf("0x%01280x", init_slice('h25))), + .INITVAL_26($sformatf("0x%01280x", init_slice('h26))), + .INITVAL_27($sformatf("0x%01280x", init_slice('h27))), + .INITVAL_28($sformatf("0x%01280x", init_slice('h28))), + .INITVAL_29($sformatf("0x%01280x", init_slice('h29))), + .INITVAL_2A($sformatf("0x%01280x", init_slice('h2a))), + .INITVAL_2B($sformatf("0x%01280x", init_slice('h2b))), + .INITVAL_2C($sformatf("0x%01280x", init_slice('h2c))), + .INITVAL_2D($sformatf("0x%01280x", init_slice('h2d))), + .INITVAL_2E($sformatf("0x%01280x", init_slice('h2e))), + .INITVAL_2F($sformatf("0x%01280x", init_slice('h2f))), + .INITVAL_30($sformatf("0x%01280x", init_slice('h30))), + .INITVAL_31($sformatf("0x%01280x", init_slice('h31))), + .INITVAL_32($sformatf("0x%01280x", init_slice('h32))), + .INITVAL_33($sformatf("0x%01280x", init_slice('h33))), + .INITVAL_34($sformatf("0x%01280x", init_slice('h34))), + .INITVAL_35($sformatf("0x%01280x", init_slice('h35))), + .INITVAL_36($sformatf("0x%01280x", init_slice('h36))), + .INITVAL_37($sformatf("0x%01280x", init_slice('h37))), + .INITVAL_38($sformatf("0x%01280x", init_slice('h38))), + .INITVAL_39($sformatf("0x%01280x", init_slice('h39))), + .INITVAL_3A($sformatf("0x%01280x", init_slice('h3a))), + .INITVAL_3B($sformatf("0x%01280x", init_slice('h3b))), + .INITVAL_3C($sformatf("0x%01280x", init_slice('h3c))), + .INITVAL_3D($sformatf("0x%01280x", init_slice('h3d))), + .INITVAL_3E($sformatf("0x%01280x", init_slice('h3e))), + .INITVAL_3F($sformatf("0x%01280x", init_slice('h3f))), + .INITVAL_40($sformatf("0x%01280x", init_slice('h40))), + .INITVAL_41($sformatf("0x%01280x", init_slice('h41))), + .INITVAL_42($sformatf("0x%01280x", init_slice('h42))), + .INITVAL_43($sformatf("0x%01280x", init_slice('h43))), + .INITVAL_44($sformatf("0x%01280x", init_slice('h44))), + .INITVAL_45($sformatf("0x%01280x", init_slice('h45))), + .INITVAL_46($sformatf("0x%01280x", init_slice('h46))), + .INITVAL_47($sformatf("0x%01280x", init_slice('h47))), + .INITVAL_48($sformatf("0x%01280x", init_slice('h48))), + .INITVAL_49($sformatf("0x%01280x", init_slice('h49))), + .INITVAL_4A($sformatf("0x%01280x", init_slice('h4a))), + .INITVAL_4B($sformatf("0x%01280x", init_slice('h4b))), + .INITVAL_4C($sformatf("0x%01280x", init_slice('h4c))), + .INITVAL_4D($sformatf("0x%01280x", init_slice('h4d))), + .INITVAL_4E($sformatf("0x%01280x", init_slice('h4e))), + .INITVAL_4F($sformatf("0x%01280x", init_slice('h4f))), + .INITVAL_50($sformatf("0x%01280x", init_slice('h50))), + .INITVAL_51($sformatf("0x%01280x", init_slice('h51))), + .INITVAL_52($sformatf("0x%01280x", init_slice('h52))), + .INITVAL_53($sformatf("0x%01280x", init_slice('h53))), + .INITVAL_54($sformatf("0x%01280x", init_slice('h54))), + .INITVAL_55($sformatf("0x%01280x", init_slice('h55))), + .INITVAL_56($sformatf("0x%01280x", init_slice('h56))), + .INITVAL_57($sformatf("0x%01280x", init_slice('h57))), + .INITVAL_58($sformatf("0x%01280x", init_slice('h58))), + .INITVAL_59($sformatf("0x%01280x", init_slice('h59))), + .INITVAL_5A($sformatf("0x%01280x", init_slice('h5a))), + .INITVAL_5B($sformatf("0x%01280x", init_slice('h5b))), + .INITVAL_5C($sformatf("0x%01280x", init_slice('h5c))), + .INITVAL_5D($sformatf("0x%01280x", init_slice('h5d))), + .INITVAL_5E($sformatf("0x%01280x", init_slice('h5e))), + .INITVAL_5F($sformatf("0x%01280x", init_slice('h5f))), + .INITVAL_60($sformatf("0x%01280x", init_slice('h60))), + .INITVAL_61($sformatf("0x%01280x", init_slice('h61))), + .INITVAL_62($sformatf("0x%01280x", init_slice('h62))), + .INITVAL_63($sformatf("0x%01280x", init_slice('h63))), + .INITVAL_64($sformatf("0x%01280x", init_slice('h64))), + .INITVAL_65($sformatf("0x%01280x", init_slice('h65))), + .INITVAL_66($sformatf("0x%01280x", init_slice('h66))), + .INITVAL_67($sformatf("0x%01280x", init_slice('h67))), + .INITVAL_68($sformatf("0x%01280x", init_slice('h68))), + .INITVAL_69($sformatf("0x%01280x", init_slice('h69))), + .INITVAL_6A($sformatf("0x%01280x", init_slice('h6a))), + .INITVAL_6B($sformatf("0x%01280x", init_slice('h6b))), + .INITVAL_6C($sformatf("0x%01280x", init_slice('h6c))), + .INITVAL_6D($sformatf("0x%01280x", init_slice('h6d))), + .INITVAL_6E($sformatf("0x%01280x", init_slice('h6e))), + .INITVAL_6F($sformatf("0x%01280x", init_slice('h6f))), + .INITVAL_70($sformatf("0x%01280x", init_slice('h70))), + .INITVAL_71($sformatf("0x%01280x", init_slice('h71))), + .INITVAL_72($sformatf("0x%01280x", init_slice('h72))), + .INITVAL_73($sformatf("0x%01280x", init_slice('h73))), + .INITVAL_74($sformatf("0x%01280x", init_slice('h74))), + .INITVAL_75($sformatf("0x%01280x", init_slice('h75))), + .INITVAL_76($sformatf("0x%01280x", init_slice('h76))), + .INITVAL_77($sformatf("0x%01280x", init_slice('h77))), + .INITVAL_78($sformatf("0x%01280x", init_slice('h78))), + .INITVAL_79($sformatf("0x%01280x", init_slice('h79))), + .INITVAL_7A($sformatf("0x%01280x", init_slice('h7a))), + .INITVAL_7B($sformatf("0x%01280x", init_slice('h7b))), + .INITVAL_7C($sformatf("0x%01280x", init_slice('h7c))), + .INITVAL_7D($sformatf("0x%01280x", init_slice('h7d))), + .INITVAL_7E($sformatf("0x%01280x", init_slice('h7e))), + .INITVAL_7F($sformatf("0x%01280x", init_slice('h7f))), + .OUTREG_A("NO_REG"), + .OUTREG_B("NO_REG"), + .ECC_BYTE_SEL("BYTE_EN"), + .GSR("DISABLED"), + .RESETMODE(OPTION_RESETMODE), + .ASYNC_RESET_RELEASE(OPTION_RESETMODE), +) _TECHMAP_REPLACE_ ( + .CLK(CLK_C), + + .WEA(PORT_A_WR_EN), + .CEA(PORT_A_CLK_EN), + .RSTA(OPTION_RESETMODE == "SYNC" ? PORT_A_RD_SRST : PORT_A_RD_ARST), + .CSA(1'b1), + .ADA(PORT_A_ADDR), + .BENA_N(~PORT_A_WR_BE), + .DIA(PORT_A_WR_DATA), + .DOA(PORT_A_RD_DATA), + + .WEB(PORT_B_WR_EN), + .CEB(PORT_B_CLK_EN), + .RSTB(OPTION_RESETMODE == "SYNC" ? PORT_B_RD_SRST : PORT_B_RD_ARST), + .CSB(1'b1), + .BENB_N(~PORT_B_WR_BE), + .ADB(PORT_B_ADDR), + .DIB(PORT_B_WR_DATA), + .DOB(PORT_B_RD_DATA), +); endmodule diff --git a/techlibs/nexus/lutrams.txt b/techlibs/nexus/lutrams.txt index 2568b9998..90e1e7bfd 100644 --- a/techlibs/nexus/lutrams.txt +++ b/techlibs/nexus/lutrams.txt @@ -1,26 +1,12 @@ -bram $__NEXUS_DPR16X4 - init 1 - abits 4 - dbits 4 - groups 2 - ports 1 1 - wrmode 0 1 - enable 0 1 - transp 0 0 - clocks 0 1 - clkpol 0 2 -endbram - -# The syn_* attributes are described in: -# https://www.latticesemi.com/-/media/LatticeSemi/Documents/Tutorials/AK/LatticeDiamondTutorial311.ashx -attr_icase 1 - -match $__NEXUS_DPR16X4 - attribute !syn_ramstyle syn_ramstyle=auto syn_ramstyle=distributed - attribute !syn_romstyle syn_romstyle=auto - attribute !ram_block - attribute !rom_block - attribute !logic_block - make_outreg - min wports 1 -endmatch +ram distributed $__NEXUS_DPR16X4_ { + abits 4; + width 4; + cost 4; + init no_undef; + prune_rom; + port sw "W" { + clock posedge; + } + port ar "R" { + } +} diff --git a/techlibs/nexus/lutrams_map.v b/techlibs/nexus/lutrams_map.v index 0910664ce..d12b49060 100644 --- a/techlibs/nexus/lutrams_map.v +++ b/techlibs/nexus/lutrams_map.v @@ -1,34 +1,23 @@ -module \$__NEXUS_DPR16X4 (CLK1, A1ADDR, A1DATA, B1ADDR, B1DATA, B1EN); - parameter [63:0] INIT = 64'b0; - parameter CLKPOL2 = 1; - input CLK1; +module $__NEXUS_DPR16X4_ (...); + parameter INIT = 64'b0; - input [3:0] A1ADDR; - output [3:0] A1DATA; + input PORT_W_CLK; + input [3:0] PORT_W_ADDR; + input [3:0] PORT_W_WR_DATA; + input PORT_W_WR_EN; - input [3:0] B1ADDR; - input [3:0] B1DATA; - input B1EN; - - - wire wck; - - generate - if (CLKPOL2) - assign wck = CLK1; - else - INV wck_inv_i (.A(CLK1), .Z(wck)); - endgenerate + input [3:0] PORT_R_ADDR; + output [3:0] PORT_R_RD_DATA; DPR16X4 #( .INITVAL($sformatf("0x%08x", INIT)) ) _TECHMAP_REPLACE_ ( - .RAD(A1ADDR), - .DO(A1DATA), + .RAD(PORT_R_ADDR), + .DO(PORT_R_RD_DATA), - .WAD(B1ADDR), - .DI(B1DATA), - .WCK(CLK1), - .WRE(B1EN) + .WAD(PORT_W_ADDR), + .DI(PORT_W_WR_DATA), + .WCK(PORT_W_CLK), + .WRE(PORT_W_WR_EN) ); endmodule diff --git a/techlibs/nexus/synth_nexus.cc b/techlibs/nexus/synth_nexus.cc index 03bff0649..6fd15ba55 100644 --- a/techlibs/nexus/synth_nexus.cc +++ b/techlibs/nexus/synth_nexus.cc @@ -296,33 +296,24 @@ struct SynthNexusPass : public ScriptPass run("opt_clean"); } - if (!nolram && check_label("map_lram", "(skip if -nolram)")) + if (check_label("map_ram")) { - run("memory_bram -rules +/nexus/lrams.txt"); - run("setundef -zero -params t:$__NX_PDPSC512K"); - run("techmap -map +/nexus/lrams_map.v"); - } - - if (!nobram && check_label("map_bram", "(skip if -nobram)")) - { - run("memory_bram -rules +/nexus/brams.txt"); - run("setundef -zero -params t:$__NX_PDP16K"); - run("techmap -map +/nexus/brams_map.v"); - } - - if (!nolutram && check_label("map_lutram", "(skip if -nolutram)")) - { - run("memory_bram -rules +/nexus/lutrams.txt"); - run("setundef -zero -params t:$__NEXUS_DPR16X4"); - run("techmap -map +/nexus/lutrams_map.v"); + std::string args = ""; + args += " -no-auto-huge"; + if (nobram) + args += " -no-auto-block"; + if (nolutram) + args += " -no-auto-distributed"; + if (help_mode) + args += " [-no-auto-block] [-no-auto-distributed]"; + run("memory_libmap -lib +/nexus/lutrams.txt -lib +/nexus/brams.txt -lib +/nexus/lrams.txt" + args, "(-no-auto-block if -nobram, -no-auto-distributed if -nolutram)"); + run("techmap -map +/nexus/lutrams_map.v -map +/nexus/brams_map.v -map +/nexus/lrams_map.v"); } if (check_label("map_ffram")) { run("opt -fast -mux_undef -undriven -fine"); - run("memory_map -iattr -attr !ram_block -attr !rom_block -attr logic_block " - "-attr syn_ramstyle=auto -attr syn_ramstyle=registers " - "-attr syn_romstyle=auto -attr syn_romstyle=logic"); + run("memory_map"); run("opt -undriven -fine"); } diff --git a/tests/arch/nexus/blockram.ys b/tests/arch/nexus/blockram.ys index 9540136d5..a85b5141e 100644 --- a/tests/arch/nexus/blockram.ys +++ b/tests/arch/nexus/blockram.ys @@ -3,7 +3,7 @@ design -save read # Check that we use the right dual and single clock variants -chparam -set ADDRESS_WIDTH 10 -set DATA_WIDTH 18 sync_ram_sdp +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 36 sync_ram_sdp synth_nexus -top sync_ram_sdp cd sync_ram_sdp select -assert-count 1 t:PDPSC16K @@ -11,7 +11,7 @@ select -assert-none t:PDPSC16K t:INV t:IB t:OB t:VLO t:VHI %% t:* %D design -reset read_verilog blockram_dc.v -chparam -set ADDRESS_WIDTH 10 -set DATA_WIDTH 18 sync_ram_sdp_dc +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 36 sync_ram_sdp_dc synth_nexus -top sync_ram_sdp_dc cd sync_ram_sdp_dc select -assert-count 1 t:PDP16K -- 2.30.2