#
class Instance:
- def __init__(self, of, outs=[], ins=[], parameters=[], clkport="", rstport="", name=""):
+ def __init__(self, of, outs=[], ins=[], inouts=[], parameters=[], clkport="", rstport="", name=""):
self.of = of
if name:
self.name_override = name
raise TypeError
self.outs = dict(map(process_io, outs))
self.ins = dict(map(process_io, ins))
+ self.inouts = dict(map(process_io, inouts))
self.parameters = parameters
self.clkport = clkport
self.rstport = rstport
groups.append((targets, [statement]))
return groups
-def list_inst_ios(i, ins, outs):
+def list_inst_ios(i, ins, outs, inouts):
if isinstance(i, Fragment):
- return list_inst_ios(i.instances, ins, outs)
+ return list_inst_ios(i.instances, ins, outs, inouts)
else:
l = []
for x in i:
l += x.ins.values()
if outs:
l += x.outs.values()
+ if inouts:
+ l += x.inouts.values()
return set(l)
def list_mem_ios(m, ins, outs):
return r
def _printheader(f, ios, name, ns):
- sigs = list_signals(f) | list_inst_ios(f, True, True) | list_mem_ios(f, True, True)
- inst_mem_outs = list_inst_ios(f, False, True) | list_mem_ios(f, False, True)
+ sigs = list_signals(f) | list_inst_ios(f, True, True, True) | list_mem_ios(f, True, True)
+ inst_mem_outs = list_inst_ios(f, False, True, False) | list_mem_ios(f, False, True)
+ inouts = list_inst_ios(f, False, False, True)
targets = list_targets(f) | inst_mem_outs
wires = _list_comb_wires(f) | inst_mem_outs
r = "module " + name + "(\n"
if not firstp:
r += ",\n"
firstp = False
- if sig in targets:
+ if sig in inouts:
+ r += "\tinout " + _printsig(ns, sig)
+ elif sig in targets:
if sig in wires:
r += "\toutput " + _printsig(ns, sig)
else:
ios |= f.pads
ns = build_namespace(list_signals(f) \
- | list_inst_ios(f, True, True) \
+ | list_inst_ios(f, True, True, True) \
| list_mem_ios(f, True, True) \
| ios)