From 23f77d3923c5c14b60f215f6f0d4bc809fe2bc1f Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 23 Jul 2018 06:47:32 +0100 Subject: [PATCH] create new get/put interface pinmux declaration --- src/bsv/interface_decl.py | 23 ++++++++++++++++++++--- src/bsv/pinmux_generator.py | 9 ++++++--- src/test_bsv/pinmux_experiment.bsv | 6 +++--- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/bsv/interface_decl.py b/src/bsv/interface_decl.py index 4e16fa1..f87bdd9 100644 --- a/src/bsv/interface_decl.py +++ b/src/bsv/interface_decl.py @@ -186,7 +186,7 @@ class Interface(PeripheralIface): return 'input' return None - def pname(self, name): + def iname(self): """ generates the interface spec e.g. flexbus_ale if there is only one flexbus interface, or sd{0}_cmd if there are several. string format @@ -194,8 +194,17 @@ class Interface(PeripheralIface): appropriate. single mode stops the numerical extension. """ if self.single: - return '%s_%s' % (self.ifacename, name) - return '%s{0}_%s' % (self.ifacename, name) + return self.ifacename + return '%s{0}' % self.ifacename + + def pname(self, name): + """ generates the interface spec e.g. flexbus_ale + if there is only one flexbus interface, or + sd{0}_cmd if there are several. string format + function turns this into sd0_cmd, sd1_cmd as + appropriate. single mode stops the numerical extension. + """ + return "%s_%s" % (self.iname(), name) def busfmt(self, *args): """ this function creates a bus "ganging" system based @@ -343,6 +352,14 @@ class Interfaces(InterfacesBase, PeripheralInterfaces): f.write(c.format(i)) f.write(self.data[name].ifacefmt(i)) + def ifacefmt2(self, f, *args): + comment = ''' + interface PeripheralSide{0} {1};''' + for (name, count) in self.ifacecount: + for i in range(count): + iname = self.data[name].iname().format(i) + f.write(comment.format(name.upper(), iname)) + def wirefmt(self, f, *args): comment = '\n // following wires capture signals ' \ 'to IO CELL if %s-{0} is\n' \ diff --git a/src/bsv/pinmux_generator.py b/src/bsv/pinmux_generator.py index a74eee1..69a19c5 100644 --- a/src/bsv/pinmux_generator.py +++ b/src/bsv/pinmux_generator.py @@ -176,7 +176,7 @@ def write_pmp(pmp, p, ifaces, iocells): # ============================================================== # == create method definitions for all peripheral interfaces ==# - ifaces.ifacefmt(bsv_file) + ifaces.ifacefmt2(bsv_file) bsv_file.write("\n endinterface\n") # ===== finish interface definition and start module definition======= @@ -205,6 +205,7 @@ def write_pmp(pmp, p, ifaces, iocells): // the I/O from the IOcell actually goes. interface IOCellSide iocell_side; endinterface + (*synthesize*) module mkpinmux(Ifc_pinmux); ''') @@ -245,16 +246,18 @@ def write_pmp(pmp, p, ifaces, iocells): bsv_file.write("\n endinterface;") bsv_file.write(''' + interface iocell_side = interface IOCellSide ''') iocells.ifacedef(bsv_file) bsv_file.write("\n endinterface;") bsv_file.write(''' - interface peripheral_side = interface PeripheralSide + + interface peripheral_side = interface PeripheralSide ''') ifaces.ifacedef(bsv_file) - bsv_file.write("\n endinterface;") + bsv_file.write("\n endinterface;") bsv_file.write(footer) print("BSV file successfully generated: bsv_src/pinmux.bsv") diff --git a/src/test_bsv/pinmux_experiment.bsv b/src/test_bsv/pinmux_experiment.bsv index 49bee6f..94c880f 100644 --- a/src/test_bsv/pinmux_experiment.bsv +++ b/src/test_bsv/pinmux_experiment.bsv @@ -85,7 +85,6 @@ import GetPut::*; // peripheral and an output field will be an input to the peripheral. // Bi-directional functions also have an output-enable (which // again comes *in* from the peripheral) - // interface declaration between UART-0 and pinmux interface PeripheralSideUART uart; interface PeripheralSideGPIOA gpioa; interface PeripheralSideTWI twi; @@ -115,8 +114,8 @@ import GetPut::*; // the I/O from the IOcell actually goes. interface IOCellSide iocell_side; endinterface - (*synthesize*) + (*synthesize*) module mkpinmux(Ifc_pinmux); // the followins wires capture the pin-mux selection @@ -289,7 +288,8 @@ import GetPut::*; endmethod endinterface; - interface peripheral_side= interface PeripheralSide + + interface peripheral_side = interface PeripheralSide interface uart = interface PeripheralSideUART // interface declaration between UART and pinmux interface tx = interface Put -- 2.30.2