From eb6cfab95e4041dd2b12a0a484c51611e814c802 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 30 Jul 2018 07:19:26 +0100 Subject: [PATCH] vectorise pincon sync --- src/bsv/peripheral_gen/base.py | 32 +++++++++++++++++++++++++++++ src/bsv/peripheral_gen/rgbttl.py | 35 ++++++-------------------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/bsv/peripheral_gen/base.py b/src/bsv/peripheral_gen/base.py index 7b8ca98..fd30384 100644 --- a/src/bsv/peripheral_gen/base.py +++ b/src/bsv/peripheral_gen/base.py @@ -196,6 +196,20 @@ else""" ret += cn return '\n'.join(ret) + def _mk_vpincon(self, name, count, ptyp, typ, pname): + ret = [] + 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) + ps_ = "{0}.{1}".format(ps, pname) + ret += self._mk_actual_connection(typ, name, count, typ, + pname, ps_, n, pname) + return '\n'.join(ret) + def _mk_actual_connection(self, ctype, name, count, typ, pname, ps, n, fname): ret = [] @@ -227,6 +241,7 @@ else""" sync, n)) return ret + def _mk_clk_con(self, name, count, ctype): ret = [] ck = self.get_clock_reset(name, count) @@ -265,6 +280,23 @@ Ifc_sync#({0}) {1}_sync <-mksyncconnection( ret.append(template.format("Bit#(1)", n_, spc, ck)) return '\n'.join(ret) + def _mk_clk_vcon(self, name, count, ctype, typ, pname, bitspec): + ck = self.get_clock_reset(name, count) + if ck == PBase.get_clock_reset(self, name, count): + return '' + if ctype == 'slow': + spc = "sp_clock, sp_reset" + else: + spc = ck + ck = "core_clock, core_reset" + template = """\ +Ifc_sync#({0}) {1}_sync <-mksyncconnection( + {2}, {3});""" + + n_ = "{0}{1}".format(name, count) + n_ = '{0}_{1}'.format(n_, pname) + return template.format(bitspec, n_, ck, spc) + def mk_cellconn(self, *args): return '' diff --git a/src/bsv/peripheral_gen/rgbttl.py b/src/bsv/peripheral_gen/rgbttl.py index 91f2eb9..9c917e7 100644 --- a/src/bsv/peripheral_gen/rgbttl.py +++ b/src/bsv/peripheral_gen/rgbttl.py @@ -29,39 +29,16 @@ class rgbttl(PBase): def _mk_pincon(self, name, count, ptyp): ret = [PBase._mk_pincon(self, name, count, ptyp)] - 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) - for ptype in ['data_out']: - ps_ = "{0}.{1}".format(ps, ptype) - ret += self._mk_actual_connection('out', name, count, 'out', - ptype, ps_, n, ptype) + txt = self._mk_vpincon(name, count, ptyp, "out", "data_out") + ret.append(txt) return '\n'.join(ret) def _mk_clk_con(self, name, count, ctype): ret = [PBase._mk_clk_con(self, name, count, ctype)] - ck = self.get_clock_reset(name, count) - if ck == PBase.get_clock_reset(self, name, count): - return ret - if ctype == 'slow': - spc = "sp_clock, sp_reset" - else: - spc = ck - ck = "core_clock, core_reset" - template = """\ -Ifc_sync#({0}) {1}_sync <-mksyncconnection( - {2}, {3});""" - # one pin, data_out, might as well hard-code it - typ = 'out' - pname = 'data_out' - n = name - n_ = "{0}{1}".format(n, count) - n_ = '{0}_{1}'.format(n_, pname) + # data_out (hard-coded) sz = len(self.peripheral.pinspecs) - 4 # subtract CK, DE, HS, VS - ret.append(template.format("Bit#(%d)" % sz, n_, ck, spc)) + bitspec = "Bit#(%d)" % sz + txt = self._mk_clk_vcon(name, count, ctype, "out", "data_out", bitspec) + ret.append(txt) return '\n'.join(ret) -- 2.30.2