From: Luke Kenneth Casson Leighton Date: Tue, 24 Jul 2018 12:31:39 +0000 (+0100) Subject: add peripheral interfaces X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75b4bf4b217d00df82dc26a74d56e71def99018c;p=pinmux.git add peripheral interfaces --- diff --git a/src/bsv/peripheral_gen/base.py b/src/bsv/peripheral_gen/base.py index 90aae7d..324fbf3 100644 --- a/src/bsv/peripheral_gen/base.py +++ b/src/bsv/peripheral_gen/base.py @@ -5,10 +5,10 @@ class PBase(object): def __init__(self, name): self.name = name - def slowifdeclmux(self): + def slowifdeclmux(self, name, count): return '' - def slowifinstance(self): + def slowifinstance(self, name, count): return '' def slowimport(self): @@ -274,15 +274,15 @@ class PeripheralInterfaces(object): def slowifinstance(self, *args): ret = [] for (name, count) in self.ifacecount: - #print "slowimport", name, self.data[name].slowimport - ret.append(self.data[name].slowifinstance()) + for i in range(count): + ret.append(self.data[name].slowifinstance(name, i)) return '\n'.join(list(filter(None, ret))) def slowifdeclmux(self, *args): ret = [] for (name, count) in self.ifacecount: for i in range(count): - ret.append(self.data[name].slowifdeclmux().format(i, name)) + ret.append(self.data[name].slowifdeclmux(name, i)) return '\n'.join(list(filter(None, ret))) def slowifdecl(self, *args): diff --git a/src/bsv/peripheral_gen/gpio.py b/src/bsv/peripheral_gen/gpio.py index 9419f1c..4b6ab4c 100644 --- a/src/bsv/peripheral_gen/gpio.py +++ b/src/bsv/peripheral_gen/gpio.py @@ -8,9 +8,10 @@ class gpio(PBase): " import mux::*;\n" + \ " import gpio::*;\n" - def slowifdeclmux(self): + def slowifdeclmux(self, name, count): size = len(self.peripheral.pinspecs) - return " interface GPIO_config#(%d) pad_config{0};" % size + return " interface GPIO_config#(%d) pad_config%d;" % \ + (size, count) def num_axi_regs32(self): return 2 diff --git a/src/bsv/peripheral_gen/jtag.py b/src/bsv/peripheral_gen/jtag.py index 0592b38..e4c9e52 100644 --- a/src/bsv/peripheral_gen/jtag.py +++ b/src/bsv/peripheral_gen/jtag.py @@ -12,25 +12,13 @@ class jtag(PBase): def axi_addr_map(self, name, ifacenum): return '' - def slowifdeclmux(self): - return " method Action jtag_ms (Bit#(1) in);\n" + \ - " method Bit#(1) jtag_di;\n" + \ - " method Action jtag_do (Bit#(1) in);\n" + \ - " method Action jtag_ck (Bit#(1) in);" - - def slowifinstance(self): - return jtag_method_template # bit of a lazy hack this... - - -jtag_method_template = """\ - method Action jtag_ms (Bit#(1) in); - pinmux.peripheral_side.jtag_ms(in); - endmethod - method Bit#(1) jtag_di=pinmux.peripheral_side.jtag_di; - method Action jtag_do (Bit#(1) in); - pinmux.peripheral_side.jtag_do(in); - endmethod - method Action jtag_ck (Bit#(1) in); - pinmux.peripheral_side.jtag_ck(in); - endmethod -""" + def slowifdeclmux(self, name, count): + sname = self.get_iname(count) + return " interface PeripheralSideJTAG %s;" % sname + + def slowifinstance(self, name, count): + sname = self.peripheral.iname().format(count) + pname = self.get_iname(count) + template = " interface {0} = pinmux.peripheral_side.{1};" + return template.format(pname, sname) + diff --git a/src/bsv/peripheral_gen/nspi.py b/src/bsv/peripheral_gen/nspi.py index 46ff961..0f97013 100644 --- a/src/bsv/peripheral_gen/nspi.py +++ b/src/bsv/peripheral_gen/nspi.py @@ -56,5 +56,6 @@ class nspi(PBase): name = self.get_iname(inum) return " method {0}_isint = {0}.interrupts[5];".format(name) - def slowifdeclmux(self): - return " method Bit#(1) {1}{0}_isint;" + def slowifdeclmux(self, name, count): + sname = self.peripheral.iname().format(count) + return " method Bit#(1) %s_isint;" % sname diff --git a/src/bsv/peripheral_gen/quart.py b/src/bsv/peripheral_gen/quart.py index 36ddaba..a6646db 100644 --- a/src/bsv/peripheral_gen/quart.py +++ b/src/bsv/peripheral_gen/quart.py @@ -62,8 +62,9 @@ class quart(PBase): name = self.get_iname(inum) return " method {0}_intr = {0}.irq;".format(name) - def slowifdeclmux(self): - return " method Bit#(1) {1}{0}_intr;" + def slowifdeclmux(self, name, count): + sname = self.peripheral.iname().format(count) + return " method Bit#(1) %s_intr;" % sname uart_plic_template = """\ diff --git a/src/bsv/peripheral_gen/rgbttl.py b/src/bsv/peripheral_gen/rgbttl.py index e9a8325..ca065bb 100644 --- a/src/bsv/peripheral_gen/rgbttl.py +++ b/src/bsv/peripheral_gen/rgbttl.py @@ -34,4 +34,13 @@ class rgbttl(PBase): ret.append(template.format(ps, ptype, n)) return '\n'.join(ret) + def slowifdeclmux(self, name, count): + sname = self.get_iname(count) + return " interface PeripheralSideLCD %s;" % sname + + def slowifinstance(self, name, count): + sname = self.peripheral.iname().format(count) + pname = self.get_iname(count) + template = " interface {0} = pinmux.peripheral_side.{1};" + return template.format(pname, sname) diff --git a/src/bsv/peripheral_gen/twi.py b/src/bsv/peripheral_gen/twi.py index e20ea4c..b77724f 100644 --- a/src/bsv/peripheral_gen/twi.py +++ b/src/bsv/peripheral_gen/twi.py @@ -44,5 +44,6 @@ class twi(PBase): name = self.get_iname(inum) return " method {0}_isint = {0}.isint;".format(name) - def slowifdeclmux(self): - return " method Bit#(1) {1}{0}_isint;" + def slowifdeclmux(self, name, inum): + sname = self.get_iname(inum) + return " method Bit#(1) %s_isint;" % sname