+ cn = self._mk_actual_connection('in', name,
+ count, typ,
+ pname, ps_, n_, fname)
+ ret += cn
+ return '\n'.join(ret)
+
+ def _mk_vpincon(self, name, count, ptyp, typ, pname, stype=None):
+ if stype is None:
+ stype = pname
+ ret = []
+ ret.append("//%s %s %s %s %s" % (name, ptyp, typ, pname, stype))
+ if ptyp == 'fast':
+ sname = self.get_iname(count)
+ ps = "slow_peripherals.%s" % sname
+ else:
+ sname = self.peripheral.iname().format(count)
+ ps = "pinmux.peripheral_side.%s" % sname
+ n = self.get_iname(count)
+ if typ == 'in':
+ n = "{0}.{1}".format(n, stype)
+ ps_ = "{0}.{1}".format(ps, pname)
+ ret += self._mk_actual_connection(typ, name, count, typ,
+ pname, ps_, n, stype)
+ return '\n'.join(ret)
+
+ def _mk_actual_connection(self, ctype, name, count, typ,
+ pname, ps, n, fname):
+ ret = []
+ ck = self.get_clock_reset(name, count)
+ if ctype == 'out':
+ if ck == PBase.get_clock_reset(self, name, count):
+ ret.append("mkConnection({0},\n\t\t\t{1}.{2});"
+ .format(ps, n, fname))
+ else:
+ n2 = "{0}{1}".format(name, count)
+ sync = '{0}_{1}_sync'.format(n2, pname)
+ ret.append("mkConnection({0},\n\t\t\t{1}.get);"
+ .format(ps, sync))
+ ret.append("mkConnection({0}.put,\n\t\t\t{1}.{2});"
+ .format(sync, n, fname))
+ elif ctype == 'outen':
+ ret.append("mkConnection({0}_outen,\n\t\t\t{1});"
+ .format(ps, fname))
+ elif ctype == 'in':
+ if ck == PBase.get_clock_reset(self, name, count):
+ ret.append("mkConnection({1},\n\t\t\t{0});".format(
+ ps, n))
+ else:
+ n2 = "{0}{1}".format(name, count)
+ sync = '{0}_{1}_sync'.format(n2, pname)
+ ret.append("mkConnection({1}.put,\n\t\t\t{0});".format(
+ ps, sync))
+ ret.append("mkConnection({1},\n\t\t\t{0}.get);".format(
+ sync, n))
+ return ret
+
+ def _mk_clk_con(self, name, count, ctype):
+ ret = []
+ ck = self.get_clock_reset(name, count)
+ if ck == PBase.get_clock_reset(self, name, count):
+ return ''
+ if ctype == 'slow':
+ spc = self.get_clk_spc(ctype)
+ else:
+ spc = ck
+ ck = self.get_clk_spc(ctype)
+ template = "Ifc_sync#({0}) {1}_sync <-mksyncconnection(\n" + \
+ " {2}, {3});"
+ for p in self.peripheral.pinspecs:
+ typ = p['type']
+ pname = p['name']
+ n = name
+ if typ == 'out' or typ == 'inout':
+ fname = self.pinname_out(pname)
+ if not fname:
+ continue
+ if not n.startswith('gpio'): # XXX EURGH! horrible hack
+ n_ = "{0}{1}".format(n, count)
+ else:
+ n_ = n
+ n_ = '{0}_{1}'.format(n_, pname)
+ ret.append(template.format("Bit#(1)", n_, ck, spc))
+ if typ == 'in' or typ == 'inout':
+ fname = self.pinname_in(pname)
+ if not fname:
+ continue
+ #fname = self.pinname_in(pname)
+ n_ = "{0}{1}".format(n, count)
+ n_ = '{0}_{1}'.format(n_, pname)
+ #n_ = self.ifname_tweak(pname, 'in', n_)
+ ret.append(template.format("Bit#(1)", n_, spc, ck))