| 1 |
import sys |
| 2 |
import os |
| 3 |
import re |
| 4 |
import bisect |
| 5 |
import itertools |
| 6 |
import math |
| 7 |
import json |
| 8 |
import argparse |
| 9 |
import importlib.resources |
| 10 |
from collections import namedtuple |
| 11 |
from apycula import codegen |
| 12 |
from apycula import chipdb |
| 13 |
from apycula.chipdb import add_attr_val, get_shortval_fuses, get_longval_fuses, get_bank_fuses, get_bank_io_fuses, get_long_fuses, load_chipdb |
| 14 |
from apycula import attrids |
| 15 |
from apycula import bslib |
| 16 |
from apycula import bitmatrix |
| 17 |
from apycula import wirenames as wnames |
| 18 |
|
| 19 |
device = "" |
| 20 |
pnr = None |
| 21 |
bsram_init_map = None |
| 22 |
gw5a_bsrams = [] |
| 23 |
adc_iolocs = {} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
_vcc_net = [] |
| 34 |
_gnd_net = [] |
| 35 |
|
| 36 |
def is_gnd_net(wire): |
| 37 |
return wire in _gnd_net |
| 38 |
|
| 39 |
def is_vcc_net(wire): |
| 40 |
return wire in _vcc_net |
| 41 |
|
| 42 |
def is_const_net(wire): |
| 43 |
return is_gnd_net(wire) or is_vcc_net(wire) |
| 44 |
|
| 45 |
def is_connected(wire, connections): |
| 46 |
return len(connections[wire]) != 0 |
| 47 |
|
| 48 |
|
| 49 |
def iob_is_gnd_net(flags, wire): |
| 50 |
return flags.get(f'NET_{wire}', False) == 'GND' |
| 51 |
|
| 52 |
def iob_is_vcc_net(flags, wire): |
| 53 |
return flags.get(f'NET_{wire}', False) == 'VCC' |
| 54 |
|
| 55 |
def iob_is_connected(flags, wire): |
| 56 |
return f'NET_{wire}' in flags |
| 57 |
|
| 58 |
def iob_is_connected_to_HCLK_GCLK(connections): |
| 59 |
if 'O' not in connections: |
| 60 |
return False |
| 61 |
for net_name in pnr['modules']['top']['netnames']: |
| 62 |
net = pnr['modules']['top']['netnames'][net_name] |
| 63 |
for out_bits in connections['O']: |
| 64 |
if out_bits in net['bits']: |
| 65 |
if 'ROUTING' in net['attributes'] and 'HCLK_GCLK' in net['attributes']['ROUTING']: |
| 66 |
return True |
| 67 |
return False |
| 68 |
|
| 69 |
|
| 70 |
def rc2tbrl(db, row, col, num): |
| 71 |
edge = 'T' |
| 72 |
idx = col + 1 |
| 73 |
if row == db.rows - 1: |
| 74 |
edge = 'B' |
| 75 |
elif col == 0: |
| 76 |
edge = 'L' |
| 77 |
idx = row + 1 |
| 78 |
elif col == db.cols - 1: |
| 79 |
edge = 'R' |
| 80 |
idx = row + 1 |
| 81 |
return f"IO{edge}{idx}{num}" |
| 82 |
|
| 83 |
_verilog_name = re.compile(r"^[A-Za-z_0-9][A-Za-z_0-9$]*$") |
| 84 |
def sanitize_name(name): |
| 85 |
retname = name |
| 86 |
if name[-3:] == '_LC': |
| 87 |
retname = name[:-3] |
| 88 |
elif name[-6:] == '_DFFLC': |
| 89 |
retname = name[:-6] |
| 90 |
elif name[-4:] == '$iob': |
| 91 |
retname = name[:-4] |
| 92 |
if _verilog_name.fullmatch(retname): |
| 93 |
return retname |
| 94 |
return f"\\{retname} " |
| 95 |
|
| 96 |
def attrs_upper(attrs): |
| 97 |
for k, v in attrs.items(): |
| 98 |
if isinstance(v, str): |
| 99 |
attrs[k] = v.upper() |
| 100 |
|
| 101 |
def extra_pll_bels(cell, row, col, num, cellname): |
| 102 |
|
| 103 |
offx = 1 |
| 104 |
if device in {'GW1N-9C', 'GW1N-9', 'GW2A-18', 'GW2A-18C'}: |
| 105 |
if int(col) > 28: |
| 106 |
offx = -1 |
| 107 |
for off in [1, 2, 3]: |
| 108 |
yield ('RPLLB', int(row), int(col) + offx * off, num, |
| 109 |
cell['parameters'], cell['attributes'], sanitize_name(cellname) + f'B{off}', cell) |
| 110 |
elif device in {'GW1N-1', 'GW1NZ-1', 'GW1N-4'}: |
| 111 |
for off in [1]: |
| 112 |
yield ('RPLLB', int(row), int(col) + offx * off, num, |
| 113 |
cell['parameters'], cell['attributes'], sanitize_name(cellname) + f'B{off}', cell) |
| 114 |
|
| 115 |
def extra_clkdiv_bels(cell, row, col, num, cellname): |
| 116 |
if device in {'GW1NS-4'}: |
| 117 |
if int(col) == 18: |
| 118 |
bel_type = f'{cell["type"]}_AUX' |
| 119 |
yield (bel_type, int(row), int(col) + 3, num, |
| 120 |
cell['parameters'], cell['attributes'], sanitize_name(cellname) + 'AUX', cell) |
| 121 |
if int(col) == 17: |
| 122 |
bel_type = f'{cell["type"]}_AUX' |
| 123 |
yield (bel_type, int(row), int(col) + 1, num, |
| 124 |
cell['parameters'], cell['attributes'], sanitize_name(cellname) + 'AUX', cell) |
| 125 |
|
| 126 |
def extra_mipi_bels(cell, row, col, num, cellname): |
| 127 |
yield ('MIPI_IBUF_AUX', int(row), int(col) + 1, num, |
| 128 |
cell['parameters'], cell['attributes'], sanitize_name(cellname) + 'AUX', cell) |
| 129 |
|
| 130 |
def extra_bsram_bels(cell, row, col, num, cellname): |
| 131 |
for off in [1, 2]: |
| 132 |
yield ('BSRAM_AUX', int(row), int(col) + off, num, |
| 133 |
cell['parameters'], cell['attributes'], sanitize_name(cellname) + f'AUX{off}', cell) |
| 134 |
|
| 135 |
def extra_dsp_bels(cell, row, col, num, cellname): |
| 136 |
extra_cnt = 9 |
| 137 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 138 |
extra_cnt = 3 |
| 139 |
for off in range(1, extra_cnt): |
| 140 |
yield ('DSP_AUX', int(row), int(col) + off, num, |
| 141 |
cell['parameters'], cell['attributes'], sanitize_name(cellname) + f'AUX{off}', cell) |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
def store_bsram_init_val(db, row, col, typ, parms, attrs, map_offset = 0): |
| 158 |
global bsram_init_map |
| 159 |
|
| 160 |
if typ == 'BSRAM_AUX' or 'INIT_RAM_00' not in parms: |
| 161 |
return |
| 162 |
|
| 163 |
attrs_upper(attrs) |
| 164 |
subtype = attrs['BSRAM_SUBTYPE'] |
| 165 |
if bsram_init_map is None: |
| 166 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 167 |
|
| 168 |
bsram_init_map = bitmatrix.zeros(72 * len(db.simplio_rows), db.width) |
| 169 |
else: |
| 170 |
|
| 171 |
bsram_init_map = bitmatrix.zeros(256 * len(db.simplio_rows), db.width) |
| 172 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 173 |
|
| 174 |
loc_map = bitmatrix.zeros(256, 72) |
| 175 |
else: |
| 176 |
|
| 177 |
loc_map = bitmatrix.zeros(256, 3 * 60) |
| 178 |
|
| 179 |
if not subtype.strip(): |
| 180 |
width = 256 |
| 181 |
elif subtype in {'X9'}: |
| 182 |
width = 288 |
| 183 |
else: |
| 184 |
raise Exception(f"Init for {subtype} is not supported") |
| 185 |
|
| 186 |
def get_bits(init_data): |
| 187 |
bit_no = 0 |
| 188 |
ptr = -1 |
| 189 |
while ptr >= -width: |
| 190 |
if bit_no == 8 or bit_no == 17: |
| 191 |
if width == 288: |
| 192 |
yield (init_data[ptr], bit_no, lambda x: x) |
| 193 |
ptr -= 1 |
| 194 |
else: |
| 195 |
yield ('0', bit_no, lambda x: x) |
| 196 |
bit_no = (bit_no + 1) % 18 |
| 197 |
else: |
| 198 |
yield (init_data[ptr], bit_no, lambda x: x + 1) |
| 199 |
ptr -= 1 |
| 200 |
bit_no = (bit_no + 1) % 18 |
| 201 |
|
| 202 |
addr = -1 |
| 203 |
for init_row in range(0x40): |
| 204 |
row_name = f'INIT_RAM_{init_row:02X}' |
| 205 |
|
| 206 |
if row_name not in parms: |
| 207 |
addr += 0x100 |
| 208 |
continue |
| 209 |
init_data = parms[row_name] |
| 210 |
|
| 211 |
for ptr_bit_inc in get_bits(init_data): |
| 212 |
addr = ptr_bit_inc[2](addr) |
| 213 |
if ptr_bit_inc[0] == '0': |
| 214 |
continue |
| 215 |
logic_line = ptr_bit_inc[1] * 4 + (addr >> 12) |
| 216 |
bit = db.rev_logicinfo('BSRAM_INIT')[logic_line][0] - 1 |
| 217 |
quad = {0x30: 0xc0, 0x20: 0x40, 0x10: 0x80, 0x00: 0x00}[addr & 0x30] |
| 218 |
map_row = quad + ((addr >> 6) & 0x3f) |
| 219 |
|
| 220 |
loc_map[map_row][bit] = 1 |
| 221 |
|
| 222 |
|
| 223 |
height = 256 |
| 224 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 225 |
height = 72 |
| 226 |
loc_map = bitmatrix.transpose(loc_map) |
| 227 |
y = 0 |
| 228 |
for brow in sorted(db.simplio_rows): |
| 229 |
if row == brow: |
| 230 |
break |
| 231 |
y += height |
| 232 |
|
| 233 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 234 |
x = 256 * map_offset |
| 235 |
else: |
| 236 |
x = 0 |
| 237 |
for jdx in range(col): |
| 238 |
x += db[0, jdx].width |
| 239 |
loc_map = bitmatrix.flipud(loc_map) |
| 240 |
for row in loc_map: |
| 241 |
x0 = x |
| 242 |
for val in row: |
| 243 |
bsram_init_map[y][x0] = val |
| 244 |
x0 += 1 |
| 245 |
y += 1 |
| 246 |
|
| 247 |
def is_ram_pin(db, r, c, idx): |
| 248 |
""" Internal SDRAM/HyperRAM pins do not have an IO standard, so we will ignore them """ |
| 249 |
partno = pnr['modules']['top']['settings'].get('packer.partno', '') |
| 250 |
pkg, series, _ = db.packages[partno] |
| 251 |
if not db.sip_cst or series not in db.sip_cst or pkg not in db.sip_cst[series]: |
| 252 |
return False |
| 253 |
row = int(r) - 1 |
| 254 |
col = int(c) - 1 |
| 255 |
for pin_desc in db.sip_cst[series][pkg]: |
| 256 |
if row == pin_desc[1] and col == pin_desc[2] and idx == pin_desc[3]: |
| 257 |
return True |
| 258 |
return False |
| 259 |
|
| 260 |
_clkdiv_cell_types = {'CLKDIV', 'CLKDIV2'} |
| 261 |
_bsram_cell_types = {'DP', 'SDP', 'SP', 'ROM'} |
| 262 |
_dsp_cell_types = {'ALU54D', 'MULT36X36', 'MULTALU36X18', 'MULTADDALU18X18', 'MULTALU18X18', 'MULT18X18', 'MULT9X9', 'PADD18', 'PADD9', 'MULT12X12', 'MULTALU27X18', 'MULTADDALU12X12'} |
| 263 |
def get_bels(db, data): |
| 264 |
later = [] |
| 265 |
belre = re.compile(r"X(\d+)Y(\d+)/(?:GSR|LUT|DFF|IOB|MUX|ALU|ODDR|OSC[ZFHWOA]?|BUF[GS]|RAM16SDP4|RAM16SDP2|RAM16SDP1|PLL|IOLOGIC|CLKDIV2|CLKDIV|BSRAM|ALU|MULTALU18X18|MULTALU27X18|MULTALU36X18|MULTADDALU18X18|MULTADDALU12X12|MULT36X36|MULT18X18|MULT12X12|MULT9X9|PADD18|PADD9|BANDGAP|DQCE|DCS|USERFLASH|EMCU|DHCEN|MIPI_OBUF|MIPI_IBUF|DLLDLY|PINCFG|PLLA|ADC)(\w*)") |
| 266 |
|
| 267 |
for cellname, cell in data['modules']['top']['cells'].items(): |
| 268 |
if cell['type'].startswith('DUMMY_') or cell['type'] in {'OSER16', 'IDES16'} or 'NEXTPNR_BEL' not in cell['attributes']: |
| 269 |
continue |
| 270 |
bel = cell['attributes']['NEXTPNR_BEL'] |
| 271 |
if bel in {"VCC", "GND"}: continue |
| 272 |
if bel[-4:] in {'/GND', '/VCC'}: |
| 273 |
continue |
| 274 |
|
| 275 |
bels = belre.match(bel) |
| 276 |
if not bels: |
| 277 |
raise Exception(f"Unknown bel:{bel}") |
| 278 |
col, row, num = bels.groups() |
| 279 |
col = str(int(col) + 1) |
| 280 |
row = str(int(row) + 1) |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
if 'DIFF' in cell['attributes'] or is_ram_pin(db, row, col, num): |
| 286 |
later.append((cellname, cell, row, col, num)) |
| 287 |
continue |
| 288 |
cell_type = cell['type'] |
| 289 |
if cell_type == 'rPLL': |
| 290 |
cell_type = 'RPLLA' |
| 291 |
yield from extra_pll_bels(cell, row, col, num, cellname) |
| 292 |
if cell_type in _clkdiv_cell_types: |
| 293 |
yield from extra_clkdiv_bels(cell, row, col, num, cellname) |
| 294 |
if cell_type in _bsram_cell_types: |
| 295 |
yield from extra_bsram_bels(cell, row, col, num, cellname) |
| 296 |
if cell_type in _dsp_cell_types: |
| 297 |
yield from extra_dsp_bels(cell, row, col, num, cellname) |
| 298 |
if cell_type == 'MIPI_IBUF': |
| 299 |
yield from extra_mipi_bels(cell, row, col, num, cellname) |
| 300 |
yield (cell_type, int(row), int(col), num, |
| 301 |
cell['parameters'], cell['attributes'], sanitize_name(cellname), cell) |
| 302 |
|
| 303 |
|
| 304 |
for cellname, cell, row, col, num in later: |
| 305 |
yield (cell['type'], int(row), int(col), num, |
| 306 |
cell['parameters'], cell['attributes'], sanitize_name(cellname), cell) |
| 307 |
|
| 308 |
_pip_bels = [] |
| 309 |
def get_pips(data): |
| 310 |
pipre = re.compile(r"X(\d+)Y(\d+)/([\w_]+)/([\w_]+)") |
| 311 |
for net in data['modules']['top']['netnames'].values(): |
| 312 |
routing = net['attributes']['ROUTING'] |
| 313 |
pips = routing.split(';')[1::3] |
| 314 |
for pip in pips: |
| 315 |
res = pipre.fullmatch(pip) |
| 316 |
if res: |
| 317 |
row, col, src, dest = res.groups() |
| 318 |
|
| 319 |
if src.startswith('XD'): |
| 320 |
if dest.startswith('F'): |
| 321 |
continue |
| 322 |
|
| 323 |
num = dest[1] |
| 324 |
init = {'A': '1010101010101010', 'B': '1100110011001100', |
| 325 |
'C': '1111000011110000', 'D': '1111111100000000'}[dest[0]] |
| 326 |
_pip_bels.append(("LUT4", int(col) + 1, int(row) + 1, num, {"INIT": init}, {}, f'$PACKER_PASS_LUT_{len(_pip_bels)}', None)) |
| 327 |
continue |
| 328 |
yield int(col) + 1, int(row) + 1, dest, src |
| 329 |
elif pip and "DUMMY" not in pip: |
| 330 |
print("Invalid pip:", pip) |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
def isolate_segments(pnr, db, tilemap): |
| 336 |
wire_re = re.compile(r"X(\d+)Y(\d+)/([\w]+)") |
| 337 |
for net in pnr['modules']['top']['netnames'].values(): |
| 338 |
if 'SEG_WIRES_TO_ISOLATE' not in net['attributes']: |
| 339 |
continue |
| 340 |
val = net['attributes']['SEG_WIRES_TO_ISOLATE'] |
| 341 |
wires = val.split(';') |
| 342 |
for wire_ex in wires: |
| 343 |
if not wire_ex: |
| 344 |
continue |
| 345 |
res = wire_re.fullmatch(wire_ex) |
| 346 |
if res: |
| 347 |
s_col, s_row, wire = res.groups() |
| 348 |
row = int(s_row) |
| 349 |
col = int(s_col) |
| 350 |
tiledata = db[row, col] |
| 351 |
tile = tilemap[(row, col)] |
| 352 |
if wire not in tiledata.alonenode_6: |
| 353 |
raise Exception(f"Wire {wire} is not in alonenode fuse table") |
| 354 |
if len(tiledata.alonenode_6[wire]) != 1: |
| 355 |
raise Exception(f"Incorrect alonenode fuse table for {wire}") |
| 356 |
bits = tiledata.alonenode_6[wire][0][1] |
| 357 |
for row, col in bits: |
| 358 |
tile[row][col] = 1 |
| 359 |
else: |
| 360 |
raise Exception(f"Invalid isolated wire:{wire_ex}") |
| 361 |
|
| 362 |
def infovaluemap(infovalue, start=2): |
| 363 |
return {tuple(iv[:start]):iv[start:] for iv in infovalue} |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
_permitted_freqs = { |
| 368 |
"GW1N-1": (400, 450, 3.125, 900, 400), |
| 369 |
"GW1NZ-1": (400, 400, 3.125, 800, 400), |
| 370 |
"GW1N-4": (400, 500, 3.125, 1000, 400), |
| 371 |
"GW1NS-4": (400, 600, 4.6875, 1200, 400), |
| 372 |
"GW1N-9": (400, 500, 3.125, 1000, 400), |
| 373 |
"GW1N-9C": (400, 600, 3.125, 1200, 400), |
| 374 |
"GW1NS-2": (400, 500, 3.125, 1200, 400), |
| 375 |
"GW2A-18": (500, 625, 3.90625, 1250, 500), |
| 376 |
"GW2A-18C": (500, 625, 3.90625, 1250, 500), |
| 377 |
"GW5A-25A": (800, 1600, 6.25, 1600, 800), |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
_freq_R = [[(2.6, 65100.0), (3.87, 43800.0), (7.53, 22250.0), (14.35, 11800.0), (28.51, 5940.0), (57.01, 2970.0), (114.41, 1480), (206.34, 820.0)], |
| 392 |
[(2.4, 69410.0), (3.53, 47150.0), (6.82, 24430.0), (12.93, 12880.0), (25.7, 6480.0), (51.4, 3240.0), (102.81, 1620), (187.13, 890.0)], |
| 393 |
[(3.24, 72300), (4.79, 48900), (9.22, 25400), (17.09, 13700), (34.08, 6870), (68.05, 3440), (136.1, 1720), (270.95, 864)]] |
| 394 |
def calc_pll_pump(fref, fvco): |
| 395 |
fclkin_idx = int((fref - 1) // 30) |
| 396 |
if (fclkin_idx == 13 and fref <= 395) or (fclkin_idx == 14 and fref <= 430) or (fclkin_idx == 15 and fref <= 465) or fclkin_idx == 16: |
| 397 |
fclkin_idx = fclkin_idx - 1 |
| 398 |
|
| 399 |
if device in {'GW2A-18', 'GW2A-18C'}: |
| 400 |
freq_Ri = _freq_R[1] |
| 401 |
elif device in {'GW5A-25A'}: |
| 402 |
freq_Ri = _freq_R[2] |
| 403 |
else: |
| 404 |
freq_Ri = _freq_R[0] |
| 405 |
r_vals = [(fr[1], len(freq_Ri) - 1 - idx) for idx, fr in enumerate(freq_Ri) if fr[0] < fref] |
| 406 |
r_vals.reverse() |
| 407 |
|
| 408 |
|
| 409 |
if device in {'GW2A-18', 'GW2A-18C'}: |
| 410 |
K0 = (-28.938 + math.sqrt(837.407844 - (385.07 - fvco) * 0.9892)) / 0.4846 |
| 411 |
K1 = 0.1942 * K0 * K0 - 13.173 * K0 + 518.86 |
| 412 |
C1 = 6.69244e-11 |
| 413 |
elif device in {'GW5A-25A'}: |
| 414 |
K1 = 120 |
| 415 |
if fvco >= 1400.0: |
| 416 |
K1 = 240 |
| 417 |
C1 = 4.725e-11 |
| 418 |
else: |
| 419 |
K0 = (497.5 - math.sqrt(247506.25 - (2675.4 - fvco) * 78.46)) / 39.23 |
| 420 |
K1 = 4.8714 * K0 * K0 + 6.5257 * K0 + 142.67 |
| 421 |
C1 = 6.69244e-11 |
| 422 |
Kvco = 1000000.0 * K1 |
| 423 |
Ndiv = fvco / fref |
| 424 |
|
| 425 |
for R1, r_idx in r_vals: |
| 426 |
Ic = (1.8769 / (R1 * R1 * Kvco * C1)) * 4.0 * Ndiv |
| 427 |
if Ic <= 0.00028: |
| 428 |
icp = int(Ic * 100000.0 + 0.5) * 10 |
| 429 |
break |
| 430 |
|
| 431 |
return ((fclkin_idx + 1) * 16, icp, r_idx) |
| 432 |
|
| 433 |
|
| 434 |
_default_pll_inattrs = { |
| 435 |
'FCLKIN' : '100.00', |
| 436 |
'IDIV_SEL' : '0', |
| 437 |
'DYN_IDIV_SEL' : 'FALSE', |
| 438 |
'FBDIV_SEL' : '00000000000000000000000000000000', |
| 439 |
'DYN_FBDIV_SEL' : 'FALSE', |
| 440 |
'ODIV_SEL' : '00000000000000000000000000001000', |
| 441 |
'DYN_ODIV_SEL' : 'FALSE', |
| 442 |
'PSDA_SEL' : '0000 ', |
| 443 |
'DUTYDA_SEL' : '1000 ', |
| 444 |
'DYN_DA_EN' : 'FALSE', |
| 445 |
'CLKOUT_FT_DIR' : '1', |
| 446 |
'CLKOUT_DLY_STEP': '00000000000000000000000000000000', |
| 447 |
'CLKOUTP_FT_DIR': '1', |
| 448 |
'CLKOUTP_DLY_STEP': '00000000000000000000000000000000', |
| 449 |
'DYN_SDIV_SEL' : '00000000000000000000000000000010', |
| 450 |
'CLKFB_SEL' : 'INTERNAL', |
| 451 |
'CLKOUTD_SRC' : 'CLKOUT', |
| 452 |
'CLKOUTD3_SRC' : 'CLKOUT', |
| 453 |
'CLKOUT_BYPASS' : 'FALSE', |
| 454 |
'CLKOUTP_BYPASS': 'FALSE', |
| 455 |
'CLKOUTD_BYPASS': 'FALSE', |
| 456 |
'DEVICE' : 'GW1N-1' |
| 457 |
} |
| 458 |
|
| 459 |
_default_plla_inattrs = { |
| 460 |
'FCLKIN' : '100.00', |
| 461 |
'A_IDIV_SEL' : '1', |
| 462 |
'A_FBDIV_SEL' : '1', |
| 463 |
'A_ODIV0_SEL' : '8', |
| 464 |
'A_ODIV1_SEL' : '8', |
| 465 |
'A_ODIV2_SEL' : '8', |
| 466 |
'A_ODIV3_SEL' : '8', |
| 467 |
'A_ODIV4_SEL' : '8', |
| 468 |
'A_ODIV5_SEL' : '8', |
| 469 |
'A_ODIV6_SEL' : '8', |
| 470 |
'A_MDIV_SEL' : '8', |
| 471 |
'A_MDIV_FRAC_SEL' : '0', |
| 472 |
'A_ODIV0_FRAC_SEL' : '0', |
| 473 |
'A_CLKOUT0_EN' : 'TRUE', |
| 474 |
'A_CLKOUT1_EN' : 'TRUE', |
| 475 |
'A_CLKOUT2_EN' : 'TRUE', |
| 476 |
'A_CLKOUT3_EN' : 'TRUE', |
| 477 |
'A_CLKOUT4_EN' : 'TRUE', |
| 478 |
'A_CLKOUT5_EN' : 'TRUE', |
| 479 |
'A_CLKOUT6_EN' : 'TRUE', |
| 480 |
'A_CLKFB_SEL' : 'INTERNAL', |
| 481 |
'A_CLKOUT0_DT_DIR' : '1', |
| 482 |
'A_CLKOUT1_DT_DIR' : '1', |
| 483 |
'A_CLKOUT2_DT_DIR' : '1', |
| 484 |
'A_CLKOUT3_DT_DIR' : '1', |
| 485 |
'A_CLKOUT0_DT_STEP' : '0', |
| 486 |
'A_CLKOUT1_DT_STEP' : '0', |
| 487 |
'A_CLKOUT2_DT_STEP' : '0', |
| 488 |
'A_CLKOUT3_DT_STEP' : '0', |
| 489 |
'A_CLK0_IN_SEL' : '0', |
| 490 |
'A_CLK0_OUT_SEL' : '0', |
| 491 |
'A_CLK1_IN_SEL' : '0', |
| 492 |
'A_CLK1_OUT_SEL' : '0', |
| 493 |
'A_CLK2_IN_SEL' : '0', |
| 494 |
'A_CLK2_OUT_SEL' : '0', |
| 495 |
'A_CLK3_IN_SEL' : '0', |
| 496 |
'A_CLK3_OUT_SEL' : '0', |
| 497 |
'A_CLK4_IN_SEL' : '0', |
| 498 |
'A_CLK4_OUT_SEL' : '0', |
| 499 |
'A_CLK5_IN_SEL' : '0', |
| 500 |
'A_CLK5_OUT_SEL' : '0', |
| 501 |
'A_CLK6_IN_SEL' : '0', |
| 502 |
'A_CLK6_OUT_SEL' : '0', |
| 503 |
'A_DYN_DPA_EN' : 'FALSE', |
| 504 |
'A_CLKOUT0_PE_COARSE' : '0', |
| 505 |
'A_CLKOUT0_PE_FINE' : '0', |
| 506 |
'A_CLKOUT1_PE_COARSE' : '0', |
| 507 |
'A_CLKOUT1_PE_FINE' : '0', |
| 508 |
'A_CLKOUT2_PE_COARSE' : '0', |
| 509 |
'A_CLKOUT2_PE_FINE' : '0', |
| 510 |
'A_CLKOUT3_PE_COARSE' : '0', |
| 511 |
'A_CLKOUT3_PE_FINE' : '0', |
| 512 |
'A_CLKOUT4_PE_COARSE' : '0', |
| 513 |
'A_CLKOUT4_PE_FINE' : '0', |
| 514 |
'A_CLKOUT5_PE_COARSE' : '0', |
| 515 |
'A_CLKOUT5_PE_FINE' : '0', |
| 516 |
'A_CLKOUT6_PE_COARSE' : '0', |
| 517 |
'A_CLKOUT6_PE_FINE' : '0', |
| 518 |
'A_DYN_PE0_SEL' : 'FALSE', |
| 519 |
'A_DYN_PE1_SEL' : 'FALSE', |
| 520 |
'A_DYN_PE2_SEL' : 'FALSE', |
| 521 |
'A_DYN_PE3_SEL' : 'FALSE', |
| 522 |
'A_DYN_PE4_SEL' : 'FALSE', |
| 523 |
'A_DYN_PE5_SEL' : 'FALSE', |
| 524 |
'A_DYN_PE6_SEL' : 'FALSE', |
| 525 |
'A_DE0_EN' : 'FALSE', |
| 526 |
'A_DE1_EN' : 'FALSE', |
| 527 |
'A_DE2_EN' : 'FALSE', |
| 528 |
'A_DE3_EN' : 'FALSE', |
| 529 |
'A_DE4_EN' : 'FALSE', |
| 530 |
'A_DE5_EN' : 'FALSE', |
| 531 |
'A_DE6_EN' : 'FALSE', |
| 532 |
'A_RESET_I_EN' : 'FALSE', |
| 533 |
'A_RESET_O_EN' : 'FALSE', |
| 534 |
'A_DYN_ICP_SEL' : 'FALSE', |
| 535 |
'A_ICP_SEL' : '0', |
| 536 |
'A_DYN_LPF_SEL' : 'FALSE', |
| 537 |
'A_LPF_RES' : '0', |
| 538 |
'A_LPF_CAP' : '0', |
| 539 |
'A_SSC_EN' : '0', |
| 540 |
} |
| 541 |
|
| 542 |
_default_pll_internal_attrs = { |
| 543 |
'INSEL': 'CLKIN1', |
| 544 |
'FBSEL': 'CLKFB3', |
| 545 |
'PLOCK': 'ENABLE', |
| 546 |
'FLOCK': 'ENABLE', |
| 547 |
'FLTOP': 'ENABLE', |
| 548 |
'GMCMODE': 15, |
| 549 |
'CLKOUTDIV3': 'ENABLE', |
| 550 |
'CLKOUTDIV': 'ENABLE', |
| 551 |
'CLKOUTPS': 'ENABLE', |
| 552 |
'PDN': 'ENABLE', |
| 553 |
'PASEL': 0, |
| 554 |
'IRSTEN': 'DISABLE', |
| 555 |
'SRSTEN': 'DISABLE', |
| 556 |
'PWDEN': 'ENABLE', |
| 557 |
'RSTEN': 'ENABLE', |
| 558 |
'FLDCOUNT': 16, |
| 559 |
'GMCGAIN': 0, |
| 560 |
'LPR': 'R4', |
| 561 |
'ICPSEL': 50, |
| 562 |
} |
| 563 |
|
| 564 |
_default_plla_internal_attrs = { |
| 565 |
'A_RESET_EN' : 'TRUE', |
| 566 |
'PWDEN' : 'ENABLE', |
| 567 |
'PDN' : 'ENABLE', |
| 568 |
'PLOCK' : 'ENABLE', |
| 569 |
'FLOCK' : 'ENABLE', |
| 570 |
'FLTOP' : 'ENABLE', |
| 571 |
'A_GMC_SEL' : 15, |
| 572 |
'A_CLKIN_SEL' : 'CLKIN0', |
| 573 |
'FLDCOUNT' : 32, |
| 574 |
'A_VR_EN' : 'DISABLE', |
| 575 |
'A_DYN_DPA_EN' : 'FALSE', |
| 576 |
'A_RESET_I_EN' : 'FALSE', |
| 577 |
'A_RESET_O_EN' : 'FALSE', |
| 578 |
'A_DYN_ICP_SEL' : 'FALSE', |
| 579 |
'A_DYN_LPF_SEL' : 'FALSE', |
| 580 |
'A_SSC_EN' : 'FALSE', |
| 581 |
'A_CLKFBOUT_PE_COARSE' : 0, |
| 582 |
'A_CLKFBOUT_PE_FINE' : 0, |
| 583 |
} |
| 584 |
|
| 585 |
_default_adc_attrs = { |
| 586 |
'CLK_SEL' : "0", |
| 587 |
'DIV_CTL' : "0", |
| 588 |
'PHASE_SEL' : "0", |
| 589 |
'UNK0' : "101", |
| 590 |
'ADC_EN_SEL' : "0", |
| 591 |
'IBIAS_CTL' : "1000", |
| 592 |
'UNK1' : "1", |
| 593 |
'UNK2' : "10000", |
| 594 |
'CHOP_EN' : "1", |
| 595 |
'GAIN' : "100", |
| 596 |
'CAP_CTL' : "0", |
| 597 |
'BUF_EN' : "0", |
| 598 |
'CSR_VSEN_CTRL' : "0", |
| 599 |
'CSR_ADC_MODE' : "1", |
| 600 |
'CSR_SAMPLE_CNT_SEL' : "0", |
| 601 |
'CSR_RATE_CHANGE_CTRL' : "0", |
| 602 |
'CSR_FSCAL' : bin(730), |
| 603 |
'CSR_OFFSET' : bin(1180), |
| 604 |
} |
| 605 |
|
| 606 |
def plla_attr_rename(attrs): |
| 607 |
new_attrs = {} |
| 608 |
for attr, val in attrs.items(): |
| 609 |
if attr != 'FCLKIN': |
| 610 |
new_attrs['A_' + attr] = val |
| 611 |
else: |
| 612 |
new_attrs[attr] = val |
| 613 |
return new_attrs |
| 614 |
|
| 615 |
def add_pll_default_attrs(attrs, default_attrs = _default_pll_inattrs): |
| 616 |
pll_inattrs = attrs.copy() |
| 617 |
for k, v in default_attrs.items(): |
| 618 |
if k in pll_inattrs: |
| 619 |
continue |
| 620 |
pll_inattrs[k] = v |
| 621 |
return pll_inattrs |
| 622 |
|
| 623 |
def add_adc_default_attrs(attrs, default_attrs = _default_adc_attrs): |
| 624 |
adc_inattrs = attrs.copy() |
| 625 |
for k, v in default_attrs.items(): |
| 626 |
if k in adc_inattrs: |
| 627 |
continue |
| 628 |
adc_inattrs[k] = v |
| 629 |
return adc_inattrs |
| 630 |
|
| 631 |
def set_adc_attrs(db, idx, attrs): |
| 632 |
attrs_upper(attrs) |
| 633 |
adc_inattrs = add_adc_default_attrs(attrs) |
| 634 |
|
| 635 |
|
| 636 |
adc_attrs = {} |
| 637 |
for attr, vl in adc_inattrs.items(): |
| 638 |
val = int(vl, 2) |
| 639 |
if not attr.startswith('BUF_BK'): |
| 640 |
adc_attrs[attr] = val |
| 641 |
if attr == 'CLK_SEL': |
| 642 |
if val == 1: |
| 643 |
adc_attrs[attr] = 'CLK_CLK' |
| 644 |
continue |
| 645 |
if attr == 'DIV_CTL': |
| 646 |
if val: |
| 647 |
adc_attrs[attr] = 2**val |
| 648 |
continue |
| 649 |
if attr == 'PHASE_SEL': |
| 650 |
if val: |
| 651 |
adc_attrs[attr] = 'PHASE_180' |
| 652 |
continue |
| 653 |
if attr == 'ADC_EN_SEL': |
| 654 |
if val == 1: |
| 655 |
adc_attrs[attr] = 'ADC' |
| 656 |
continue |
| 657 |
if attr == 'UNK0': |
| 658 |
if val == 0: |
| 659 |
adc_attrs[attr] = 'DISABLE' |
| 660 |
else: |
| 661 |
adc_attrs[attr] = val |
| 662 |
continue |
| 663 |
if attr == 'UNK1': |
| 664 |
if val == 1: |
| 665 |
adc_attrs[attr] = 'OFF' |
| 666 |
continue |
| 667 |
if attr == 'UNK2': |
| 668 |
if val == 0: |
| 669 |
adc_attrs[attr] = 'DISABLE' |
| 670 |
continue |
| 671 |
if attr == 'IBIAS_CTL': |
| 672 |
if val == 0: |
| 673 |
adc_attrs[attr] = 'DISABLE' |
| 674 |
else: |
| 675 |
adc_attrs[attr] = val |
| 676 |
continue |
| 677 |
if attr == 'CHOP_EN': |
| 678 |
if val == 1: |
| 679 |
adc_attrs[attr] = 'ON' |
| 680 |
else: |
| 681 |
adc_attrs[attr] = 'UNKNOWN' |
| 682 |
continue |
| 683 |
if attr == 'GAIN': |
| 684 |
if val == 0: |
| 685 |
adc_attrs[attr] = 'DISABLE' |
| 686 |
else: |
| 687 |
adc_attrs[attr] = val |
| 688 |
continue |
| 689 |
if attr == 'CAP_CTL': |
| 690 |
adc_attrs[attr] = val |
| 691 |
continue |
| 692 |
if attr == 'BUF_EN': |
| 693 |
for i in range(12): |
| 694 |
if val & (2**i): |
| 695 |
adc_attrs[f'BUF_{i}_EN'] = 'ON' |
| 696 |
del(adc_attrs[attr]) |
| 697 |
continue |
| 698 |
if attr == 'CSR_ADC_MODE': |
| 699 |
if val == 1: |
| 700 |
adc_attrs[attr] = '1' |
| 701 |
else: |
| 702 |
adc_attrs[attr] = 'UNKNOWN' |
| 703 |
continue |
| 704 |
if attr == 'CSR_VSEN_CTRL': |
| 705 |
if val == 4: |
| 706 |
adc_attrs[attr] = 'UNK1' |
| 707 |
elif val == 7: |
| 708 |
adc_attrs[attr] = 'UNK0' |
| 709 |
continue |
| 710 |
if attr == 'CSR_SAMPLE_CNT_SEL': |
| 711 |
if val > 4: |
| 712 |
adc_attrs[attr] = 2048 |
| 713 |
else: |
| 714 |
adc_attrs[attr] = (2**val) * 64 |
| 715 |
continue |
| 716 |
if attr == 'CSR_RATE_CHANGE_CTRL': |
| 717 |
if val > 4: |
| 718 |
adc_attrs[attr] = 80 |
| 719 |
else: |
| 720 |
adc_attrs[attr] = (2**val) * 4 |
| 721 |
continue |
| 722 |
if attr == 'CSR_FSCAL': |
| 723 |
if val in range(452, 841): |
| 724 |
adc_attrs['CSR_FSCAL1'] = val |
| 725 |
adc_attrs['CSR_FSCAL0'] = val |
| 726 |
del(adc_attrs[attr]) |
| 727 |
continue |
| 728 |
if attr == 'CSR_OFFSET': |
| 729 |
if val == 0: |
| 730 |
adc_attrs[attr] = 'DISABLE' |
| 731 |
else: |
| 732 |
if val & 1 << 11: |
| 733 |
val -= 1 << 12; |
| 734 |
adc_attrs[attr] = val |
| 735 |
continue |
| 736 |
|
| 737 |
fin_attrs = set() |
| 738 |
|
| 739 |
for attr, val in adc_attrs.items(): |
| 740 |
if isinstance(val, str): |
| 741 |
val = attrids.adc_attrvals[val] |
| 742 |
add_attr_val(db, 'ADC', fin_attrs, attrids.adc_attrids[attr], val) |
| 743 |
return fin_attrs |
| 744 |
|
| 745 |
|
| 746 |
def set_pll_attrs(db, typ, idx, attrs): |
| 747 |
attrs_upper(attrs) |
| 748 |
if typ not in {'RPLL', 'PLLVR', 'PLLA'}: |
| 749 |
raise Exception(f"PLL type {typ} is not supported for now") |
| 750 |
if typ in {'RPLL', 'PLLVR'}: |
| 751 |
pll_inattrs = add_pll_default_attrs(attrs) |
| 752 |
pll_attrs = _default_pll_internal_attrs.copy() |
| 753 |
else: |
| 754 |
new_attrs = plla_attr_rename(attrs) |
| 755 |
pll_inattrs = add_pll_default_attrs(new_attrs, _default_plla_inattrs) |
| 756 |
pll_attrs = _default_plla_internal_attrs.copy() |
| 757 |
|
| 758 |
if typ == 'PLLVR': |
| 759 |
pll_attrs[['PLLVCC0', 'PLLVCC1'][idx]] = 'ENABLE' |
| 760 |
|
| 761 |
|
| 762 |
for attr, val in pll_inattrs.items(): |
| 763 |
if attr in pll_attrs: |
| 764 |
pll_attrs[attr] = val |
| 765 |
if attr.startswith('A_CLKOUT') and attr[-3:] == '_EN': |
| 766 |
pll_attrs[attr] = val |
| 767 |
continue |
| 768 |
if attr.startswith('A_DYN_PE') and attr[-3:] == 'SEL': |
| 769 |
pll_attrs[attr] = val |
| 770 |
continue |
| 771 |
if attr.startswith('A_DE') and attr[-3:] == '_EN': |
| 772 |
pll_attrs[attr] = val |
| 773 |
continue |
| 774 |
if attr == 'A_CLKFB_SEL': |
| 775 |
if val == 'INTERNAL': |
| 776 |
pll_attrs[attr] = 'CLKFB2' |
| 777 |
continue |
| 778 |
if attr == 'CLKOUTD_SRC': |
| 779 |
if val == 'CLKOUTP': |
| 780 |
pll_attrs['CLKOUTDIVSEL'] = 'CLKOUTPS' |
| 781 |
continue |
| 782 |
if attr == 'CLKOUTD3_SRC': |
| 783 |
if val == 'CLKOUTP': |
| 784 |
pll_attrs['CLKOUTDIV3SEL'] = 'CLKOUTPS' |
| 785 |
continue |
| 786 |
if attr == 'DYN_IDIV_SEL': |
| 787 |
if val == 'TRUE': |
| 788 |
pll_attrs['IDIVSEL'] = 'DYN' |
| 789 |
continue |
| 790 |
if attr == 'DYN_FBDIV_SEL': |
| 791 |
if val == 'TRUE': |
| 792 |
pll_attrs['FDIVSEL'] = 'DYN' |
| 793 |
continue |
| 794 |
if attr == 'DYN_ODIV_SEL': |
| 795 |
if val == 'TRUE': |
| 796 |
pll_attrs['ODIVSEL'] = 'DYN' |
| 797 |
continue |
| 798 |
if attr == 'CLKOUT_BYPASS': |
| 799 |
if val == 'TRUE': |
| 800 |
pll_attrs['BYPCK'] = 'BYPASS' |
| 801 |
continue |
| 802 |
if attr == 'CLKOUTP_BYPASS': |
| 803 |
if val == 'TRUE': |
| 804 |
pll_attrs['BYPCKPS'] = 'BYPASS' |
| 805 |
continue |
| 806 |
if attr == 'CLKOUTD_BYPASS': |
| 807 |
if val == 'TRUE': |
| 808 |
pll_attrs['BYPCKDIV'] = 'BYPASS' |
| 809 |
continue |
| 810 |
if attr == 'IDIV_SEL': |
| 811 |
idiv = 1 + int(val, 2) |
| 812 |
pll_attrs['IDIV'] = idiv |
| 813 |
continue |
| 814 |
if attr == 'A_IDIV_SEL': |
| 815 |
idiv = int(val, 2) |
| 816 |
pll_attrs['A_IDIV_SEL'] = idiv |
| 817 |
continue |
| 818 |
if attr == 'FBDIV_SEL': |
| 819 |
fbdiv = 1 + int(val, 2) |
| 820 |
pll_attrs['FDIV'] = fbdiv |
| 821 |
continue |
| 822 |
if attr == 'A_FBDIV_SEL': |
| 823 |
fbdiv = int(val, 2) |
| 824 |
pll_attrs['A_FBDIV_SEL'] = fbdiv |
| 825 |
continue |
| 826 |
if attr == 'DYN_SDIV_SEL': |
| 827 |
pll_attrs['SDIV'] = int(val, 2) |
| 828 |
continue |
| 829 |
if attr == 'ODIV_SEL': |
| 830 |
odiv = int(val, 2) |
| 831 |
pll_attrs['ODIV'] = odiv |
| 832 |
continue |
| 833 |
if attr == 'A_ODIV0_FRAC_SEL': |
| 834 |
odiv_frac = int(val, 2) |
| 835 |
pll_attrs['A_ODIV0_FRAC_SEL'] = odiv_frac |
| 836 |
continue |
| 837 |
if attr == 'A_ODIV0_SEL': |
| 838 |
odiv = int(val, 2) |
| 839 |
pll_attrs['A_ODIV0_SEL'] = odiv |
| 840 |
continue |
| 841 |
if attr == 'A_ODIV1_SEL': |
| 842 |
odiv = int(val, 2) |
| 843 |
pll_attrs['A_ODIV1_SEL'] = odiv |
| 844 |
continue |
| 845 |
if attr == 'A_ODIV2_SEL': |
| 846 |
odiv = int(val, 2) |
| 847 |
pll_attrs['A_ODIV2_SEL'] = odiv |
| 848 |
continue |
| 849 |
if attr == 'A_ODIV3_SEL': |
| 850 |
odiv = int(val, 2) |
| 851 |
pll_attrs['A_ODIV3_SEL'] = odiv |
| 852 |
continue |
| 853 |
if attr == 'A_ODIV4_SEL': |
| 854 |
odiv = int(val, 2) |
| 855 |
pll_attrs['A_ODIV4_SEL'] = odiv |
| 856 |
continue |
| 857 |
if attr == 'A_ODIV5_SEL': |
| 858 |
odiv = int(val, 2) |
| 859 |
pll_attrs['A_ODIV5_SEL'] = odiv |
| 860 |
continue |
| 861 |
if attr == 'A_ODIV6_SEL': |
| 862 |
odiv = int(val, 2) |
| 863 |
pll_attrs['A_ODIV6_SEL'] = odiv |
| 864 |
continue |
| 865 |
if attr == 'A_MDIV_SEL': |
| 866 |
mdiv = int(val, 2) |
| 867 |
pll_attrs['A_MDIV_SEL'] = mdiv |
| 868 |
continue |
| 869 |
if attr == 'A_MDIV_FRAC_SEL': |
| 870 |
mdiv_frac_sel = int(val, 2) |
| 871 |
pll_attrs['A_MDIV_FRAC_SEL'] = mdiv_frac_sel |
| 872 |
continue |
| 873 |
if attr == 'A_CLKOUT0_DT_DIR': |
| 874 |
dt_dir = int(val, 2) |
| 875 |
pll_attrs['A_CLKOUT0_DT_DIR'] = dt_dir |
| 876 |
continue |
| 877 |
if attr == 'A_CLKOUT1_DT_DIR': |
| 878 |
dt_dir = int(val, 2) |
| 879 |
pll_attrs['A_CLKOUT1_DT_DIR'] = dt_dir |
| 880 |
continue |
| 881 |
if attr == 'A_CLKOUT2_DT_DIR': |
| 882 |
dt_dir = int(val, 2) |
| 883 |
pll_attrs['A_CLKOUT2_DT_DIR'] = dt_dir |
| 884 |
continue |
| 885 |
if attr == 'A_CLKOUT3_DT_DIR': |
| 886 |
dt_dir = int(val, 2) |
| 887 |
pll_attrs['A_CLKOUT3_DT_DIR'] = dt_dir |
| 888 |
continue |
| 889 |
if attr == 'A_CLKOUT0_DT_STEP': |
| 890 |
dt_step = int(val, 2) |
| 891 |
pll_attrs['A_CLKOUT0_DT_STEP'] = dt_step |
| 892 |
continue |
| 893 |
if attr == 'A_CLKOUT1_DT_STEP': |
| 894 |
dt_step = int(val, 2) |
| 895 |
pll_attrs['A_CLKOUT1_DT_STEP'] = dt_step |
| 896 |
continue |
| 897 |
if attr == 'A_CLKOUT2_DT_STEP': |
| 898 |
dt_step = int(val, 2) |
| 899 |
pll_attrs['A_CLKOUT2_DT_STEP'] = dt_step |
| 900 |
continue |
| 901 |
if attr == 'A_CLKOUT3_DT_STEP': |
| 902 |
dt_step = int(val, 2) |
| 903 |
pll_attrs['A_CLKOUT3_DT_STEP'] = dt_step |
| 904 |
continue |
| 905 |
if attr == 'A_CLKIN0_SEL': |
| 906 |
a_clkin_sel= int(val, 2) |
| 907 |
pll_attrs['A_CLKIN0_SEL'] = a_clkin_sel |
| 908 |
continue |
| 909 |
if attr == 'A_CLKOUT0_SEL': |
| 910 |
a_clkout_sel= int(val, 2) |
| 911 |
pll_attrs['A_CLKOUT0_SEL'] = a_clkout_sel |
| 912 |
continue |
| 913 |
if attr == 'A_CLKIN1_SEL': |
| 914 |
a_clkin_sel= int(val, 2) |
| 915 |
pll_attrs['A_CLKIN1_SEL'] = a_clkin_sel |
| 916 |
continue |
| 917 |
if attr == 'A_CLKOUT1_SEL': |
| 918 |
a_clkout_sel= int(val, 2) |
| 919 |
pll_attrs['A_CLKOUT1_SEL'] = a_clkout_sel |
| 920 |
continue |
| 921 |
if attr == 'A_CLKIN2_SEL': |
| 922 |
a_clkin_sel= int(val, 2) |
| 923 |
pll_attrs['A_CLKIN2_SEL'] = a_clkin_sel |
| 924 |
continue |
| 925 |
if attr == 'A_CLKOUT2_SEL': |
| 926 |
a_clkout_sel= int(val, 2) |
| 927 |
pll_attrs['A_CLKOUT2_SEL'] = a_clkout_sel |
| 928 |
continue |
| 929 |
if attr == 'A_CLKIN3_SEL': |
| 930 |
a_clkin_sel= int(val, 2) |
| 931 |
pll_attrs['A_CLKIN3_SEL'] = a_clkin_sel |
| 932 |
continue |
| 933 |
if attr == 'A_CLKOUT3_SEL': |
| 934 |
a_clkout_sel= int(val, 2) |
| 935 |
pll_attrs['A_CLKOUT3_SEL'] = a_clkout_sel |
| 936 |
continue |
| 937 |
if attr == 'A_CLKIN4_SEL': |
| 938 |
a_clkin_sel= int(val, 2) |
| 939 |
pll_attrs['A_CLKIN4_SEL'] = a_clkin_sel |
| 940 |
continue |
| 941 |
if attr == 'A_CLKOUT4_SEL': |
| 942 |
a_clkout_sel= int(val, 2) |
| 943 |
pll_attrs['A_CLKOUT4_SEL'] = a_clkout_sel |
| 944 |
continue |
| 945 |
if attr == 'A_CLKIN5_SEL': |
| 946 |
a_clkin_sel= int(val, 2) |
| 947 |
pll_attrs['A_CLKIN5_SEL'] = a_clkin_sel |
| 948 |
continue |
| 949 |
if attr == 'A_CLKOUT5_SEL': |
| 950 |
a_clkout_sel= int(val, 2) |
| 951 |
pll_attrs['A_CLKOUT5_SEL'] = a_clkout_sel |
| 952 |
continue |
| 953 |
if attr == 'A_CLKIN6_SEL': |
| 954 |
a_clkin_sel= int(val, 2) |
| 955 |
pll_attrs['A_CLKIN6_SEL'] = a_clkin_sel |
| 956 |
continue |
| 957 |
if attr == 'A_CLKOUT6_SEL': |
| 958 |
a_clkout_sel= int(val, 2) |
| 959 |
pll_attrs['A_CLKOUT6_SEL'] = a_clkout_sel |
| 960 |
continue |
| 961 |
if attr == 'A_CLKOUT0_PE_COARSE': |
| 962 |
pe_coarse = int(val, 2) |
| 963 |
pll_attrs['A_CLKOUT0_PE_COARSE'] = pe_coarse |
| 964 |
continue |
| 965 |
if attr == 'A_CLKOUT0_PE_FINE': |
| 966 |
pe_fine = int(val, 2) |
| 967 |
pll_attrs['A_CLKOUT0_PE_FINE'] = pe_fine |
| 968 |
continue |
| 969 |
if attr == 'A_CLKOUT1_PE_COARSE': |
| 970 |
pe_coarse = int(val, 2) |
| 971 |
pll_attrs['A_CLKOUT1_PE_COARSE'] = pe_coarse |
| 972 |
continue |
| 973 |
if attr == 'A_CLKOUT1_PE_FINE': |
| 974 |
pe_fine = int(val, 2) |
| 975 |
pll_attrs['A_CLKOUT1_PE_FINE'] = pe_fine |
| 976 |
continue |
| 977 |
if attr == 'A_CLKOUT2_PE_COARSE': |
| 978 |
pe_coarse = int(val, 2) |
| 979 |
pll_attrs['A_CLKOUT2_PE_COARSE'] = pe_coarse |
| 980 |
continue |
| 981 |
if attr == 'A_CLKOUT2_PE_FINE': |
| 982 |
pe_fine = int(val, 2) |
| 983 |
pll_attrs['A_CLKOUT2_PE_FINE'] = pe_fine |
| 984 |
continue |
| 985 |
if attr == 'A_CLKOUT3_PE_COARSE': |
| 986 |
pe_coarse = int(val, 2) |
| 987 |
pll_attrs['A_CLKOUT3_PE_COARSE'] = pe_coarse |
| 988 |
continue |
| 989 |
if attr == 'A_CLKOUT3_PE_FINE': |
| 990 |
pe_fine = int(val, 2) |
| 991 |
pll_attrs['A_CLKOUT3_PE_FINE'] = pe_fine |
| 992 |
continue |
| 993 |
if attr == 'A_CLKOUT4_PE_COARSE': |
| 994 |
pe_coarse = int(val, 2) |
| 995 |
pll_attrs['A_CLKOUT4_PE_COARSE'] = pe_coarse |
| 996 |
continue |
| 997 |
if attr == 'A_CLKOUT4_PE_FINE': |
| 998 |
pe_fine = int(val, 2) |
| 999 |
pll_attrs['A_CLKOUT4_PE_FINE'] = pe_fine |
| 1000 |
continue |
| 1001 |
if attr == 'A_CLKOUT5_PE_COARSE': |
| 1002 |
pe_coarse = int(val, 2) |
| 1003 |
pll_attrs['A_CLKOUT5_PE_COARSE'] = pe_coarse |
| 1004 |
continue |
| 1005 |
if attr == 'A_CLKOUT5_PE_FINE': |
| 1006 |
pe_fine = int(val, 2) |
| 1007 |
pll_attrs['A_CLKOUT5_PE_FINE'] = pe_fine |
| 1008 |
continue |
| 1009 |
if attr == 'A_CLKOUT6_PE_COARSE': |
| 1010 |
pe_coarse = int(val, 2) |
| 1011 |
pll_attrs['A_CLKOUT6_PE_COARSE'] = pe_coarse |
| 1012 |
continue |
| 1013 |
if attr == 'A_CLKOUT6_PE_FINE': |
| 1014 |
pe_fine = int(val, 2) |
| 1015 |
pll_attrs['A_CLKOUT6_PE_FINE'] = pe_fine |
| 1016 |
continue |
| 1017 |
if attr == 'DYN_DA_EN': |
| 1018 |
if val == 'TRUE': |
| 1019 |
pll_attrs['DPSEL'] = 'DYN' |
| 1020 |
pll_attrs['DUTY'] = 0 |
| 1021 |
pll_attrs['PHASE'] = 0 |
| 1022 |
pll_attrs['PASEL'] = 'DISABLE' |
| 1023 |
|
| 1024 |
tmp_val = int(pll_inattrs['CLKOUT_DLY_STEP'], 2) * 50 |
| 1025 |
pll_attrs['OPDLY'] = tmp_val |
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
tmp_val = int(pll_inattrs['CLKOUTP_DLY_STEP'], 2) * 50 |
| 1030 |
pll_attrs['OSDLY'] = tmp_val |
| 1031 |
else: |
| 1032 |
pll_attrs['OSDLY'] = 'DISABLE' |
| 1033 |
pll_attrs['OPDLY'] = 'DISABLE' |
| 1034 |
phase_val = int(pll_inattrs['PSDA_SEL'].strip(), 2) |
| 1035 |
pll_attrs['PHASE'] = phase_val |
| 1036 |
duty_val = int(pll_inattrs['DUTYDA_SEL'].strip(), 2) |
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
if (phase_val + duty_val) < 16: |
| 1041 |
duty_val = phase_val + duty_val |
| 1042 |
else: |
| 1043 |
duty_val = phase_val + duty_val - 16 |
| 1044 |
pll_attrs['DUTY'] = duty_val |
| 1045 |
continue |
| 1046 |
if attr == 'FCLKIN': |
| 1047 |
fclkin = float(val) |
| 1048 |
if fclkin < 3 or fclkin > _permitted_freqs[device][0]: |
| 1049 |
print(f"The {fclkin}MHz frequency is outside the permissible range of 3-{_permitted_freqs[device][0]}MHz.") |
| 1050 |
fclkin = 100.0 |
| 1051 |
continue |
| 1052 |
|
| 1053 |
|
| 1054 |
if device in {'GW5A-25A'}: |
| 1055 |
|
| 1056 |
Fpfd = fclkin / idiv |
| 1057 |
Fclkfb = Fpfd * fbdiv |
| 1058 |
|
| 1059 |
Fvco = Fclkfb * mdiv |
| 1060 |
fclkin_idx, icp, r_idx = calc_pll_pump(Fpfd, Fvco) |
| 1061 |
pll_attrs['KVCO'] = fclkin_idx // 16 |
| 1062 |
if Fvco >= 1400.0: |
| 1063 |
fclkin_idx += 1 |
| 1064 |
pll_attrs['A_ICP_SEL'] = int(icp) |
| 1065 |
pll_attrs['A_LPF_RES_SEL'] = f"R{r_idx}" |
| 1066 |
else: |
| 1067 |
if pll_inattrs['DYN_IDIV_SEL'] == 'FALSE' and pll_inattrs['DYN_FBDIV_SEL'] == 'FALSE' and pll_inattrs['DYN_ODIV_SEL'] == 'FALSE': |
| 1068 |
|
| 1069 |
clkout = fclkin * fbdiv / idiv |
| 1070 |
if clkout <= _permitted_freqs[device][2] or clkout > _permitted_freqs[device][1]: |
| 1071 |
raise Exception(f"CLKOUT = FCLKIN*(FBDIV_SEL+1)/(IDIV_SEL+1) = {clkout}MHz not in range {_permitted_freqs[device][2]} - {_permitted_freqs[device][1]}MHz") |
| 1072 |
pfd = fclkin / idiv |
| 1073 |
if pfd < 3.0 or pfd > _permitted_freqs[device][0]: |
| 1074 |
raise Exception(f"PFD = FCLKIN/(IDIV_SEL+1) = {pfd}MHz not in range 3.0 - {_permitted_freqs[device][0]}MHz") |
| 1075 |
fvco = odiv * fclkin * fbdiv / idiv |
| 1076 |
if fvco < _permitted_freqs[device][4] or fvco > _permitted_freqs[device][3]: |
| 1077 |
raise Exception(f"VCO = FCLKIN*(FBDIV_SEL+1)*ODIV_SEL/(IDIV_SEL+1) = {fvco}MHz not in range {_permitted_freqs[device][4]} - {_permitted_freqs[device][3]}MHz") |
| 1078 |
|
| 1079 |
fref = fclkin / idiv |
| 1080 |
fvco = (odiv * fbdiv * fclkin) / idiv |
| 1081 |
fclkin_idx, icp, r_idx = calc_pll_pump(fref, fvco) |
| 1082 |
pll_attrs['ICPSEL'] = int(icp) |
| 1083 |
pll_attrs['LPR'] = f"R{r_idx}" |
| 1084 |
pll_attrs['FLDCOUNT'] = fclkin_idx |
| 1085 |
|
| 1086 |
fin_attrs = set() |
| 1087 |
for i in range(16): |
| 1088 |
add_attr_val(db, 'PLL', fin_attrs, i, 0) |
| 1089 |
for attr, val in pll_attrs.items(): |
| 1090 |
if isinstance(val, str): |
| 1091 |
val = attrids.pll_attrvals[val] |
| 1092 |
add_attr_val(db, 'PLL', fin_attrs, attrids.pll_attrids[attr], val) |
| 1093 |
return fin_attrs |
| 1094 |
|
| 1095 |
_dcs_spine2quadrant_idx = { |
| 1096 |
'SPINE6' : ('1', 'DCS6'), |
| 1097 |
'SPINE7' : ('1', 'DCS7'), |
| 1098 |
'SPINE14' : ('2', 'DCS6'), |
| 1099 |
'SPINE15' : ('2', 'DCS7'), |
| 1100 |
'SPINE22' : ('3', 'DCS6'), |
| 1101 |
'SPINE23' : ('3', 'DCS7'), |
| 1102 |
'SPINE30' : ('4', 'DCS6'), |
| 1103 |
'SPINE31' : ('4', 'DCS7'), |
| 1104 |
} |
| 1105 |
def set_dcs_attrs(db, spine, attrs): |
| 1106 |
q, _ = _dcs_spine2quadrant_idx[spine] |
| 1107 |
|
| 1108 |
attrs_upper(attrs) |
| 1109 |
dcs_attrs = {} |
| 1110 |
dcs_attrs[q] = attrs['DCS_MODE'] |
| 1111 |
|
| 1112 |
fin_attrs = set() |
| 1113 |
for attr, val in dcs_attrs.items(): |
| 1114 |
if isinstance(val, str): |
| 1115 |
val = attrids.dcs_attrvals[val] |
| 1116 |
add_attr_val(db, 'DCS', fin_attrs, attrids.dcs_attrids[attr], val) |
| 1117 |
return fin_attrs |
| 1118 |
|
| 1119 |
|
| 1120 |
def sp_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs): |
| 1121 |
bsram_attrs[f'{typ}A_BEHB'] = 'DISABLE' |
| 1122 |
bsram_attrs[f'{typ}A_BELB'] = 'DISABLE' |
| 1123 |
bsram_attrs[f'{typ}B_BEHB'] = 'DISABLE' |
| 1124 |
bsram_attrs[f'{typ}B_BELB'] = 'DISABLE' |
| 1125 |
|
| 1126 |
def sp_16_18_byte_enable(typ, cell, bsram_attrs): |
| 1127 |
constant_byte_enable = is_const_net(cell['connections']['AD0'][0]) and is_const_net(cell['connections']['AD1'][0]) |
| 1128 |
if constant_byte_enable: |
| 1129 |
bsram_attrs[f'{typ}A_BEHB'] = 'ENABLE' |
| 1130 |
bsram_attrs[f'{typ}A_BELB'] = 'ENABLE' |
| 1131 |
else: |
| 1132 |
bsram_attrs[f'{typ}A_BEHB'] = 'DISABLE' |
| 1133 |
bsram_attrs[f'{typ}A_BELB'] = 'DISABLE' |
| 1134 |
bsram_attrs[f'{typ}B_BEHB'] = 'DISABLE' |
| 1135 |
bsram_attrs[f'{typ}B_BELB'] = 'DISABLE' |
| 1136 |
|
| 1137 |
def sp_32_36_byte_enable(typ, cell, bsram_attrs): |
| 1138 |
constant_byte_enable = is_const_net(cell['connections']['AD0'][0]) and is_const_net(cell['connections']['AD1'][0]) \ |
| 1139 |
and is_const_net(cell['connections']['AD2'][0]) and is_const_net(cell['connections']['AD3'][0]) |
| 1140 |
if constant_byte_enable: |
| 1141 |
bsram_attrs[f'{typ}A_BEHB'] = 'ENABLE' |
| 1142 |
bsram_attrs[f'{typ}A_BELB'] = 'ENABLE' |
| 1143 |
bsram_attrs[f'{typ}B_BEHB'] = 'ENABLE' |
| 1144 |
bsram_attrs[f'{typ}B_BELB'] = 'ENABLE' |
| 1145 |
else: |
| 1146 |
bsram_attrs[f'{typ}A_BEHB'] = 'DISABLE' |
| 1147 |
bsram_attrs[f'{typ}A_BELB'] = 'DISABLE' |
| 1148 |
bsram_attrs[f'{typ}B_BEHB'] = 'DISABLE' |
| 1149 |
bsram_attrs[f'{typ}B_BELB'] = 'DISABLE' |
| 1150 |
|
| 1151 |
def sdp_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs): |
| 1152 |
sp_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs) |
| 1153 |
|
| 1154 |
def sdp_16_18_byte_enable(typ, cell, bsram_attrs): |
| 1155 |
constant_byte_enable = is_const_net(cell['connections']['ADA0'][0]) and is_const_net(cell['connections']['ADA1'][0]) |
| 1156 |
if constant_byte_enable: |
| 1157 |
bsram_attrs[f'{typ}A_BEHB'] = 'ENABLE' |
| 1158 |
bsram_attrs[f'{typ}A_BELB'] = 'ENABLE' |
| 1159 |
else: |
| 1160 |
bsram_attrs[f'{typ}A_BEHB'] = 'DISABLE' |
| 1161 |
bsram_attrs[f'{typ}A_BELB'] = 'DISABLE' |
| 1162 |
bsram_attrs[f'{typ}B_BEHB'] = 'DISABLE' |
| 1163 |
bsram_attrs[f'{typ}B_BELB'] = 'DISABLE' |
| 1164 |
|
| 1165 |
def sdp_32_36_byte_enable(typ, cell, bsram_attrs): |
| 1166 |
constant_byte_enable = is_const_net(cell['connections']['ADA0'][0]) and is_const_net(cell['connections']['ADA1'][0]) \ |
| 1167 |
and is_const_net(cell['connections']['ADA2'][0]) and is_const_net(cell['connections']['ADA3'][0]) |
| 1168 |
if constant_byte_enable: |
| 1169 |
bsram_attrs[f'{typ}A_BEHB'] = 'ENABLE' |
| 1170 |
bsram_attrs[f'{typ}A_BELB'] = 'ENABLE' |
| 1171 |
bsram_attrs[f'{typ}B_BEHB'] = 'ENABLE' |
| 1172 |
bsram_attrs[f'{typ}B_BELB'] = 'ENABLE' |
| 1173 |
else: |
| 1174 |
bsram_attrs[f'{typ}A_BEHB'] = 'DISABLE' |
| 1175 |
bsram_attrs[f'{typ}A_BELB'] = 'DISABLE' |
| 1176 |
bsram_attrs[f'{typ}B_BEHB'] = 'DISABLE' |
| 1177 |
bsram_attrs[f'{typ}B_BELB'] = 'DISABLE' |
| 1178 |
|
| 1179 |
def dpa_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs): |
| 1180 |
bsram_attrs[f'{typ}A_BEHB'] = 'DISABLE' |
| 1181 |
bsram_attrs[f'{typ}A_BELB'] = 'DISABLE' |
| 1182 |
|
| 1183 |
def dpa_16_18_byte_enable(typ, cell, bsram_attrs): |
| 1184 |
constant_byte_enable = is_const_net(cell['connections']['ADA0'][0]) and is_const_net(cell['connections']['ADA1'][0]) |
| 1185 |
if constant_byte_enable: |
| 1186 |
bsram_attrs[f'{typ}A_BEHB'] = 'ENABLE' |
| 1187 |
bsram_attrs[f'{typ}A_BELB'] = 'ENABLE' |
| 1188 |
else: |
| 1189 |
bsram_attrs[f'{typ}A_BEHB'] = 'DISABLE' |
| 1190 |
bsram_attrs[f'{typ}A_BELB'] = 'DISABLE' |
| 1191 |
|
| 1192 |
def dpb_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs): |
| 1193 |
bsram_attrs[f'{typ}B_BEHB'] = 'DISABLE' |
| 1194 |
bsram_attrs[f'{typ}B_BELB'] = 'DISABLE' |
| 1195 |
|
| 1196 |
def dpb_16_18_byte_enable(typ, cell, bsram_attrs): |
| 1197 |
constant_byte_enable = is_const_net(cell['connections']['ADB0'][0]) and is_const_net(cell['connections']['ADB1'][0]) |
| 1198 |
if constant_byte_enable: |
| 1199 |
bsram_attrs[f'{typ}B_BEHB'] = 'ENABLE' |
| 1200 |
bsram_attrs[f'{typ}B_BELB'] = 'ENABLE' |
| 1201 |
else: |
| 1202 |
bsram_attrs[f'{typ}B_BEHB'] = 'DISABLE' |
| 1203 |
bsram_attrs[f'{typ}B_BELB'] = 'DISABLE' |
| 1204 |
|
| 1205 |
_bsram_bit_widths = { 1: '1', 2: '2', 4: '4', 8: '9', 9: '9', 16: '16', 18: '16', 32: 'X36', 36: 'X36'} |
| 1206 |
def set_bsram_attrs(db, cell, typ, params): |
| 1207 |
bsram_attrs = {} |
| 1208 |
bsram_attrs['MODE'] = 'ENABLE' |
| 1209 |
bsram_attrs['GSR'] = 'DISABLE' |
| 1210 |
|
| 1211 |
attrs_upper(params) |
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
if typ == 'ROM': |
| 1217 |
bsram_attrs['CEMUX_CEA'] = 'INV' |
| 1218 |
bsram_attrs[f'{typ}A_BEHB'] = 'DISABLE' |
| 1219 |
bsram_attrs[f'{typ}A_BELB'] = 'DISABLE' |
| 1220 |
bsram_attrs[f'{typ}B_BEHB'] = 'DISABLE' |
| 1221 |
bsram_attrs[f'{typ}B_BELB'] = 'DISABLE' |
| 1222 |
|
| 1223 |
for parm, val in params.items(): |
| 1224 |
if parm == 'BIT_WIDTH': |
| 1225 |
val = int(val, 2) |
| 1226 |
if val in _bsram_bit_widths: |
| 1227 |
if typ not in {'ROM'}: |
| 1228 |
if val in {16, 18}: |
| 1229 |
sp_16_18_byte_enable(typ, cell, bsram_attrs) |
| 1230 |
elif val in {32, 36}: |
| 1231 |
sp_32_36_byte_enable(typ, cell, bsram_attrs) |
| 1232 |
else: |
| 1233 |
sp_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs) |
| 1234 |
|
| 1235 |
if val not in {32, 36}: |
| 1236 |
bsram_attrs[f'{typ}A_DATA_WIDTH'] = _bsram_bit_widths[val] |
| 1237 |
bsram_attrs[f'{typ}B_DATA_WIDTH'] = _bsram_bit_widths[val] |
| 1238 |
elif typ != 'SP': |
| 1239 |
bsram_attrs['DBLWA'] = _bsram_bit_widths[val] |
| 1240 |
bsram_attrs['DBLWB'] = _bsram_bit_widths[val] |
| 1241 |
else: |
| 1242 |
raise Exception(f"BSRAM width of {val} isn't supported for now") |
| 1243 |
elif parm == 'BIT_WIDTH_0': |
| 1244 |
val = int(val, 2) |
| 1245 |
if val in _bsram_bit_widths: |
| 1246 |
if val not in {32, 36}: |
| 1247 |
bsram_attrs[f'{typ}A_DATA_WIDTH'] = _bsram_bit_widths[val] |
| 1248 |
else: |
| 1249 |
bsram_attrs['DBLWA'] = _bsram_bit_widths[val] |
| 1250 |
if val in {16, 18}: |
| 1251 |
if typ == 'SDP': |
| 1252 |
sdp_16_18_byte_enable(typ, cell, bsram_attrs) |
| 1253 |
elif typ =='DP': |
| 1254 |
dpa_16_18_byte_enable(typ, cell, bsram_attrs) |
| 1255 |
else: |
| 1256 |
raise Exception(f"BIT_WIDTH_0 for BSRAM type {typ} isn't supported") |
| 1257 |
elif val in {32, 36}: |
| 1258 |
if typ == 'SDP': |
| 1259 |
sdp_32_36_byte_enable(typ, cell, bsram_attrs) |
| 1260 |
else: |
| 1261 |
raise Exception(f"BIT_WIDTH_0={val} for BSRAM type {typ} isn't supported") |
| 1262 |
else: |
| 1263 |
if typ == 'SDP': |
| 1264 |
sdp_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs) |
| 1265 |
elif typ =='DP': |
| 1266 |
dpa_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs) |
| 1267 |
else: |
| 1268 |
raise Exception(f"BIT_WIDTH_0 for BSRAM type {typ} isn't supported") |
| 1269 |
else: |
| 1270 |
raise Exception(f"BSRAM width of {val} isn't supported for now") |
| 1271 |
elif parm == 'BIT_WIDTH_1': |
| 1272 |
val = int(val, 2) |
| 1273 |
if val in _bsram_bit_widths: |
| 1274 |
if val not in {32, 36}: |
| 1275 |
bsram_attrs[f'{typ}B_DATA_WIDTH'] = _bsram_bit_widths[val] |
| 1276 |
else: |
| 1277 |
bsram_attrs['DBLWB'] = _bsram_bit_widths[val] |
| 1278 |
if val in {16, 18}: |
| 1279 |
if typ =='DP': |
| 1280 |
dpb_16_18_byte_enable(typ, cell, bsram_attrs) |
| 1281 |
elif typ != 'SDP': |
| 1282 |
raise Exception(f"BIT_WIDTH_1 for BSRAM type {typ} isn't supported") |
| 1283 |
elif val in {32, 36}: |
| 1284 |
if typ != 'SDP': |
| 1285 |
raise Exception(f"BIT_WIDTH_1={val} for BSRAM type {typ} isn't supported") |
| 1286 |
else: |
| 1287 |
if typ =='DP': |
| 1288 |
dpb_1_2_4_8_9_byte_enable(typ, cell, bsram_attrs) |
| 1289 |
elif typ != 'SDP': |
| 1290 |
raise Exception(f"BIT_WIDTH_1 for BSRAM type {typ} isn't supported") |
| 1291 |
else: |
| 1292 |
raise Exception(f"BSRAM width of {val} isn't supported for now") |
| 1293 |
elif parm == 'BLK_SEL': |
| 1294 |
for i in range(3): |
| 1295 |
if val[-1 - i] == '0': |
| 1296 |
bsram_attrs[f'CSA_{i}'] = 'SET' |
| 1297 |
bsram_attrs[f'CSB_{i}'] = 'SET' |
| 1298 |
elif parm == 'BLK_SEL_0': |
| 1299 |
for i in range(3): |
| 1300 |
if val[-1 - i] == '0': |
| 1301 |
bsram_attrs[f'CSA_{i}'] = 'SET' |
| 1302 |
elif parm == 'BLK_SEL_1': |
| 1303 |
for i in range(3): |
| 1304 |
if val[-1 - i] == '0': |
| 1305 |
bsram_attrs[f'CSB_{i}'] = 'SET' |
| 1306 |
elif parm == 'READ_MODE0': |
| 1307 |
val = int(val, 2) |
| 1308 |
if val == 1: |
| 1309 |
bsram_attrs[f'{typ}A_REGMODE'] = 'OUTREG' |
| 1310 |
elif parm == 'READ_MODE1': |
| 1311 |
val = int(val, 2) |
| 1312 |
if val == 1: |
| 1313 |
bsram_attrs[f'{typ}B_REGMODE'] = 'OUTREG' |
| 1314 |
elif parm == 'READ_MODE': |
| 1315 |
val = int(val, 2) |
| 1316 |
if val == 1: |
| 1317 |
bsram_attrs[f'{typ}A_REGMODE'] = 'OUTREG' |
| 1318 |
bsram_attrs[f'{typ}B_REGMODE'] = 'OUTREG' |
| 1319 |
elif parm == 'RESET_MODE': |
| 1320 |
if val == 'ASYNC': |
| 1321 |
bsram_attrs[f'OUTREG_ASYNC'] = 'RESET' |
| 1322 |
elif parm == 'WRITE_MODE0': |
| 1323 |
val = int(val, 2) |
| 1324 |
if val == 1: |
| 1325 |
bsram_attrs[f'{typ}A_MODE'] = 'WT' |
| 1326 |
elif val == 2: |
| 1327 |
bsram_attrs[f'{typ}A_MODE'] = 'RBW' |
| 1328 |
elif parm == 'WRITE_MODE1': |
| 1329 |
val = int(val, 2) |
| 1330 |
if val == 1: |
| 1331 |
bsram_attrs[f'{typ}B_MODE'] = 'WT' |
| 1332 |
elif val == 2: |
| 1333 |
bsram_attrs[f'{typ}B_MODE'] = 'RBW' |
| 1334 |
elif parm == 'WRITE_MODE': |
| 1335 |
val = int(val, 2) |
| 1336 |
if val == 1: |
| 1337 |
bsram_attrs[f'{typ}A_MODE'] = 'WT' |
| 1338 |
bsram_attrs[f'{typ}B_MODE'] = 'WT' |
| 1339 |
elif val == 2: |
| 1340 |
bsram_attrs[f'{typ}A_MODE'] = 'RBW' |
| 1341 |
bsram_attrs[f'{typ}B_MODE'] = 'RBW' |
| 1342 |
fin_attrs = set() |
| 1343 |
|
| 1344 |
for attr, val in bsram_attrs.items(): |
| 1345 |
if isinstance(val, str): |
| 1346 |
val = attrids.bsram_attrvals[val] |
| 1347 |
add_attr_val(db, 'BSRAM', fin_attrs, attrids.bsram_attrids[attr], val) |
| 1348 |
|
| 1349 |
return fin_attrs |
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
def set_dsp_regs_0(parms, names): |
| 1354 |
for name in names: |
| 1355 |
if not name in parms: |
| 1356 |
parms[name] = "0" |
| 1357 |
|
| 1358 |
|
| 1359 |
_ABLH = [('A', 'L'), ('A', 'H'), ('B', 'L'), ('B', 'H')] |
| 1360 |
_01LH = [(0, 'L'), (1, 'H')] |
| 1361 |
def set_multalu18x18_attrs(db, typ, params, num, attrs, dsp_attrs, mac): |
| 1362 |
attrs_upper(attrs) |
| 1363 |
ce_val = 'UNKNOWN' |
| 1364 |
if int(attrs['CE'], 2): |
| 1365 |
ce_val = f"CEIN{int(attrs['CE'], 2)}" |
| 1366 |
clk_val = 'UNKNOWN' |
| 1367 |
if int(attrs['CLK'], 2): |
| 1368 |
clk_val = f"CLKIN{int(attrs['CLK'], 2)}" |
| 1369 |
reset_val = 'UNKNOWN' |
| 1370 |
if int(attrs['RESET'], 2): |
| 1371 |
reset_val = f"RSTIN{int(attrs['RESET'], 2)}" |
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
mode = int(params['MULTALU18X18_MODE'], 2) |
| 1377 |
mode_01 = 0 |
| 1378 |
if mode != 2: |
| 1379 |
mode_01 = 1 |
| 1380 |
|
| 1381 |
accload = attrs['NET_ACCLOAD'] |
| 1382 |
|
| 1383 |
dsp_attrs["RCISEL_3"] = "1" |
| 1384 |
if mode_01: |
| 1385 |
dsp_attrs["RCISEL_1"] = "1" |
| 1386 |
|
| 1387 |
dsp_attrs['OR2CIB_EN0L_0'] = "ENABLE" |
| 1388 |
dsp_attrs['OR2CIB_EN0H_1'] = "ENABLE" |
| 1389 |
dsp_attrs['OR2CIB_EN1L_2'] = "ENABLE" |
| 1390 |
dsp_attrs['OR2CIB_EN1H_3'] = "ENABLE" |
| 1391 |
|
| 1392 |
if 'B_ADD_SUB' in params: |
| 1393 |
if int(params['B_ADD_SUB'], 2) == 1: |
| 1394 |
dsp_attrs['OPCD_7'] = "1" |
| 1395 |
|
| 1396 |
dsp_attrs['ALU_EN'] = "ENABLE" |
| 1397 |
dsp_attrs['OPCD_5'] = "1" |
| 1398 |
dsp_attrs['OPCD_9'] = "1" |
| 1399 |
for i in {5, 6}: |
| 1400 |
dsp_attrs[f'CINBY_{i}'] = "ENABLE" |
| 1401 |
dsp_attrs[f'CINNS_{i}'] = "ENABLE" |
| 1402 |
dsp_attrs[f'CPRBY_{i}'] = "ENABLE" |
| 1403 |
dsp_attrs[f'CPRNS_{i}'] = "ENABLE" |
| 1404 |
|
| 1405 |
if "USE_CASCADE_IN" in attrs: |
| 1406 |
dsp_attrs['CSGIN_EXT'] = "ENABLE" |
| 1407 |
dsp_attrs['CSIGN_PRE'] = "ENABLE" |
| 1408 |
if "USE_CASCADE_OUT" in attrs: |
| 1409 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1410 |
|
| 1411 |
if mode_01: |
| 1412 |
dsp_attrs['OPCD_2'] = "1" |
| 1413 |
if accload == "VCC": |
| 1414 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1415 |
elif accload == "GND": |
| 1416 |
dsp_attrs['OPCD_0'] = "1" |
| 1417 |
dsp_attrs['OPCD_1'] = "1" |
| 1418 |
else: |
| 1419 |
dsp_attrs['OPCDDYN_0'] = "ENABLE" |
| 1420 |
dsp_attrs['OPCDDYN_1'] = "ENABLE" |
| 1421 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1422 |
dsp_attrs['OPCDDYN_INV_0'] = "ENABLE" |
| 1423 |
dsp_attrs['OPCDDYN_INV_1'] = "ENABLE" |
| 1424 |
if mode == 0: |
| 1425 |
dsp_attrs['OPCD_4'] = "1" |
| 1426 |
if 'C_ADD_SUB' in params: |
| 1427 |
if int(params['C_ADD_SUB'], 2) == 1: |
| 1428 |
dsp_attrs['OPCD_8'] = "1" |
| 1429 |
else: |
| 1430 |
dsp_attrs['OPCD_0'] = "1" |
| 1431 |
dsp_attrs['OPCD_3'] = "1" |
| 1432 |
|
| 1433 |
set_dsp_regs_0(params, {'AREG', 'BREG', 'CREG', 'DREG', 'DSIGN_REG', 'ASIGN_REG', 'BSIGN_REG', 'PIPE_REG', 'OUT_REG'}) |
| 1434 |
|
| 1435 |
for parm, val in params.items(): |
| 1436 |
if parm == 'AREG': |
| 1437 |
if val == '0': |
| 1438 |
for i, h in _01LH: |
| 1439 |
dsp_attrs[f'IRBY_IREG{mode_01}A{h}_{4 * mode_01 + i}'] = "ENABLE" |
| 1440 |
dsp_attrs[f'IRNS_IREG{mode_01}A{h}_{4 * mode_01 + i}'] = "ENABLE" |
| 1441 |
else: |
| 1442 |
for h in "LH": |
| 1443 |
dsp_attrs[f'CE{h}MUX_REGMA{mode_01}'] = ce_val |
| 1444 |
dsp_attrs[f'CLK{h}MUX_REGMA{mode_01}'] = clk_val |
| 1445 |
dsp_attrs[f'RST{h}MUX_REGMA{mode_01}'] = reset_val |
| 1446 |
if 'MULT_RESET_MODE' in params: |
| 1447 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1448 |
for h in "LH": |
| 1449 |
dsp_attrs[f'RSTGEN{h}MUX_REGMA{mode_01}'] = 'SYNC' |
| 1450 |
if parm == 'BREG': |
| 1451 |
if val == '0': |
| 1452 |
for i, h in _01LH: |
| 1453 |
dsp_attrs[f'IRBY_IREG{mode_01}B{h}_{4 * mode_01 + 2 + i}'] = "ENABLE" |
| 1454 |
dsp_attrs[f'IRNS_IREG{mode_01}B{h}_{4 * mode_01 + 2 + i}'] = "ENABLE" |
| 1455 |
else: |
| 1456 |
for h in "LH": |
| 1457 |
dsp_attrs[f'CE{h}MUX_REGMB{mode_01}'] = ce_val |
| 1458 |
dsp_attrs[f'CLK{h}MUX_REGMB{mode_01}'] = clk_val |
| 1459 |
dsp_attrs[f'RST{h}MUX_REGMB{mode_01}'] = reset_val |
| 1460 |
if 'MULT_RESET_MODE' in params: |
| 1461 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1462 |
for h in "LH": |
| 1463 |
dsp_attrs[f'RSTGEN{h}MUX_REGMB{mode_01}'] = 'SYNC' |
| 1464 |
if parm == 'CREG' and mode_01: |
| 1465 |
if val == '0': |
| 1466 |
for i, h in _01LH: |
| 1467 |
dsp_attrs[f'CIR_BYP{h}_{i}'] = "1" |
| 1468 |
else: |
| 1469 |
for h in "LH": |
| 1470 |
dsp_attrs[f'CE{h}MUX_CREG'] = ce_val |
| 1471 |
dsp_attrs[f'CLK{h}MUX_CREG'] = clk_val |
| 1472 |
dsp_attrs[f'RST{h}MUX_CREG'] = reset_val |
| 1473 |
if 'MULT_RESET_MODE' in params: |
| 1474 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1475 |
for h in "LH": |
| 1476 |
dsp_attrs[f'RSTGEN{h}MUX_REGC0'] = 'SYNC' |
| 1477 |
if parm == 'DREG' and not mode_01: |
| 1478 |
if val == '0': |
| 1479 |
dsp_attrs['CIR_BYPH_1'] = "1" |
| 1480 |
ii = 4 |
| 1481 |
for i, h in _ABLH: |
| 1482 |
dsp_attrs[f'IRBY_IREG1{i}{h}_{ii}'] = "ENABLE" |
| 1483 |
dsp_attrs[f'IRNS_IREG1{i}{h}_{ii}'] = "ENABLE" |
| 1484 |
ii += 1 |
| 1485 |
else: |
| 1486 |
dsp_attrs['CEHMUX_CREG'] = ce_val |
| 1487 |
dsp_attrs['CLKHMUX_CREG'] = clk_val |
| 1488 |
dsp_attrs['RSTHMUX_CREG'] = reset_val |
| 1489 |
for i, h in _ABLH: |
| 1490 |
dsp_attrs[f'CE{h}MUX_REGM{i}1'] = ce_val |
| 1491 |
dsp_attrs[f'CLK{h}MUX_REGM{i}1'] = clk_val |
| 1492 |
dsp_attrs[f'RST{h}MUX_REGM{i}1'] = reset_val |
| 1493 |
if 'MULT_RESET_MODE' in params: |
| 1494 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1495 |
dsp_attrs['RSTGENHMUX_REGC0'] = 'SYNC' |
| 1496 |
for i, h in _ABLH: |
| 1497 |
dsp_attrs[f'RSTGEN{h}MUX_REGM{i}1'] = 'SYNC' |
| 1498 |
if parm == 'ASIGN_REG': |
| 1499 |
if val == '0': |
| 1500 |
dsp_attrs[f'CINNS_{3 * mode_01}'] = "ENABLE" |
| 1501 |
dsp_attrs[f'CINBY_{3 * mode_01}'] = "ENABLE" |
| 1502 |
else: |
| 1503 |
dsp_attrs[f'CEMUX_ASIGN{mode_01}1'] = ce_val |
| 1504 |
dsp_attrs[f'CLKMUX_ASIGN{mode_01}1'] = clk_val |
| 1505 |
dsp_attrs[f'RSTMUX_ASIGN{mode_01}1'] = reset_val |
| 1506 |
if 'MULT_RESET_MODE' in params: |
| 1507 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1508 |
dsp_attrs[f'RSTGENMUX_ASIGN{mode_01}1'] = 'SYNC' |
| 1509 |
if parm == 'BSIGN_REG': |
| 1510 |
if val == '0': |
| 1511 |
dsp_attrs[f'CINNS_{1 + 3 * mode_01}'] = "ENABLE" |
| 1512 |
dsp_attrs[f'CINBY_{1 + 3 * mode_01}'] = "ENABLE" |
| 1513 |
else: |
| 1514 |
dsp_attrs[f'CEMUX_BSIGN{mode_01}1'] = ce_val |
| 1515 |
dsp_attrs[f'CLKMUX_BSIGN{mode_01}1'] = clk_val |
| 1516 |
dsp_attrs[f'RSTMUX_BSIGN{mode_01}1'] = reset_val |
| 1517 |
if 'MULT_RESET_MODE' in params: |
| 1518 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1519 |
dsp_attrs[f'RSTGENMUX_BSIGN{mode_01}1'] = 'SYNC' |
| 1520 |
if parm == 'DSIGN_REG' and not mode_01: |
| 1521 |
if val == '0': |
| 1522 |
dsp_attrs['CINNS_4'] = "ENABLE" |
| 1523 |
dsp_attrs['CINBY_4'] = "ENABLE" |
| 1524 |
else: |
| 1525 |
dsp_attrs['CEMUX_BSIGN11'] = ce_val |
| 1526 |
dsp_attrs['CLKMUX_BSIGN11'] = clk_val |
| 1527 |
dsp_attrs['RSTMUX_BSIGN11'] = reset_val |
| 1528 |
if 'MULT_RESET_MODE' in params: |
| 1529 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1530 |
dsp_attrs['RSTGENMUX_BSIGN11'] = 'SYNC' |
| 1531 |
if 'PIPE_REG' in params: |
| 1532 |
if params['PIPE_REG'] == '0': |
| 1533 |
dsp_attrs['CPRNS_4'] = "ENABLE" |
| 1534 |
dsp_attrs['CPRBY_4'] = "ENABLE" |
| 1535 |
else: |
| 1536 |
dsp_attrs['CLK_BSIGN12'] = clk_val |
| 1537 |
dsp_attrs['RST_BSIGN12'] = reset_val |
| 1538 |
if 'MULT_RESET_MODE' in params: |
| 1539 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1540 |
dsp_attrs[f'RSTGENMUX_BSIGN12'] = 'SYNC' |
| 1541 |
|
| 1542 |
if parm == 'PIPE_REG': |
| 1543 |
if val == '0': |
| 1544 |
dsp_attrs[f'CPRNS_{3 * mode_01}'] = "ENABLE" |
| 1545 |
dsp_attrs[f'CPRBY_{3 * mode_01}'] = "ENABLE" |
| 1546 |
dsp_attrs[f'CPRNS_{1 + 3 * mode_01}'] = "ENABLE" |
| 1547 |
dsp_attrs[f'CPRBY_{1 + 3 * mode_01}'] = "ENABLE" |
| 1548 |
for i, h in _01LH: |
| 1549 |
dsp_attrs[f'PPREG{mode_01}_NS{h}_{2 * mode_01 + i}'] = "ENABLE" |
| 1550 |
dsp_attrs[f'PPREG{mode_01}_BYP{h}_{2 * mode_01 + i}'] = "ENABLE" |
| 1551 |
else: |
| 1552 |
for i in "AB": |
| 1553 |
dsp_attrs[f'CEMUX_{i}SIGN{1 - mode_01}2'] = ce_val |
| 1554 |
dsp_attrs[f'CLKMUX_{i}SIGN{1 - mode_01}2'] = clk_val |
| 1555 |
dsp_attrs[f'RSTMUX_{i}SIGN{1 - mode_01}2'] = reset_val |
| 1556 |
for i in "LH": |
| 1557 |
dsp_attrs[f'CE{i}MUX_REGP{1 - mode_01}'] = ce_val |
| 1558 |
dsp_attrs[f'CLK{i}MUX_REGP{1 - mode_01}'] = clk_val |
| 1559 |
dsp_attrs[f'RST{i}MUX_REGP{1 - mode_01}'] = reset_val |
| 1560 |
if 'MULT_RESET_MODE' in params: |
| 1561 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1562 |
dsp_attrs[f'RSTGENMUX_ASIGN{1 - mode_01}2'] = 'SYNC' |
| 1563 |
dsp_attrs[f'RSTGENMUX_BSIGN{1 - mode_01}2'] = 'SYNC' |
| 1564 |
dsp_attrs[f'RSTGENLMUX_REGP{1 - mode_01}'] = 'SYNC' |
| 1565 |
dsp_attrs[f'RSTGENHMUX_REGP{1 - mode_01}'] = 'SYNC' |
| 1566 |
if parm == 'OUT_REG': |
| 1567 |
if val == '0': |
| 1568 |
for i in range(2): |
| 1569 |
dsp_attrs[f'OREG{i}_NSL_{2 * i}'] = "ENABLE" |
| 1570 |
dsp_attrs[f'OREG{i}_BYPL_{2 * i}'] = "ENABLE" |
| 1571 |
dsp_attrs[f'OREG{i}_NSH_{2 * i + 1}'] = "ENABLE" |
| 1572 |
dsp_attrs[f'OREG{i}_BYPH_{2 * i + 1}'] = "ENABLE" |
| 1573 |
else: |
| 1574 |
for i in range(2): |
| 1575 |
for h in "LH": |
| 1576 |
dsp_attrs[f'CE{h}MUX_OREG{i}'] = ce_val |
| 1577 |
dsp_attrs[f'CLK{h}MUX_OREG{i}'] = clk_val |
| 1578 |
dsp_attrs[f'RST{h}MUX_OREG{i}'] = reset_val |
| 1579 |
if 'MULT_RESET_MODE' in params: |
| 1580 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1581 |
for h in "LH": |
| 1582 |
dsp_attrs[f'RSTGEN{h}MUX_OREG0'] = 'SYNC' |
| 1583 |
dsp_attrs[f'RSTGEN{h}MUX_OREG1'] = 'SYNC' |
| 1584 |
if parm == 'ACCLOAD_REG0': |
| 1585 |
if val == '0': |
| 1586 |
dsp_attrs['CINNS_2'] = "ENABLE" |
| 1587 |
dsp_attrs['CINBY_2'] = "ENABLE" |
| 1588 |
else: |
| 1589 |
dsp_attrs['CEMUX_ALUSEL1'] = ce_val |
| 1590 |
dsp_attrs['CLKMUX_ALUSEL1'] = clk_val |
| 1591 |
dsp_attrs['RSTMUX_ALUSEL1'] = reset_val |
| 1592 |
if 'MULT_RESET_MODE' in params: |
| 1593 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1594 |
dsp_attrs['RSTGENMUX_ALUSEL1'] = 'SYNC' |
| 1595 |
if parm == 'ACCLOAD_REG1': |
| 1596 |
if val == '0': |
| 1597 |
dsp_attrs['CPRNS_2'] = "ENABLE" |
| 1598 |
dsp_attrs['CPRBY_2'] = "ENABLE" |
| 1599 |
else: |
| 1600 |
dsp_attrs['CEMUX_ALUSEL2'] = ce_val |
| 1601 |
dsp_attrs['CLKMUX_ALUSEL2'] = clk_val |
| 1602 |
dsp_attrs['RSTMUX_ALUSEL2'] = reset_val |
| 1603 |
if 'MULT_RESET_MODE' in params: |
| 1604 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1605 |
dsp_attrs['RSTGENMUX_ALUSEL2'] = 'SYNC' |
| 1606 |
|
| 1607 |
|
| 1608 |
def set_multaddalu18x18_attrs(db, typ, params, num, attrs, dsp_attrs, mac): |
| 1609 |
attrs_upper(attrs) |
| 1610 |
ce_val = 'UNKNOWN' |
| 1611 |
if int(attrs['CE'], 2): |
| 1612 |
ce_val = f"CEIN{int(attrs['CE'], 2)}" |
| 1613 |
clk_val = 'UNKNOWN' |
| 1614 |
if int(attrs['CLK'], 2): |
| 1615 |
clk_val = f"CLKIN{int(attrs['CLK'], 2)}" |
| 1616 |
reset_val = 'UNKNOWN' |
| 1617 |
if int(attrs['RESET'], 2): |
| 1618 |
reset_val = f"RSTIN{int(attrs['RESET'], 2)}" |
| 1619 |
|
| 1620 |
mode = int(params['MULTADDALU18X18_MODE'], 2) |
| 1621 |
accload = attrs['NET_ACCLOAD'] |
| 1622 |
|
| 1623 |
if mode == 0: |
| 1624 |
dsp_attrs["RCISEL_3"] = "1" |
| 1625 |
dsp_attrs["RCISEL_1"] = "1" |
| 1626 |
|
| 1627 |
dsp_attrs['OR2CIB_EN0L_0'] = "ENABLE" |
| 1628 |
dsp_attrs['OR2CIB_EN0H_1'] = "ENABLE" |
| 1629 |
dsp_attrs['OR2CIB_EN1L_2'] = "ENABLE" |
| 1630 |
dsp_attrs['OR2CIB_EN1H_3'] = "ENABLE" |
| 1631 |
|
| 1632 |
if 'B_ADD_SUB' in params: |
| 1633 |
if int(params['B_ADD_SUB'], 2) == 1: |
| 1634 |
dsp_attrs['OPCD_7'] = "1" |
| 1635 |
|
| 1636 |
if "USE_CASCADE_IN" in attrs: |
| 1637 |
dsp_attrs['CSGIN_EXT'] = "ENABLE" |
| 1638 |
dsp_attrs['CSIGN_PRE'] = "ENABLE" |
| 1639 |
if "USE_CASCADE_OUT" in attrs: |
| 1640 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1641 |
|
| 1642 |
dsp_attrs['ALU_EN'] = "ENABLE" |
| 1643 |
dsp_attrs['OPCD_0'] = "1" |
| 1644 |
dsp_attrs['OPCD_2'] = "1" |
| 1645 |
dsp_attrs['OPCD_9'] = "1" |
| 1646 |
for i in {5, 6}: |
| 1647 |
dsp_attrs[f'CINBY_{i}'] = "ENABLE" |
| 1648 |
dsp_attrs[f'CINNS_{i}'] = "ENABLE" |
| 1649 |
dsp_attrs[f'CPRBY_{i}'] = "ENABLE" |
| 1650 |
dsp_attrs[f'CPRNS_{i}'] = "ENABLE" |
| 1651 |
|
| 1652 |
if mode == 0: |
| 1653 |
dsp_attrs['OPCD_4'] = "1" |
| 1654 |
dsp_attrs['OPCD_5'] = "1" |
| 1655 |
if 'C_ADD_SUB' in params: |
| 1656 |
if int(params['C_ADD_SUB'], 2) == 1: |
| 1657 |
dsp_attrs['OPCD_8'] = "1" |
| 1658 |
elif mode == 2: |
| 1659 |
dsp_attrs['OPCD_5'] = "1" |
| 1660 |
else: |
| 1661 |
if accload == "VCC": |
| 1662 |
dsp_attrs['OPCD_4'] = "1" |
| 1663 |
dsp_attrs['OPCD_6'] = "1" |
| 1664 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1665 |
elif accload != "GND": |
| 1666 |
dsp_attrs['OPCDDYN_4'] = "ENABLE" |
| 1667 |
dsp_attrs['OPCDDYN_6'] = "ENABLE" |
| 1668 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1669 |
|
| 1670 |
if attrs['NET_ASEL0'] == 'VCC': |
| 1671 |
dsp_attrs['AIRMUX1_0'] = "ENABLE" |
| 1672 |
elif attrs['NET_ASEL0'] and attrs['NET_ASEL0'] != 'GND': |
| 1673 |
dsp_attrs['AIRMUX1_SEL_0'] = "ENABLE" |
| 1674 |
|
| 1675 |
if attrs['NET_ASEL1'] == 'VCC': |
| 1676 |
dsp_attrs['AIRMUX1_1'] = "ENABLE" |
| 1677 |
elif attrs['NET_ASEL1'] and attrs['NET_ASEL1'] != 'GND': |
| 1678 |
dsp_attrs['AIRMUX1_SEL_1'] = "ENABLE" |
| 1679 |
|
| 1680 |
if attrs['NET_BSEL0'] == 'VCC': |
| 1681 |
dsp_attrs['BIRMUX1_0'] = "ENABLE" |
| 1682 |
elif attrs['NET_BSEL0'] and attrs['NET_BSEL0'] != 'GND': |
| 1683 |
dsp_attrs['BIRMUX0_0'] = "ENABLE" |
| 1684 |
dsp_attrs['BIRMUX0_1'] = "ENABLE" |
| 1685 |
dsp_attrs['BIRMUX1_0'] = "ENABLE" |
| 1686 |
dsp_attrs['BIRMUX1_1'] = "ENABLE" |
| 1687 |
|
| 1688 |
if attrs['NET_BSEL1'] == 'VCC': |
| 1689 |
dsp_attrs['BIRMUX1_2'] = "ENABLE" |
| 1690 |
elif attrs['NET_BSEL1'] and attrs['NET_BSEL1'] != 'GND': |
| 1691 |
dsp_attrs['BIRMUX1_2'] = "ENABLE" |
| 1692 |
dsp_attrs['BIRMUX1_3'] = "ENABLE" |
| 1693 |
|
| 1694 |
dsp_attrs['MATCH_SHFEN'] = "ENABLE" |
| 1695 |
dsp_attrs['IRASHFEN_0'] = "1" |
| 1696 |
dsp_attrs['IRASHFEN_1'] = "1" |
| 1697 |
dsp_attrs['IRBSHFEN_0'] = "1" |
| 1698 |
dsp_attrs['IRBSHFEN_1'] = "1" |
| 1699 |
|
| 1700 |
set_dsp_regs_0(params, {'A0REG', 'A1REG', 'B0REG', 'B1REG', 'CREG', 'PIPE0_REG', 'PIPE1_REG', 'OUT_REG', |
| 1701 |
'ASIGN0_REG', 'ASIGN1_REG', 'ACCLOAD_REG0', 'ACCLOAD_REG1', 'BSIGN0_REG', 'BSIGN1_REG', |
| 1702 |
'SOA_REG'}) |
| 1703 |
for parm, val in params.items(): |
| 1704 |
if parm in {'A0REG', 'A1REG'}: |
| 1705 |
k = int(parm[1], 2) |
| 1706 |
if val == '0': |
| 1707 |
for i, h in _01LH: |
| 1708 |
dsp_attrs[f'IRBY_IREG{k}A{h}_{4 * k + i}'] = "ENABLE" |
| 1709 |
dsp_attrs[f'IRNS_IREG{k}A{h}_{4 * k + i}'] = "ENABLE" |
| 1710 |
else: |
| 1711 |
for h in "LH": |
| 1712 |
dsp_attrs[f'CE{h}MUX_REGMA{k}'] = ce_val |
| 1713 |
dsp_attrs[f'CLK{h}MUX_REGMA{k}'] = clk_val |
| 1714 |
dsp_attrs[f'RST{h}MUX_REGMA{k}'] = reset_val |
| 1715 |
if 'MULT_RESET_MODE' in params: |
| 1716 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1717 |
for h in "LH": |
| 1718 |
dsp_attrs[f'RSTGEN{h}MUX_REGMA{k}'] = 'SYNC' |
| 1719 |
if parm in {'B0REG', 'B1REG'}: |
| 1720 |
k = int(parm[1], 2) |
| 1721 |
if val == '0': |
| 1722 |
for i, h in _01LH: |
| 1723 |
dsp_attrs[f'IRBY_IREG{k}B{h}_{4 * k + 2 + i}'] = "ENABLE" |
| 1724 |
dsp_attrs[f'IRNS_IREG{k}B{h}_{4 * k + 2 + i}'] = "ENABLE" |
| 1725 |
else: |
| 1726 |
for h in "LH": |
| 1727 |
dsp_attrs[f'CE{h}MUX_REGMB{k}'] = ce_val |
| 1728 |
dsp_attrs[f'CLK{h}MUX_REGMB{k}'] = clk_val |
| 1729 |
dsp_attrs[f'RST{h}MUX_REGMB{k}'] = reset_val |
| 1730 |
if 'MULT_RESET_MODE' in params: |
| 1731 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1732 |
for h in "LH": |
| 1733 |
dsp_attrs[f'RSTGEN{h}MUX_REGMB{k}'] = 'SYNC' |
| 1734 |
if parm == 'CREG' and mode == 0: |
| 1735 |
if val == '0': |
| 1736 |
for i, h in _01LH: |
| 1737 |
dsp_attrs[f'CIR_BYP{h}_{i}'] = "1" |
| 1738 |
else: |
| 1739 |
for h in "LH": |
| 1740 |
dsp_attrs[f'CE{h}MUX_CREG'] = ce_val |
| 1741 |
dsp_attrs[f'CLK{h}MUX_CREG'] = clk_val |
| 1742 |
dsp_attrs[f'RST{h}MUX_CREG'] = reset_val |
| 1743 |
if 'MULT_RESET_MODE' in params: |
| 1744 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1745 |
for h in "LH": |
| 1746 |
dsp_attrs[f'RSTGEN{h}MUX_REGC0'] = 'SYNC' |
| 1747 |
if parm in {'ASIGN0_REG', 'ASIGN1_REG'}: |
| 1748 |
k = int(parm[5], 2) |
| 1749 |
if val == '0': |
| 1750 |
dsp_attrs[f'CINNS_{3 * k}'] = "ENABLE" |
| 1751 |
dsp_attrs[f'CINBY_{3 * k}'] = "ENABLE" |
| 1752 |
else: |
| 1753 |
dsp_attrs[f'CEMUX_ASIGN{k}1'] = ce_val |
| 1754 |
dsp_attrs[f'CLKMUX_ASIGN{k}1'] = clk_val |
| 1755 |
dsp_attrs[f'RSTMUX_ASIGN{k}1'] = reset_val |
| 1756 |
if 'MULT_RESET_MODE' in params: |
| 1757 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1758 |
dsp_attrs[f'RSTGENMUX_ASIGN{k}1'] = 'SYNC' |
| 1759 |
if parm in {'BSIGN0_REG', 'BSIGN1_REG'}: |
| 1760 |
k = int(parm[5], 2) |
| 1761 |
if val == '0': |
| 1762 |
dsp_attrs[f'CINNS_{1 + 3 * k}'] = "ENABLE" |
| 1763 |
dsp_attrs[f'CINBY_{1 + 3 * k}'] = "ENABLE" |
| 1764 |
else: |
| 1765 |
dsp_attrs[f'CEMUX_BSIGN{k}1'] = ce_val |
| 1766 |
dsp_attrs[f'CLKMUX_BSIGN{k}1'] = clk_val |
| 1767 |
dsp_attrs[f'RSTMUX_BSIGN{k}1'] = reset_val |
| 1768 |
if 'MULT_RESET_MODE' in params: |
| 1769 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1770 |
dsp_attrs[f'RSTGENMUX_BSIGN{k}1'] = 'SYNC' |
| 1771 |
if parm in {'PIPE0_REG', 'PIPE1_REG'}: |
| 1772 |
k = int(parm[4], 2) |
| 1773 |
if val == '0': |
| 1774 |
dsp_attrs[f'CPRNS_{3 * k}'] = "ENABLE" |
| 1775 |
dsp_attrs[f'CPRBY_{3 * k}'] = "ENABLE" |
| 1776 |
dsp_attrs[f'CPRNS_{1 + 3 * k}'] = "ENABLE" |
| 1777 |
dsp_attrs[f'CPRBY_{1 + 3 * k}'] = "ENABLE" |
| 1778 |
for i, h in _01LH: |
| 1779 |
dsp_attrs[f'PPREG{k}_NS{h}_{2 * k + i}'] = "ENABLE" |
| 1780 |
dsp_attrs[f'PPREG{k}_BYP{h}_{2 * k + i}'] = "ENABLE" |
| 1781 |
else: |
| 1782 |
for i in "AB": |
| 1783 |
dsp_attrs[f'CEMUX_{i}SIGN{k}2'] = ce_val |
| 1784 |
dsp_attrs[f'CLKMUX_{i}SIGN{k}2'] = clk_val |
| 1785 |
dsp_attrs[f'RSTMUX_{i}SIGN{k}2'] = reset_val |
| 1786 |
for i in "LH": |
| 1787 |
dsp_attrs[f'CE{i}MUX_REGP{k}'] = ce_val |
| 1788 |
dsp_attrs[f'CLK{i}MUX_REGP{k}'] = clk_val |
| 1789 |
dsp_attrs[f'RST{i}MUX_REGP{k}'] = reset_val |
| 1790 |
if 'MULT_RESET_MODE' in params: |
| 1791 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1792 |
dsp_attrs[f'RSTGENMUX_ASIGN{k}2'] = 'SYNC' |
| 1793 |
dsp_attrs[f'RSTGENMUX_BSIGN{k}2'] = 'SYNC' |
| 1794 |
dsp_attrs[f'RSTGENLMUX_REGP{k}'] = 'SYNC' |
| 1795 |
dsp_attrs[f'RSTGENHMUX_REGP{k}'] = 'SYNC' |
| 1796 |
if parm == 'SOA_REG': |
| 1797 |
if val == '0': |
| 1798 |
dsp_attrs['IRBY_IRMATCHH_9'] = "ENABLE" |
| 1799 |
dsp_attrs['IRNS_IRMATCHH_9'] = "ENABLE" |
| 1800 |
dsp_attrs['IRBY_IRMATCHL_8'] = "ENABLE" |
| 1801 |
dsp_attrs['IRNS_IRMATCHL_8'] = "ENABLE" |
| 1802 |
else: |
| 1803 |
dsp_attrs[f'CEHMUX_REGSD'] = ce_val |
| 1804 |
dsp_attrs[f'CLKHMUX_REGSD'] = clk_val |
| 1805 |
dsp_attrs[f'RSTHMUX_REGSD'] = reset_val |
| 1806 |
dsp_attrs[f'CELMUX_REGSD'] = ce_val |
| 1807 |
dsp_attrs[f'CLKLMUX_REGSD'] = clk_val |
| 1808 |
dsp_attrs[f'RSTLMUX_REGSD'] = reset_val |
| 1809 |
if 'MULT_RESET_MODE' in params: |
| 1810 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1811 |
dsp_attrs[f'RSTGENHMUX_REGSD'] = 'SYNC' |
| 1812 |
dsp_attrs[f'RSTGENLMUX_REGSD'] = 'SYNC' |
| 1813 |
if parm == 'OUT_REG': |
| 1814 |
if val == '0': |
| 1815 |
for k in range(2): |
| 1816 |
dsp_attrs[f'OREG{k}_NSL_{2 * k}'] = "ENABLE" |
| 1817 |
dsp_attrs[f'OREG{k}_BYPL_{2 * k}'] = "ENABLE" |
| 1818 |
dsp_attrs[f'OREG{k}_NSH_{2 * k + 1}'] = "ENABLE" |
| 1819 |
dsp_attrs[f'OREG{k}_BYPH_{2 * k + 1}'] = "ENABLE" |
| 1820 |
else: |
| 1821 |
for k in range(2): |
| 1822 |
for h in "LH": |
| 1823 |
dsp_attrs[f'CE{h}MUX_OREG{k}'] = ce_val |
| 1824 |
dsp_attrs[f'CLK{h}MUX_OREG{k}'] = clk_val |
| 1825 |
dsp_attrs[f'RST{h}MUX_OREG{k}'] = reset_val |
| 1826 |
if 'MULT_RESET_MODE' in params: |
| 1827 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1828 |
for h in "LH": |
| 1829 |
dsp_attrs[f'RSTGEN{h}MUX_OREG0'] = 'SYNC' |
| 1830 |
dsp_attrs[f'RSTGEN{h}MUX_OREG1'] = 'SYNC' |
| 1831 |
if parm == 'ACCLOAD_REG0': |
| 1832 |
if val == '0': |
| 1833 |
dsp_attrs['CINNS_2'] = "ENABLE" |
| 1834 |
dsp_attrs['CINBY_2'] = "ENABLE" |
| 1835 |
else: |
| 1836 |
dsp_attrs['CEMUX_ALUSEL1'] = ce_val |
| 1837 |
dsp_attrs['CLKMUX_ALUSEL1'] = clk_val |
| 1838 |
dsp_attrs['RSTMUX_ALUSEL1'] = reset_val |
| 1839 |
if 'MULT_RESET_MODE' in params: |
| 1840 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1841 |
dsp_attrs['RSTGENMUX_ALUSEL1'] = 'SYNC' |
| 1842 |
if parm == 'ACCLOAD_REG1': |
| 1843 |
if val == '0': |
| 1844 |
dsp_attrs['CPRNS_2'] = "ENABLE" |
| 1845 |
dsp_attrs['CPRBY_2'] = "ENABLE" |
| 1846 |
else: |
| 1847 |
dsp_attrs['CEMUX_ALUSEL2'] = ce_val |
| 1848 |
dsp_attrs['CLKMUX_ALUSEL2'] = clk_val |
| 1849 |
dsp_attrs['RSTMUX_ALUSEL2'] = reset_val |
| 1850 |
if 'MULT_RESET_MODE' in params: |
| 1851 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1852 |
dsp_attrs['RSTGENMUX_ALUSEL2'] = 'SYNC' |
| 1853 |
|
| 1854 |
|
| 1855 |
|
| 1856 |
def set_multalu36x18_attrs(db, typ, params, num, attrs, dsp_attrs, mac): |
| 1857 |
attrs_upper(attrs) |
| 1858 |
ce_val = 'UNKNOWN' |
| 1859 |
if int(attrs['CE'], 2): |
| 1860 |
ce_val = f"CEIN{int(attrs['CE'], 2)}" |
| 1861 |
clk_val = 'UNKNOWN' |
| 1862 |
if int(attrs['CLK'], 2): |
| 1863 |
clk_val = f"CLKIN{int(attrs['CLK'], 2)}" |
| 1864 |
reset_val = 'UNKNOWN' |
| 1865 |
if int(attrs['RESET'], 2): |
| 1866 |
reset_val = f"RSTIN{int(attrs['RESET'], 2)}" |
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
se |
| 1871 |
mode = int(params['MULTALU36X18_MODE'], 2) |
| 1872 |
accload = attrs['NET_ACCLOAD'] |
| 1873 |
|
| 1874 |
dsp_attrs["RCISEL_1"] = "1" |
| 1875 |
dsp_attrs["RCISEL_3"] = "1" |
| 1876 |
|
| 1877 |
dsp_attrs['OR2CIB_EN0L_0'] = "ENABLE" |
| 1878 |
dsp_attrs['OR2CIB_EN0H_1'] = "ENABLE" |
| 1879 |
dsp_attrs['OR2CIB_EN1L_2'] = "ENABLE" |
| 1880 |
dsp_attrs['OR2CIB_EN1H_3'] = "ENABLE" |
| 1881 |
|
| 1882 |
dsp_attrs['ALU_EN'] = "ENABLE" |
| 1883 |
for i in {5, 6}: |
| 1884 |
dsp_attrs[f'CINBY_{i}'] = "ENABLE" |
| 1885 |
dsp_attrs[f'CINNS_{i}'] = "ENABLE" |
| 1886 |
dsp_attrs[f'CPRBY_{i}'] = "ENABLE" |
| 1887 |
dsp_attrs[f'CPRNS_{i}'] = "ENABLE" |
| 1888 |
|
| 1889 |
if "USE_CASCADE_IN" in attrs: |
| 1890 |
dsp_attrs['CSGIN_EXT'] = "ENABLE" |
| 1891 |
dsp_attrs['CSIGN_PRE'] = "ENABLE" |
| 1892 |
if "USE_CASCADE_OUT" in attrs: |
| 1893 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1894 |
|
| 1895 |
dsp_attrs['OPCD_0'] = "1" |
| 1896 |
dsp_attrs['OPCD_9'] = "1" |
| 1897 |
if mode == 0: |
| 1898 |
dsp_attrs['OPCD_4'] = "1" |
| 1899 |
dsp_attrs['OPCD_5'] = "1" |
| 1900 |
if 'C_ADD_SUB' in params: |
| 1901 |
if int(params['C_ADD_SUB'], 2) == 1: |
| 1902 |
dsp_attrs['OPCD_8'] = "1" |
| 1903 |
elif mode == 2: |
| 1904 |
dsp_attrs['OPCD_5'] = "1" |
| 1905 |
else: |
| 1906 |
if accload == "VCC": |
| 1907 |
dsp_attrs['OPCD_4'] = "1" |
| 1908 |
dsp_attrs['OPCD_6'] = "1" |
| 1909 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1910 |
elif accload != "GND": |
| 1911 |
dsp_attrs['OPCDDYN_4'] = "ENABLE" |
| 1912 |
dsp_attrs['OPCDDYN_6'] = "ENABLE" |
| 1913 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 1914 |
|
| 1915 |
set_dsp_regs_0(params, {'AREG', 'BREG', 'CREG', 'PIPE_REG', 'OUT_REG', 'ASIGN_REG', 'BSIGN_REG', 'ACCLOAD_REG0', |
| 1916 |
'ACCLOAD_REG1'}) |
| 1917 |
for parm, val in params.items(): |
| 1918 |
if parm == 'AREG': |
| 1919 |
if val == '0': |
| 1920 |
for k in range(2): |
| 1921 |
for i, h in _01LH: |
| 1922 |
dsp_attrs[f'IRBY_IREG{k}A{h}_{4 * k + i}'] = "ENABLE" |
| 1923 |
dsp_attrs[f'IRNS_IREG{k}A{h}_{4 * k + i}'] = "ENABLE" |
| 1924 |
else: |
| 1925 |
for k in range(2): |
| 1926 |
for h in "LH": |
| 1927 |
dsp_attrs[f'CE{h}MUX_REGMA{k}'] = ce_val |
| 1928 |
dsp_attrs[f'CLK{h}MUX_REGMA{k}'] = clk_val |
| 1929 |
dsp_attrs[f'RST{h}MUX_REGMA{k}'] = reset_val |
| 1930 |
if 'MULT_RESET_MODE' in params: |
| 1931 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1932 |
for k in range(2): |
| 1933 |
for h in "LH": |
| 1934 |
dsp_attrs[f'RSTGEN{h}MUX_REGMA{k}'] = 'SYNC' |
| 1935 |
if parm == 'BREG': |
| 1936 |
if val == '0': |
| 1937 |
for k in range(2): |
| 1938 |
for i, h in _01LH: |
| 1939 |
dsp_attrs[f'IRBY_IREG{k}B{h}_{4 * k + 2 + i}'] = "ENABLE" |
| 1940 |
dsp_attrs[f'IRNS_IREG{k}B{h}_{4 * k + 2 + i}'] = "ENABLE" |
| 1941 |
else: |
| 1942 |
for k in range(2): |
| 1943 |
for h in "LH": |
| 1944 |
dsp_attrs[f'CE{h}MUX_REGMB{k}'] = ce_val |
| 1945 |
dsp_attrs[f'CLK{h}MUX_REGMB{k}'] = clk_val |
| 1946 |
dsp_attrs[f'RST{h}MUX_REGMB{k}'] = reset_val |
| 1947 |
if 'MULT_RESET_MODE' in params: |
| 1948 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1949 |
for k in range(2): |
| 1950 |
for h in "LH": |
| 1951 |
dsp_attrs[f'RSTGEN{h}MUX_REGMB{k}'] = 'SYNC' |
| 1952 |
if parm == 'CREG': |
| 1953 |
if val == '0': |
| 1954 |
for i, h in _01LH: |
| 1955 |
dsp_attrs[f'CIR_BYP{h}_{i}'] = "1" |
| 1956 |
else: |
| 1957 |
for h in "LH": |
| 1958 |
dsp_attrs[f'CE{h}MUX_CREG'] = ce_val |
| 1959 |
dsp_attrs[f'CLK{h}MUX_CREG'] = clk_val |
| 1960 |
dsp_attrs[f'RST{h}MUX_CREG'] = reset_val |
| 1961 |
if 'MULT_RESET_MODE' in params: |
| 1962 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1963 |
for h in "LH": |
| 1964 |
dsp_attrs[f'RSTGEN{h}MUX_REGC0'] = 'SYNC' |
| 1965 |
if parm == 'ASIGN_REG': |
| 1966 |
if val == '0': |
| 1967 |
for k in range(2): |
| 1968 |
dsp_attrs[f'CINNS_{3 * k}'] = "ENABLE" |
| 1969 |
dsp_attrs[f'CINBY_{3 * k}'] = "ENABLE" |
| 1970 |
else: |
| 1971 |
for k in range(2): |
| 1972 |
dsp_attrs[f'CEMUX_ASIGN{k}1'] = ce_val |
| 1973 |
dsp_attrs[f'CLKMUX_ASIGN{k}1'] = clk_val |
| 1974 |
dsp_attrs[f'RSTMUX_ASIGN{k}1'] = reset_val |
| 1975 |
if 'MULT_RESET_MODE' in params: |
| 1976 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1977 |
for k in range(2): |
| 1978 |
dsp_attrs[f'RSTGENMUX_ASIGN{k}1'] = 'SYNC' |
| 1979 |
if parm == 'BSIGN_REG': |
| 1980 |
if val == '0': |
| 1981 |
for k in range(2): |
| 1982 |
dsp_attrs[f'CINNS_{1 + 3 * k}'] = "ENABLE" |
| 1983 |
dsp_attrs[f'CINBY_{1 + 3 * k}'] = "ENABLE" |
| 1984 |
else: |
| 1985 |
for k in range(2): |
| 1986 |
dsp_attrs[f'CEMUX_BSIGN{k}1'] = ce_val |
| 1987 |
dsp_attrs[f'CLKMUX_BSIGN{k}1'] = clk_val |
| 1988 |
dsp_attrs[f'RSTMUX_BSIGN{k}1'] = reset_val |
| 1989 |
if 'MULT_RESET_MODE' in params: |
| 1990 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 1991 |
for k in range(2): |
| 1992 |
dsp_attrs[f'RSTGENMUX_BSIGN{k}1'] = 'SYNC' |
| 1993 |
if parm == 'PIPE_REG': |
| 1994 |
if val == '0': |
| 1995 |
for k in range(2): |
| 1996 |
dsp_attrs[f'CPRNS_{3 * k}'] = "ENABLE" |
| 1997 |
dsp_attrs[f'CPRBY_{3 * k}'] = "ENABLE" |
| 1998 |
dsp_attrs[f'CPRNS_{1 + 3 * k}'] = "ENABLE" |
| 1999 |
dsp_attrs[f'CPRBY_{1 + 3 * k}'] = "ENABLE" |
| 2000 |
for i, h in _01LH: |
| 2001 |
dsp_attrs[f'PPREG{k}_NS{h}_{2 * k + i}'] = "ENABLE" |
| 2002 |
dsp_attrs[f'PPREG{k}_BYP{h}_{2 * k + i}'] = "ENABLE" |
| 2003 |
else: |
| 2004 |
for k in range(2): |
| 2005 |
for i in "AB": |
| 2006 |
dsp_attrs[f'CEMUX_{i}SIGN{k}2'] = ce_val |
| 2007 |
dsp_attrs[f'CLKMUX_{i}SIGN{k}2'] = clk_val |
| 2008 |
dsp_attrs[f'RSTMUX_{i}SIGN{k}2'] = reset_val |
| 2009 |
for i in "LH": |
| 2010 |
dsp_attrs[f'CE{i}MUX_REGP{k}'] = ce_val |
| 2011 |
dsp_attrs[f'CLK{i}MUX_REGP{k}'] = clk_val |
| 2012 |
dsp_attrs[f'RST{i}MUX_REGP{k}'] = reset_val |
| 2013 |
if 'MULT_RESET_MODE' in params: |
| 2014 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2015 |
for k in range(2): |
| 2016 |
dsp_attrs[f'RSTGENMUX_ASIGN{k}2'] = 'SYNC' |
| 2017 |
dsp_attrs[f'RSTGENMUX_BSIGN{k}2'] = 'SYNC' |
| 2018 |
dsp_attrs[f'RSTGENLMUX_REGP{k}'] = 'SYNC' |
| 2019 |
dsp_attrs[f'RSTGENHMUX_REGP{k}'] = 'SYNC' |
| 2020 |
if parm == 'OUT_REG': |
| 2021 |
|
| 2022 |
if mac == 0 and typ == 'MULT36X36': |
| 2023 |
dsp_attrs['OREG0_NSH_1'] = "ENABLE" |
| 2024 |
dsp_attrs['OREG0_BYPH_1'] = "ENABLE" |
| 2025 |
dsp_attrs['OREG1_NSL_2'] = "ENABLE" |
| 2026 |
dsp_attrs['OREG1_BYPL_2'] = "ENABLE" |
| 2027 |
dsp_attrs['OREG1_NSH_3'] = "ENABLE" |
| 2028 |
dsp_attrs['OREG1_BYPH_3'] = "ENABLE" |
| 2029 |
if val == '0': |
| 2030 |
dsp_attrs['OREG0_NSL_0'] = "ENABLE" |
| 2031 |
dsp_attrs['OREG0_BYPL_0'] = "ENABLE" |
| 2032 |
else: |
| 2033 |
dsp_attrs['CELMUX_OREG0'] = ce_val |
| 2034 |
dsp_attrs['CLKLMUX_OREG0'] = clk_val |
| 2035 |
dsp_attrs['RSTLMUX_OREG0'] = reset_val |
| 2036 |
if 'MULT_RESET_MODE' in params: |
| 2037 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2038 |
dsp_attrs['RSTGENLMUX_OREG0'] = 'SYNC' |
| 2039 |
else: |
| 2040 |
if val == '0': |
| 2041 |
for k in range(2): |
| 2042 |
dsp_attrs[f'OREG{k}_NSL_{2 * k}'] = "ENABLE" |
| 2043 |
dsp_attrs[f'OREG{k}_BYPL_{2 * k}'] = "ENABLE" |
| 2044 |
dsp_attrs[f'OREG{k}_NSH_{2 * k + 1}'] = "ENABLE" |
| 2045 |
dsp_attrs[f'OREG{k}_BYPH_{2 * k + 1}'] = "ENABLE" |
| 2046 |
else: |
| 2047 |
for k in range(2): |
| 2048 |
for h in "LH": |
| 2049 |
dsp_attrs[f'CE{h}MUX_OREG{k}'] = ce_val |
| 2050 |
dsp_attrs[f'CLK{h}MUX_OREG{k}'] = clk_val |
| 2051 |
dsp_attrs[f'RST{h}MUX_OREG{k}'] = reset_val |
| 2052 |
if 'MULT_RESET_MODE' in params: |
| 2053 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2054 |
for h in "LH": |
| 2055 |
dsp_attrs[f'RSTGEN{h}MUX_OREG0'] = 'SYNC' |
| 2056 |
dsp_attrs[f'RSTGEN{h}MUX_OREG1'] = 'SYNC' |
| 2057 |
if parm == 'ACCLOAD_REG0': |
| 2058 |
if val == '0': |
| 2059 |
dsp_attrs['CINNS_2'] = "ENABLE" |
| 2060 |
dsp_attrs['CINBY_2'] = "ENABLE" |
| 2061 |
else: |
| 2062 |
dsp_attrs['CEMUX_ALUSEL1'] = ce_val |
| 2063 |
dsp_attrs['CLKMUX_ALUSEL1'] = clk_val |
| 2064 |
dsp_attrs['RSTMUX_ALUSEL1'] = reset_val |
| 2065 |
if 'MULT_RESET_MODE' in params: |
| 2066 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2067 |
dsp_attrs['RSTGENMUX_ALUSEL1'] = 'SYNC' |
| 2068 |
if parm == 'ACCLOAD_REG1': |
| 2069 |
if val == '0': |
| 2070 |
dsp_attrs['CPRNS_2'] = "ENABLE" |
| 2071 |
dsp_attrs['CPRBY_2'] = "ENABLE" |
| 2072 |
else: |
| 2073 |
dsp_attrs['CEMUX_ALUSEL2'] = ce_val |
| 2074 |
dsp_attrs['CLKMUX_ALUSEL2'] = clk_val |
| 2075 |
dsp_attrs['RSTMUX_ALUSEL2'] = reset_val |
| 2076 |
if 'MULT_RESET_MODE' in params: |
| 2077 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2078 |
dsp_attrs['RSTGENMUX_ALUSEL2'] = 'SYNC' |
| 2079 |
|
| 2080 |
def set_alu54d_attrs(db, typ, params, num, attrs, dsp_attrs, mac): |
| 2081 |
attrs_upper(attrs) |
| 2082 |
dsp_attrs['ALU_EN'] = "ENABLE" |
| 2083 |
for i in range(2, 7): |
| 2084 |
dsp_attrs[f'CPRNS_{i}'] = "ENABLE" |
| 2085 |
dsp_attrs[f'CPRBY_{i}'] = "ENABLE" |
| 2086 |
if i > 4: |
| 2087 |
dsp_attrs[f'CINNS_{i}'] = "ENABLE" |
| 2088 |
dsp_attrs[f'CINBY_{i}'] = "ENABLE" |
| 2089 |
|
| 2090 |
dsp_attrs["OPCD_3"] = "1" |
| 2091 |
dsp_attrs["OPCD_9"] = "1" |
| 2092 |
if params['B_ADD_SUB'] == '1': |
| 2093 |
dsp_attrs['OPCD_7'] = "1" |
| 2094 |
|
| 2095 |
|
| 2096 |
if "USE_CASCADE_IN" in attrs: |
| 2097 |
dsp_attrs['CSGIN_EXT'] = "ENABLE" |
| 2098 |
dsp_attrs['CSIGN_PRE'] = "ENABLE" |
| 2099 |
if "USE_CASCADE_OUT" in attrs: |
| 2100 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 2101 |
|
| 2102 |
ce_val = 'UNKNOWN' |
| 2103 |
if int(attrs['CE'], 2): |
| 2104 |
ce_val = f"CEIN{int(attrs['CE'], 2)}" |
| 2105 |
clk_val = 'UNKNOWN' |
| 2106 |
if int(attrs['CLK'], 2): |
| 2107 |
clk_val = f"CLKIN{int(attrs['CLK'], 2)}" |
| 2108 |
reset_val = 'UNKNOWN' |
| 2109 |
if int(attrs['RESET'], 2): |
| 2110 |
reset_val = f"RSTIN{int(attrs['RESET'], 2)}" |
| 2111 |
|
| 2112 |
set_dsp_regs_0(params, {'AREG', 'BREG', 'OUT_REG', 'ACCLOAD_REG'}) |
| 2113 |
for parm, val in params.items(): |
| 2114 |
if parm == 'ALUD_MODE': |
| 2115 |
ival = int(val, 2) |
| 2116 |
if ival == 2: |
| 2117 |
dsp_attrs['OPCD_1'] = "1" |
| 2118 |
dsp_attrs['OPCD_5'] = "1" |
| 2119 |
else: |
| 2120 |
if ival == 0: |
| 2121 |
dsp_attrs['OPCD_6'] = "1" |
| 2122 |
if params['C_ADD_SUB'] == "1": |
| 2123 |
dsp_attrs['OPCD_8'] = "1" |
| 2124 |
else: |
| 2125 |
dsp_attrs['OPCD_5'] = "1" |
| 2126 |
if attrs['NET_ACCLOAD'] == "GND": |
| 2127 |
dsp_attrs['OPCD_0'] = "1" |
| 2128 |
dsp_attrs['OPCD_1'] = "1" |
| 2129 |
elif attrs['NET_ACCLOAD'] == "VCC": |
| 2130 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 2131 |
else: |
| 2132 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 2133 |
dsp_attrs['OPCDDYN_0'] = "ENABLE" |
| 2134 |
dsp_attrs['OPCDDYN_1'] = "ENABLE" |
| 2135 |
dsp_attrs['OPCDDYN_INV_0'] = "ENABLE" |
| 2136 |
dsp_attrs['OPCDDYN_INV_1'] = "ENABLE" |
| 2137 |
|
| 2138 |
if parm == 'OUT_REG': |
| 2139 |
ii = 0 |
| 2140 |
if val == '0': |
| 2141 |
for i, h in [(i, h) for i in range(2) for h in "LH"]: |
| 2142 |
dsp_attrs[f'OREG{i}_NS{h}_{ii}'] = "ENABLE" |
| 2143 |
dsp_attrs[f'OREG{i}_BYP{h}_{ii}'] = "ENABLE" |
| 2144 |
dsp_attrs[f'OR2CIB_EN{i}{h}_{ii}'] = "ENABLE" |
| 2145 |
ii += 1 |
| 2146 |
else: |
| 2147 |
for i, h in [(i, h) for i in range(2) for h in "LH"]: |
| 2148 |
dsp_attrs[f'CE{h}MUX_OREG{i}'] = ce_val |
| 2149 |
dsp_attrs[f'CLK{h}MUX_OREG{i}'] = clk_val |
| 2150 |
dsp_attrs[f'RST{h}MUX_OREG{i}'] = reset_val |
| 2151 |
dsp_attrs[f'OR2CIB_EN{i}{h}_{ii}'] = "ENABLE" |
| 2152 |
ii += 1 |
| 2153 |
|
| 2154 |
if 'ALU_RESET_MODE' in params: |
| 2155 |
if params['ALU_RESET_MODE'] == 'SYNC': |
| 2156 |
for i, h in [(i, h) for h in "HL" for i in range(2)]: |
| 2157 |
dsp_attrs[f'RSTGEN{h}MUX_OREG{i}'] = 'SYNC' |
| 2158 |
if parm == 'AREG': |
| 2159 |
if val == '0': |
| 2160 |
ii = 0 |
| 2161 |
dsp_attrs['CIR_BYPL_0'] = "1" |
| 2162 |
for i, h in [(i, h) for i in "AB" for h in "LH"]: |
| 2163 |
dsp_attrs[f'IRBY_IREG0{i}{h}_{ii}'] = "ENABLE" |
| 2164 |
dsp_attrs[f'IRNS_IREG0{i}{h}_{ii}'] = "ENABLE" |
| 2165 |
ii += 1 |
| 2166 |
else: |
| 2167 |
dsp_attrs['CELMUX_CREG'] = ce_val |
| 2168 |
dsp_attrs['CLKLMUX_CREG'] = clk_val |
| 2169 |
dsp_attrs['RSTLMUX_CREG'] = reset_val |
| 2170 |
for i, h in [(i, h) for i in "AB" for h in "LH"]: |
| 2171 |
dsp_attrs[f'CE{h}MUX_REGM{i}0'] = ce_val |
| 2172 |
dsp_attrs[f'CLK{h}MUX_REGM{i}0'] = clk_val |
| 2173 |
dsp_attrs[f'RST{h}MUX_REGM{i}0'] = reset_val |
| 2174 |
|
| 2175 |
if 'ALU_RESET_MODE' in params: |
| 2176 |
if params['ALU_RESET_MODE'] == 'SYNC': |
| 2177 |
dsp_attrs['RSTGENLMUX_REGC0'] = 'SYNC' |
| 2178 |
for i, h in [(i, h) for i in "AB" for h in "LH"]: |
| 2179 |
dsp_attrs[f'RSTGEN{h}MUX_REGM{i}0'] = 'SYNC' |
| 2180 |
|
| 2181 |
if parm == 'BREG': |
| 2182 |
if val == '0': |
| 2183 |
ii = 4 |
| 2184 |
dsp_attrs['CIR_BYPH_1'] = "1" |
| 2185 |
for i, h in [(i, h) for i in "AB" for h in "LH"]: |
| 2186 |
dsp_attrs[f'IRBY_IREG1{i}{h}_{ii}'] = "ENABLE" |
| 2187 |
dsp_attrs[f'IRNS_IREG1{i}{h}_{ii}'] = "ENABLE" |
| 2188 |
ii += 1 |
| 2189 |
else: |
| 2190 |
dsp_attrs['CEHMUX_CREG'] = ce_val |
| 2191 |
dsp_attrs['CLKHMUX_CREG'] = clk_val |
| 2192 |
dsp_attrs['RSTHMUX_CREG'] = reset_val |
| 2193 |
for i, h in [(i, h) for i in "AB" for h in "LH"]: |
| 2194 |
dsp_attrs[f'CE{h}MUX_REGM{i}1'] = ce_val |
| 2195 |
dsp_attrs[f'CLK{h}MUX_REGM{i}1'] = clk_val |
| 2196 |
dsp_attrs[f'RST{h}MUX_REGM{i}1'] = reset_val |
| 2197 |
|
| 2198 |
if 'ALU_RESET_MODE' in params: |
| 2199 |
if params['ALU_RESET_MODE'] == 'SYNC': |
| 2200 |
dsp_attrs['RSTGENLMUX_REGC0'] = 'SYNC' |
| 2201 |
for i, h in [(i, h) for i in "AB" for h in "LH"]: |
| 2202 |
dsp_attrs[f'RSTGEN{h}MUX_REGM{i}0'] = 'SYNC' |
| 2203 |
|
| 2204 |
if parm == 'ASIGN_REG': |
| 2205 |
if val == '0': |
| 2206 |
dsp_attrs['CINBY_3'] = "ENABLE" |
| 2207 |
dsp_attrs['CINNS_3'] = "ENABLE" |
| 2208 |
else: |
| 2209 |
dsp_attrs['CEMUX_ASIGN11'] = ce_val |
| 2210 |
dsp_attrs['CLKMUX_ASIGN11'] = clk_val |
| 2211 |
dsp_attrs['RSTMUX_ASIGN11'] = reset_val |
| 2212 |
|
| 2213 |
if 'ALU_RESET_MODE' in params: |
| 2214 |
if params['ALU_RESET_MODE'] == 'SYNC': |
| 2215 |
dsp_attrs['RSTGENMUX_ASIGN11'] = 'SYNC' |
| 2216 |
|
| 2217 |
if parm == 'BSIGN_REG': |
| 2218 |
if val == '0': |
| 2219 |
dsp_attrs['CINBY_4'] = "ENABLE" |
| 2220 |
dsp_attrs['CINNS_4'] = "ENABLE" |
| 2221 |
else: |
| 2222 |
dsp_attrs['CEMUX_BSIGN11'] = ce_val |
| 2223 |
dsp_attrs['CLKMUX_BSIGN11'] = clk_val |
| 2224 |
dsp_attrs['RSTMUX_BSIGN11'] = reset_val |
| 2225 |
|
| 2226 |
if 'ALU_RESET_MODE' in params: |
| 2227 |
if params['ALU_RESET_MODE'] == 'SYNC': |
| 2228 |
dsp_attrs['RSTGENMUX_BSIGN11'] = 'SYNC' |
| 2229 |
|
| 2230 |
if parm == 'ACCLOAD_REG': |
| 2231 |
if val == '0': |
| 2232 |
dsp_attrs['CINBY_2'] = "ENABLE" |
| 2233 |
dsp_attrs['CINNS_2'] = "ENABLE" |
| 2234 |
else: |
| 2235 |
dsp_attrs['CEMUX_ALUSEL1'] = ce_val |
| 2236 |
dsp_attrs['CLKMUX_ALUSEL1'] = clk_val |
| 2237 |
dsp_attrs['RSTMUX_ALUSEL1'] = reset_val |
| 2238 |
|
| 2239 |
if 'ALU_RESET_MODE' in params: |
| 2240 |
if params['ALU_RESET_MODE'] == 'SYNC': |
| 2241 |
dsp_attrs['RSTGENMUX_ALUSEL1'] = 'SYNC' |
| 2242 |
|
| 2243 |
dsp_attrs['RCISEL_1'] = "1" |
| 2244 |
dsp_attrs['RCISEL_3'] = "1" |
| 2245 |
|
| 2246 |
|
| 2247 |
def set_padd9_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx): |
| 2248 |
attrs_upper(attrs) |
| 2249 |
dsp_attrs[f'CINBY_{pair_idx + 7}'] = "ENABLE" |
| 2250 |
dsp_attrs[f'CINNS_{pair_idx + 7}'] = "ENABLE" |
| 2251 |
if pair_idx: |
| 2252 |
dsp_attrs['CIR_BYPH_1'] = "1" |
| 2253 |
dsp_attrs['RCISEL_3'] = "1" |
| 2254 |
else: |
| 2255 |
dsp_attrs['CIR_BYPL_0'] = "1" |
| 2256 |
dsp_attrs['RCISEL_1'] = "1" |
| 2257 |
|
| 2258 |
if pair_idx == 0 and 'LAST_IN_CHAIN' in attrs: |
| 2259 |
dsp_attrs['PRAD_FBB1'] = "ENABLE" |
| 2260 |
|
| 2261 |
dsp_attrs[f'PRAD_MUXA0EN_{pair_idx}'] = "ENABLE" |
| 2262 |
|
| 2263 |
if attrs['NET_ASEL'] == 'VCC': |
| 2264 |
dsp_attrs[f'PRAD_MUXA1_{pair_idx * 2}'] = "ENABLE" |
| 2265 |
elif attrs['NET_ASEL'] and attrs['NET_ASEL'] != 'GND': |
| 2266 |
dsp_attrs[f'PRAD_MUXA1_{pair_idx * 2}'] = "ENABLE" |
| 2267 |
dsp_attrs[f'PRAD_MUXA1_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2268 |
|
| 2269 |
|
| 2270 |
ce_val = 'UNKNOWN' |
| 2271 |
if int(attrs['CE'], 2): |
| 2272 |
ce_val = f"CEIN{int(attrs['CE'], 2)}" |
| 2273 |
clk_val = 'UNKNOWN' |
| 2274 |
if int(attrs['CLK'], 2): |
| 2275 |
clk_val = f"CLKIN{int(attrs['CLK'], 2)}" |
| 2276 |
reset_val = 'UNKNOWN' |
| 2277 |
if int(attrs['RESET'], 2): |
| 2278 |
reset_val = f"RSTIN{int(attrs['RESET'], 2)}" |
| 2279 |
|
| 2280 |
if pair_idx: |
| 2281 |
dsp_attrs['MATCH'] = "ENABLE" |
| 2282 |
dsp_attrs['MATCH_SHFEN'] = "ENABLE" |
| 2283 |
|
| 2284 |
dsp_attrs[f'OR2CIB_EN{pair_idx}L_{pair_idx * 2}'] = "ENABLE" |
| 2285 |
|
| 2286 |
set_dsp_regs_0(params, {'AREG', 'BREG'}) |
| 2287 |
for parm, val in params.items(): |
| 2288 |
if parm == 'AREG': |
| 2289 |
if val == '0': |
| 2290 |
if even_odd: |
| 2291 |
dsp_attrs[f'IRNS_PRAD{pair_idx}AH_{pair_idx * 4 + 1}'] = "ENABLE" |
| 2292 |
dsp_attrs[f'IRBY_PRAD{pair_idx}AH_{pair_idx * 4 + 1}'] = "ENABLE" |
| 2293 |
else: |
| 2294 |
dsp_attrs[f'IRNS_PRAD{pair_idx}AL_{pair_idx * 4}'] = "ENABLE" |
| 2295 |
dsp_attrs[f'IRBY_PRAD{pair_idx}AL_{pair_idx * 4}'] = "ENABLE" |
| 2296 |
else: |
| 2297 |
if even_odd: |
| 2298 |
dsp_attrs[f'CEHMUX_REGA{pair_idx}'] = ce_val |
| 2299 |
dsp_attrs[f'CLKHMUX_REGA{pair_idx}'] = clk_val |
| 2300 |
dsp_attrs[f'RSTHMUX_REGA{pair_idx}'] = reset_val |
| 2301 |
if 'PADD_RESET_MODE' in params: |
| 2302 |
if params['PADD_RESET_MODE'] == 'SYNC': |
| 2303 |
dsp_attrs[f'RSTGENHMUX_REGA{pair_idx}'] = 'SYNC' |
| 2304 |
else: |
| 2305 |
dsp_attrs[f'CELMUX_REGMA{pair_idx}'] = ce_val |
| 2306 |
dsp_attrs[f'CLKLMUX_REGMA{pair_idx}'] = clk_val |
| 2307 |
dsp_attrs[f'RSTLMUX_REGMA{pair_idx}'] = reset_val |
| 2308 |
if 'PADD_RESET_MODE' in params: |
| 2309 |
if params['PADD_RESET_MODE'] == 'SYNC': |
| 2310 |
dsp_attrs[f'RSTGENLMUX_REGA{pair_idx}'] = 'SYNC' |
| 2311 |
if parm == 'BREG': |
| 2312 |
if val == '0': |
| 2313 |
if even_odd: |
| 2314 |
dsp_attrs[f'IRNS_PRAD{pair_idx}BH_{pair_idx * 4 + 3}'] = "ENABLE" |
| 2315 |
dsp_attrs[f'IRBY_PRAD{pair_idx}BH_{pair_idx * 4 + 3}'] = "ENABLE" |
| 2316 |
else: |
| 2317 |
dsp_attrs[f'IRNS_PRAD{pair_idx}BL_{pair_idx * 4 + 2}'] = "ENABLE" |
| 2318 |
dsp_attrs[f'IRBY_PRAD{pair_idx}BL_{pair_idx * 4 + 2}'] = "ENABLE" |
| 2319 |
else: |
| 2320 |
if even_odd: |
| 2321 |
dsp_attrs[f'CEHMUX_REGB{pair_idx}'] = ce_val |
| 2322 |
dsp_attrs[f'CLKHMUX_REGB{pair_idx}'] = clk_val |
| 2323 |
dsp_attrs[f'RSTHMUX_REGB{pair_idx}'] = reset_val |
| 2324 |
if 'PADD_RESET_MODE' in params: |
| 2325 |
if params['PADD_RESET_MODE'] == 'SYNC': |
| 2326 |
dsp_attrs[f'RSTGENHMUX_REGB{pair_idx}'] = 'SYNC' |
| 2327 |
else: |
| 2328 |
dsp_attrs[f'CELMUX_REGMA{pair_idx}'] = ce_val |
| 2329 |
dsp_attrs[f'CLKLMUX_REGMA{pair_idx}'] = clk_val |
| 2330 |
dsp_attrs[f'RSTLMUX_REGMA{pair_idx}'] = reset_val |
| 2331 |
if 'PADD_RESET_MODE' in params: |
| 2332 |
if params['PADD_RESET_MODE'] == 'SYNC': |
| 2333 |
dsp_attrs[f'RSTGENLMUX_REGB{pair_idx}'] = 'SYNC' |
| 2334 |
if parm == 'SOREG': |
| 2335 |
if pair_idx: |
| 2336 |
if val == '0': |
| 2337 |
if even_odd: |
| 2338 |
dsp_attrs['IRNS_IRMATCHH_9'] = "ENABLE" |
| 2339 |
dsp_attrs['IRBY_IRMATCHH_9'] = "ENABLE" |
| 2340 |
else: |
| 2341 |
dsp_attrs['IRNS_IRMATCHL_8'] = "ENABLE" |
| 2342 |
dsp_attrs['IRBY_IRMATCHL_8'] = "ENABLE" |
| 2343 |
else: |
| 2344 |
if even_odd: |
| 2345 |
dsp_attrs['CEHMUX_REGSD'] = ce_val |
| 2346 |
dsp_attrs['CLKHMUX_REGSD'] = clk_val |
| 2347 |
dsp_attrs['RSTHMUX_REGSD'] = reset_val |
| 2348 |
if 'PADD_RESET_MODE' in params: |
| 2349 |
if params['PADD_RESET_MODE'] == 'SYNC': |
| 2350 |
dsp_attrs['RSTGENHMUX_REGSD'] = 'SYNC' |
| 2351 |
else: |
| 2352 |
dsp_attrs['CELMUX_REGSD'] = ce_val |
| 2353 |
dsp_attrs['CLKLMUX_REGSD'] = clk_val |
| 2354 |
dsp_attrs['RSTLMUX_REGSD'] = reset_val |
| 2355 |
if 'PADD_RESET_MODE' in params: |
| 2356 |
if params['PADD_RESET_MODE'] == 'SYNC': |
| 2357 |
dsp_attrs['RSTGENLMUX_REGSD'] = 'SYNC' |
| 2358 |
|
| 2359 |
if parm == 'BSEL_MODE': |
| 2360 |
if val == '0': |
| 2361 |
dsp_attrs[f'PRAD_MUXB_{pair_idx * 2}'] = "ENABLE" |
| 2362 |
else: |
| 2363 |
dsp_attrs[f'PRAD_MUXB_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2364 |
|
| 2365 |
|
| 2366 |
dsp_attrs[f'AIRMUX0_{pair_idx}'] = "ENABLE" |
| 2367 |
dsp_attrs[f'BIRMUX0_{pair_idx * 2}'] = "ENABLE" |
| 2368 |
if even_odd: |
| 2369 |
dsp_attrs[f'IRBY_IREG{pair_idx}AH_{pair_idx * 4 + 1}'] = "ENABLE" |
| 2370 |
dsp_attrs[f'IRNS_IREG{pair_idx}AH_{pair_idx * 4 + 1}'] = "ENABLE" |
| 2371 |
dsp_attrs[f'IRBY_IREG{pair_idx}BH_{pair_idx * 4 + 3}'] = "ENABLE" |
| 2372 |
dsp_attrs[f'IRNS_IREG{pair_idx}BH_{pair_idx * 4 + 3}'] = "ENABLE" |
| 2373 |
dsp_attrs[f'CINNS_{pair_idx * 3}'] = "ENABLE" |
| 2374 |
dsp_attrs[f'CINBY_{pair_idx * 3}'] = "ENABLE" |
| 2375 |
dsp_attrs[f'CPRNS_{pair_idx * 3}'] = "ENABLE" |
| 2376 |
dsp_attrs[f'CPRBY_{pair_idx * 3}'] = "ENABLE" |
| 2377 |
dsp_attrs[f'CINNS_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2378 |
dsp_attrs[f'CINBY_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2379 |
dsp_attrs[f'CPRNS_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2380 |
dsp_attrs[f'CPRBY_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2381 |
dsp_attrs[f'PPREG{pair_idx}_NSH_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2382 |
dsp_attrs[f'PPREG{pair_idx}_BYPH_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2383 |
dsp_attrs[f'OREG{pair_idx}_NSH_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2384 |
dsp_attrs[f'OREG{pair_idx}_BYPH_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2385 |
dsp_attrs[f'OR2CIB_EN{pair_idx}H_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2386 |
else: |
| 2387 |
dsp_attrs[f'IRBY_IREG{pair_idx}AL_{pair_idx * 4}'] = "ENABLE" |
| 2388 |
dsp_attrs[f'IRNS_IREG{pair_idx}AL_{pair_idx * 4}'] = "ENABLE" |
| 2389 |
dsp_attrs[f'IRBY_IREG{pair_idx}BL_{pair_idx * 4 + 2}'] = "ENABLE" |
| 2390 |
dsp_attrs[f'IRNS_IREG{pair_idx}BL_{pair_idx * 4 + 2}'] = "ENABLE" |
| 2391 |
dsp_attrs[f'CINNS_{pair_idx * 3}'] = "ENABLE" |
| 2392 |
dsp_attrs[f'CINBY_{pair_idx * 3}'] = "ENABLE" |
| 2393 |
dsp_attrs[f'CPRNS_{pair_idx * 3}'] = "ENABLE" |
| 2394 |
dsp_attrs[f'CPRBY_{pair_idx * 3}'] = "ENABLE" |
| 2395 |
dsp_attrs[f'CINNS_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2396 |
dsp_attrs[f'CINBY_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2397 |
dsp_attrs[f'CPRNS_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2398 |
dsp_attrs[f'CPRBY_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2399 |
dsp_attrs[f'PPREG{pair_idx}_NSL_{pair_idx * 2}'] = "ENABLE" |
| 2400 |
dsp_attrs[f'PPREG{pair_idx}_BYPL_{pair_idx * 2}'] = "ENABLE" |
| 2401 |
dsp_attrs[f'OREG{pair_idx}_NSL_{pair_idx * 2}'] = "ENABLE" |
| 2402 |
dsp_attrs[f'OREG{pair_idx}_BYPL_{pair_idx * 2}'] = "ENABLE" |
| 2403 |
dsp_attrs[f'OR2CIB_EN{pair_idx}L_{pair_idx * 2}'] = "ENABLE" |
| 2404 |
|
| 2405 |
|
| 2406 |
def set_mult12x12_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx): |
| 2407 |
attrs_upper(attrs) |
| 2408 |
|
| 2409 |
dsp_attrs['UNK_192'] = "UNK_23" |
| 2410 |
dsp_attrs['CE0_MUX'] = "CE0_IN" |
| 2411 |
dsp_attrs['CE1_MUX'] = "CE1_IN" |
| 2412 |
if idx: |
| 2413 |
dsp_attrs['MULT12_1_EN'] = "TRUE" |
| 2414 |
else: |
| 2415 |
dsp_attrs['MULT12X12_EN'] = "TRUE" |
| 2416 |
dsp_attrs['ALU_OP0_MUX'] = "MULT0" t. |
| 2417 |
|
| 2418 |
for parm, val in params.items(): |
| 2419 |
if parm in {'AREG_CLK', 'BREG_CLK', 'PREG_CLK', 'AREG_CE', 'BREG_CE', 'PREG_CE', |
| 2420 |
'AREG_RESET', 'BREG_RESET', 'PREG_RESET', }: |
| 2421 |
parm = parm[0] + str(idx) + parm[1:] |
| 2422 |
if val in attrids.dsp_5a_attrvals: |
| 2423 |
dsp_attrs[parm] = val |
| 2424 |
elif parm in {'OREG_CLK', 'OREG_CE', 'OREG_RESET'}: |
| 2425 |
if device not in {'GW5AST-138C'}: |
| 2426 |
parm = parm[0] + str(idx) + parm[1:] |
| 2427 |
if val in attrids.dsp_5a_attrvals: |
| 2428 |
dsp_attrs[parm] = val |
| 2429 |
elif parm not in attrids.dsp_5a_attrids: |
| 2430 |
raise Exception(f"Unknown {parm} parameter for {typ}.") |
| 2431 |
elif val in attrids.dsp_5a_attrvals: |
| 2432 |
dsp_attrs[parm] = val |
| 2433 |
|
| 2434 |
|
| 2435 |
|
| 2436 |
def set_multalu27x18_attrs(db, typ, params, num, attrs, dsp_attrs, mac): |
| 2437 |
attrs_upper(attrs) |
| 2438 |
|
| 2439 |
|
| 2440 |
dsp_attrs['UNK_192'] = "UNK_23" |
| 2441 |
dsp_attrs['CE0_MUX'] = "CE0_IN" |
| 2442 |
dsp_attrs['CE1_MUX'] = "CE1_IN" |
| 2443 |
dsp_attrs['ALU_OP0_MUX'] = "MULT0" |
| 2444 |
dsp_attrs['ALU'] = "ENABLE" |
| 2445 |
dsp_attrs['UNK_CLK_191'] = "CLK0" |
| 2446 |
|
| 2447 |
if "USE_CASCADE_OUT" in attrs: |
| 2448 |
dsp_attrs['CASO'] = "ENABLE" |
| 2449 |
|
| 2450 |
|
| 2451 |
mult27x36_params = {} |
| 2452 |
if "MULT27X36_MAIN" in attrs or "MULT27X36_AUX" in attrs: |
| 2453 |
mult27x36_params = { |
| 2454 |
'C_IREG_CLK': "BYPASS", 'C_IREG_CE': "CE0", 'C_IREG_RESET': "RESET0", |
| 2455 |
'C_PREG_CLK': "BYPASS", 'C_PREG_CE': "CE0", 'C_PREG_RESET': "RESET0", |
| 2456 |
'ADDSUB0_IREG_CLK': "BYPASS", 'ADDSUB0_IREG_CE': "CE0", 'ADDSUB0_IREG_RESET': "RESET0", |
| 2457 |
'ADDSUB1_IREG_CLK': "BYPASS", 'ADDSUB1_IREG_CE': "CE0", 'ADDSUB1_IREG_RESET': "RESET0", |
| 2458 |
'CSEL_IREG_CLK': "BYPASS", 'CSEL_IREG_CE': "CE0", 'CSEL_IREG_RESET': "RESET0", |
| 2459 |
'CASISEL_IREG_CLK': "BYPASS", 'CASISEL_IREG_CE': "CE0", 'CASISEL_IREG_RESET': "RESET0", |
| 2460 |
'ACCSEL_IREG_CLK': "BYPASS", 'ACCSEL_IREG_CE': "CE0", 'ACCSEL_IREG_RESET': "RESET0", |
| 2461 |
'ADDSUB0_PREG_CLK': "BYPASS", 'ADDSUB0_PREG_CE': "CE0", 'ADDSUB0_PREG_RESET': "RESET0", |
| 2462 |
'ADDSUB1_PREG_CLK': "BYPASS", 'ADDSUB1_PREG_CE': "CE0", 'ADDSUB1_PREG_RESET': "RESET0", |
| 2463 |
'CSEL_PREG_CLK': "BYPASS", 'CSEL_PREG_CE': "CE0", 'CSEL_PREG_RESET': "RESET0", |
| 2464 |
'CASISEL_PREG_CLK': "BYPASS", 'CASISEL_PREG_CE': "CE0", 'CASISEL_PREG_RESET': "RESET0", |
| 2465 |
'ACCSEL_PREG_CLK': "BYPASS", 'ACCSEL_PREG_CE': "CE0", 'ACCSEL_PREG_RESET': "RESET0", |
| 2466 |
'FB_PREG_EN': "FALSE", 'SOA_PREG_EN': "FALSE", 'PRE_LOAD': "0", |
| 2467 |
'DYN_A_SEL': "FALSE", 'A_SEL': "0", 'DYN_ADD_SUB_0': "FALSE", 'ADD_SUB_0': "0", |
| 2468 |
'DYN_ADD_SUB_1': "FALSE", 'ADD_SUB_1': "0", 'DYN_C_SEL': "FALSE", 'C_SEL': "0", |
| 2469 |
'DYN_CASI_SEL': "FALSE", 'CASI_SEL': "0", 'MULT12X12_EN': "FALSE", |
| 2470 |
} |
| 2471 |
if "MULT27X36_MAIN" in attrs: |
| 2472 |
dsp_attrs['MULT27X36'] = 'ENABLE' |
| 2473 |
else: |
| 2474 |
mult27x36_params['CASI_SEL'] = "1" |
| 2475 |
|
| 2476 |
for parm, val in itertools.chain(params.items(), mult27x36_params.items()): |
| 2477 |
if parm in {'OREG_CLK', 'OREG_CE', 'OREG_RESET'}: |
| 2478 |
if device not in {'GW5AST-138C'}: |
| 2479 |
dsp_attrs[f'{parm[0]}0{parm[1:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2480 |
dsp_attrs[f'{parm[0]}1{parm[1:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2481 |
elif parm in {'AREG_CLK', 'AREG_CE', 'AREG_RESET', 'BREG_CLK', 'BREG_CE', 'BREG_RESET',}: |
| 2482 |
dsp_attrs[f'{parm[0]}0{parm[1:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2483 |
elif parm in {'DREG_CLK', 'DREG_CE', 'DREG_RESET',}: |
| 2484 |
dsp_attrs[f'A1{parm[1:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2485 |
dsp_attrs[f'B1{parm[1:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2486 |
elif parm.startswith('DYN_CASI_SEL'): |
| 2487 |
|
| 2488 |
dsp_attrs[parm] = val |
| 2489 |
if val == 'TRUE': |
| 2490 |
dsp_attrs['CASISEL_PAD'] = 'INV' |
| 2491 |
elif parm.startswith('PREG'): |
| 2492 |
dsp_attrs[f'P0{parm[1:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2493 |
elif parm.startswith('ACCSEL'): |
| 2494 |
dsp_attrs[f'ACCSEL_0{parm[6:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2495 |
dsp_attrs[f'ACCSEL_1{parm[6:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2496 |
elif parm == 'PRE_LOAD': |
| 2497 |
pre_load = str(val) |
| 2498 |
if len(pre_load) > 58: |
| 2499 |
pre_load = pre_load[-48:] |
| 2500 |
else: |
| 2501 |
pre_load = pre_load * (48 // len(val)) |
| 2502 |
for bitnum, pre_loadbit in enumerate(pre_load[::-1]): |
| 2503 |
dsp_attrs[f'PRELOAD_BIT_{bitnum}'] = pre_loadbit |
| 2504 |
elif parm not in attrids.dsp_5a_attrids: |
| 2505 |
raise Exception(f"Unknown {parm} parameter for {typ}.") |
| 2506 |
elif val in attrids.dsp_5a_attrvals: |
| 2507 |
dsp_attrs[parm] = val |
| 2508 |
|
| 2509 |
|
| 2510 |
|
| 2511 |
def set_multaddalu12x12_attrs(db, typ, params, num, attrs, dsp_attrs, mac): |
| 2512 |
attrs_upper(attrs) |
| 2513 |
|
| 2514 |
|
| 2515 |
dsp_attrs['UNK_192'] = "UNK_23" |
| 2516 |
dsp_attrs['CE0_MUX'] = "CE0_IN" |
| 2517 |
dsp_attrs['CE1_MUX'] = "CE1_IN" |
| 2518 |
dsp_attrs['MULT12_1_EN'] = "TRUE" |
| 2519 |
dsp_attrs['MULT12X12_EN'] = "TRUE" |
| 2520 |
dsp_attrs['ALU_OP0_MUX'] = "MULT0" |
| 2521 |
dsp_attrs['ALU'] = "ENABLE" |
| 2522 |
dsp_attrs['UNK_CLK_191'] = "CLK0" |
| 2523 |
|
| 2524 |
if "USE_CASCADE_OUT" in attrs: |
| 2525 |
dsp_attrs['CASO'] = "ENABLE" |
| 2526 |
|
| 2527 |
for parm, val in params.items(): |
| 2528 |
if parm in {'OREG_CLK', 'OREG_CE', 'OREG_RESET'}: |
| 2529 |
if device not in {'GW5AST-138C'}: |
| 2530 |
dsp_attrs[f'{parm[0]}0{parm[1:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2531 |
dsp_attrs[f'{parm[0]}1{parm[1:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2532 |
elif parm.startswith('DYN_CASI_SEL'): |
| 2533 |
|
| 2534 |
dsp_attrs[parm] = val |
| 2535 |
if val == 'TRUE': |
| 2536 |
dsp_attrs['CASISEL_PAD'] = 'INV' |
| 2537 |
elif parm.startswith('PREG'): |
| 2538 |
parm = f'P{parm[4]}REG{parm[5:]}' |
| 2539 |
if val in attrids.dsp_5a_attrvals: |
| 2540 |
dsp_attrs[parm] = val |
| 2541 |
elif parm.startswith('ACCSEL'): |
| 2542 |
dsp_attrs[f'ACCSEL_0{parm[6:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2543 |
dsp_attrs[f'ACCSEL_1{parm[6:]}'] = val if val in attrids.dsp_5a_attrvals else 'UNKNOWN' |
| 2544 |
elif parm == 'PRE_LOAD': |
| 2545 |
pre_load = str(val) |
| 2546 |
if len(pre_load) > 58: |
| 2547 |
pre_load = pre_load[-48:] |
| 2548 |
else: |
| 2549 |
pre_load = pre_load * (48 // len(val)) |
| 2550 |
for bitnum, pre_loadbit in enumerate(pre_load[::-1]): |
| 2551 |
dsp_attrs[f'PRELOAD_BIT_{bitnum}'] = pre_loadbit |
| 2552 |
elif parm not in attrids.dsp_5a_attrids: |
| 2553 |
raise Exception(f"Unknown {parm} parameter for {typ}.") |
| 2554 |
elif val in attrids.dsp_5a_attrvals: |
| 2555 |
dsp_attrs[parm] = val |
| 2556 |
|
| 2557 |
|
| 2558 |
|
| 2559 |
def set_mult9x9_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx): |
| 2560 |
attrs_upper(attrs) |
| 2561 |
ce_val = 'UNKNOWN' |
| 2562 |
if int(attrs['CE'], 2): |
| 2563 |
ce_val = f"CEIN{int(attrs['CE'], 2)}" |
| 2564 |
clk_val = 'UNKNOWN' |
| 2565 |
if int(attrs['CLK'], 2): |
| 2566 |
clk_val = f"CLKIN{int(attrs['CLK'], 2)}" |
| 2567 |
reset_val = 'UNKNOWN' |
| 2568 |
if int(attrs['RESET'], 2): |
| 2569 |
reset_val = f"RSTIN{int(attrs['RESET'], 2)}" |
| 2570 |
|
| 2571 |
dsp_attrs[f'IRASHFEN_{pair_idx}'] = "1" |
| 2572 |
dsp_attrs[f'IRBSHFEN_{pair_idx}'] = "1" |
| 2573 |
if pair_idx: |
| 2574 |
dsp_attrs['MATCH_SHFEN'] = "ENABLE" |
| 2575 |
if even_odd: |
| 2576 |
dsp_attrs[f'OR2CIB_EN{pair_idx}H_{idx}'] = "ENABLE" |
| 2577 |
else: |
| 2578 |
dsp_attrs[f'OR2CIB_EN{pair_idx}L_{idx}'] = "ENABLE" |
| 2579 |
|
| 2580 |
if attrs['NET_ASEL'] == 'VCC': |
| 2581 |
dsp_attrs[f'AIRMUX1_{pair_idx}'] = "ENABLE" |
| 2582 |
elif attrs['NET_ASEL'] and attrs['NET_ASEL'] != 'GND': |
| 2583 |
dsp_attrs[f'AIRMUX1_SEL_{pair_idx}'] = "ENABLE" |
| 2584 |
if attrs['NET_BSEL'] == 'VCC': |
| 2585 |
dsp_attrs[f'BIRMUX1_{pair_idx * 2}'] = "ENABLE" |
| 2586 |
elif attrs['NET_BSEL'] and attrs['NET_BSEL'] != 'GND': |
| 2587 |
dsp_attrs[f'BIRMUX0_{pair_idx * 2}'] = "ENABLE" |
| 2588 |
dsp_attrs[f'BIRMUX0_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2589 |
dsp_attrs[f'BIRMUX1_{pair_idx * 2}'] = "ENABLE" |
| 2590 |
dsp_attrs[f'BIRMUX1_{pair_idx * 2 + 1}'] = "ENABLE" |
| 2591 |
|
| 2592 |
set_dsp_regs_0(params, {'AREG', 'BREG', 'OUT_REG', 'PIPE_REG', 'ASIGN_REG', 'BSIGN_REG', 'SOA_REG'}) |
| 2593 |
for parm, val in params.items(): |
| 2594 |
if parm == 'AREG': |
| 2595 |
if val == '0': |
| 2596 |
if even_odd: |
| 2597 |
dsp_attrs[f'IRBY_IREG{pair_idx}AH_{pair_idx * 4 + 1}'] = "ENABLE" |
| 2598 |
dsp_attrs[f'IRNS_IREG{pair_idx}AH_{pair_idx * 4 + 1}'] = "ENABLE" |
| 2599 |
else: |
| 2600 |
dsp_attrs[f'IRBY_IREG{pair_idx}AL_{pair_idx * 4}'] = "ENABLE" |
| 2601 |
dsp_attrs[f'IRNS_IREG{pair_idx}AL_{pair_idx * 4}'] = "ENABLE" |
| 2602 |
else: |
| 2603 |
if even_odd: |
| 2604 |
dsp_attrs[f'CEHMUX_REGMA{pair_idx}'] = ce_val |
| 2605 |
dsp_attrs[f'CLKHMUX_REGMA{pair_idx}'] = clk_val |
| 2606 |
dsp_attrs[f'RSTHMUX_REGMA{pair_idx}'] = reset_val |
| 2607 |
if 'MULT_RESET_MODE' in params: |
| 2608 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2609 |
dsp_attrs[f'RSTGENHMUX_REGMA{pair_idx}'] = 'SYNC' |
| 2610 |
else: |
| 2611 |
dsp_attrs[f'CELMUX_REGMA{pair_idx}'] = ce_val |
| 2612 |
dsp_attrs[f'CLKLMUX_REGMA{pair_idx}'] = clk_val |
| 2613 |
dsp_attrs[f'RSTLMUX_REGMA{pair_idx}'] = reset_val |
| 2614 |
if 'MULT_RESET_MODE' in params: |
| 2615 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2616 |
dsp_attrs[f'RSTGENLMUX_REGMA{pair_idx}'] = 'SYNC' |
| 2617 |
if parm == 'BREG': |
| 2618 |
if val == '0': |
| 2619 |
if even_odd: |
| 2620 |
dsp_attrs[f'IRBY_IREG{pair_idx}BH_{pair_idx * 4 + 3}'] = "ENABLE" |
| 2621 |
dsp_attrs[f'IRNS_IREG{pair_idx}BH_{pair_idx * 4 + 3}'] = "ENABLE" |
| 2622 |
else: |
| 2623 |
dsp_attrs[f'IRBY_IREG{pair_idx}BL_{pair_idx * 4 + 2}'] = "ENABLE" |
| 2624 |
dsp_attrs[f'IRNS_IREG{pair_idx}BL_{pair_idx * 4 + 2}'] = "ENABLE" |
| 2625 |
else: |
| 2626 |
if even_odd: |
| 2627 |
dsp_attrs[f'CEHMUX_REGMB{pair_idx}'] = ce_val |
| 2628 |
dsp_attrs[f'CLKHMUX_REGMB{pair_idx}'] = clk_val |
| 2629 |
dsp_attrs[f'RSTHMUX_REGMB{pair_idx}'] = reset_val |
| 2630 |
if 'MULT_RESET_MODE' in params: |
| 2631 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2632 |
dsp_attrs[f'RSTGENHMUX_REGMB{pair_idx}'] = 'SYNC' |
| 2633 |
else: |
| 2634 |
dsp_attrs[f'CELMUX_REGMB{pair_idx}'] = ce_val |
| 2635 |
dsp_attrs[f'CLKLMUX_REGMB{pair_idx}'] = clk_val |
| 2636 |
dsp_attrs[f'RSTLMUX_REGMB{pair_idx}'] = reset_val |
| 2637 |
if 'MULT_RESET_MODE' in params: |
| 2638 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2639 |
dsp_attrs[f'RSTGENLMUX_REGMB{pair_idx}'] = 'SYNC' |
| 2640 |
if parm == 'ASIGN_REG': |
| 2641 |
if val == '0': |
| 2642 |
dsp_attrs[f'CINNS_{pair_idx * 3}'] = "ENABLE" |
| 2643 |
dsp_attrs[f'CINBY_{pair_idx * 3}'] = "ENABLE" |
| 2644 |
else: |
| 2645 |
dsp_attrs[f'CEMUX_ASIGN{pair_idx}1'] = ce_val |
| 2646 |
dsp_attrs[f'CLKMUX_ASIGN{pair_idx}1'] = clk_val |
| 2647 |
dsp_attrs[f'RSTMUX_ASIGN{pair_idx}1'] = reset_val |
| 2648 |
if 'MULT_RESET_MODE' in params: |
| 2649 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2650 |
dsp_attrs[f'RSTGENMUX_ASIGN{pair_idx}1'] = 'SYNC' |
| 2651 |
if parm == 'BSIGN_REG': |
| 2652 |
if val == '0': |
| 2653 |
dsp_attrs[f'CINNS_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2654 |
dsp_attrs[f'CINBY_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2655 |
else: |
| 2656 |
dsp_attrs[f'CEMUX_BSIGN{pair_idx}1'] = ce_val |
| 2657 |
dsp_attrs[f'CLKMUX_BSIGN{pair_idx}1'] = clk_val |
| 2658 |
dsp_attrs[f'RSTMUX_BSIGN{pair_idx}1'] = reset_val |
| 2659 |
if 'MULT_RESET_MODE' in params: |
| 2660 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2661 |
dsp_attrs[f'RSTGENMUX_BSIGN{pair_idx}1'] = 'SYNC' |
| 2662 |
if parm == 'PIPE_REG': |
| 2663 |
if val == '0': |
| 2664 |
dsp_attrs[f'CPRNS_{pair_idx * 3}'] = "ENABLE" |
| 2665 |
dsp_attrs[f'CPRBY_{pair_idx * 3}'] = "ENABLE" |
| 2666 |
dsp_attrs[f'CPRNS_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2667 |
dsp_attrs[f'CPRBY_{pair_idx * 3 + 1}'] = "ENABLE" |
| 2668 |
if even_odd: |
| 2669 |
dsp_attrs[f'PPREG{pair_idx}_NSH_{idx}'] = "ENABLE" |
| 2670 |
dsp_attrs[f'PPREG{pair_idx}_BYPH_{idx}'] = "ENABLE" |
| 2671 |
else: |
| 2672 |
dsp_attrs[f'PPREG{pair_idx}_NSL_{idx}'] = "ENABLE" |
| 2673 |
dsp_attrs[f'PPREG{pair_idx}_BYPL_{idx}'] = "ENABLE" |
| 2674 |
else: |
| 2675 |
dsp_attrs[f'CEMUX_ASIGN{pair_idx}2'] = ce_val |
| 2676 |
dsp_attrs[f'CLKMUX_ASIGN{pair_idx}2'] = clk_val |
| 2677 |
dsp_attrs[f'RSTMUX_ASIGN{pair_idx}2'] = reset_val |
| 2678 |
dsp_attrs[f'CEMUX_BSIGN{pair_idx}2'] = ce_val |
| 2679 |
dsp_attrs[f'CLKMUX_BSIGN{pair_idx}2'] = clk_val |
| 2680 |
dsp_attrs[f'RSTMUX_BSIGN{pair_idx}2'] = reset_val |
| 2681 |
if even_odd: |
| 2682 |
dsp_attrs[f'CEHMUX_REGP{pair_idx}'] = ce_val |
| 2683 |
dsp_attrs[f'CLKHMUX_REGP{pair_idx}'] = clk_val |
| 2684 |
dsp_attrs[f'RSTHMUX_REGP{pair_idx}'] = reset_val |
| 2685 |
else: |
| 2686 |
dsp_attrs[f'CELMUX_REGP{pair_idx}'] = ce_val |
| 2687 |
dsp_attrs[f'CLKLMUX_REGP{pair_idx}'] = clk_val |
| 2688 |
dsp_attrs[f'RSTLMUX_REGP{pair_idx}'] = reset_val |
| 2689 |
if 'MULT_RESET_MODE' in params: |
| 2690 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2691 |
dsp_attrs[f'RSTGENMUX_ASIGN{pair_idx}2'] = 'SYNC' |
| 2692 |
dsp_attrs[f'RSTGENMUX_BSIGN{pair_idx}2'] = 'SYNC' |
| 2693 |
if even_odd: |
| 2694 |
dsp_attrs[f'RSTGENHMUX_REGP{pair_idx}'] = 'SYNC' |
| 2695 |
else: |
| 2696 |
dsp_attrs[f'RSTGENLMUX_REGP{pair_idx}'] = 'SYNC' |
| 2697 |
if parm == 'OUT_REG': |
| 2698 |
if val == '0': |
| 2699 |
if even_odd: |
| 2700 |
dsp_attrs[f'OREG{pair_idx}_BYPH_{idx}'] = "ENABLE" |
| 2701 |
dsp_attrs[f'OREG{pair_idx}_NSH_{idx}'] = "ENABLE" |
| 2702 |
else: |
| 2703 |
dsp_attrs[f'OREG{pair_idx}_BYPL_{idx}'] = "ENABLE" |
| 2704 |
dsp_attrs[f'OREG{pair_idx}_NSL_{idx}'] = "ENABLE" |
| 2705 |
else: |
| 2706 |
if even_odd: |
| 2707 |
dsp_attrs[f'CEHMUX_OREG{pair_idx}'] = ce_val |
| 2708 |
dsp_attrs[f'CLKHMUX_OREG{pair_idx}'] = clk_val |
| 2709 |
dsp_attrs[f'RSTHMUX_OREG{pair_idx}'] = reset_val |
| 2710 |
else: |
| 2711 |
dsp_attrs[f'CELMUX_OREG{pair_idx}'] = ce_val |
| 2712 |
dsp_attrs[f'CLKLMUX_OREG{pair_idx}'] = clk_val |
| 2713 |
dsp_attrs[f'RSTLMUX_OREG{pair_idx}'] = reset_val |
| 2714 |
if 'MULT_RESET_MODE' in params: |
| 2715 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2716 |
if even_odd: |
| 2717 |
dsp_attrs[f'RSTGENHMUX_OREG{pair_idx}'] = 'SYNC' |
| 2718 |
else: |
| 2719 |
dsp_attrs[f'RSTGENLMUX_OREG{pair_idx}'] = 'SYNC' |
| 2720 |
|
| 2721 |
if parm == 'SOA_REG' and pair_idx: |
| 2722 |
if val == '0': |
| 2723 |
if pair_idx: |
| 2724 |
if even_odd: |
| 2725 |
dsp_attrs['IRBY_IRMATCHH_9'] = "ENABLE" |
| 2726 |
dsp_attrs['IRNS_IRMATCHH_9'] = "ENABLE" |
| 2727 |
else: |
| 2728 |
dsp_attrs['IRBY_IRMATCHL_8'] = "ENABLE" |
| 2729 |
dsp_attrs['IRNS_IRMATCHL_8'] = "ENABLE" |
| 2730 |
else: |
| 2731 |
if even_odd: |
| 2732 |
dsp_attrs[f'CEHMUX_REGSD'] = ce_val |
| 2733 |
dsp_attrs[f'CLKHMUX_REGSD'] = clk_val |
| 2734 |
dsp_attrs[f'RSTHMUX_REGSD'] = reset_val |
| 2735 |
else: |
| 2736 |
dsp_attrs[f'CELMUX_REGSD'] = ce_val |
| 2737 |
dsp_attrs[f'CLKLMUX_REGSD'] = clk_val |
| 2738 |
dsp_attrs[f'RSTLMUX_REGSD'] = reset_val |
| 2739 |
if 'MULT_RESET_MODE' in params: |
| 2740 |
if params['MULT_RESET_MODE'] == 'SYNC': |
| 2741 |
if even_odd: |
| 2742 |
dsp_attrs[f'RSTGENHMUX_REGSD'] = 'SYNC' |
| 2743 |
else: |
| 2744 |
dsp_attrs[f'RSTGENLMUX_REGSD'] = 'SYNC' |
| 2745 |
|
| 2746 |
def set_dsp_attrs(db, typ, params, num, attrs): |
| 2747 |
dsp_attrs = {} |
| 2748 |
mac = int(num[0]) |
| 2749 |
idx = int(num[1]) |
| 2750 |
even_odd = idx & 1 |
| 2751 |
pair_idx = idx // 2 |
| 2752 |
|
| 2753 |
|
| 2754 |
if typ in {"PADD9", "MULT9X9"}: |
| 2755 |
dsp_attrs['M9MODE_EN'] = "ENABLE" |
| 2756 |
|
| 2757 |
if typ == "PADD9": |
| 2758 |
set_padd9_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx) |
| 2759 |
elif typ == "PADD18": |
| 2760 |
idx *= 2 |
| 2761 |
even_odd = idx & 1 |
| 2762 |
pair_idx = idx // 2 |
| 2763 |
set_padd9_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx) |
| 2764 |
idx += 1 |
| 2765 |
even_odd = idx & 1 |
| 2766 |
pair_idx = idx // 2 |
| 2767 |
set_padd9_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx) |
| 2768 |
elif typ == "MULT9X9": |
| 2769 |
set_mult9x9_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx) |
| 2770 |
elif typ == "MULT12X12": |
| 2771 |
set_mult12x12_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx) |
| 2772 |
elif typ == "MULT18X18": |
| 2773 |
idx *= 2 |
| 2774 |
even_odd = idx & 1 |
| 2775 |
pair_idx = idx // 2 |
| 2776 |
set_mult9x9_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx) |
| 2777 |
idx += 1 |
| 2778 |
even_odd = idx & 1 |
| 2779 |
pair_idx = idx // 2 |
| 2780 |
set_mult9x9_attrs(db, typ, params, num, attrs, dsp_attrs, mac, idx, even_odd, pair_idx) |
| 2781 |
elif typ == "ALU54D": |
| 2782 |
set_alu54d_attrs(db, typ, params, num, attrs, dsp_attrs, mac) |
| 2783 |
elif typ == "MULTALU18X18": |
| 2784 |
set_multalu18x18_attrs(db, typ, params, num, attrs, dsp_attrs, mac) |
| 2785 |
elif typ == "MULTALU27X18": |
| 2786 |
set_multalu27x18_attrs(db, typ, params, num, attrs, dsp_attrs, mac) |
| 2787 |
elif typ == "MULTALU36X18": |
| 2788 |
set_multalu36x18_attrs(db, typ, params, num, attrs, dsp_attrs, mac) |
| 2789 |
elif typ == "MULTADDALU12X12": |
| 2790 |
set_multaddalu12x12_attrs(db, typ, params, num, attrs, dsp_attrs, mac) |
| 2791 |
elif typ == "MULTADDALU18X18": |
| 2792 |
set_multaddalu18x18_attrs(db, typ, params, num, attrs, dsp_attrs, mac) |
| 2793 |
|
| 2794 |
fin_attrs = set() |
| 2795 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 2796 |
for attr, val in dsp_attrs.items(): |
| 2797 |
if isinstance(val, str): |
| 2798 |
val = attrids.dsp_5a_attrvals[val] |
| 2799 |
add_attr_val(db, '5A_DSP', fin_attrs, attrids.dsp_5a_attrids[attr], val) |
| 2800 |
else: |
| 2801 |
for attr, val in dsp_attrs.items(): |
| 2802 |
if isinstance(val, str): |
| 2803 |
val = attrids.dsp_attrvals[val] |
| 2804 |
add_attr_val(db, 'DSP', fin_attrs, attrids.dsp_attrids[attr], val) |
| 2805 |
return fin_attrs |
| 2806 |
|
| 2807 |
|
| 2808 |
def set_dsp_mult36x36_attrs(db, typ, params, attrs): |
| 2809 |
attrs_upper(attrs) |
| 2810 |
attrs['NET_ASEL'] = 'GND' |
| 2811 |
attrs['NET_BSEL'] = 'GND' |
| 2812 |
|
| 2813 |
set_dsp_regs_0(params, {'AREG', 'BREG', 'ASIGN_REG', 'BSIGN_REG'}) |
| 2814 |
|
| 2815 |
dsp_attrs = {} |
| 2816 |
params['MULTALU36X18_MODE'] = "1" |
| 2817 |
attrs['NET_ACCLOAD'] = "GND" |
| 2818 |
params['OUT_REG'] = params.get('OUT0_REG', "0") |
| 2819 |
params['ACCLOAD_REG0'] = "0" |
| 2820 |
params['ACCLOAD_REG1'] = "0" |
| 2821 |
set_multalu36x18_attrs(db, typ, params, "00", attrs, dsp_attrs, 0) |
| 2822 |
dsp_attrs['OR2CASCADE_EN'] = "ENABLE" |
| 2823 |
dsp_attrs['IRNS_IRMATCHH_9'] = "ENABLE" |
| 2824 |
dsp_attrs['IRNS_IRMATCHL_8'] = "ENABLE" |
| 2825 |
dsp_attrs['IRBY_IRMATCHH_9'] = "ENABLE" |
| 2826 |
dsp_attrs['IRBY_IRMATCHL_8'] = "ENABLE" |
| 2827 |
dsp_attrs['MATCH_SHFEN'] = "ENABLE" |
| 2828 |
dsp_attrs.pop('IRASHFEN_0', None) |
| 2829 |
dsp_attrs.pop('RCISEL_1', None) |
| 2830 |
dsp_attrs.pop('RCISEL_3', None) |
| 2831 |
|
| 2832 |
ret_attrs = [] |
| 2833 |
fin_attrs = set() |
| 2834 |
for attr, val in dsp_attrs.items(): |
| 2835 |
if isinstance(val, str): |
| 2836 |
val = attrids.dsp_attrvals[val] |
| 2837 |
add_attr_val(db, 'DSP', fin_attrs, attrids.dsp_attrids[attr], val) |
| 2838 |
ret_attrs.append(fin_attrs) |
| 2839 |
|
| 2840 |
|
| 2841 |
dsp_attrs = {} |
| 2842 |
params['MULTALU36X18_MODE'] = "10" |
| 2843 |
params['OUT_REG'] = params.get('OUT1_REG', "0") |
| 2844 |
set_multalu36x18_attrs(db, typ, params, "00", attrs, dsp_attrs, 1) |
| 2845 |
|
| 2846 |
dsp_attrs['CSGIN_EXT'] = "ENABLE" |
| 2847 |
dsp_attrs['CSIGN_PRE'] = "ENABLE" |
| 2848 |
dsp_attrs['IRNS_IRMATCHH_9'] = "ENABLE" |
| 2849 |
dsp_attrs['IRNS_IRMATCHL_8'] = "ENABLE" |
| 2850 |
dsp_attrs['IRBY_IRMATCHH_9'] = "ENABLE" |
| 2851 |
dsp_attrs['IRBY_IRMATCHL_8'] = "ENABLE" |
| 2852 |
dsp_attrs['MATCH_SHFEN'] = "ENABLE" |
| 2853 |
dsp_attrs.pop('IRASHFEN_0', None) |
| 2854 |
dsp_attrs.pop('RCISEL_1', None) |
| 2855 |
dsp_attrs.pop('RCISEL_3', None) |
| 2856 |
dsp_attrs.pop('OPCD_5', None) |
| 2857 |
dsp_attrs['OPCD_4'] = "1" |
| 2858 |
|
| 2859 |
fin_attrs = set() |
| 2860 |
for attr, val in dsp_attrs.items(): |
| 2861 |
if isinstance(val, str): |
| 2862 |
val = attrids.dsp_attrvals[val] |
| 2863 |
add_attr_val(db, 'DSP', fin_attrs, attrids.dsp_attrids[attr], val) |
| 2864 |
ret_attrs.append(fin_attrs) |
| 2865 |
return ret_attrs |
| 2866 |
|
| 2867 |
def set_osc_attrs(db, typ, params): |
| 2868 |
attrs_upper(params) |
| 2869 |
osc_attrs = dict() |
| 2870 |
for param, val in params.items(): |
| 2871 |
if param == 'FREQ_DIV': |
| 2872 |
fdiv = int(val, 2) |
| 2873 |
if fdiv % 2 == 1: |
| 2874 |
if fdiv == 3 and device in {'GW5A-25A'}: |
| 2875 |
fdiv = 0 |
| 2876 |
else: |
| 2877 |
raise Exception(f"Divisor of {typ} must be even") |
| 2878 |
osc_attrs['MCLKCIB'] = fdiv |
| 2879 |
osc_attrs['MCLKCIB_EN'] = "ENABLE" |
| 2880 |
continue |
| 2881 |
if param == 'REGULATOR_EN': |
| 2882 |
reg = int(val, 2) |
| 2883 |
if reg == 1: |
| 2884 |
osc_attrs['OSCREG'] = "ENABLE" |
| 2885 |
continue |
| 2886 |
if typ not in {'OSCA'}: |
| 2887 |
osc_attrs['NORMAL'] = "ENABLE" |
| 2888 |
if typ not in {'OSC', 'OSCW'}: |
| 2889 |
osc_attrs['USERPOWER_SAVE'] = 'ENABLE' |
| 2890 |
|
| 2891 |
fin_attrs = set() |
| 2892 |
for attr, val in osc_attrs.items(): |
| 2893 |
if isinstance(val, str): |
| 2894 |
val = attrids.osc_attrvals[val] |
| 2895 |
add_attr_val(db, 'OSC', fin_attrs, attrids.osc_attrids[attr], val) |
| 2896 |
return fin_attrs |
| 2897 |
|
| 2898 |
def set_dlldly_attrs(db, typ, params, cell): |
| 2899 |
attrs_upper(params) |
| 2900 |
dlldly_attrs = dict() |
| 2901 |
dlldly_attrs['DLL_INSEL'] = params.get('DLL_INSEL', "1") |
| 2902 |
dlldly_attrs['DLY_SIGN'] = params.get('DLY_SIGN', "0") |
| 2903 |
dlldly_attrs['DLY_ADJ'] = params.get('DLY_ADJ', "00000000000000000000000000000000") |
| 2904 |
|
| 2905 |
if dlldly_attrs['DLL_INSEL'] != '1': |
| 2906 |
raise Exception(f"DLL_INSEL parameter values other than 1 are not supported") |
| 2907 |
dlldly_attrs.pop('DLL_INSEL') |
| 2908 |
dlldly_attrs['ENABLED'] = 'ENABLE' |
| 2909 |
dlldly_attrs['MODE'] = 'NORMAL' |
| 2910 |
|
| 2911 |
if dlldly_attrs['DLY_SIGN'] == '1': |
| 2912 |
dlldly_attrs['SIGN'] = 'NEG' |
| 2913 |
dlldly_attrs.pop('DLY_SIGN') |
| 2914 |
|
| 2915 |
for i, ch in enumerate(dlldly_attrs['DLY_ADJ'][-1::-1]): |
| 2916 |
if ch == '1': |
| 2917 |
dlldly_attrs[f'ADJ{i}'] = '1' |
| 2918 |
dlldly_attrs.pop('DLY_ADJ') |
| 2919 |
|
| 2920 |
fin_attrs = set() |
| 2921 |
for attr, val in dlldly_attrs.items(): |
| 2922 |
if isinstance(val, str): |
| 2923 |
val = attrids.dlldly_attrvals[val] |
| 2924 |
add_attr_val(db, 'DLLDLY', fin_attrs, attrids.dlldly_attrids[attr], val) |
| 2925 |
return fin_attrs |
| 2926 |
|
| 2927 |
_wire2attr_val = { |
| 2928 |
'HCLK_IN0': ('HSB0MUX0_HSTOP', 'HCLKCIBSTOP0'), |
| 2929 |
'HCLK_IN1': ('HSB1MUX0_HSTOP', 'HCLKCIBSTOP2'), |
| 2930 |
'HCLK_IN2': ('HSB0MUX1_HSTOP', 'HCLKCIBSTOP1'), |
| 2931 |
'HCLK_IN3': ('HSB1MUX1_HSTOP', 'HCLKCIBSTOP3'), |
| 2932 |
'HCLK_BANK_OUT0': ('BRGMUX0_BRGSTOP', 'BRGCIBSTOP0'), |
| 2933 |
'HCLK_BANK_OUT1': ('BRGMUX1_BRGSTOP', 'BRGCIBSTOP1'), |
| 2934 |
} |
| 2935 |
def find_and_set_dhcen_hclk_fuses(db, tilemap, wire, side): |
| 2936 |
fin_attrs = set() |
| 2937 |
attr, attr_val = _wire2attr_val[wire] |
| 2938 |
val = attrids.hclk_attrvals[attr_val] |
| 2939 |
add_attr_val(db, 'HCLK', fin_attrs, attrids.hclk_attrids[attr], val) |
| 2940 |
|
| 2941 |
def set_fuse(): |
| 2942 |
ttyp = db.grid[row][col] |
| 2943 |
if 'HCLK' in db.shortval[ttyp]: |
| 2944 |
bits = get_shortval_fuses(db, ttyp, fin_attrs, "HCLK") |
| 2945 |
tile = tilemap[row, col] |
| 2946 |
for r, c in bits: |
| 2947 |
tile[r][c] = 1 |
| 2948 |
|
| 2949 |
if side in "TB": |
| 2950 |
if side == 'T': |
| 2951 |
row = 0 |
| 2952 |
else: |
| 2953 |
row = db.rows - 1 |
| 2954 |
for col in range(db.cols): |
| 2955 |
set_fuse() |
| 2956 |
else: |
| 2957 |
if side == 'L': |
| 2958 |
col = 0 |
| 2959 |
else: |
| 2960 |
col = db.cols - 1 |
| 2961 |
for row in range(db.rows): |
| 2962 |
set_fuse() |
| 2963 |
|
| 2964 |
def bin_str_to_dec(str_val): |
| 2965 |
bin_pattern = r'^[0,1]+' |
| 2966 |
bin_str = re.findall(bin_pattern, str_val) |
| 2967 |
if bin_str: |
| 2968 |
dec_num = int(bin_str[0], 2) |
| 2969 |
return str(dec_num) |
| 2970 |
return None |
| 2971 |
|
| 2972 |
def set_5a_hclk_attrs(db, params, num, typ, cell_name): |
| 2973 |
attrs = {} |
| 2974 |
if typ == "CLKDIV": |
| 2975 |
attrs[f"HCLKDIV{num[-1]}_DIV"] = params["DIV_MODE"] |
| 2976 |
|
| 2977 |
fin_attrs = set() |
| 2978 |
for attr, val in attrs.items(): |
| 2979 |
if isinstance(val, str): |
| 2980 |
val = attrids.hclk_attrvals[val] |
| 2981 |
add_attr_val(db, 'HCLK', fin_attrs, attrids.hclk_attrids[attr], val) |
| 2982 |
return fin_attrs |
| 2983 |
|
| 2984 |
_hclk_default_params ={"GSREN": "FALSE", "DIV_MODE":"2"} |
| 2985 |
def set_hclk_attrs(db, params, num, typ, cell_name): |
| 2986 |
attrs_upper(params) |
| 2987 |
if device in {'GW5A-25A'}: |
| 2988 |
return set_5a_hclk_attrs(db, params, num, typ, cell_name) |
| 2989 |
|
| 2990 |
name_pattern = r'^_HCLK([0,1])_SECT([0,1])$' |
| 2991 |
params = dict(_hclk_default_params | params) |
| 2992 |
attrs = {} |
| 2993 |
pattern_match = re.findall(name_pattern, num) |
| 2994 |
if (not pattern_match): |
| 2995 |
raise Exception (f"Unknown HCLK Bel/HCLK Section: {typ}{num}") |
| 2996 |
hclk_idx, section_idx = pattern_match[0] |
| 2997 |
|
| 2998 |
valid_div_modes = ["2", "3.5", "4", "5"] |
| 2999 |
if device in ["GW1N-1S","GW1N-2","GW1NR-2","GW1NS-4","GW1NS-4C","GW1NSR-4",\ |
| 3000 |
"GW1NSR-4C","GW1NSER-4C","GW1N-9","GW1NR-9", "GW1N-9C","GW1NR-9C","GW1N-1P5"]: |
| 3001 |
valid_div_modes.append("8") |
| 3002 |
|
| 3003 |
if (params["DIV_MODE"]) not in valid_div_modes: |
| 3004 |
bin_match = bin_str_to_dec(params["DIV_MODE"]) |
| 3005 |
if bin_match is None or bin_match not in valid_div_modes: |
| 3006 |
raise Exception(f"Invalid DIV_MODE {bin_match or params['DIV_MODE']} for CLKDIV {cell_name} on device {device}") |
| 3007 |
params["DIV_MODE"] = str(bin_match[0]) |
| 3008 |
|
| 3009 |
if typ.startswith("CLKDIV2"): |
| 3010 |
attrs[f"BK{section_idx}MUX{hclk_idx}_OUTSEL"] = "DIV2" |
| 3011 |
elif typ.startswith("CLKDIV"): |
| 3012 |
attrs[f"HCLKDIV{hclk_idx}_DIV"] = params["DIV_MODE"] |
| 3013 |
if (section_idx == '1'): |
| 3014 |
attrs[f"HCLKDCS{hclk_idx}_SEL"] = f"HCLKBK{section_idx}{hclk_idx}" |
| 3015 |
|
| 3016 |
fin_attrs = set() |
| 3017 |
for attr, val in attrs.items(): |
| 3018 |
if isinstance(val, str): |
| 3019 |
val = attrids.hclk_attrvals[val] |
| 3020 |
add_attr_val(db, 'HCLK', fin_attrs, attrids.hclk_attrids[attr], val) |
| 3021 |
return fin_attrs |
| 3022 |
|
| 3023 |
_iologic_default_attrs = { |
| 3024 |
'DUMMY': {}, |
| 3025 |
'IOLOGIC': {}, |
| 3026 |
'IOLOGIC_DUMMY': {}, |
| 3027 |
'IOLOGICI_EMPTY': {'GSREN': 'FALSE', 'LSREN': 'TRUE'}, |
| 3028 |
'IOLOGICO_EMPTY': {'GSREN': 'FALSE', 'LSREN': 'TRUE'}, |
| 3029 |
'ODDR': { 'TXCLK_POL': '0'}, |
| 3030 |
'ODDRC': { 'TXCLK_POL': '0'}, |
| 3031 |
'OSER4': { 'GSREN': 'FALSE', 'LSREN': 'TRUE', 'TXCLK_POL': '0', 'HWL': 'FALSE'}, |
| 3032 |
'OSER8': { 'GSREN': 'FALSE', 'LSREN': 'TRUE', 'TXCLK_POL': '0', 'HWL': 'FALSE'}, |
| 3033 |
'OSER10': { 'GSREN': 'FALSE', 'LSREN': 'TRUE'}, |
| 3034 |
'OSER16': { 'GSREN': 'FALSE', 'LSREN': 'TRUE', 'CLKOMUX': 'ENABLE'}, |
| 3035 |
'OVIDEO': { 'GSREN': 'FALSE', 'LSREN': 'TRUE'}, |
| 3036 |
'IDES4': { 'GSREN': 'FALSE', 'LSREN': 'TRUE'}, |
| 3037 |
'IDES8': { 'GSREN': 'FALSE', 'LSREN': 'TRUE'}, |
| 3038 |
'IDES10': { 'GSREN': 'FALSE', 'LSREN': 'TRUE'}, |
| 3039 |
'IVIDEO': { 'GSREN': 'FALSE', 'LSREN': 'TRUE'}, |
| 3040 |
'IDDR' : {'CLKIMUX': 'ENABLE', 'LSRIMUX_0': '0', 'LSROMUX_0': '0'}, |
| 3041 |
'IDDRC' : {'CLKIMUX': 'ENABLE', 'LSRIMUX_0': '1', 'LSROMUX_0': '0'}, |
| 3042 |
'IDES16': { 'GSREN': 'FALSE', 'LSREN': 'TRUE', 'CLKIMUX': 'ENABLE'}, |
| 3043 |
} |
| 3044 |
|
| 3045 |
_iologic_5a_default_attrs = { |
| 3046 |
'TSHX': 'UNKNOWN', 'UPDATE': 'UNKNOWN', 'TSMUX_1': '1', 'GSR': 'ENABLE', 'CEMUX_CE': 'SIG', |
| 3047 |
'CLKMUX_CLK': 'SIG', 'CLKIMUX_1': '1', 'CLKOMUX_1': '1', |
| 3048 |
'LSRMUX_LSR': '0', 'LSRIMUX_0': '0', 'LSROMUX_0': '0', |
| 3049 |
} |
| 3050 |
|
| 3051 |
def iologic_mod_attrs(attrs): |
| 3052 |
attrs_upper(attrs) |
| 3053 |
if 'TXCLK_POL' in attrs: |
| 3054 |
if int(attrs['TXCLK_POL']) == 0: |
| 3055 |
attrs['TSHX'] = 'SIG' |
| 3056 |
else: |
| 3057 |
attrs['TSHX'] = 'INV' |
| 3058 |
del attrs['TXCLK_POL'] |
| 3059 |
if 'HWL' in attrs: |
| 3060 |
if attrs['HWL'] == 'TRUE': |
| 3061 |
attrs['UPDATE'] = 'SAME' |
| 3062 |
del attrs['HWL'] |
| 3063 |
if 'GSREN' in attrs: |
| 3064 |
if attrs['GSREN'] == 'TRUE': |
| 3065 |
attrs['GSR'] = 'ENGSR' |
| 3066 |
del attrs['GSREN'] |
| 3067 |
if 'OUTMODE' in attrs and attrs['OUTMODE'] == 'VIDEOTX': |
| 3068 |
attrs['OUTMODE'] = 'VIDEORX' |
| 3069 |
|
| 3070 |
attrs.pop('LSREN', None) |
| 3071 |
attrs.pop('Q0_INIT', None) |
| 3072 |
attrs.pop('Q1_INIT', None) |
| 3073 |
|
| 3074 |
def make_iodelay_attrs(in_attrs, param): |
| 3075 |
if 'IODELAY' not in param: |
| 3076 |
return |
| 3077 |
if param['IODELAY'] == 'IN': |
| 3078 |
in_attrs['INDEL'] = 'ENABLE' |
| 3079 |
else: |
| 3080 |
in_attrs['OUTDEL'] = 'ENABLE' |
| 3081 |
in_attrs['CLKOMUX'] = 'ENABLE' |
| 3082 |
in_attrs['IMARG'] = 'ENABLE' |
| 3083 |
in_attrs['INDEL_0'] = 'ENABLE' |
| 3084 |
in_attrs['INDEL_1'] = 'ENABLE' |
| 3085 |
if 'C_STATIC_DLY' not in in_attrs: |
| 3086 |
return |
| 3087 |
for i in range(1, 8): |
| 3088 |
if in_attrs['C_STATIC_DLY'][-i] == '1': |
| 3089 |
in_attrs[f'DELAY_DEL{i - 1}'] = '1' |
| 3090 |
in_attrs.pop('C_STATIC_DLY', None); |
| 3091 |
|
| 3092 |
def set_iologic_fclk(in_attrs, attrs, param, out = True): |
| 3093 |
if device not in {'GW5A-25A', 'GW5AST-138C'}: |
| 3094 |
if out: |
| 3095 |
if attrs['OUTMODE'] != 'ODDRX1': |
| 3096 |
in_attrs['CLKODDRMUX_WRCLK'] = 'ECLK0' |
| 3097 |
in_attrs['CLKODDRMUX_ECLK'] = 'UNKNOWN' |
| 3098 |
if param['IOLOGIC_FCLK'] in {'SPINE12', 'SPINE13'}: |
| 3099 |
in_attrs['CLKODDRMUX_ECLK'] = 'ECLK1' |
| 3100 |
elif param['IOLOGIC_FCLK'] in {'SPINE10', 'SPINE11'}: |
| 3101 |
in_attrs['CLKODDRMUX_ECLK'] = 'ECLK0' |
| 3102 |
else: |
| 3103 |
if param['IOLOGIC_FCLK'] in {'SPINE12', 'SPINE13'}: |
| 3104 |
in_attrs['CLKIDDRMUX_ECLK'] = 'ECLK1' |
| 3105 |
elif param['IOLOGIC_FCLK'] in {'SPINE10', 'SPINE11'}: |
| 3106 |
in_attrs['CLKIDDRMUX_ECLK'] = 'ECLK0' |
| 3107 |
else: |
| 3108 |
if out: |
| 3109 |
if param['IOLOGIC_FCLK'] != 'UNKNOWN': |
| 3110 |
in_attrs['WRFCLKSEL'] = 'UNK102' |
| 3111 |
if param['IOLOGIC_FCLK'] == 'SPINE10': |
| 3112 |
in_attrs['FCLKSEL0'] = 'HCLK0' |
| 3113 |
in_attrs['FCLKSEL1'] = 'HCLK0' |
| 3114 |
in_attrs['FCLKSEL2'] = 'HCLK0_' |
| 3115 |
in_attrs['FCLKSEL3'] = 'HCLK0' |
| 3116 |
elif param['IOLOGIC_FCLK'] == 'SPINE11': |
| 3117 |
in_attrs['FCLKSEL0'] = 'HCLK1' |
| 3118 |
in_attrs['FCLKSEL1'] = 'HCLK1' |
| 3119 |
in_attrs['FCLKSEL2'] = 'HCLK1_' |
| 3120 |
in_attrs['FCLKSEL4'] = 'HCLK1' |
| 3121 |
elif param['IOLOGIC_FCLK'] == 'SPINE12': |
| 3122 |
in_attrs['FCLKSEL0'] = 'HCLK2' |
| 3123 |
in_attrs['FCLKSEL1'] = 'HCLK2' |
| 3124 |
in_attrs['FCLKSEL2'] = 'HCLK2_' |
| 3125 |
in_attrs['FCLKSEL3'] = 'HCLK2' |
| 3126 |
elif param['IOLOGIC_FCLK'] == 'SPINE13': |
| 3127 |
in_attrs['FCLKSEL0'] = 'HCLK3' |
| 3128 |
in_attrs['FCLKSEL1'] = 'HCLK3' |
| 3129 |
in_attrs['FCLKSEL2'] = 'HCLK3_' |
| 3130 |
in_attrs['FCLKSEL4'] = 'HCLK3' |
| 3131 |
else: |
| 3132 |
if in_attrs['INMODE'] == 'DDRENABLE': |
| 3133 |
return |
| 3134 |
if param['IOLOGIC_FCLK'] == 'SPINE10': |
| 3135 |
in_attrs['FCLKSEL5'] = 'HCLK0' |
| 3136 |
in_attrs['FCLKSEL6'] = 'HCLK0' |
| 3137 |
in_attrs['FCLKSEL7'] = 'HCLK0_' |
| 3138 |
in_attrs['FCLKSEL3'] = 'HCLK0' |
| 3139 |
elif param['IOLOGIC_FCLK'] == 'SPINE11': |
| 3140 |
in_attrs['FCLKSEL5'] = 'HCLK1' |
| 3141 |
in_attrs['FCLKSEL6'] = 'HCLK1' |
| 3142 |
in_attrs['FCLKSEL7'] = 'HCLK1_' |
| 3143 |
in_attrs['FCLKSEL4'] = 'HCLK1' |
| 3144 |
elif param['IOLOGIC_FCLK'] == 'SPINE12': |
| 3145 |
in_attrs['FCLKSEL5'] = 'HCLK2' |
| 3146 |
in_attrs['FCLKSEL6'] = 'HCLK2' |
| 3147 |
in_attrs['FCLKSEL7'] = 'HCLK2_' |
| 3148 |
in_attrs['FCLKSEL3'] = 'HCLK2' |
| 3149 |
elif param['IOLOGIC_FCLK'] == 'SPINE13': |
| 3150 |
in_attrs['FCLKSEL5'] = 'HCLK3' |
| 3151 |
in_attrs['FCLKSEL6'] = 'HCLK3' |
| 3152 |
in_attrs['FCLKSEL7'] = 'HCLK3_' |
| 3153 |
in_attrs['FCLKSEL4'] = 'HCLK3' |
| 3154 |
|
| 3155 |
def set_iologic_attrs(db, attrs, param): |
| 3156 |
def set_pre5a_out_attrs(): |
| 3157 |
if attrs['OUTMODE'] != 'ODDRX1' or param['IOLOGIC_TYPE'] == 'ODDRC': |
| 3158 |
in_attrs['LSROMUX_0'] = '1' |
| 3159 |
else: |
| 3160 |
in_attrs['LSROMUX_0'] = '0' |
| 3161 |
if attrs['OUTMODE'] == 'ODDRX8' or attrs['OUTMODE'] == 'DDRENABLE16': |
| 3162 |
in_attrs['LSROMUX_0'] = '0' |
| 3163 |
if attrs['OUTMODE'] == 'DDRENABLE16': |
| 3164 |
in_attrs['OUTMODE'] = 'DDRENABLE' |
| 3165 |
in_attrs['ISI'] = 'ENABLE' |
| 3166 |
if attrs['OUTMODE'] == 'DDRENABLE': |
| 3167 |
in_attrs['ISI'] = 'ENABLE' |
| 3168 |
in_attrs['LSRIMUX_0'] = '0' |
| 3169 |
in_attrs['CLKOMUX'] = 'ENABLE' |
| 3170 |
|
| 3171 |
return |
| 3172 |
|
| 3173 |
def set_pre5a_in_attrs(): |
| 3174 |
if param['IOLOGIC_TYPE'] not in {'IDDR', 'IDDRC'}: |
| 3175 |
|
| 3176 |
in_attrs['CLKIMUX_1'] = '1' |
| 3177 |
in_attrs['LSRIMUX_0'] = '1' |
| 3178 |
if attrs['INMODE'] == 'IDDRX8' or attrs['INMODE'] == 'DDRENABLE16': |
| 3179 |
in_attrs['LSRIMUX_0'] = '0' |
| 3180 |
if attrs['INMODE'] == 'DDRENABLE16': |
| 3181 |
in_attrs['INMODE'] = 'DDRENABLE' |
| 3182 |
in_attrs['ISI'] = 'ENABLE' |
| 3183 |
if attrs['INMODE'] == 'DDRENABLE': |
| 3184 |
in_attrs['ISI'] = 'ENABLE' |
| 3185 |
in_attrs['LSROMUX_0'] = '0' |
| 3186 |
in_attrs['CLKIMUX'] = 'ENABLE' |
| 3187 |
return |
| 3188 |
|
| 3189 |
def set_5a_out_attrs(): |
| 3190 |
if 'HWL' in in_attrs: |
| 3191 |
if in_attrs['HWL'] != 'TRUE': |
| 3192 |
del in_attrs['HWL'] |
| 3193 |
if 'TXCLK_POL' in in_attrs: |
| 3194 |
if int(in_attrs['TXCLK_POL']) == 0: |
| 3195 |
in_attrs['TXCLK_POL'] = '0' |
| 3196 |
else: |
| 3197 |
in_attrs['TXCLK_POL'] = '1' |
| 3198 |
if in_attrs['OUTMODE'] in {'ODDRX1', 'ODDRX2', 'ODDRX4'}: |
| 3199 |
in_attrs['CLKOMUX'] = 'ENABLE' |
| 3200 |
in_attrs['OCLKCE'] = 'CE' |
| 3201 |
elif in_attrs['OUTMODE'] in {'ODDRX5'}: |
| 3202 |
in_attrs['HWL'] = 'TRUE' |
| 3203 |
in_attrs['CLKOMUX'] = 'ENABLE' |
| 3204 |
in_attrs['CLKOMUX_CLK'] = 'SIG' |
| 3205 |
in_attrs['LSROMUX_0'] = 'UNKNOWN' |
| 3206 |
in_attrs['OCLKCE'] = 'CE' |
| 3207 |
elif in_attrs['OUTMODE'] in {'DDRENABLE'}: |
| 3208 |
if in_attrs['MAIN_CELL_OUTMODE'] == 'VIDEOTX': |
| 3209 |
in_attrs['OUTMODE'] = 'LVDSOUT' |
| 3210 |
in_attrs['CLKOMUX'] = 'ENABLE' |
| 3211 |
in_attrs['OCLKCE'] = 'CE' |
| 3212 |
else: |
| 3213 |
in_attrs['OUTMODE'] = 'UNKNOWN' |
| 3214 |
in_attrs['CLKOMUX'] = 'ENABLE' |
| 3215 |
in_attrs['CLKOMUX_CLK'] = 'SIG' |
| 3216 |
in_attrs['LSROMUX_0'] = 'UNKNOWN' |
| 3217 |
in_attrs['OUTCLK'] = 'ENABLE' |
| 3218 |
in_attrs['OCLKCE'] = 'CE' |
| 3219 |
elif in_attrs['OUTMODE'] == 'VIDEOTX': |
| 3220 |
in_attrs['OUTMODE'] = 'LVDSOUT' |
| 3221 |
in_attrs['CLKOMUX'] = 'ENABLE' |
| 3222 |
in_attrs['OCLKCE'] = 'CE' |
| 3223 |
in_attrs.pop('MAIN_CELL_OUTMODE', None) |
| 3224 |
return |
| 3225 |
|
| 3226 |
def set_5a_in_attrs(): |
| 3227 |
in_attrs['LSRMUX_LSR'] = 'SIG' |
| 3228 |
if in_attrs['INMODE'] in {'IDDRX1', 'IDDRX2', 'IDDRX4', 'IDDRX5'}: |
| 3229 |
in_attrs['CLKIMUX'] = 'ENABLE' |
| 3230 |
elif in_attrs['INMODE'] == 'VIDEORX': |
| 3231 |
in_attrs['INMODE'] = 'LVDSIN' |
| 3232 |
in_attrs['CLKIMUX'] = 'ENABLE' |
| 3233 |
in_attrs.pop('MAIN_CELL_INMODE', None) |
| 3234 |
return |
| 3235 |
|
| 3236 |
attrs_upper(attrs) |
| 3237 |
if device in {'GW5A-25A'}: |
| 3238 |
in_attrs = _iologic_5a_default_attrs.copy() |
| 3239 |
in_attrs.update(attrs) |
| 3240 |
else: |
| 3241 |
in_attrs = _iologic_default_attrs[param['IOLOGIC_TYPE']].copy() |
| 3242 |
in_attrs.update(attrs) |
| 3243 |
iologic_mod_attrs(in_attrs) |
| 3244 |
fin_attrs = set() |
| 3245 |
if 'OUTMODE' in attrs: |
| 3246 |
if param['IOLOGIC_TYPE'] == 'IOLOGICO_EMPTY': |
| 3247 |
in_attrs.pop('OUTMODE', None); |
| 3248 |
else: |
| 3249 |
if device not in {'GW5A-25A'}: |
| 3250 |
set_pre5a_out_attrs(); |
| 3251 |
else: |
| 3252 |
set_5a_out_attrs(); |
| 3253 |
set_iologic_fclk(in_attrs, attrs, param) |
| 3254 |
|
| 3255 |
if 'INMODE' in attrs: |
| 3256 |
if param['IOLOGIC_TYPE'] == 'IOLOGICI_EMPTY': |
| 3257 |
in_attrs.pop('INMODE', None); |
| 3258 |
else: |
| 3259 |
if device not in {'GW5A-25A'}: |
| 3260 |
set_pre5a_in_attrs(); |
| 3261 |
else: |
| 3262 |
set_5a_in_attrs(); |
| 3263 |
set_iologic_fclk(in_attrs, attrs, param, False) |
| 3264 |
|
| 3265 |
if device not in {'GW5A-25A'}: |
| 3266 |
make_iodelay_attrs(in_attrs, param); |
| 3267 |
|
| 3268 |
for k, val in in_attrs.items(): |
| 3269 |
if k not in attrids.iologic_attrids: |
| 3270 |
print(f'XXX IOLOGIC: add {k} key handle') |
| 3271 |
else: |
| 3272 |
add_attr_val(db, 'IOLOGIC', fin_attrs, attrids.iologic_attrids[k], attrids.iologic_attrvals[val]) |
| 3273 |
return fin_attrs |
| 3274 |
|
| 3275 |
_iostd_alias = { |
| 3276 |
frozenset({"BLVDS25E"}): "BLVDS_E", |
| 3277 |
frozenset({"LVTTL33"}): "LVCMOS33", |
| 3278 |
frozenset({"LVCMOS12D", "LVCMOS15D", "LVCMOS18D", "LVCMOS25D", "LVCMOS33D", }): "LVCMOS_D", |
| 3279 |
frozenset({"HSTL15", "HSTL18_I", "HSTL18_II"}): "HSTL", |
| 3280 |
frozenset({"SSTL15", "SSTL18_I", "SSTL18_II", "SSTL25_I", "SSTL25_II", "SSTL33_I", "SSTL33_II"}): "SSTL", |
| 3281 |
frozenset({"MLVDS25E"}): "MLVDS_E", |
| 3282 |
frozenset({"SSTL15D", "SSTL18D_I", "SSTL18D_II", "SSTL25D_I", "SSTL25D_II", "SSTL33D_I", "SSTL33D_II"}): "SSTL_D", |
| 3283 |
frozenset({"HSTL15D", "HSTL18D_I", "HSTL18D_II"}): "HSTL_D", |
| 3284 |
frozenset({"RSDS"}): "RSDS25", |
| 3285 |
frozenset({"RSDS25E"}): "RSDS_E", |
| 3286 |
} |
| 3287 |
def get_iostd_alias(iostd): |
| 3288 |
for k, v in _iostd_alias.items(): |
| 3289 |
if iostd in k: |
| 3290 |
iostd = v |
| 3291 |
break |
| 3292 |
return iostd |
| 3293 |
|
| 3294 |
|
| 3295 |
class BankDesc: |
| 3296 |
def __init__(self, iostd, bels): |
| 3297 |
self.iostd = iostd |
| 3298 |
self.bels = bels |
| 3299 |
_banks = {} |
| 3300 |
|
| 3301 |
|
| 3302 |
|
| 3303 |
class IOBelDesc: |
| 3304 |
def __init__(self, row, col, idx, attrs, flags, connections): |
| 3305 |
self.pos = (row, col, idx) |
| 3306 |
self.attrs = attrs |
| 3307 |
self.flags = flags |
| 3308 |
self.connections = connections |
| 3309 |
_io_bels = {} |
| 3310 |
_default_iostd = { |
| 3311 |
'IBUF': 'LVCMOS18', 'OBUF': 'LVCMOS18', 'TBUF': 'LVCMOS18', 'IOBUF': 'LVCMOS18', |
| 3312 |
'TLVDS_IBUF': 'LVDS25', 'TLVDS_OBUF': 'LVDS25', 'TLVDS_TBUF': 'LVDS25', |
| 3313 |
'TLVDS_IOBUF': 'LVDS25', |
| 3314 |
'ELVDS_IBUF': 'LVCMOS33D', 'ELVDS_OBUF': 'LVCMOS33D', 'ELVDS_TBUF': 'LVCMOS33D', |
| 3315 |
'ELVDS_IOBUF': 'LVCMOS33D', |
| 3316 |
} |
| 3317 |
_vcc_ios = {'LVCMOS10': '1.0', 'LVCMOS12': '1.2', 'LVCMOS15': '1.5', 'LVCMOS18': '1.8', 'LVCMOS25': '2.5', |
| 3318 |
'LVCMOS33': '3.3', 'LVDS25': '2.5', 'LVCMOS33D': '3.3', 'LVCMOS_D': '3.3', 'MIPI': '1.2', |
| 3319 |
'SSTL15': '1.5', 'SSTL18_I': '1.8', 'SSTL18_II': '1.8', 'SSTL25_I': '2.5', 'SSTL25_II': '2.5', 'SSTL33_I': '3.3', 'SSTL33_II': '3.3', |
| 3320 |
'SSTL15D': '1.5', 'SSTL18D_I': '1.8', 'SSTL18D_II': '1.8', 'SSTL25D_I': '2.5', 'SSTL25D_II': '2.5', 'SSTL33D_I': '3.3', 'SSTL33D_II': '3.3'} |
| 3321 |
_init_io_attrs = { |
| 3322 |
'IBUF': {'PADDI': 'PADDI', 'HYSTERESIS': 'NONE', 'PULLMODE': 'UP', 'SLEWRATE': 'SLOW', |
| 3323 |
'DRIVE': '0', 'CLAMP': 'OFF', 'OPENDRAIN': 'OFF', 'DIFFRESISTOR': 'OFF', |
| 3324 |
'VREF': 'OFF', 'LVDS_OUT': 'OFF'}, |
| 3325 |
'OBUF': {'ODMUX_1': '1', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST', |
| 3326 |
'DRIVE': '8', 'HYSTERESIS': 'NONE', 'CLAMP': 'OFF', |
| 3327 |
'SINGLERESISTOR': 'OFF', 'BANK_VCCIO': '1.8', 'LVDS_OUT': 'OFF', 'DDR_DYNTERM': 'NA', 'TO': 'INV', 'OPENDRAIN': 'OFF'}, |
| 3328 |
'TBUF': {'ODMUX_1': 'UNKNOWN', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST', |
| 3329 |
'DRIVE': '8', 'HYSTERESIS': 'NONE', 'CLAMP': 'OFF', |
| 3330 |
'SINGLERESISTOR': 'OFF', 'BANK_VCCIO': '1.8', 'LVDS_OUT': 'OFF', 'DDR_DYNTERM': 'NA', |
| 3331 |
'TO': 'INV', 'PERSISTENT': 'OFF', 'ODMUX': 'TRIMUX', 'OPENDRAIN': 'OFF'}, |
| 3332 |
'IOBUF': {'ODMUX_1': 'UNKNOWN', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST', |
| 3333 |
'DRIVE': '8', 'HYSTERESIS': 'NONE', 'CLAMP': 'OFF', 'DIFFRESISTOR': 'OFF', |
| 3334 |
'SINGLERESISTOR': 'OFF', 'BANK_VCCIO': '1.8', 'LVDS_OUT': 'OFF', 'DDR_DYNTERM': 'NA', |
| 3335 |
'TO': 'INV', 'PERSISTENT': 'OFF', 'ODMUX': 'TRIMUX', 'PADDI': 'PADDI', 'OPENDRAIN': 'OFF'}, |
| 3336 |
} |
| 3337 |
|
| 3338 |
_refine_attrs = {'SLEW_RATE': 'SLEWRATE', 'PULL_MODE': 'PULLMODE', 'OPEN_DRAIN': 'OPENDRAIN'} |
| 3339 |
def refine_io_attrs(attr): |
| 3340 |
return _refine_attrs.get(attr, attr) |
| 3341 |
|
| 3342 |
def place_lut(db, tiledata, tile, parms, num, row, col, slice_attrvals): |
| 3343 |
lutmap = tiledata.bels[f'LUT{num}'].flags |
| 3344 |
init = str(parms['INIT']) |
| 3345 |
if len(init) > 16: |
| 3346 |
init = init[-16:] |
| 3347 |
else: |
| 3348 |
init = init*(16//len(init)) |
| 3349 |
for bitnum, lutbit in enumerate(init[::-1]): |
| 3350 |
if lutbit == '0': |
| 3351 |
fuses = lutmap[bitnum] |
| 3352 |
for brow, bcol in fuses: |
| 3353 |
tile[brow][bcol] = 1 |
| 3354 |
slice_attrvals.setdefault((row, col, int(num) // 2), {}) |
| 3355 |
|
| 3356 |
def place_alu(db, tiledata, tile, parms, num, row, col, slice_attrvals): |
| 3357 |
lutmap = tiledata.bels[f'LUT{num}'].flags |
| 3358 |
alu_bel = tiledata.bels[f"ALU{num}"] |
| 3359 |
for r_c in lutmap.values(): |
| 3360 |
for r, c in r_c: |
| 3361 |
tile[r][c] = 0 |
| 3362 |
|
| 3363 |
if "ALU_MODE" in parms and parms['ALU_MODE'] == "0 ": |
| 3364 |
parms['RAW_ALU_LUT'] = "0011000011001100" |
| 3365 |
|
| 3366 |
|
| 3367 |
if 'RAW_ALU_LUT' in parms: |
| 3368 |
alu_init = parms['RAW_ALU_LUT'] |
| 3369 |
if len(alu_init) > 16: |
| 3370 |
alu_init = alu_init[-16:] |
| 3371 |
else: |
| 3372 |
alu_init = alu_init*(16 // len(alu_init)) |
| 3373 |
bits = set() |
| 3374 |
for bitnum, bit in enumerate(alu_init[::-1]): |
| 3375 |
if bit == '0': |
| 3376 |
bits.update(lutmap[bitnum]) |
| 3377 |
else: |
| 3378 |
mode = str(parms['ALU_MODE']) |
| 3379 |
if mode in alu_bel.modes: |
| 3380 |
bits = alu_bel.modes[mode] |
| 3381 |
else: |
| 3382 |
bits = alu_bel.modes[str(int(mode, 2))] |
| 3383 |
for r, c in bits: |
| 3384 |
tile[r][c] = 1 |
| 3385 |
|
| 3386 |
|
| 3387 |
|
| 3388 |
alu_mode_attrs = slice_attrvals.setdefault((row, col, int(num) // 2), {}) |
| 3389 |
alu_mode_attrs.update({'MODE': 'ALU'}) |
| 3390 |
alu_mode_attrs.update({f'MODE_5A_{int(num) % 2}': 'ALU'}) |
| 3391 |
|
| 3392 |
if 'CIN_NETTYPE' in parms: |
| 3393 |
if parms['CIN_NETTYPE'] == 'VCC': |
| 3394 |
alu_mode_attrs.update({'ALU_CIN_MUX': 'ALU_5A_CIN_VCC'}) |
| 3395 |
elif parms['CIN_NETTYPE'] == 'GND': |
| 3396 |
alu_mode_attrs.update({'ALU_CIN_MUX': 'ALU_5A_CIN_GND'}) |
| 3397 |
else: |
| 3398 |
alu_mode_attrs.update({'ALU_CIN_MUX': 'ALU_5A_CIN_COUT'}) |
| 3399 |
elif 'ALU_CIN_MUX' not in alu_mode_attrs: |
| 3400 |
alu_mode_attrs.update({'ALU_CIN_MUX': 'ALU_5A_CIN_COUT'}) |
| 3401 |
|
| 3402 |
def place_dff(db, tiledata, tile, parms, num, mode, row, col, slice_attrvals, has_ce_port, is_latch=False): |
| 3403 |
dff_attrs = slice_attrvals.setdefault((row, col, int(num) // 2), {}) |
| 3404 |
dff_attrs.update({'REGMODE': 'LATCH' if is_latch else 'FF'}) |
| 3405 |
if has_ce_port: |
| 3406 |
dff_attrs.update({'CEMUX_1': 'UNKNOWN', 'CEMUX_CE': 'SIG'}) |
| 3407 |
else: |
| 3408 |
|
| 3409 |
dff_attrs.update({'CEMUX_1': '1'}) |
| 3410 |
|
| 3411 |
if mode in {'DFFR', 'DFFC', 'DFFNR', 'DFFNC', 'DFF', 'DFFN'}: |
| 3412 |
dff_attrs.update({f'REG{int(num) % 2}_REGSET': 'RESET'}) |
| 3413 |
else: |
| 3414 |
dff_attrs.update({f'REG{int(num) % 2}_REGSET': 'SET'}) |
| 3415 |
|
| 3416 |
if mode not in {'DFF', 'DFFN'}: |
| 3417 |
dff_attrs.update({'LSRONMUX': 'LSRMUX'}) |
| 3418 |
|
| 3419 |
if mode in {'DFFN', 'DFFNR', 'DFFNC', 'DFFNP', 'DFFNS'}: |
| 3420 |
dff_attrs.update({'CLKMUX_CLK': 'INV'}) |
| 3421 |
else: |
| 3422 |
dff_attrs.update({'CLKMUX_CLK': 'SIG'}) |
| 3423 |
|
| 3424 |
if mode in {'DFFNC', 'DFFNP', 'DFFC', 'DFFP'}: |
| 3425 |
dff_attrs.update({'SRMODE': 'ASYNC'}) |
| 3426 |
|
| 3427 |
_mipi_aux_attrs = { |
| 3428 |
'A': {('IO_TYPE', 'LVDS25'), ('LPRX_A2', 'ENABLE'), ('ODMUX', 'TRIMUX'), ('OPENDRAIN', 'OFF'), |
| 3429 |
('DIFFRESISTOR', 'OFF'), ('BANK_VCCIO', '2.5')}, |
| 3430 |
'B': {('IO_TYPE', 'LVDS25'), ('BANK_VCCIO', '2.5')}, |
| 3431 |
} |
| 3432 |
|
| 3433 |
_hclk_io_pairs = {(36, 11): (36, 30), (36, 25): (36, 32), (36, 53): (36, 28), (36, 74): (36, 90), } |
| 3434 |
|
| 3435 |
_sides = "AB" |
| 3436 |
|
| 3437 |
def set_dcs_fuses(db, tilemap, dcs_idx, dcs_attrs, spine_idx): |
| 3438 |
dcs_name = f'DCS{dcs_idx + 6}' |
| 3439 |
for row in range(db.rows): |
| 3440 |
for col in range(db.cols): |
| 3441 |
ttyp = db.grid[row][col] |
| 3442 |
if ttyp in db.longfuses and dcs_name in db.longfuses[ttyp]: |
| 3443 |
tile = tilemap[(row, col)] |
| 3444 |
bits = get_long_fuses(db, ttyp, dcs_attrs, spine_idx) |
| 3445 |
for brow, bcol in bits: |
| 3446 |
tile[brow][bcol] = 1 |
| 3447 |
|
| 3448 |
def check_adc_io(db, io_loc): |
| 3449 |
global adc_iolocs |
| 3450 |
|
| 3451 |
iore = re.compile(r"(\d+)/X(\d+)Y(\d+)") |
| 3452 |
res = iore.fullmatch(io_loc) |
| 3453 |
if not res: |
| 3454 |
raise Exception(f"Bad IOLOC {io_loc} in the ADC src list.") |
| 3455 |
adc_bus, io_col, io_row = res.groups() |
| 3456 |
row = int(io_row) |
| 3457 |
col = int(io_col) |
| 3458 |
pin_bus = db.extra_func[row, col]['adcio']['bus'] |
| 3459 |
if pin_bus != f'BUS{adc_bus}': |
| 3460 |
raise Exception(f"IO({row}, {col}) has ADC bus {pin_bus[-1]}, but used in bus {adc_bus}.") |
| 3461 |
|
| 3462 |
for pos, desc in adc_iolocs.items(): |
| 3463 |
if desc['bus'] == adc_bus and adc_bus in "01": |
| 3464 |
raise Exception(f"IO at ({row}, {col}) and at ({pos[0]}, {pos[1]}) have same bus {adc_bus}. Only one IO in the one bus allowed.") |
| 3465 |
|
| 3466 |
adc = adc_iolocs.setdefault((row, col), {}) |
| 3467 |
adc['bus'] = adc_bus |
| 3468 |
|
| 3469 |
|
| 3470 |
|
| 3471 |
_no_pullup_cfgs = { f'D{x:02}' for x in range(8, 32)} |
| 3472 |
_no_pullup_cfgs.update({'INITDLY0', 'INITDLY1'}) |
| 3473 |
def get_pullup_io(cfg): |
| 3474 |
pullup_io = {'PADDI': 'PADDI', 'PULLMODE': 'UP'} |
| 3475 |
if 'TDO' in cfg or 'DOUT' in cfg: |
| 3476 |
pullup_io = {'TO': 'INV', 'ODMUX_1': '1', 'PULLMODE': 'UP'} |
| 3477 |
elif 'RDWR' in cfg or 'RDWR_B' in cfg or 'PUDC_B' in cfg: |
| 3478 |
pullup_io = {'PADDI': 'PADDI', 'PULLMODE': 'DOWN'} |
| 3479 |
else: |
| 3480 |
for cf in cfg: |
| 3481 |
if cf in _no_pullup_cfgs: |
| 3482 |
pullup_io = {'PADDI': 'PADDI', 'PULLMODE': 'NONE'} |
| 3483 |
break |
| 3484 |
return pullup_io |
| 3485 |
|
| 3486 |
def place(db, tilemap, bels, cst, args, slice_attrvals, extra_slots): |
| 3487 |
global adc_ios |
| 3488 |
for typ, row, col, num, parms, attrs, cellname, cell in bels: |
| 3489 |
tiledata = db[row-1, col-1] |
| 3490 |
tile = tilemap[(row-1, col-1)] |
| 3491 |
|
| 3492 |
if typ in {'IBUF', 'OBUF', 'TBUF', 'IOBUF'}: |
| 3493 |
if typ == 'IBUF': |
| 3494 |
parms['OUTPUT_USED'] = "0" |
| 3495 |
parms['INPUT_USED'] = "1" |
| 3496 |
parms['ENABLE_USED'] = "0" |
| 3497 |
elif typ == 'TBUF': |
| 3498 |
parms['OUTPUT_USED'] = "1" |
| 3499 |
parms['INPUT_USED'] = "0" |
| 3500 |
parms['ENABLE_USED'] = "1" |
| 3501 |
elif typ == 'IOBUF': |
| 3502 |
parms['OUTPUT_USED'] = "1" |
| 3503 |
parms['INPUT_USED'] = "1" |
| 3504 |
parms['ENABLE_USED'] = "1" |
| 3505 |
else: |
| 3506 |
parms['OUTPUT_USED'] = "1" |
| 3507 |
parms['INPUT_USED'] = "0" |
| 3508 |
parms['ENABLE_USED'] = "0" |
| 3509 |
typ = 'IOB' |
| 3510 |
|
| 3511 |
if typ in {'IOLOGIC', 'IOLOGICI', 'IOLOGICO', 'IOLOGIC_DUMMY', 'ODDR', 'ODDRC', 'OSER4', |
| 3512 |
'OSER8', 'OSER10', 'OVIDEO', 'IDDR', 'IDDRC', 'IDES4', 'IDES8', 'IDES10', 'IVIDEO', |
| 3513 |
'IOLOGICI_EMPTY', 'IOLOGICO_EMPTY'}: |
| 3514 |
if num[-1] in {'I', 'O'}: |
| 3515 |
num = num[:-1] |
| 3516 |
if typ == 'IOLOGIC_DUMMY': |
| 3517 |
attrs['IOLOGIC_FCLK'] = pnr['modules']['top']['cells'][attrs['MAIN_CELL']]['attributes']['IOLOGIC_FCLK'] |
| 3518 |
if device in {'GW5A-25A'}: |
| 3519 |
main_cell_params = pnr['modules']['top']['cells'][attrs['MAIN_CELL']]['parameters'] |
| 3520 |
if 'OUTMODE' in main_cell_params: |
| 3521 |
parms['MAIN_CELL_OUTMODE'] = main_cell_params['OUTMODE'] |
| 3522 |
elif 'INMODE' in main_cell_params: |
| 3523 |
parms['MAIN_CELL_INMODE'] = main_cell_params['INMODE'] |
| 3524 |
attrs['IOLOGIC_TYPE'] = typ |
| 3525 |
if typ not in {'IDDR', 'IDDRC', 'ODDR', 'ODDRC', 'IOLOGICI_EMPTY', 'IOLOGICO_EMPTY'}: |
| 3526 |
|
| 3527 |
|
| 3528 |
|
| 3529 |
|
| 3530 |
|
| 3531 |
recode_spines = {'UNKNOWN': 'UNKNOWN', 'HCLK_OUT0': 'SPINE10', |
| 3532 |
'HCLK_OUT1': 'SPINE11', 'HCLK_OUT2': 'SPINE12', |
| 3533 |
'HCLK_OUT3': 'SPINE13'} |
| 3534 |
if attrs['IOLOGIC_FCLK'] in recode_spines: |
| 3535 |
attrs['IOLOGIC_FCLK'] = recode_spines[attrs['IOLOGIC_FCLK']] |
| 3536 |
else: |
| 3537 |
attrs['IOLOGIC_FCLK'] = 'UNKNOWN' |
| 3538 |
typ = 'IOLOGIC' |
| 3539 |
|
| 3540 |
if typ == "GSR": |
| 3541 |
pass |
| 3542 |
elif typ == "BANDGAP": |
| 3543 |
pass |
| 3544 |
elif typ == "PINCFG": |
| 3545 |
if args.i2c_as_gpio != ('I2C' in parms): |
| 3546 |
raise Exception(f" i2c_as_gpio has conflicting settings in nexpnr and gowin_pack.") |
| 3547 |
if args.sspi_as_gpio != ('SSPI' in parms): |
| 3548 |
raise Exception(f" sspi_as_gpio has conflicting settings in nexpnr and gowin_pack.") |
| 3549 |
elif typ.startswith("FLASH"): |
| 3550 |
pass |
| 3551 |
elif typ.startswith("EMCU"): |
| 3552 |
pass |
| 3553 |
elif typ.startswith('MUX2_'): |
| 3554 |
pass |
| 3555 |
elif typ.startswith("MIPI_OBUF"): |
| 3556 |
pass |
| 3557 |
elif typ.startswith("MIPI_IBUF_AUX"): |
| 3558 |
for iob_idx in ['A', 'B']: |
| 3559 |
iob_attrs = set() |
| 3560 |
for k, val in _mipi_aux_attrs[iob_idx]: |
| 3561 |
add_attr_val(db, 'IOB', iob_attrs, attrids.iob_attrids[k], attrids.iob_attrvals[val]) |
| 3562 |
bits = get_longval_fuses(db, tiledata.ttyp, iob_attrs, f'IOB{iob_idx}') |
| 3563 |
for row_, col_ in bits: |
| 3564 |
tile[row_][col_] = 1 |
| 3565 |
pass |
| 3566 |
elif typ.startswith("MIPI_IBUF"): |
| 3567 |
pass |
| 3568 |
elif typ == "BUFS": |
| 3569 |
|
| 3570 |
bits2zero = set() |
| 3571 |
for fuses in [fuses for fuses in parms.keys() if fuses in {'L', 'R'}]: |
| 3572 |
bits2zero.update(tiledata.bels[f'BUFS{num}'].flags[fuses]) |
| 3573 |
for r, c in bits2zero: |
| 3574 |
tile[r][c] = 0 |
| 3575 |
elif typ.startswith("BUFG"): |
| 3576 |
continue |
| 3577 |
|
| 3578 |
elif typ in {'OSC', 'OSCZ', 'OSCF', 'OSCH', 'OSCW', 'OSCO', 'OSCA'}: |
| 3579 |
|
| 3580 |
if device == 'GW1NZ-1': |
| 3581 |
en_tiledata = db[db.rows - 1, db.cols - 1] |
| 3582 |
en_tile = tilemap[(db.rows - 1, db.cols - 1)] |
| 3583 |
en_tile[23][63] = 0 |
| 3584 |
en_tile[22][63] = 1 |
| 3585 |
|
| 3586 |
clear_attrs = set() |
| 3587 |
add_attr_val(db, 'OSC', clear_attrs, attrids.osc_attrids['POWER_SAVE'], attrids.osc_attrvals['ENABLE']) |
| 3588 |
bits = get_shortval_fuses(db, tiledata.ttyp, clear_attrs, 'OSC') |
| 3589 |
for r, c in bits: |
| 3590 |
tile[r][c] = 0 |
| 3591 |
|
| 3592 |
osc_attrs = set_osc_attrs(db, typ, parms) |
| 3593 |
if device in {'GW5A-25A'}: |
| 3594 |
|
| 3595 |
for row_col, func_desc in db.extra_func.items(): |
| 3596 |
if 'osc' in func_desc or 'osc_fuses_only' in func_desc: |
| 3597 |
osc_row, osc_col = row_col |
| 3598 |
osc_tile = tilemap[osc_row, osc_col] |
| 3599 |
bits = get_shortval_fuses(db, db.grid[osc_row][osc_col], osc_attrs, 'OSC') |
| 3600 |
|
| 3601 |
for r, c in bits: |
| 3602 |
osc_tile[r][c] = 1 |
| 3603 |
else: |
| 3604 |
bits = get_shortval_fuses(db, tiledata.ttyp, osc_attrs, 'OSC') |
| 3605 |
for r, c in bits: |
| 3606 |
tile[r][c] = 1 |
| 3607 |
|
| 3608 |
elif typ.startswith("DFF"): |
| 3609 |
mode = typ.strip('E') |
| 3610 |
is_latch = attrs.get('LATCH', '') == '00000000000000000000000000000001' |
| 3611 |
place_dff(db, tiledata, tile, parms, num, mode, row, col, slice_attrvals, typ[-1] == 'E', is_latch) |
| 3612 |
elif typ.startswith('LUT'): |
| 3613 |
place_lut(db, tiledata, tile, parms, num, row, col, slice_attrvals) |
| 3614 |
|
| 3615 |
elif typ[:3] == "IOB": |
| 3616 |
edge = 'T' |
| 3617 |
idx = col |
| 3618 |
if row == db.rows: |
| 3619 |
edge = 'B' |
| 3620 |
elif col == 1: |
| 3621 |
edge = 'L' |
| 3622 |
idx = row |
| 3623 |
elif col == db.cols: |
| 3624 |
edge = 'R' |
| 3625 |
idx = row |
| 3626 |
bel_name = f"IO{edge}{idx}{num}" |
| 3627 |
cst.ports[cellname] = bel_name |
| 3628 |
iob = tiledata.bels[f'IOB{num}'] |
| 3629 |
if 'MIPI_IBUF' in parms and num == 'B': |
| 3630 |
continue |
| 3631 |
if 'DIFF' in parms: |
| 3632 |
|
| 3633 |
if parms['DIFF'] == 'N': |
| 3634 |
continue |
| 3635 |
|
| 3636 |
if not iob.is_diff: |
| 3637 |
raise ValueError(f"Cannot place {cellname} at {bel_name} - not a diff pin") |
| 3638 |
if not iob.is_diff_p: |
| 3639 |
raise ValueError(f"Cannot place {cellname} at {bel_name} - not a P pin") |
| 3640 |
mode = parms['DIFF_TYPE'] |
| 3641 |
if iob.is_true_lvds and mode[0] != 'T': |
| 3642 |
raise ValueError(f"Cannot place {cellname} at {bel_name} - it is a true lvds pin") |
| 3643 |
if not iob.is_true_lvds and mode[0] == 'T': |
| 3644 |
raise ValueError(f"Cannot place {cellname} at {bel_name} - it is an emulated lvds pin") |
| 3645 |
if parms['DIFF_TYPE'] == 'TLVDS_IBUF_ADC': |
| 3646 |
|
| 3647 |
check_adc_io(db, f'2/X{col - 1}Y{row - 1}') |
| 3648 |
continue |
| 3649 |
else: |
| 3650 |
if int(parms["ENABLE_USED"], 2): |
| 3651 |
if int(parms["INPUT_USED"], 2): |
| 3652 |
mode = "IOBUF" |
| 3653 |
else: |
| 3654 |
mode = "TBUF" |
| 3655 |
elif int(parms["INPUT_USED"], 2): |
| 3656 |
mode = "IBUF" |
| 3657 |
elif int(parms["OUTPUT_USED"], 2): |
| 3658 |
mode = "OBUF" |
| 3659 |
else: |
| 3660 |
raise ValueError("IOB has no in or output") |
| 3661 |
|
| 3662 |
pinless_io = False |
| 3663 |
try: |
| 3664 |
bank = chipdb.loc2bank(db, row - 1, col - 1) |
| 3665 |
iostd = _banks.setdefault(bank, BankDesc(None, set())).iostd |
| 3666 |
except KeyError: |
| 3667 |
if not args.allow_pinless_io: |
| 3668 |
raise Exception(f"IO{edge}{idx}{num} is not allowed for a given package") |
| 3669 |
pinless_io = True |
| 3670 |
iostd = None |
| 3671 |
|
| 3672 |
flags = {'mode': mode} |
| 3673 |
flags.update({port: net for port, net in parms.items() if port.startswith('NET_')}) |
| 3674 |
if int(parms.get("IOLOGIC_IOB", "0")): |
| 3675 |
flags['USED_BY_IOLOGIC'] = True |
| 3676 |
|
| 3677 |
io_desc = IOBelDesc(row - 1, col - 1, num, {}, flags, cell['connections']) |
| 3678 |
_io_bels.setdefault(bank, {})[bel_name] = io_desc |
| 3679 |
|
| 3680 |
|
| 3681 |
iostd = _default_iostd[mode] |
| 3682 |
io_desc.attrs['IO_TYPE'] = iostd |
| 3683 |
for flag in attrs.keys(): |
| 3684 |
flag_name_val = flag.split("=") |
| 3685 |
if len(flag_name_val) < 2: |
| 3686 |
continue |
| 3687 |
if flag[0] != chipdb.mode_attr_sep: |
| 3688 |
continue |
| 3689 |
if flag_name_val[0] == chipdb.mode_attr_sep + "IO_TYPE": |
| 3690 |
iostd = _iostd_alias.get(flag_name_val[1], flag_name_val[1]) |
| 3691 |
else: |
| 3692 |
io_desc.attrs[flag_name_val[0][1:]] = flag_name_val[1] |
| 3693 |
io_desc.attrs['IO_TYPE'] = iostd |
| 3694 |
if 'DIFF' in parms and 'MIPI_OBUF' in parms: |
| 3695 |
io_desc.attrs['MIPI'] = 'ENABLE' |
| 3696 |
if 'I3C_IOBUF' in parms: |
| 3697 |
io_desc.attrs['I3C_IOBUF'] = 'ENABLE' |
| 3698 |
if device in {'GW5A-25A'}: |
| 3699 |
|
| 3700 |
if iob_is_connected_to_HCLK_GCLK(io_desc.connections): |
| 3701 |
|
| 3702 |
|
| 3703 |
|
| 3704 |
|
| 3705 |
|
| 3706 |
|
| 3707 |
|
| 3708 |
if (row - 1, col - 1) in _hclk_io_pairs: |
| 3709 |
pair_row, pair_col = _hclk_io_pairs[row - 1, col - 1] |
| 3710 |
io_desc_pair = IOBelDesc(pair_row, pair_col, 'A', {}, flags.copy(), {}) |
| 3711 |
_io_bels.setdefault(bank, {})[f'{bel_name}$pair'] = io_desc_pair |
| 3712 |
io_desc_pair.flags['HCLK_PAIR'] = True |
| 3713 |
io_desc_pair.attrs['IO_TYPE'] = iostd |
| 3714 |
io_desc.flags['HCLK'] = True |
| 3715 |
if pinless_io: |
| 3716 |
return |
| 3717 |
elif typ.startswith("RAM16SDP") or typ == "RAMW": |
| 3718 |
for idx in range(4): |
| 3719 |
ram_attrs = slice_attrvals.setdefault((row, col, idx), {}) |
| 3720 |
ram_attrs.update({'MODE': 'SSRAM'}) |
| 3721 |
|
| 3722 |
|
| 3723 |
|
| 3724 |
ram_attrs = slice_attrvals.setdefault((row, col, 2), {}) |
| 3725 |
ram_attrs.update({'LSRONMUX': 'LSRMUX'}) |
| 3726 |
ram_attrs.update({'LSR_MUX_LSR': 'INV'}) |
| 3727 |
ram_attrs.update({'CLKMUX_1': 'UNKNOWN'}) |
| 3728 |
ram_attrs.update({'CLKMUX_CLK': 'SIG'}) |
| 3729 |
elif typ == 'IOLOGIC': |
| 3730 |
|
| 3731 |
|
| 3732 |
|
| 3733 |
|
| 3734 |
iologic_attrs = set_iologic_attrs(db, parms, attrs) |
| 3735 |
bits = set() |
| 3736 |
table_type = f'IOLOGIC{num}' |
| 3737 |
fuse_ttyp = tiledata.ttyp |
| 3738 |
off = tiledata.bels[f'IOB{num}'].fuse_cell_offset |
| 3739 |
fuse_row, fuse_col, fuse_ttyp = row - 1, col - 1, tiledata.ttyp |
| 3740 |
if off: |
| 3741 |
fuse_row += off[0] |
| 3742 |
fuse_col += off[1] |
| 3743 |
fuse_ttyp = db.grid[fuse_row][fuse_col] |
| 3744 |
bits = get_shortval_fuses(db, fuse_ttyp, iologic_attrs, table_type) |
| 3745 |
tile = tilemap[(fuse_row, fuse_col)] |
| 3746 |
for r, c in bits: |
| 3747 |
tile[r][c] = 1 |
| 3748 |
elif typ in _bsram_cell_types or typ == 'BSRAM_AUX': |
| 3749 |
is_aux = (typ == 'BSRAM_AUX') |
| 3750 |
if typ == 'BSRAM_AUX': |
| 3751 |
typ = cell['type'] |
| 3752 |
elif device in {'GW5A-25A', 'GW5AST-138C'}: |
| 3753 |
bisect.insort(gw5a_bsrams, (col - 1, row - 1, typ, parms, attrs)) |
| 3754 |
else: |
| 3755 |
store_bsram_init_val(db, row - 1, col -1, typ, parms, attrs) |
| 3756 |
bsram_attrs = set_bsram_attrs(db, cell, typ, parms) |
| 3757 |
try: |
| 3758 |
bsrambits = get_shortval_fuses(db, tiledata.ttyp, bsram_attrs, f'BSRAM_{typ}') |
| 3759 |
|
| 3760 |
for brow, bcol in bsrambits: |
| 3761 |
tile[brow][bcol] = 1 |
| 3762 |
except KeyError: |
| 3763 |
assert device == 'GW5AST-138C' and is_aux |
| 3764 |
elif typ in {'MULTADDALU18X18', 'MULTALU36X18', 'MULTALU18X18', 'MULT36X36', 'MULT18X18', 'MULT9X9', 'PADD18', 'PADD9', 'ALU54D', 'MULT12X12', 'MULTALU27X18', 'MULTADDALU12X12'} or typ == 'DSP_AUX': |
| 3765 |
if typ == 'DSP_AUX': |
| 3766 |
typ = cell['type'] |
| 3767 |
if typ in {'MULTADDALU18X18', 'MULTALU36X18', 'MULTALU18X18', 'ALU54D'}: |
| 3768 |
num = num[-1] + num[-1] |
| 3769 |
if typ == 'MULT36X36': |
| 3770 |
dsp_attrs = set_dsp_mult36x36_attrs(db, typ, parms, attrs) |
| 3771 |
dspbits = set() |
| 3772 |
for mac in range(2): |
| 3773 |
if f'DSP{mac}' in db.shortval[tiledata.ttyp]: |
| 3774 |
dspbits.update(get_shortval_fuses(db, tiledata.ttyp, dsp_attrs[mac], f'DSP{mac}')) |
| 3775 |
elif typ in {'MULT12X12', 'MULTADDALU12X12', 'MULTALU27X18'}: |
| 3776 |
dsp_attrs = set_dsp_attrs(db, typ, parms, num, attrs) |
| 3777 |
dspbits = set() |
| 3778 |
if '5A_DSP' in db.shortval[tiledata.ttyp]: |
| 3779 |
dspbits = get_shortval_fuses(db, tiledata.ttyp, dsp_attrs, '5A_DSP') |
| 3780 |
else: |
| 3781 |
dsp_attrs = set_dsp_attrs(db, typ, parms, num, attrs) |
| 3782 |
dspbits = set() |
| 3783 |
if f'DSP{num[-2]}' in db.shortval[tiledata.ttyp]: |
| 3784 |
dspbits = get_shortval_fuses(db, tiledata.ttyp, dsp_attrs, f'DSP{num[-2]}') |
| 3785 |
|
| 3786 |
|
| 3787 |
for brow, bcol in dspbits: |
| 3788 |
tile[brow][bcol] = 1 |
| 3789 |
elif typ.startswith('ADC'): |
| 3790 |
|
| 3791 |
for attr, val in attrs.items(): |
| 3792 |
if attr.startswith('ADC_IO_'): |
| 3793 |
check_adc_io(db, val) |
| 3794 |
|
| 3795 |
|
| 3796 |
adc_attrs = set_adc_attrs(db, 0, parms) |
| 3797 |
bits = set() |
| 3798 |
if 'ADC' in db.shortval[tiledata.ttyp]: |
| 3799 |
bits = get_shortval_fuses(db, tiledata.ttyp, adc_attrs, 'ADC') |
| 3800 |
|
| 3801 |
for r, c in bits: |
| 3802 |
tile[r][c] = 1 |
| 3803 |
|
| 3804 |
bits = get_shortval_fuses(db, 1026, adc_attrs, 'ADC') |
| 3805 |
slot_bitmap = extra_slots.setdefault(db.extra_func[row - 1, col - 1]['adc']['slot_idx'], bitmatrix.zeros(8, 6)) |
| 3806 |
|
| 3807 |
for r, c in bits: |
| 3808 |
slot_bitmap[r][c] = 1 |
| 3809 |
|
| 3810 |
|
| 3811 |
elif typ.startswith('RPLL'): |
| 3812 |
pll_attrs = set_pll_attrs(db, 'RPLL', 0, parms) |
| 3813 |
bits = set() |
| 3814 |
if 'PLL' in db.shortval[tiledata.ttyp]: |
| 3815 |
bits = get_shortval_fuses(db, tiledata.ttyp, pll_attrs, 'PLL') |
| 3816 |
|
| 3817 |
for r, c in bits: |
| 3818 |
tile[r][c] = 1 |
| 3819 |
elif typ.startswith('PLLA'): |
| 3820 |
pll_attrs = set_pll_attrs(db, 'PLLA', 0, parms) |
| 3821 |
bits = get_shortval_fuses(db, 1024, pll_attrs, 'PLL') |
| 3822 |
slot_bitmap = extra_slots.setdefault(db.extra_func[row - 1, col - 1]['pll']['slot_idx'], bitmatrix.zeros(8, 35)) |
| 3823 |
for r, c in bits: |
| 3824 |
slot_bitmap[r][c] = 1 |
| 3825 |
|
| 3826 |
|
| 3827 |
elif typ.startswith('ALU'): |
| 3828 |
place_alu(db, tiledata, tile, parms, num, row, col, slice_attrvals) |
| 3829 |
elif typ == 'PLLVR': |
| 3830 |
idx = 0 |
| 3831 |
if col != 28: |
| 3832 |
idx = 1 |
| 3833 |
pll_attrs = set_pll_attrs(db, 'PLLVR', idx, parms) |
| 3834 |
bits = get_shortval_fuses(db, tiledata.ttyp, pll_attrs, 'PLL') |
| 3835 |
|
| 3836 |
for r, c in bits: |
| 3837 |
tile[r][c] = 1 |
| 3838 |
|
| 3839 |
cfg_type = 51 |
| 3840 |
bits = get_shortval_fuses(db, cfg_type, pll_attrs, 'PLL') |
| 3841 |
cfg_tile = tilemap[(0, 37)] |
| 3842 |
for r, c in bits: |
| 3843 |
cfg_tile[r][c] = 1 |
| 3844 |
elif typ == 'DLLDLY': |
| 3845 |
dlldly_attrs = set_dlldly_attrs(db, typ, parms, cell) |
| 3846 |
for dlldly_row, dlldly_col in db.extra_func[row - 1, col -1]['dlldly_fusebels']: |
| 3847 |
dlldly_tiledata = db[dlldly_row, dlldly_col] |
| 3848 |
dlldly_tile = tilemap[(dlldly_row, dlldly_col)] |
| 3849 |
bits = get_long_fuses(db, dlldly_tiledata.ttyp, dlldly_attrs, f'DLLDEL{num}') |
| 3850 |
for r, c in bits: |
| 3851 |
dlldly_tile[r][c] = 1 |
| 3852 |
elif typ == 'DHCEN': |
| 3853 |
if 'DHCEN_USED' not in attrs: |
| 3854 |
continue |
| 3855 |
|
| 3856 |
|
| 3857 |
|
| 3858 |
_, wire, _, side = db.extra_func[row - 1, col -1]['dhcen'][int(num)]['pip'] |
| 3859 |
hclk_attrs = find_and_set_dhcen_hclk_fuses(db, tilemap, wire, side) |
| 3860 |
elif typ.startswith("CLKDIV"): |
| 3861 |
hclk_attrs = set_hclk_attrs(db, parms, num, typ, cellname) |
| 3862 |
bits = get_shortval_fuses(db, tiledata.ttyp, hclk_attrs, "HCLK") |
| 3863 |
|
| 3864 |
for r, c in bits: |
| 3865 |
tile[r][c] = 1 |
| 3866 |
elif typ == 'DQCE': |
| 3867 |
|
| 3868 |
pipre = re.compile(r"X(\d+)Y(\d+)/([\w_]+)/([\w_]+)") |
| 3869 |
if 'DQCE_PIP' not in attrs: |
| 3870 |
continue |
| 3871 |
pip = attrs['DQCE_PIP'] |
| 3872 |
res = pipre.fullmatch(pip) |
| 3873 |
if not res: |
| 3874 |
raise Exception(f"Bad DQCE pip {pip} at {cellname}") |
| 3875 |
pip_col, pip_row, dest, src = res.groups() |
| 3876 |
pip_row = int(pip_row) |
| 3877 |
pip_col = int(pip_col) |
| 3878 |
|
| 3879 |
pip_tiledata = db[pip_row, pip_col] |
| 3880 |
pip_tile = tilemap[(pip_row, pip_col)] |
| 3881 |
bits = pip_tiledata.clock_pips[dest][src] |
| 3882 |
for r, c in bits: |
| 3883 |
pip_tile[r][c] = 1 |
| 3884 |
elif typ == 'DCS': |
| 3885 |
if 'DCS_MODE' not in attrs: |
| 3886 |
continue |
| 3887 |
spine = db.extra_func[row - 1, col - 1]['dcs'][int(num)]['clkout'] |
| 3888 |
dcs_attrs = set_dcs_attrs(db, spine, attrs) |
| 3889 |
_, idx = _dcs_spine2quadrant_idx[spine] |
| 3890 |
if device in {'GW5A-25A'}: |
| 3891 |
set_dcs_fuses(db, tilemap, int(num), dcs_attrs, idx) |
| 3892 |
else: |
| 3893 |
bits = get_long_fuses(db, tiledata.ttyp, dcs_attrs, idx) |
| 3894 |
for r, c in bits: |
| 3895 |
tile[r][c] = 1 |
| 3896 |
else: |
| 3897 |
print("unknown type", typ) |
| 3898 |
|
| 3899 |
|
| 3900 |
for bank, ios in _io_bels.items(): |
| 3901 |
in_bank_attrs = {} |
| 3902 |
|
| 3903 |
vccio = None |
| 3904 |
iostd = None |
| 3905 |
for iob_name, iob in ios.items(): |
| 3906 |
|
| 3907 |
if (iob.pos[0], iob.pos[1]) in adc_iolocs: |
| 3908 |
raise Exception(f"{iob_name} is ADC IO. Can't use it as GPIO.") |
| 3909 |
|
| 3910 |
|
| 3911 |
if iob.pos[0] in db.simplio_rows: |
| 3912 |
if iob.flags['mode'].startswith('ELVDS') or iob.flags['mode'].startswith('TLVDS'): |
| 3913 |
raise Exception(f"Differential IO cant be placed at special row {iob.pos[0]}") |
| 3914 |
|
| 3915 |
if iob.flags['mode'] in {'IBUF', 'IOBUF', 'TLVDS_IBUF', 'TLVDS_IOBUF', 'ELVDS_IBUF', 'ELVDS_IOBUF'}: |
| 3916 |
iob.attrs['IO_TYPE'] = get_iostd_alias(iob.attrs['IO_TYPE']) |
| 3917 |
if iob.attrs.get('SINGLERESISTOR', 'OFF') != 'OFF': |
| 3918 |
iob.attrs['DDR_DYNTERM'] = 'ON' |
| 3919 |
if iob.flags['mode'] in {'OBUF', 'IOBUF', 'TLVDS_OBUF', 'TLVDS_IOBUF', 'TLVDS_TBUF', 'TLVDS_TBUF', 'ELVDS_OBUF', 'ELVDS_IOBUF'}: |
| 3920 |
if iob.flags['mode'] in {'ELVDS_OBUF', 'ELVDS_IOBUF'}: |
| 3921 |
in_bank_attrs['BANK_VCCIO'] = '1.2' |
| 3922 |
|
| 3923 |
if 'BANK_VCCIO' in iob.attrs: |
| 3924 |
if iob.attrs['BANK_VCCIO'] != _vcc_ios[iob.attrs['IO_TYPE']]: |
| 3925 |
raise Exception(f"Conflict bank VCC at {iob_name}.") |
| 3926 |
if not vccio: |
| 3927 |
if not (iob.attrs['IO_TYPE'].startswith('LVDS') or is_ram_pin(db, row, col, num)): |
| 3928 |
iostd = iob.attrs['IO_TYPE'] |
| 3929 |
vccio = _vcc_ios[iostd] |
| 3930 |
elif vccio != _vcc_ios[iob.attrs['IO_TYPE']] and not iob.attrs['IO_TYPE'].startswith('LVDS'): |
| 3931 |
snd_type = iob.attrs['IO_TYPE'] |
| 3932 |
fst = [name for name, iob in ios.items() if iob.attrs['IO_TYPE'] == iostd][0] |
| 3933 |
snd = iob_name |
| 3934 |
raise Exception(f"Different IO standard for bank {bank}: {fst} sets {iostd}, {snd} sets {iob.attrs['IO_TYPE']}.") |
| 3935 |
|
| 3936 |
if not vccio: |
| 3937 |
if device not in {'GW5A-25A', 'GW5AST-138C'}: |
| 3938 |
iostd = 'LVCMOS12' |
| 3939 |
else: |
| 3940 |
iostd = 'LVCMOS33' |
| 3941 |
|
| 3942 |
if 'BANK_VCCIO' not in in_bank_attrs: |
| 3943 |
in_bank_attrs['BANK_VCCIO'] = _vcc_ios[iostd] |
| 3944 |
|
| 3945 |
_banks[bank].iostd = iostd |
| 3946 |
|
| 3947 |
|
| 3948 |
for name, iob in ios.items(): |
| 3949 |
row, col, idx = iob.pos |
| 3950 |
tiledata = db[row, col] |
| 3951 |
|
| 3952 |
mode_for_attrs = iob.flags['mode'] |
| 3953 |
lvds_attrs = {} |
| 3954 |
if mode_for_attrs.startswith('TLVDS_') or mode_for_attrs.startswith('ELVDS_'): |
| 3955 |
mode_for_attrs = mode_for_attrs[6:] |
| 3956 |
lvds_attrs = {'HYSTERESIS': 'NA', 'PULLMODE': 'NONE', 'OPENDRAIN': 'OFF'} |
| 3957 |
|
| 3958 |
in_iob_attrs = _init_io_attrs[mode_for_attrs].copy() |
| 3959 |
in_iob_attrs.update(lvds_attrs) |
| 3960 |
|
| 3961 |
|
| 3962 |
if iob.flags['mode'] not in {'IBUF', 'TLVDS_IBUF', 'ELVDS_IBUF'}: |
| 3963 |
if iob_is_connected(iob.flags, 'OEN'): |
| 3964 |
if iob_is_gnd_net(iob.flags, 'OEN'): |
| 3965 |
in_iob_attrs['TRIMUX_PADDT'] = 'SIG' |
| 3966 |
elif iob_is_vcc_net(iob.flags, 'OEN'): |
| 3967 |
in_iob_attrs['ODMUX_1'] = '0' |
| 3968 |
else: |
| 3969 |
in_iob_attrs['TRIMUX_PADDT'] = 'SIG' |
| 3970 |
in_iob_attrs['TO'] = 'SIG' |
| 3971 |
else: |
| 3972 |
in_iob_attrs['ODMUX_1'] = '1' |
| 3973 |
|
| 3974 |
|
| 3975 |
for k, val in iob.attrs.items(): |
| 3976 |
k = refine_io_attrs(k) |
| 3977 |
in_iob_attrs[k] = val |
| 3978 |
in_iob_attrs['BANK_VCCIO'] = in_bank_attrs['BANK_VCCIO'] |
| 3979 |
|
| 3980 |
|
| 3981 |
|
| 3982 |
if iob.flags['mode'] in {'TLVDS_OBUF', 'TLVDS_TBUF', 'TLVDS_IOBUF'}: |
| 3983 |
in_iob_attrs.update({'LVDS_OUT': 'ON', 'ODMUX_1': 'UNKNOWN', 'ODMUX': 'TRIMUX', |
| 3984 |
'SLEWRATE': 'FAST', 'PERSISTENT': 'OFF', 'DRIVE': '0', 'DIFFRESISTOR': 'OFF'}) |
| 3985 |
elif iob.flags['mode'] in {'ELVDS_OBUF', 'ELVDS_TBUF', 'ELVDS_IOBUF'}: |
| 3986 |
in_iob_attrs.update({'ODMUX_1': 'UNKNOWN', 'ODMUX': 'TRIMUX', |
| 3987 |
'PERSISTENT': 'OFF', 'DIFFRESISTOR': 'OFF'}) |
| 3988 |
in_iob_attrs['IO_TYPE'] = get_iostd_alias(in_iob_attrs['IO_TYPE']) |
| 3989 |
if iob.flags['mode'] in {'TLVDS_IBUF', 'ELVDS_IBUF'}: |
| 3990 |
in_iob_attrs['ODMUX_1'] = 'UNKNOWN' |
| 3991 |
in_iob_attrs.pop('BANK_VCCIO', None) |
| 3992 |
if 'IO_TYPE' in in_iob_attrs and in_iob_attrs['IO_TYPE'] == 'MIPI': |
| 3993 |
in_iob_attrs['LPRX_A1'] = 'ENABLE' |
| 3994 |
in_iob_attrs.pop('SLEWRATE', None) |
| 3995 |
in_iob_attrs.pop('BANK_VCCIO', None) |
| 3996 |
in_iob_attrs['PULLMODE'] = 'NONE' |
| 3997 |
in_iob_attrs['LVDS_ON'] = 'ENABLE' |
| 3998 |
in_iob_attrs['IOBUF_MIPI_LP'] = 'ENABLE' |
| 3999 |
if 'I3C_IOBUF' in in_iob_attrs: |
| 4000 |
in_iob_attrs.pop('I3C_IOBUF', None) |
| 4001 |
in_iob_attrs['PULLMODE'] = 'NONE' |
| 4002 |
in_iob_attrs['OPENDRAIN'] = 'OFF' |
| 4003 |
in_iob_attrs['OD'] = 'ENABLE' |
| 4004 |
in_iob_attrs['DIFFRESISTOR'] = 'NA' |
| 4005 |
in_iob_attrs['SINGLERESISTOR'] = 'NA' |
| 4006 |
in_iob_attrs['DRIVE'] = '16' |
| 4007 |
|
| 4008 |
|
| 4009 |
if device == 'GW1N-1': |
| 4010 |
if row == 5 and mode_for_attrs == 'OBUF': |
| 4011 |
in_iob_attrs['TO'] = 'UNKNOWN' |
| 4012 |
if device not in {'GW1N-4', 'GW1NS-4'}: |
| 4013 |
if mode[1:].startswith('LVDS') and in_iob_attrs['DRIVE'] != '0': |
| 4014 |
in_iob_attrs['DRIVE'] = 'UNKNOWN' |
| 4015 |
in_iob_b_attrs = {} |
| 4016 |
if 'IO_TYPE' in in_iob_attrs and in_iob_attrs['IO_TYPE'] == 'MIPI': |
| 4017 |
in_iob_attrs['IO_TYPE'] = 'LVDS25' |
| 4018 |
in_iob_b_attrs['IO_TYPE'] = 'LVDS25' |
| 4019 |
in_iob_b_attrs['PULLMODE'] = 'NONE' |
| 4020 |
in_iob_b_attrs['OPENDRAIN'] = 'OFF' |
| 4021 |
in_iob_b_attrs['IOBUF_MIPI_LP'] = 'ENABLE' |
| 4022 |
in_iob_b_attrs['PERSISTENT'] = 'OFF' |
| 4023 |
if iob.flags['mode'] in {'TLVDS_OBUF', 'TLVDS_TBUF', 'TLVDS_IOBUF'}: |
| 4024 |
in_iob_b_attrs = in_iob_attrs.copy() |
| 4025 |
elif iob.flags['mode'] in {'TLVDS_IBUF', 'ELVDS_IBUF'}: |
| 4026 |
in_iob_b_attrs = in_iob_attrs.copy() |
| 4027 |
if iob.flags['mode'] in {'ELVDS_IBUF'}: |
| 4028 |
in_iob_attrs['PULLMODE'] = 'UP' |
| 4029 |
in_iob_b_attrs['PULLMODE'] = 'NONE' |
| 4030 |
in_iob_b_attrs['IO_TYPE'] = in_iob_attrs.get('IO_TYPE', 'UNKNOWN') |
| 4031 |
in_iob_b_attrs['DIFFRESISTOR'] = in_iob_attrs.get('DIFFRESISTOR', 'OFF') |
| 4032 |
elif iob.flags['mode'] in {'ELVDS_OBUF', 'ELVDS_TBUF', 'ELVDS_IOBUF'}: |
| 4033 |
if iob.flags['mode'] in {'ELVDS_IOBUF'}: |
| 4034 |
in_iob_attrs['PULLMODE'] = 'UP' |
| 4035 |
in_iob_b_attrs['PULLMODE'] = 'UP' |
| 4036 |
in_iob_b_attrs = in_iob_attrs.copy() |
| 4037 |
|
| 4038 |
for iob_idx, atr in [(idx, in_iob_attrs), ('B', in_iob_b_attrs)]: |
| 4039 |
_banks[bank].bels.add(rc2tbrl(db, row, col, iob_idx)) |
| 4040 |
iob_attrs = set() |
| 4041 |
for k, val in atr.items(): |
| 4042 |
if k not in attrids.iob_attrids: |
| 4043 |
print(f'XXX IO: add {k} key handle') |
| 4044 |
else: |
| 4045 |
add_attr_val(db, 'IOB', iob_attrs, attrids.iob_attrids[k], attrids.iob_attrvals[val]) |
| 4046 |
if k == 'LVDS_OUT' and val not in {'ENABLE', 'ON'}: |
| 4047 |
if device not in {'GW5A-25A', 'GW5AST-138C'}: |
| 4048 |
continue |
| 4049 |
if k == 'IO_TYPE' and k in in_bank_attrs and in_bank_attrs[k].startswith('LVDS'): |
| 4050 |
continue |
| 4051 |
in_bank_attrs[k] = val |
| 4052 |
fuse_row, fuse_col = (row, col) |
| 4053 |
if device not in {'GW5A-25A', 'GW5AST-138C'}: |
| 4054 |
bits = get_longval_fuses(db, tiledata.ttyp, iob_attrs, f'IOB{iob_idx}') |
| 4055 |
else: |
| 4056 |
|
| 4057 |
if mode_for_attrs in {'OBUF', 'IOBUF', 'TBUF'}: |
| 4058 |
add_attr_val(db, 'IOB', iob_attrs, attrids.iob_attrids['IOB_UNKNOWN51'], attrids.iob_attrvals['TRIMUX']) |
| 4059 |
elif mode_for_attrs == 'IBUF': |
| 4060 |
if 'HCLK' in iob.flags: |
| 4061 |
add_attr_val(db, 'IOB', iob_attrs, attrids.iob_attrids['IOB_UNKNOWN67'], attrids.iob_attrvals['UNKNOWN263']) |
| 4062 |
elif 'HCLK_PAIR' in iob.flags: |
| 4063 |
add_attr_val(db, 'IOB', iob_attrs, attrids.iob_attrids['IOB_UNKNOWN67'], attrids.iob_attrvals['UNKNOWN266']) |
| 4064 |
|
| 4065 |
|
| 4066 |
fuse_ttyp = tiledata.ttyp |
| 4067 |
off = tiledata.bels[f'IOB{iob_idx}'].fuse_cell_offset |
| 4068 |
if off: |
| 4069 |
fuse_row += off[0] |
| 4070 |
fuse_col += off[1] |
| 4071 |
fuse_ttyp = db.grid[fuse_row][fuse_col] |
| 4072 |
|
| 4073 |
if (row, col, iob_idx) == (2, 91, 'B'): |
| 4074 |
iob_idx = 'A' |
| 4075 |
bits = get_longval_fuses(db, fuse_ttyp, iob_attrs, f'IOB{iob_idx}') |
| 4076 |
|
| 4077 |
tile = tilemap[(fuse_row, fuse_col)] |
| 4078 |
for row_, col_ in bits: |
| 4079 |
tile[row_][col_] = 1 |
| 4080 |
if idx == 'B': |
| 4081 |
break |
| 4082 |
if not lvds_attrs: |
| 4083 |
break |
| 4084 |
|
| 4085 |
|
| 4086 |
brow, bcol = db.bank_tiles[bank] |
| 4087 |
tiledata = db[brow, bcol] |
| 4088 |
|
| 4089 |
bank_attrs = set() |
| 4090 |
for k, val in in_bank_attrs.items(): |
| 4091 |
if k not in attrids.iob_attrids: |
| 4092 |
print(f'XXX BANK: add {k} key handle') |
| 4093 |
else: |
| 4094 |
if k in {'BANK_VCCIO', 'IO_TYPE', 'LVDS_OUT', 'DRIVE', 'OPENDRAIN', 'PULL_STRENGTH'}: |
| 4095 |
add_attr_val(db, 'IOB', bank_attrs, attrids.iob_attrids[k], attrids.iob_attrvals[val]) |
| 4096 |
|
| 4097 |
|
| 4098 |
bits = get_bank_fuses(db, tiledata.ttyp, bank_attrs, 'BANK', bank) |
| 4099 |
bits.update(get_bank_io_fuses(db, tiledata.ttyp, bank_attrs)) |
| 4100 |
|
| 4101 |
btile = tilemap[(brow, bcol)] |
| 4102 |
for row, col in bits: |
| 4103 |
btile[row][col] = 1 |
| 4104 |
|
| 4105 |
|
| 4106 |
|
| 4107 |
|
| 4108 |
|
| 4109 |
|
| 4110 |
partno = pnr['modules']['top']['settings'].get('packer.partno', '') |
| 4111 |
|
| 4112 |
for bel, cfg in db.io_cfg.items(): |
| 4113 |
attrs = {} |
| 4114 |
bank = db.pin_bank.get(bel, None) |
| 4115 |
if bank == None: |
| 4116 |
if cfg: |
| 4117 |
raise Exception(f"Pin {bel} with alt configurstions {cfg} has no bank.") |
| 4118 |
continue |
| 4119 |
if bank in _banks: |
| 4120 |
|
| 4121 |
if bel in _banks[bank].bels: |
| 4122 |
|
| 4123 |
continue |
| 4124 |
else: |
| 4125 |
if device not in {'GW5A-25A', 'GW5AST-138C'}: |
| 4126 |
io_std = 'LVCMOS18' |
| 4127 |
else: |
| 4128 |
io_std = 'LVCMOS33' |
| 4129 |
_banks.setdefault(bank, BankDesc(None, set())).iostd = io_std |
| 4130 |
|
| 4131 |
brow, bcol = db.bank_tiles[bank] |
| 4132 |
tiledata = db[brow, bcol] |
| 4133 |
|
| 4134 |
bank_attrs = set() |
| 4135 |
for k, val in in_bank_attrs.items(): |
| 4136 |
if k not in attrids.iob_attrids: |
| 4137 |
print(f'XXX BANK: add {k} key handle') |
| 4138 |
else: |
| 4139 |
add_attr_val(db, 'IOB', bank_attrs, attrids.iob_attrids['BANK_VCCIO'], attrids.iob_attrvals[_vcc_ios[io_std]]) |
| 4140 |
|
| 4141 |
bits = get_bank_fuses(db, tiledata.ttyp, bank_attrs, 'BANK', bank) |
| 4142 |
bits.update(get_bank_io_fuses(db, tiledata.ttyp, bank_attrs)) |
| 4143 |
|
| 4144 |
btile = tilemap[(brow, bcol)] |
| 4145 |
for row, col in bits: |
| 4146 |
btile[row][col] = 1 |
| 4147 |
|
| 4148 |
io_std = _banks[bank].iostd |
| 4149 |
attrs.update({'IO_TYPE': io_std, 'BANK_VCCIO': _vcc_ios[io_std]}) |
| 4150 |
|
| 4151 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 4152 |
attrs.update({'OPENDRAIN': 'OFF'}) |
| 4153 |
drive = '8' |
| 4154 |
if io_std == 'LVCMOS10': |
| 4155 |
drive = '4' |
| 4156 |
attrs.update({'DRIVE': drive, 'DRIVE_LEVEL': drive}) |
| 4157 |
pullup_and_iomode = get_pullup_io(cfg) |
| 4158 |
attrs.update(pullup_and_iomode) |
| 4159 |
|
| 4160 |
side = bel[2] |
| 4161 |
num = bel[3:-1] |
| 4162 |
iob_idx = bel[-1] |
| 4163 |
if side == 'T': |
| 4164 |
row = 0 |
| 4165 |
col = int(num) - 1 |
| 4166 |
elif side == 'B': |
| 4167 |
row = db.rows - 1 |
| 4168 |
col = int(num) - 1 |
| 4169 |
elif side == 'L': |
| 4170 |
row = int(num) - 1 |
| 4171 |
col = 0 |
| 4172 |
elif side == 'R': |
| 4173 |
row = int(num) - 1 |
| 4174 |
col = db.cols - 1 |
| 4175 |
|
| 4176 |
tiledata = db[row, col] |
| 4177 |
if f'IOB{iob_idx}' not in tiledata.bels: |
| 4178 |
continue |
| 4179 |
|
| 4180 |
iob_attrs = set() |
| 4181 |
for k, val in attrs.items(): |
| 4182 |
add_attr_val(db, 'IOB', iob_attrs, attrids.iob_attrids[k], attrids.iob_attrvals[val]) |
| 4183 |
fuse_row, fuse_col = (row, col) |
| 4184 |
|
| 4185 |
if device not in {'GW5A-25A', 'GW5AST-138C'}: |
| 4186 |
bits = get_longval_fuses(db, tiledata.ttyp, iob_attrs, f'IOB{iob_idx}') |
| 4187 |
else: |
| 4188 |
|
| 4189 |
fuse_ttyp = tiledata.ttyp |
| 4190 |
off = tiledata.bels[f'IOB{iob_idx}'].fuse_cell_offset |
| 4191 |
if off: |
| 4192 |
fuse_row += off[0] |
| 4193 |
fuse_col += off[1] |
| 4194 |
fuse_ttyp = db.grid[fuse_row][fuse_col] |
| 4195 |
|
| 4196 |
if (row, col, iob_idx) == (2, 91, 'B'): |
| 4197 |
iob_idx = 'A' |
| 4198 |
elif (row, col) == (3, 91): |
| 4199 |
continue |
| 4200 |
bits = get_longval_fuses(db, fuse_ttyp, iob_attrs, f'IOB{iob_idx}') |
| 4201 |
|
| 4202 |
tile = tilemap[(fuse_row, fuse_col)] |
| 4203 |
for row_, col_ in bits: |
| 4204 |
tile[row_][col_] = 1 |
| 4205 |
|
| 4206 |
|
| 4207 |
_used_ihclk_wires = set() |
| 4208 |
def do_hclk_banks(db, row, col, src, dest): |
| 4209 |
res = set() |
| 4210 |
if dest in {'HCLK_BANK_OUT0', 'HCLK_BANK_OUT1'}: |
| 4211 |
fin_attrs = set() |
| 4212 |
add_attr_val(db, 'HCLK', fin_attrs, attrids.hclk_attrids[f'BRGMUX{dest[-1]}_BRGOUT'], attrids.hclk_attrvals['ENABLE']) |
| 4213 |
|
| 4214 |
ttyp = db.grid[row][col] |
| 4215 |
if 'HCLK' in db.shortval[ttyp]: |
| 4216 |
res = get_shortval_fuses(db, ttyp, fin_attrs, "HCLK") |
| 4217 |
if dest.startswith('HCLK_TO_IHCLK'): |
| 4218 |
_used_ihclk_wires.add(dest) |
| 4219 |
return res |
| 4220 |
|
| 4221 |
def do_gw5_ihclk(db, tilemap): |
| 4222 |
if device not in {'GW5A-25A', 'GW5AST-138C'}: |
| 4223 |
return |
| 4224 |
if not _used_ihclk_wires: |
| 4225 |
return |
| 4226 |
for row in range(db.rows): |
| 4227 |
for col in range(db.cols): |
| 4228 |
ttyp = db.grid[row][col] |
| 4229 |
if ttyp in db.shortval and 'HCLK' in db.shortval[ttyp]: |
| 4230 |
for wire in _used_ihclk_wires: |
| 4231 |
hclk_idx = chipdb.gw5_hclk_idx(db, device, row, col) |
| 4232 |
if hclk_idx != int(wire[-2]): |
| 4233 |
continue |
| 4234 |
print(f'Enable gate {wire} ({row}, {col})') |
| 4235 |
fin_attrs = set() |
| 4236 |
add_attr_val(db, 'HCLK', fin_attrs, attrids.hclk_attrids[f'TO_IHCLK{"0213"[int(wire[-1])]}'], attrids.hclk_attrvals['ENABLE']) |
| 4237 |
bits = get_shortval_fuses(db, ttyp, fin_attrs, "HCLK") |
| 4238 |
tile = tilemap[row, col] |
| 4239 |
for row_, col_ in bits: |
| 4240 |
tile[row_][col_] = 1 |
| 4241 |
|
| 4242 |
def route(db, tilemap, pips): |
| 4243 |
|
| 4244 |
def is_clock_pip(src, dest): |
| 4245 |
if src[8:].startswith('_BOT') or src[8:].startswith('_TOP'): |
| 4246 |
return True |
| 4247 |
if src not in wnames.clknumbers: |
| 4248 |
return False |
| 4249 |
if dest not in wnames.clknumbers: |
| 4250 |
return False |
| 4251 |
if device in {'GW5A-25A'}: |
| 4252 |
return wnames.clknumbers[src] < wnames.clknumbers['UNK212'] \ |
| 4253 |
or wnames.clknumbers[src] in range(wnames.clknumbers['MPLL4CLKOUT0'], wnames.clknumbers['UNK569'] + 1) |
| 4254 |
if device in {'GW5AST-138C'}: |
| 4255 |
return wnames.clknumbers[src] < wnames.clknumbers['UNK269'] \ |
| 4256 |
or wnames.clknumbers[src] >= wnames.clknumbers['UNK309'] |
| 4257 |
|
| 4258 |
return wnames.clknumbers[src] < wnames.clknumbers['P10A'] |
| 4259 |
|
| 4260 |
used_spines = set() |
| 4261 |
|
| 4262 |
|
| 4263 |
|
| 4264 |
if device in {'GW5AST-138C'}: |
| 4265 |
clock_bridge_ttypes = range(80, 86) |
| 4266 |
clock_bridge_cols = {col for col in range(db.cols) for row in range(db.rows) if db.grid[row][col] in clock_bridge_ttypes} |
| 4267 |
clock_bridge_rows = {54} |
| 4268 |
|
| 4269 |
def set_clock_fuses(row_, col_, src, dest): |
| 4270 |
|
| 4271 |
if dest in {'GT00', 'GT10'}: |
| 4272 |
bits = db[row_ - 1, col_ - 1].clock_pips[dest][src] |
| 4273 |
tile = tilemap[(row_ - 1, col_ - 1)] |
| 4274 |
for brow, bcol in bits: |
| 4275 |
tile[brow][bcol] = 1 |
| 4276 |
return |
| 4277 |
|
| 4278 |
|
| 4279 |
|
| 4280 |
area = 'T' |
| 4281 |
allowed_rows = range(db.rows) |
| 4282 |
allowed_cols = range(db.cols) |
| 4283 |
if device in {'GW5AST-138C'}: |
| 4284 |
allowed_rows = range(55) |
| 4285 |
|
| 4286 |
if row_ - 1 not in allowed_rows: |
| 4287 |
allowed_rows = range(allowed_rows.stop, db.rows) |
| 4288 |
area = 'B' |
| 4289 |
elif db.grid[row_ - 1][col_ - 1] in clock_bridge_ttypes: |
| 4290 |
allowed_rows = clock_bridge_rows |
| 4291 |
allowed_cols = clock_bridge_cols |
| 4292 |
area = 'C' |
| 4293 |
|
| 4294 |
spine_enable_table = None |
| 4295 |
|
| 4296 |
if dest.startswith('SPINE') and (area, dest) not in used_spines: |
| 4297 |
used_spines.update({(area, dest)}) |
| 4298 |
spine_enable_table = f'5A_PCLK_ENABLE_{wnames.clknumbers[dest]:02}' |
| 4299 |
|
| 4300 |
for row in range(db.rows): |
| 4301 |
if row in allowed_rows: |
| 4302 |
for col in range(db.cols): |
| 4303 |
if col in allowed_cols: |
| 4304 |
if device in {'GW5AST-138C'} and area == 'T' and row in clock_bridge_rows and col in clock_bridge_cols: |
| 4305 |
continue |
| 4306 |
rc = db[row, col] |
| 4307 |
ttyp = db.grid[row][col] |
| 4308 |
bits = set() |
| 4309 |
if dest in rc.clock_pips: |
| 4310 |
if src in rc.clock_pips[dest]: |
| 4311 |
bits = rc.clock_pips[dest][src] |
| 4312 |
if spine_enable_table in db.shortval[ttyp] and (1, 0) in db.shortval[ttyp][spine_enable_table]: |
| 4313 |
bits.update(db.shortval[ttyp][spine_enable_table][(1, 0)]) |
| 4314 |
print(f"Enable spine {dest} <- {src} ({row_}, {col_}) by {spine_enable_table} at ({row}, {col})") |
| 4315 |
if bits: |
| 4316 |
tile = tilemap[(row, col)] |
| 4317 |
for brow, bcol in bits: |
| 4318 |
tile[brow][bcol] = 1 |
| 4319 |
|
| 4320 |
def set_5a_hclk_wire_fuses(src, dest): |
| 4321 |
fuse_set = False |
| 4322 |
for row in range(db.rows): |
| 4323 |
for col in range(db.cols): |
| 4324 |
if (row, col) in db.hclk_pips and dest in db.hclk_pips[row, col] and src in db.hclk_pips[row, col][dest]: |
| 4325 |
fuse_set = True |
| 4326 |
bits = db.hclk_pips[row, col][dest][src] |
| 4327 |
|
| 4328 |
bits.update(do_hclk_banks(db, row, col, src, dest)) |
| 4329 |
tile = tilemap[(row, col)] |
| 4330 |
for r, c in bits: |
| 4331 |
tile[r][c] = 1 |
| 4332 |
return fuse_set |
| 4333 |
|
| 4334 |
for row, col, src, dest in pips: |
| 4335 |
if device in {'GW5A-25A', 'GW5AST-138C'} and is_clock_pip(src, dest): |
| 4336 |
set_clock_fuses(row, col, src, dest) |
| 4337 |
continue |
| 4338 |
|
| 4339 |
tiledata = db[row-1, col-1] |
| 4340 |
tile = tilemap[(row-1, col-1)] |
| 4341 |
|
| 4342 |
try: |
| 4343 |
|
| 4344 |
if device not in {'GW5A-25A', 'GW5AST-138C'} and dest in tiledata.clock_pips: |
| 4345 |
bits = tiledata.clock_pips[dest][src] |
| 4346 |
elif dest in {'FCLKA', 'FCLKB'}: |
| 4347 |
continue |
| 4348 |
elif device in {'GW5A-25A', 'GW5AST-138C'} and set_5a_hclk_wire_fuses(src, dest): |
| 4349 |
continue |
| 4350 |
elif (row - 1, col - 1) in db.hclk_pips and dest in db.hclk_pips[row - 1, col - 1] and src in db.hclk_pips[row - 1, col - 1][dest]: |
| 4351 |
bits = db.hclk_pips[row - 1, col - 1][dest][src] |
| 4352 |
bits.update(do_hclk_banks(db, row - 1, col - 1, src, dest)) |
| 4353 |
else: |
| 4354 |
bits = tiledata.pips[dest][src] |
| 4355 |
|
| 4356 |
if dest in tiledata.alonenode: |
| 4357 |
for srcs_fuses in tiledata.alonenode[dest]: |
| 4358 |
srcs, fuses = srcs_fuses |
| 4359 |
if src not in srcs: |
| 4360 |
bits |= fuses |
| 4361 |
except KeyError: |
| 4362 |
print(src, dest, "not found in tile", row, col) |
| 4363 |
breakpoint() |
| 4364 |
continue |
| 4365 |
for row, col in bits: |
| 4366 |
tile[row][col] = 1 |
| 4367 |
|
| 4368 |
def header_footer(db, bs, compress): |
| 4369 |
""" |
| 4370 |
Generate fs header and footer |
| 4371 |
Currently limited to checksum with |
| 4372 |
CRC_check and security_bit_enable set |
| 4373 |
""" |
| 4374 |
bs = bitmatrix.fliplr(bs) |
| 4375 |
bs = bitmatrix.packbits(bs) |
| 4376 |
|
| 4377 |
|
| 4378 |
res = int(bitmatrix.bsum(bs[0::2]) * pow(2,8) + bitmatrix.bsum(bs[1::2])) |
| 4379 |
checksum = res & 0xffff |
| 4380 |
|
| 4381 |
db.cmd_ftr[1] = bytearray.fromhex(f"{0x0A << 56 | checksum:016x}") |
| 4382 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 4383 |
db.cmd_ftr.insert(1, bytearray(b'\x68\x00\x00\x00\x00\x00\x00\x00')) |
| 4384 |
|
| 4385 |
def gsr(db, tilemap, args): |
| 4386 |
gsr_attrs = set() |
| 4387 |
for k, val in {'GSRMODE': 'ACTIVE_LOW'}.items(): |
| 4388 |
if k not in attrids.gsr_attrids: |
| 4389 |
print(f'XXX GSR: add {k} key handle') |
| 4390 |
else: |
| 4391 |
add_attr_val(db, 'GSR', gsr_attrs, attrids.gsr_attrids[k], attrids.gsr_attrvals[val]) |
| 4392 |
|
| 4393 |
cfg_attrs = set() |
| 4394 |
cfg_function = 'F0' |
| 4395 |
cfg_done_function = 'F0' |
| 4396 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 4397 |
cfg_function = 'F1' |
| 4398 |
cfg_done_function = 'F3' |
| 4399 |
for k, val in {'GSR': 'USED', 'GOE': cfg_function}.items(): |
| 4400 |
if k not in attrids.cfg_attrids: |
| 4401 |
print(f'XXX CFG GSR: add {k} key handle') |
| 4402 |
else: |
| 4403 |
add_attr_val(db, 'CFG', cfg_attrs, attrids.cfg_attrids[k], attrids.cfg_attrvals[val]) |
| 4404 |
add_attr_val(db, 'CFG', cfg_attrs, attrids.cfg_attrids['GSR'], attrids.cfg_attrvals[cfg_function]) |
| 4405 |
add_attr_val(db, 'CFG', cfg_attrs, attrids.cfg_attrids['DONE'], attrids.cfg_attrvals[cfg_done_function]) |
| 4406 |
add_attr_val(db, 'CFG', cfg_attrs, attrids.cfg_attrids['GWD'], attrids.cfg_attrvals[cfg_function]) |
| 4407 |
|
| 4408 |
|
| 4409 |
|
| 4410 |
gsr_type = {50, 83} |
| 4411 |
cfg_type = {50, 51} |
| 4412 |
if device in {'GW2A-18', 'GW2A-18C'}: |
| 4413 |
gsr_type = {1, 83} |
| 4414 |
cfg_type = {1, 51} |
| 4415 |
elif device in {'GW5A-25A'}: |
| 4416 |
gsr_type = {49, 83} |
| 4417 |
cfg_type = {49, 51} |
| 4418 |
elif device in {'GW5AST-138C'}: |
| 4419 |
gsr_type = {220} |
| 4420 |
cfg_type = {220} |
| 4421 |
|
| 4422 |
for row in range(db.rows): |
| 4423 |
for col in range(db.cols): |
| 4424 |
ttyp = db.grid[row][col] |
| 4425 |
bits = set() |
| 4426 |
if ttyp in gsr_type: |
| 4427 |
bits = get_shortval_fuses(db, ttyp, gsr_attrs, 'GSR') |
| 4428 |
if ttyp in cfg_type: |
| 4429 |
bits.update(get_shortval_fuses(db, ttyp, cfg_attrs, 'CFG')) |
| 4430 |
if bits: |
| 4431 |
btile = tilemap[(row, col)] |
| 4432 |
for brow, bcol in bits: |
| 4433 |
btile[brow][bcol] = 1 |
| 4434 |
|
| 4435 |
def dualmode_pins(db, tilemap, args): |
| 4436 |
pin_flags = {'JTAG_AS_GPIO': 'UNKNOWN', 'SSPI_AS_GPIO': 'UNKNOWN', 'MSPI_AS_GPIO': 'UNKNOWN', |
| 4437 |
'DONE_AS_GPIO': 'UNKNOWN', 'RECONFIG_AS_GPIO': 'UNKNOWN', 'READY_AS_GPIO': 'UNKNOWN', |
| 4438 |
'CPU_AS_GPIO_25': 'UNKNOWN', 'CPU_AS_GPIO_0': 'UNKNOWN', 'CPU_AS_GPIO_1': 'UNKNOWN', |
| 4439 |
'I2C_AS_GPIO': 'UNKNOWN'} |
| 4440 |
if args.jtag_as_gpio: |
| 4441 |
pin_flags['JTAG_AS_GPIO'] = 'YES' |
| 4442 |
if args.sspi_as_gpio: |
| 4443 |
pin_flags['SSPI_AS_GPIO'] = 'YES' |
| 4444 |
if args.mspi_as_gpio: |
| 4445 |
pin_flags['MSPI_AS_GPIO'] = 'YES' |
| 4446 |
if args.ready_as_gpio: |
| 4447 |
pin_flags['READY_AS_GPIO'] = 'YES' |
| 4448 |
if args.done_as_gpio: |
| 4449 |
pin_flags['DONE_AS_GPIO'] = 'YES' |
| 4450 |
if args.reconfign_as_gpio: |
| 4451 |
pin_flags['RECONFIG_AS_GPIO'] = 'YES' |
| 4452 |
if args.cpu_as_gpio: |
| 4453 |
if device in {'GW5A-25A'}: |
| 4454 |
pin_flags['CPU_AS_GPIO_25'] = 'YES' |
| 4455 |
elif device in {'GW5AST-138C'}: |
| 4456 |
pin_flags['CPU_AS_GPIO_0'] = 'YES' |
| 4457 |
pin_flags['CPU_AS_GPIO_1'] = 'YES' |
| 4458 |
if args.i2c_as_gpio: |
| 4459 |
pin_flags['I2C_AS_GPIO'] = 'YES' |
| 4460 |
|
| 4461 |
set_attrs = set() |
| 4462 |
clr_attrs = set() |
| 4463 |
for k, val in pin_flags.items(): |
| 4464 |
if k not in attrids.cfg_attrids: |
| 4465 |
print(f'XXX CFG: add {k} key handle') |
| 4466 |
else: |
| 4467 |
add_attr_val(db, 'CFG', set_attrs, attrids.cfg_attrids[k], attrids.cfg_attrvals[val]) |
| 4468 |
add_attr_val(db, 'CFG', clr_attrs, attrids.cfg_attrids[k], attrids.cfg_attrvals['YES']) |
| 4469 |
|
| 4470 |
|
| 4471 |
|
| 4472 |
cfg_type = {50, 51} |
| 4473 |
if device in {'GW2A-18', 'GW2A-18C'}: |
| 4474 |
cfg_type = {1, 51} |
| 4475 |
elif device in {'GW5A-25A'}: |
| 4476 |
cfg_type = {49, 51} |
| 4477 |
elif device in {'GW5AST-138C'}: |
| 4478 |
cfg_type = {220} |
| 4479 |
|
| 4480 |
for row in range(db.rows): |
| 4481 |
for col in range(db.cols): |
| 4482 |
ttyp = db.grid[row][col] |
| 4483 |
bits = set() |
| 4484 |
clr_bits = set() |
| 4485 |
if ttyp in cfg_type: |
| 4486 |
bits.update(get_shortval_fuses(db, ttyp, set_attrs, 'CFG')) |
| 4487 |
clr_bits.update(get_shortval_fuses(db, ttyp, clr_attrs, 'CFG')) |
| 4488 |
if clr_bits: |
| 4489 |
btile = tilemap[(row, col)] |
| 4490 |
for brow, bcol in clr_bits: |
| 4491 |
btile[brow][bcol] = 0 |
| 4492 |
for brow, bcol in bits: |
| 4493 |
btile[brow][bcol] = 1 |
| 4494 |
|
| 4495 |
def set_const_fuses(db, row, col, tile): |
| 4496 |
tiledata = db[row, col] |
| 4497 |
if tiledata.ttyp in db.const: |
| 4498 |
for bits in db.const[tiledata.ttyp]: |
| 4499 |
brow, bcol = bits |
| 4500 |
tile[brow][bcol] = 1 |
| 4501 |
|
| 4502 |
def set_adc_iobuf_fuses(db, tilemap): |
| 4503 |
for ioloc in adc_iolocs.keys(): |
| 4504 |
row, col = ioloc |
| 4505 |
bus = adc_iolocs[ioloc]['bus'] |
| 4506 |
tiledata = db[row, col] |
| 4507 |
|
| 4508 |
attrs = {} |
| 4509 |
if bus not in '01': |
| 4510 |
attrs['IOB_GW5_ADC_DYN_IN'] = 'ENABLE' |
| 4511 |
attrs['IOB_UNKNOWN70'] = 'UNKNOWN' |
| 4512 |
attrs['IOB_UNKNOWN71'] = 'UNKNOWN' |
| 4513 |
attrs['IO_TYPE'] = 'GW5_ADC_IN' |
| 4514 |
attrs['IOB_GW5_ADC_IN'] = 'ENABLE' |
| 4515 |
attrs['PULLMODE'] = 'NONE' |
| 4516 |
attrs['HYSTERESIS'] = 'NONE' |
| 4517 |
attrs['CLAMP'] = 'OFF' |
| 4518 |
attrs['OPENDRAIN'] = 'OFF' |
| 4519 |
attrs['DDR_DYNTERM'] = 'NA' |
| 4520 |
attrs['IO_BANK'] = 'NA' |
| 4521 |
attrs['PADDI'] = 'PADDI' |
| 4522 |
attrs['PULL_STRENGTH'] = 'NONE' |
| 4523 |
attrs['IOB_GW5_VCCX_64'] = '3.3' |
| 4524 |
|
| 4525 |
io_attrs = set() |
| 4526 |
for k, val in attrs.items(): |
| 4527 |
add_attr_val(db, 'IOB', io_attrs, attrids.iob_attrids[k], attrids.iob_attrvals[val]) |
| 4528 |
|
| 4529 |
bits = get_longval_fuses(db, tiledata.ttyp, io_attrs, 'IOBA') |
| 4530 |
tile = tilemap[(row, col)] |
| 4531 |
for row_, col_ in bits: |
| 4532 |
tile[row_][col_] = 1 |
| 4533 |
|
| 4534 |
|
| 4535 |
if tiledata.bels['IOBB'].fuse_cell_offset: |
| 4536 |
row += tiledata.bels['IOBB'].fuse_cell_offset[0] |
| 4537 |
col += tiledata.bels['IOBB'].fuse_cell_offset[1] |
| 4538 |
tiledata = db[row, col] |
| 4539 |
|
| 4540 |
attrs = {} |
| 4541 |
if bus in '01': |
| 4542 |
attrs['IOB_UNKNOWN60'] = 'ON' |
| 4543 |
attrs['IOB_UNKNOWN61'] = 'ON' |
| 4544 |
else: |
| 4545 |
attrs['IOB_GW5_ADC_DYN_IN'] = 'ENABLE' |
| 4546 |
attrs['IOB_UNKNOWN70'] = 'UNKNOWN' |
| 4547 |
attrs['IOB_UNKNOWN71'] = 'UNKNOWN' |
| 4548 |
attrs['IO_TYPE'] = 'GW5_ADC_IN' |
| 4549 |
attrs['IOB_GW5_ADC_IN'] = 'ENABLE' |
| 4550 |
attrs['PULLMODE'] = 'NONE' |
| 4551 |
attrs['HYSTERESIS'] = 'NONE' |
| 4552 |
attrs['CLAMP'] = 'OFF' |
| 4553 |
attrs['OPENDRAIN'] = 'OFF' |
| 4554 |
attrs['DDR_DYNTERM'] = 'NA' |
| 4555 |
attrs['IO_BANK'] = 'NA' |
| 4556 |
attrs['PADDI'] = 'PADDI' |
| 4557 |
attrs['PULL_STRENGTH'] = 'NONE' |
| 4558 |
attrs['IOB_GW5_VCCX_64'] = '3.3' |
| 4559 |
|
| 4560 |
io_attrs = set() |
| 4561 |
for k, val in attrs.items(): |
| 4562 |
add_attr_val(db, 'IOB', io_attrs, attrids.iob_attrids[k], attrids.iob_attrvals[val]) |
| 4563 |
|
| 4564 |
bits = get_longval_fuses(db, tiledata.ttyp, io_attrs, 'IOBB') |
| 4565 |
tile = tilemap[(row, col)] |
| 4566 |
for row_, col_ in bits: |
| 4567 |
tile[row_][col_] = 1 |
| 4568 |
|
| 4569 |
|
| 4570 |
def set_slice_fuses(db, tilemap, slice_attrvals): |
| 4571 |
for pos, attrvals in slice_attrvals.items(): |
| 4572 |
row, col, num = pos |
| 4573 |
if 'MODE' in attrvals and attrvals['MODE'] == 'SSRAM': |
| 4574 |
attrvals.update({'REG0_REGSET': 'UNKNOWN'}) |
| 4575 |
attrvals.update({'REG1_REGSET': 'UNKNOWN'}) |
| 4576 |
elif 'REGMODE' not in attrvals: |
| 4577 |
attrvals.update({'LSRONMUX': '0'}) |
| 4578 |
attrvals.update({'CLKMUX_1': '1'}) |
| 4579 |
if 'REG0_REGSET' not in attrvals: |
| 4580 |
attrvals.update({'REG0_REGSET': 'RESET'}) |
| 4581 |
if 'REG1_REGSET' not in attrvals: |
| 4582 |
attrvals.update({'REG1_REGSET': 'RESET'}) |
| 4583 |
if num == 0 and 'ALU_CIN_MUX' not in attrvals: |
| 4584 |
attrvals.update({'ALU_CIN_MUX': 'ALU_5A_CIN_COUT'}) |
| 4585 |
|
| 4586 |
av = set() |
| 4587 |
for attr, val in attrvals.items(): |
| 4588 |
add_attr_val(db, 'SLICE', av, attrids.cls_attrids[attr], attrids.cls_attrvals[val]) |
| 4589 |
|
| 4590 |
if f'CLS{num}' in db.shortval[db.grid[row - 1][col - 1]]: |
| 4591 |
|
| 4592 |
bits = get_shortval_fuses(db, db.grid[row - 1][col - 1], av, f'CLS{num}') |
| 4593 |
tile = tilemap[(row - 1, col - 1)] |
| 4594 |
for brow, bcol in bits: |
| 4595 |
tile[brow][bcol] = 1 |
| 4596 |
|
| 4597 |
def set_multiboot_address(header, address): |
| 4598 |
if not 0 <= address <= 0xffffffff: |
| 4599 |
raise ValueError('Multiboot address must fit in 32 bits') |
| 4600 |
|
| 4601 |
for command in header: |
| 4602 |
if command[0] == 0xd2: |
| 4603 |
command[4:8] = address.to_bytes(4, 'big') |
| 4604 |
return |
| 4605 |
|
| 4606 |
raise ValueError('Bitstream header does not contain a multiboot address command') |
| 4607 |
|
| 4608 |
def main(): |
| 4609 |
global device |
| 4610 |
global pnr |
| 4611 |
global bsram_init_map |
| 4612 |
global _gnd_net |
| 4613 |
global _vcc_net |
| 4614 |
|
| 4615 |
pil_available = True |
| 4616 |
try: |
| 4617 |
from PIL import Image |
| 4618 |
except ImportError: |
| 4619 |
pil_available = False |
| 4620 |
parser = argparse.ArgumentParser(description='Pack Gowin bitstream') |
| 4621 |
parser.add_argument('netlist') |
| 4622 |
parser.add_argument('-d', '--device', default = None) |
| 4623 |
parser.add_argument('-o', '--output', default='pack.fs') |
| 4624 |
parser.add_argument('-c', '--compress', action='store_true') |
| 4625 |
parser.add_argument('-s', '--cst', default = None) |
| 4626 |
parser.add_argument('--jtag_as_gpio', action = 'store_true') |
| 4627 |
parser.add_argument('--sspi_as_gpio', action = 'store_true') |
| 4628 |
parser.add_argument('--mspi_as_gpio', action = 'store_true') |
| 4629 |
parser.add_argument('--ready_as_gpio', action = 'store_true') |
| 4630 |
parser.add_argument('--done_as_gpio', action = 'store_true') |
| 4631 |
parser.add_argument('--reconfign_as_gpio', action = 'store_true') |
| 4632 |
parser.add_argument('--cpu_as_gpio', action = 'store_true') |
| 4633 |
parser.add_argument('--i2c_as_gpio', action = 'store_true') |
| 4634 |
parser.add_argument( |
| 4635 |
'--multiboot_address', |
| 4636 |
type=lambda value: int(value, 0), |
| 4637 |
default=None, |
| 4638 |
help='SPI flash address of the next bitstream for multiboot' |
| 4639 |
) |
| 4640 |
if pil_available: |
| 4641 |
parser.add_argument('--png') |
| 4642 |
|
| 4643 |
args = parser.parse_args() |
| 4644 |
device = args.device |
| 4645 |
|
| 4646 |
|
| 4647 |
if device is None: |
| 4648 |
device = pnr['modules']['top']['settings']['packer.chipdb'] |
| 4649 |
|
| 4650 |
with open(args.netlist) as f: |
| 4651 |
pnr = json.load(f) |
| 4652 |
|
| 4653 |
|
| 4654 |
if pnr['modules']['top']['settings'].get('packer.arch', '') != 'himbaechel/gowin': |
| 4655 |
raise Exception("Only files made with nextpnr-himbaechel are supported.") |
| 4656 |
|
| 4657 |
|
| 4658 |
m = re.match("(GW..)(S|Z)?[A-Z]*-(LV|UV|UX)([0-9]{1,2})C?([A-Z]{2}[0-9]+P?)(C[0-9]/I[0-9])", device) |
| 4659 |
if m: |
| 4660 |
series = m.group(1) |
| 4661 |
mods = m.group(2) or "" |
| 4662 |
num = m.group(4) |
| 4663 |
device = f"{series}{mods}-{num}" |
| 4664 |
|
| 4665 |
with importlib.resources.path('apycula', f'{device}.msgpack.xz') as path: |
| 4666 |
db = load_chipdb(path) |
| 4667 |
|
| 4668 |
wnames.select_wires(device) |
| 4669 |
|
| 4670 |
|
| 4671 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 4672 |
_init_io_attrs['IBUF'].update({'PULL_STRENGTH': 'MEDIUM'}) |
| 4673 |
_init_io_attrs['OBUF'].update({'PULL_STRENGTH': 'MEDIUM'}) |
| 4674 |
_init_io_attrs['TBUF'].update({'PULL_STRENGTH': 'MEDIUM'}) |
| 4675 |
_init_io_attrs['IOBUF'].update({'PULL_STRENGTH': 'MEDIUM'}) |
| 4676 |
_default_iostd.update({'IBUF': 'LVCMOS33', 'OBUF': 'LVCMOS33', 'TBUF': 'LVCMOS33', 'IOBUF': 'LVCMOS33',}) |
| 4677 |
|
| 4678 |
if not args.sspi_as_gpio and device in {'GW5A-25A'}: |
| 4679 |
|
| 4680 |
print('Warning. For GW5A-25A SSPI must be set as GPIO.') |
| 4681 |
args.sspi_as_gpio = True |
| 4682 |
|
| 4683 |
const_nets = {'GND': '$PACKER_GND', 'VCC': '$PACKER_VCC'} |
| 4684 |
|
| 4685 |
_gnd_net = pnr['modules']['top']['netnames'].get(const_nets['GND'], {'bits': []})['bits'] |
| 4686 |
_vcc_net = pnr['modules']['top']['netnames'].get(const_nets['VCC'], {'bits': []})['bits'] |
| 4687 |
|
| 4688 |
tilemap = chipdb.tile_bitmap(db, bitmatrix.zeros(db.height, db.width), empty=True) |
| 4689 |
extra_slots = {} |
| 4690 |
|
| 4691 |
cst = codegen.Constraints() |
| 4692 |
pips = get_pips(pnr) |
| 4693 |
route(db, tilemap, pips) |
| 4694 |
do_gw5_ihclk(db, tilemap) |
| 4695 |
isolate_segments(pnr, db, tilemap) |
| 4696 |
bels = get_bels(db, pnr) |
| 4697 |
gsr(db, tilemap, args) |
| 4698 |
|
| 4699 |
|
| 4700 |
|
| 4701 |
|
| 4702 |
|
| 4703 |
|
| 4704 |
|
| 4705 |
|
| 4706 |
|
| 4707 |
|
| 4708 |
slice_attrvals = {} |
| 4709 |
|
| 4710 |
place(db, tilemap, itertools.chain(bels, _pip_bels) , cst, args, slice_attrvals, extra_slots) |
| 4711 |
set_slice_fuses(db, tilemap, slice_attrvals) |
| 4712 |
dualmode_pins(db, tilemap, args) |
| 4713 |
|
| 4714 |
|
| 4715 |
|
| 4716 |
|
| 4717 |
|
| 4718 |
|
| 4719 |
|
| 4720 |
if device in {'GW1NZ-1'}: |
| 4721 |
tile = tilemap[(db.rows - 1, db.cols - 1)] |
| 4722 |
for row, col in {(23, 63)}: |
| 4723 |
tile[row][col] = 0 |
| 4724 |
|
| 4725 |
set_adc_iobuf_fuses(db, tilemap) |
| 4726 |
|
| 4727 |
for row in range(db.rows): |
| 4728 |
for col in range(db.cols): |
| 4729 |
set_const_fuses(db, row, col, tilemap[(row, col)]) |
| 4730 |
main_map = chipdb.fuse_bitmap(db, tilemap) |
| 4731 |
|
| 4732 |
if pil_available and args.png: |
| 4733 |
bslib.display(args.png, main_map) |
| 4734 |
|
| 4735 |
if device in {'GW5A-25A', 'GW5AST-138C'}: |
| 4736 |
main_map = bitmatrix.transpose(main_map) |
| 4737 |
|
| 4738 |
header_footer(db, main_map, args.compress) |
| 4739 |
|
| 4740 |
if args.multiboot_address is not None: |
| 4741 |
set_multiboot_address(db.cmd_hdr, args.multiboot_address) |
| 4742 |
|
| 4743 |
if device in {'GW5A-25A', 'GW5AST-138C'} and gw5a_bsrams: |
| 4744 |
|
| 4745 |
|
| 4746 |
|
| 4747 |
|
| 4748 |
|
| 4749 |
|
| 4750 |
|
| 4751 |
|
| 4752 |
|
| 4753 |
), |
| 4754 |
|
| 4755 |
s, |
| 4756 |
|
| 4757 |
|
| 4758 |
|
| 4759 |
|
| 4760 |
|
| 4761 |
|
| 4762 |
|
| 4763 |
last_col = -1 |
| 4764 |
map_offset = -1 |
| 4765 |
for bsram in gw5a_bsrams: |
| 4766 |
col, row, typ, parms, attrs = bsram |
| 4767 |
if col != last_col: |
| 4768 |
last_col = col |
| 4769 |
map_offset += 1 |
| 4770 |
store_bsram_init_val(db, row, col, typ, parms, attrs, map_offset) |
| 4771 |
|
| 4772 |
def cols_iterator(): |
| 4773 |
for bsram in gw5a_bsrams: |
| 4774 |
col, _, _, _, _ = bsram |
| 4775 |
yield col |
| 4776 |
|
| 4777 |
bsram_init_map = bitmatrix.transpose(bsram_init_map) |
| 4778 |
bslib.write_bitstream(args.output, main_map, db.cmd_hdr, db.cmd_ftr, args.compress, extra_slots, bsram_init_map, cols_iterator, is_gw5a_138=(device == 'GW5AST-138C')) |
| 4779 |
elif bsram_init_map is not None: |
| 4780 |
bslib.write_bitstream_with_bsram_init(args.output, main_map, db.cmd_hdr, db.cmd_ftr, args.compress, extra_slots, bsram_init_map) |
| 4781 |
else: |
| 4782 |
bslib.write_bitstream(args.output, main_map, db.cmd_hdr, db.cmd_ftr, args.compress, extra_slots) |
| 4783 |
|
| 4784 |
if args.cst: |
| 4785 |
with open(args.cst, "w") as f: |
| 4786 |
cst.write(f) |
| 4787 |
|
| 4788 |
if __name__ == '__main__': |
| 4789 |
main() |
| 4790 |
|
| 4791 |
|