aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/xilinx/cells_xtra.py
diff options
context:
space:
mode:
authorMarcin Koƛcielnicki <koriakin@0x04.net>2019-08-28 15:28:01 +0000
committerMarcin Koƛcielnicki <koriakin@0x04.net>2019-09-19 04:02:48 +0200
commit13fa873f11c8332a10c1dda9e42c62b20e93c6b3 (patch)
tree98edcd08223ee6b4d89a9e9919b08afc54c48dfd /techlibs/xilinx/cells_xtra.py
parentc9f9518de4af34b2539d230c0894b04d174b755d (diff)
downloadyosys-13fa873f11c8332a10c1dda9e42c62b20e93c6b3.tar.gz
yosys-13fa873f11c8332a10c1dda9e42c62b20e93c6b3.tar.bz2
yosys-13fa873f11c8332a10c1dda9e42c62b20e93c6b3.zip
Use extractinv for synth_xilinx -ise
Diffstat (limited to 'techlibs/xilinx/cells_xtra.py')
-rw-r--r--techlibs/xilinx/cells_xtra.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/techlibs/xilinx/cells_xtra.py b/techlibs/xilinx/cells_xtra.py
index 4915f2a3e..561a61943 100644
--- a/techlibs/xilinx/cells_xtra.py
+++ b/techlibs/xilinx/cells_xtra.py
@@ -5,6 +5,7 @@ from io import StringIO
from enum import Enum, auto
import os.path
import sys
+import re
class Cell:
@@ -585,6 +586,8 @@ def xtract_cell_decl(cell, dirs, outf):
state = State.OUTSIDE
found = False
# Probably the most horrible Verilog "parser" ever written.
+ module_ports = []
+ invertible_ports = set()
for l in f:
l = l.partition('//')[0]
l = l.strip()
@@ -619,6 +622,15 @@ def xtract_cell_decl(cell, dirs, outf):
state = State.IN_MODULE
elif l == 'endmodule':
if state == State.IN_MODULE:
+ for kind, rng, port in module_ports:
+ for attr in cell.port_attrs.get(port, []):
+ outf.write(' (* {} *)\n'.format(attr))
+ if port in invertible_ports:
+ outf.write(' (* invertible_pin = "IS_{}_INVERTED" *)\n'.format(port))
+ if rng is None:
+ outf.write(' {} {};\n'.format(kind, port))
+ else:
+ outf.write(' {} {} {};\n'.format(kind, rng, port))
outf.write(l + '\n')
outf.write('\n')
elif state != State.IN_OTHER_MODULE:
@@ -634,9 +646,11 @@ def xtract_cell_decl(cell, dirs, outf):
kind, _, ports = l.partition(' ')
for port in ports.split(','):
port = port.strip()
- for attr in cell.port_attrs.get(port, []):
- outf.write(' (* {} *)\n'.format(attr))
- outf.write(' {} {};\n'.format(kind, port))
+ if port.startswith('['):
+ rng, port = port.split()
+ else:
+ rng = None
+ module_ports.append((kind, rng, port))
elif l.startswith('parameter ') and state == State.IN_MODULE:
if 'UNPLACED' in l:
continue
@@ -648,6 +662,9 @@ def xtract_cell_decl(cell, dirs, outf):
print('Weird parameter line in {} [{}].'.format(fname, l))
sys.exit(1)
outf.write(' {};\n'.format(l))
+ match = re.search('IS_([a-zA-Z0-9_]+)_INVERTED', l)
+ if match:
+ invertible_ports.add(match[1])
if state != State.OUTSIDE:
print('endmodule not found in {}.'.format(fname))
sys.exit(1)