Skip to content

Commit

Permalink
Fix OPEN_DRAIN IO attribute (#194)
Browse files Browse the repository at this point in the history
The coding of the OPEN_DRAIN attribute turned out to be not so
unambiguous. It looks like there is ON / OFF and one more default state.

As a temporary measure, setting OPEN_DRAIN=OFF is ignored, but you use
OPENDRAIN=ON at your own peril and risk.

Signed-off-by: YRabbit <[email protected]>
  • Loading branch information
yrabbit authored Aug 10, 2023
1 parent ba69439 commit 46ecf0c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions apycula/gowin_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,21 +519,21 @@ def __init__(self, row, col, idx, attrs, flags, connections):
'LVCMOS33': '3.3', 'LVDS25': '2.5', 'LVCMOS33D': '3.3', 'LVCMOS_D': '3.3'}
_init_io_attrs = {
'IBUF': {'PADDI': 'PADDI', 'HYSTERESIS': 'NONE', 'PULLMODE': 'UP', 'SLEWRATE': 'SLOW',
'DRIVE': '0', 'OPENDRAIN': 'OFF', 'CLAMP': 'OFF', 'DIFFRESISTOR': 'OFF',
'DRIVE': '0', 'CLAMP': 'OFF', 'DIFFRESISTOR': 'OFF',
'VREF': 'OFF', 'LVDS_OUT': 'OFF'},
'OBUF': {'ODMUX_1': '1', 'OPENDRAIN': 'OFF', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST',
'OBUF': {'ODMUX_1': '1', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST',
'DRIVE': '8', 'HYSTERESIS': 'NONE', 'CLAMP': 'OFF', 'DIFFRESISTOR': 'OFF',
'SINGLERESISTOR': 'OFF', 'VCCIO': '1.8', 'LVDS_OUT': 'OFF', 'DDR_DYNTERM': 'NA', 'TO': 'INV'},
'TBUF': {'ODMUX_1': 'UNKNOWN', 'OPENDRAIN': 'OFF', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST',
'TBUF': {'ODMUX_1': 'UNKNOWN', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST',
'DRIVE': '8', 'HYSTERESIS': 'NONE', 'CLAMP': 'OFF', 'DIFFRESISTOR': 'OFF',
'SINGLERESISTOR': 'OFF', 'VCCIO': '1.8', 'LVDS_OUT': 'OFF', 'DDR_DYNTERM': 'NA',
'TO': 'INV', 'PERSISTENT': 'OFF', 'ODMUX': 'TRIMUX'},
'IOBUF': {'ODMUX_1': 'UNKNOWN', 'OPENDRAIN': 'OFF', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST',
'IOBUF': {'ODMUX_1': 'UNKNOWN', 'PULLMODE': 'UP', 'SLEWRATE': 'FAST',
'DRIVE': '8', 'HYSTERESIS': 'NONE', 'CLAMP': 'OFF', 'DIFFRESISTOR': 'OFF',
'SINGLERESISTOR': 'OFF', 'VCCIO': '1.8', 'LVDS_OUT': 'OFF', 'DDR_DYNTERM': 'NA',
'TO': 'INV', 'PERSISTENT': 'OFF', 'ODMUX': 'TRIMUX', 'PADDI': 'PADDI'},
}
_refine_attrs = {'SLEW_RATE': 'SLEWRATE', 'PULL_MODE': 'PULLMODE'}
_refine_attrs = {'SLEW_RATE': 'SLEWRATE', 'PULL_MODE': 'PULLMODE', 'OPEN_DRAIN': 'OPENDRAIN'}
def refine_io_attrs(attr):
return _refine_attrs.get(attr, attr)

Expand Down Expand Up @@ -696,6 +696,8 @@ def place(db, tilemap, bels, cst, args):
continue
if flag_name_val[0] == chipdb.mode_attr_sep + "IO_TYPE":
iostd = _iostd_alias.get(flag_name_val[1], flag_name_val[1])
else:
io_desc.attrs[flag_name_val[0][1:]] = flag_name_val[1]
io_desc.attrs['IO_TYPE'] = iostd
if pinless_io:
return
Expand Down Expand Up @@ -839,6 +841,8 @@ def place(db, tilemap, bels, cst, args):
for k, val in atr.items():
if k not in attrids.iob_attrids.keys():
print(f'XXX IO: add {k} key handle')
elif k == 'OPENDRAIN' and val == 'OFF':
continue
else:
add_attr_val(db, 'IOB', iob_attrs, attrids.iob_attrids[k], attrids.iob_attrvals[val])
if k in {'VCCIO'}:
Expand Down Expand Up @@ -982,11 +986,11 @@ def main():
mods = m.group(1) or ""
luts = m.group(3)
device = f"GW1N{mods}-{luts}"

with importlib.resources.path('apycula', f'{args.device}.pickle') as path:
with closing(gzip.open(path, 'rb')) as f:
db = pickle.load(f)

with open(args.netlist) as f:
pnr = json.load(f)

Expand Down

0 comments on commit 46ecf0c

Please sign in to comment.