From 00a8b07dc55f3db59fda9f526a4a18c1b5c09c63 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 26 Jul 2018 07:24:32 +0100 Subject: [PATCH] big whitespace cleanup --- src/bsv/bsv_lib/slow_peripherals_template.bsv | 5 +- src/bsv/bsv_lib/soc_template.bsv | 413 +++++++++--------- src/bsv/peripheral_gen/base.py | 57 +-- src/bsv/peripheral_gen/eint.py | 12 +- src/bsv/peripheral_gen/gpio.py | 14 +- src/bsv/peripheral_gen/jtag.py | 21 +- src/bsv/peripheral_gen/nspi.py | 14 +- src/bsv/peripheral_gen/pwm.py | 6 +- src/bsv/peripheral_gen/quart.py | 34 +- src/bsv/peripheral_gen/rgbttl.py | 6 +- src/bsv/peripheral_gen/sdmmc.py | 6 +- src/bsv/peripheral_gen/twi.py | 12 +- src/bsv/peripheral_gen/uart.py | 12 +- 13 files changed, 313 insertions(+), 299 deletions(-) diff --git a/src/bsv/bsv_lib/slow_peripherals_template.bsv b/src/bsv/bsv_lib/slow_peripherals_template.bsv index 1ed48f8..6c522e3 100644 --- a/src/bsv/bsv_lib/slow_peripherals_template.bsv +++ b/src/bsv/bsv_lib/slow_peripherals_template.bsv @@ -35,9 +35,6 @@ package slow_peripherals; `ifdef AXIEXP import axiexpansion ::*; `endif - `ifdef QSPI - import qspi :: *; - `endif /*=====================================*/ /*===== interface declaration =====*/ @@ -115,7 +112,7 @@ package slow_peripherals; Ifc_AXI4Lite_AXI4_Bridge bridge<-mkAXI4Lite_AXI4_Bridge(fast_clock,fast_reset); - mkConnection (bridge.axi4_lite_master, slow_fabric.v_from_masters [0]); + mkConnection (bridge.axi4_lite_master, slow_fabric.v_from_masters [0]); /*======= Slave connections to AXI4Lite fabric =========*/ {6} `ifdef CLINT diff --git a/src/bsv/bsv_lib/soc_template.bsv b/src/bsv/bsv_lib/soc_template.bsv index 3fcd2a9..56978c6 100644 --- a/src/bsv/bsv_lib/soc_template.bsv +++ b/src/bsv/bsv_lib/soc_template.bsv @@ -2,35 +2,52 @@ Copyright (c) 2013, IIT Madras All rights reserved. -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: -* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -* Neither the name of IIT Madras nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +* Neither the name of IIT Madras nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +------------------------------------------------------------------- */ package Soc; - /*====== Package imports === */ - import FIFO::*; - import FIFOF::*; - import SpecialFIFOs::*; - import GetPut::*; - import ClientServer::*; - import Vector::*; - import Connectable::*; - import Clocks::*; - /*========================== */ - /*=== Project imports === */ - import ConcatReg::*; - import AXI4_Types::*; - import AXI4_Fabric::*; - import defined_types::*; - import MemoryMap :: *; - import slow_peripherals::*; - `include "defines.bsv" - `include "instance_defines.bsv" + /*====== Package imports === */ + import FIFO::*; + import FIFOF::*; + import SpecialFIFOs::*; + import GetPut::*; + import ClientServer::*; + import Vector::*; + import Connectable::*; + import Clocks::*; + /*========================== */ + /*=== Project imports === */ + import ConcatReg::*; + import AXI4_Types::*; + import AXI4_Fabric::*; + import defined_types::*; + import MemoryMap :: *; + import slow_peripherals::*; + `include "defines.bsv" + `include "instance_defines.bsv" {8} /*====== AXI4 slave declarations =======*/ {3} @@ -38,214 +55,214 @@ package Soc; {4} - `ifdef DMA - import DMA :: *; - `endif - `ifdef BOOTROM - import BootRom ::*; - `endif - `ifdef SDRAM - import sdr_top :: *; + `ifdef DMA + import DMA :: *; + `endif + `ifdef BOOTROM + import BootRom ::*; + `endif + `ifdef SDRAM + import sdr_top :: *; `endif - `ifdef BRAM - import Memory_AXI4 ::*; - `endif - `ifdef TCMemory - import TCM::*; - `endif - `ifdef Debug - import jtagdtm::*; - import DebugModule::*; - `else - import core::*; - `endif + `ifdef BRAM + import Memory_AXI4 ::*; + `endif + `ifdef TCMemory + import TCM::*; + `endif + `ifdef Debug + import jtagdtm::*; + import DebugModule::*; + `else + import core::*; + `endif `ifdef VME - import vme_top ::*; + import vme_top ::*; `endif `ifdef VME - import vme_master::*; + import vme_master::*; `endif `ifdef FlexBus import FlexBus_Types::*; `endif {0} - /*========================= */ - interface Ifc_Soc; - interface SP_ios slow_ios; - (*always_ready,always_enabled*) - method Action boot_sequence(Bit#(1) bootseq); - - `ifdef SDRAM - (*always_ready*) interface Ifc_sdram_out sdram_out; - `endif + /*========================= */ + interface Ifc_Soc; + interface SP_ios slow_ios; + (*always_ready,always_enabled*) + method Action boot_sequence(Bit#(1) bootseq); + + `ifdef SDRAM + (*always_ready*) interface Ifc_sdram_out sdram_out; + `endif `ifdef DDR (*prefix="M_AXI"*) interface AXI4_Master_IFC#(`PADDR, `Reg_width, `USERSPACE) master; `endif - `ifdef HYPER - (*always_ready,always_enabled*) - interface Ifc_flash ifc_flash; - `endif - /*=============================================== */ - `ifdef VME - interface Vme_out proc_ifc; - interface Data_bus_inf proc_dbus; - `endif + `ifdef HYPER + (*always_ready,always_enabled*) + interface Ifc_flash ifc_flash; + `endif + /*=============================================== */ + `ifdef VME + interface Vme_out proc_ifc; + interface Data_bus_inf proc_dbus; + `endif `ifdef FlexBus interface FlexBus_Master_IFC flexbus_out; `endif {1} - endinterface - (*synthesize*) - module mkSoc #(Bit#(`VADDR) reset_vector, + endinterface + (*synthesize*) + module mkSoc #(Bit#(`VADDR) reset_vector, Clock slow_clock, Reset slow_reset, Clock uart_clock, Reset uart_reset, Clock clk0, Clock tck, Reset trst `ifdef PWM_AXI4Lite ,Clock ext_pwm_clock `endif )(Ifc_Soc); - Clock core_clock <-exposeCurrentClock; // slow peripheral clock - Reset core_reset <-exposeCurrentReset; // slow peripheral reset + Clock core_clock <-exposeCurrentClock; // slow peripheral clock + Reset core_reset <-exposeCurrentReset; // slow peripheral reset {2} `ifdef Debug - Ifc_DebugModule core<-mkDebugModule(reset_vector); - `else - Ifc_core_AXI4 core <-mkcore_AXI4(reset_vector); - `endif - `ifdef BOOTROM - BootRom_IFC bootrom <-mkBootRom; - `endif - `ifdef SDRAM - Ifc_sdr_slave sdram<- mksdr_axi4_slave(clk0); - `endif + Ifc_DebugModule core<-mkDebugModule(reset_vector); + `else + Ifc_core_AXI4 core <-mkcore_AXI4(reset_vector); + `endif + `ifdef BOOTROM + BootRom_IFC bootrom <-mkBootRom; + `endif + `ifdef SDRAM + Ifc_sdr_slave sdram<- mksdr_axi4_slave(clk0); + `endif `ifdef BRAM - Memory_IFC#(`SDRAMMemBase,`Addr_space)main_memory <- + Memory_IFC#(`SDRAMMemBase,`Addr_space)main_memory <- mkMemory("code.mem.MSB","code.mem.LSB","MainMEM"); - `endif - `ifdef TCMemory - Ifc_TCM tcm <- mkTCM; - `endif - `ifdef DMA - DmaC#(7,`NUM_DMACHANNELS) dma <- mkDMA(); - `endif - `ifdef VME - Ifc_vme_top vme <-mkvme_top(); - `endif + `endif + `ifdef TCMemory + Ifc_TCM tcm <- mkTCM; + `endif + `ifdef DMA + DmaC#(7,`NUM_DMACHANNELS) dma <- mkDMA(); + `endif + `ifdef VME + Ifc_vme_top vme <-mkvme_top(); + `endif `ifdef FlexBus AXI4_Slave_to_FlexBus_Master_Xactor_IFC #(32, 64,0) flexbus <- mkAXI4_Slave_to_FlexBus_Master_Xactor; `endif - Ifc_slow_peripherals slow_peripherals <-mkslow_peripherals( + Ifc_slow_peripherals slow_peripherals <-mkslow_peripherals( core_clock, core_reset, uart_clock, uart_reset, clocked_by slow_clock , reset_by slow_reset `ifdef PWM_AXI4Lite , ext_pwm_clock `endif ); - // Fabric - AXI4_Fabric_IFC #(Num_Masters, Num_Slaves, `PADDR, `Reg_width,`USERSPACE) - fabric <- mkAXI4_Fabric(fn_addr_to_slave_num); + // Fabric + AXI4_Fabric_IFC #(Num_Masters, Num_Slaves, `PADDR, `Reg_width,`USERSPACE) + fabric <- mkAXI4_Fabric(fn_addr_to_slave_num); - // Connect traffic generators to fabric - mkConnection (core.dmem_master,fabric.v_from_masters + // Connect traffic generators to fabric + mkConnection (core.dmem_master,fabric.v_from_masters [fromInteger(valueOf(Dmem_master_num))]); - mkConnection (core.imem_master, fabric.v_from_masters + mkConnection (core.imem_master, fabric.v_from_masters [fromInteger(valueOf(Imem_master_num))]); - `ifdef Debug - mkConnection (core.debug_master, fabric.v_from_masters + `ifdef Debug + mkConnection (core.debug_master, fabric.v_from_masters [fromInteger(valueOf(Debug_master_num))]); - `endif - `ifdef DMA + `endif + `ifdef DMA mkConnection (dma.mmu, fabric.v_from_masters [fromInteger(valueOf(DMA_master_num))]); - `endif + `endif - // Connect fabric to memory slaves - `ifdef Debug - mkConnection (fabric.v_to_slaves + // Connect fabric to memory slaves + `ifdef Debug + mkConnection (fabric.v_to_slaves [fromInteger(valueOf(Debug_slave_num))], core.debug_slave); - `endif - `ifdef SDRAM - mkConnection (fabric.v_to_slaves + `endif + `ifdef SDRAM + mkConnection (fabric.v_to_slaves [fromInteger(valueOf(Sdram_slave_num))], sdram.axi4_slave_sdram); // - mkConnection (fabric.v_to_slaves + mkConnection (fabric.v_to_slaves [fromInteger(valueOf(Sdram_cfg_slave_num))], sdram.axi4_slave_cntrl_reg); // `endif `ifdef BRAM - mkConnection(fabric.v_to_slaves + mkConnection(fabric.v_to_slaves [fromInteger(valueOf(Sdram_slave_num))], main_memory.axi_slave); - `endif - `ifdef BOOTROM - mkConnection (fabric.v_to_slaves + `endif + `ifdef BOOTROM + mkConnection (fabric.v_to_slaves [fromInteger(valueOf(BootRom_slave_num))], bootrom.axi_slave); - `endif - `ifdef DMA - mkConnection (fabric.v_to_slaves + `endif + `ifdef DMA + mkConnection (fabric.v_to_slaves [fromInteger(valueOf(Dma_slave_num))], dma.cfg); //DMA slave - `endif - `ifdef TCMemory - mkConnection (fabric.v_to_slaves + `endif + `ifdef TCMemory + mkConnection (fabric.v_to_slaves [fromInteger(valueOf(TCM_slave_num))], tcm.axi_slave); - `endif - mkConnection(fabric.v_to_slaves + `endif + mkConnection(fabric.v_to_slaves [fromInteger(valueOf(SlowPeripheral_slave_num))], slow_peripherals.axi_slave); - `ifdef VME - mkConnection (fabric.v_to_slaves + `ifdef VME + mkConnection (fabric.v_to_slaves [fromInteger(valueOf(VME_slave_num))], vme.slave_axi_vme); - `endif - `ifdef FlexBus - mkConnection (fabric.v_to_slaves + `endif + `ifdef FlexBus + mkConnection (fabric.v_to_slaves [fromInteger(valueOf(FlexBus_slave_num))], flexbus.axi_side); - `endif + `endif // fabric connections {5} - `ifdef DMA - // rule to connect all interrupt lines to the DMA - // All the interrupt lines to DMA are active - // HIGH. For peripherals that are not connected, - // or those which do not - // generate an interrupt (like TCM), drive a constant 1 + `ifdef DMA + // rule to connect all interrupt lines to the DMA + // All the interrupt lines to DMA are active + // HIGH. For peripherals that are not connected, + // or those which do not + // generate an interrupt (like TCM), drive a constant 1 // on the corresponding interrupt line. {7} - `endif + `endif - /*==== Synchornization between the JTAG and the Debug Module ===== */ - `ifdef Debug - SyncFIFOIfc#(Bit#(40)) sync_request_to_dm <- + /*==== Synchornization between the JTAG and the Debug Module ===== */ + `ifdef Debug + SyncFIFOIfc#(Bit#(40)) sync_request_to_dm <- mkSyncFIFOToCC(1,tck,trst); - SyncFIFOIfc#(Bit#(34)) sync_response_from_dm <- + SyncFIFOIfc#(Bit#(34)) sync_response_from_dm <- mkSyncFIFOFromCC(1,tck); - rule connect_tap_request_to_syncfifo; - let x<-tap.request_to_dm; - sync_request_to_dm.enq(x); - endrule - rule read_synced_request_to_dm; - sync_request_to_dm.deq; - core.request_from_dtm(sync_request_to_dm.first); - endrule + rule connect_tap_request_to_syncfifo; + let x<-tap.request_to_dm; + sync_request_to_dm.enq(x); + endrule + rule read_synced_request_to_dm; + sync_request_to_dm.deq; + core.request_from_dtm(sync_request_to_dm.first); + endrule - rule connect_debug_response_to_syncfifo; - let x<-core.response_to_dtm; - sync_response_from_dm.enq(x); - endrule - rule read_synced_response_from_dm; - sync_response_from_dm.deq; - tap.response_from_dm(sync_response_from_dm.first); - endrule - `endif - /*============================================================ */ - + rule connect_debug_response_to_syncfifo; + let x<-core.response_to_dtm; + sync_response_from_dm.enq(x); + endrule + rule read_synced_response_from_dm; + sync_response_from_dm.deq; + tap.response_from_dm(sync_response_from_dm.first); + endrule + `endif + /*============================================================ */ + `ifdef FlexBus //rule drive_flexbus_inputs; //flexbus.flexbus_side.m_TAn(1'b1); @@ -253,54 +270,54 @@ package Soc; //endrule `endif - `ifdef CLINT - SyncBitIfc#(Bit#(1)) clint_mtip_int <- + `ifdef CLINT + SyncBitIfc#(Bit#(1)) clint_mtip_int <- mkSyncBitToCC(slow_clock,slow_reset); - SyncBitIfc#(Bit#(1)) clint_msip_int <- + SyncBitIfc#(Bit#(1)) clint_msip_int <- mkSyncBitToCC(slow_clock,slow_reset); - Reg#(Bit#(`Reg_width)) clint_mtime_value <- + Reg#(Bit#(`Reg_width)) clint_mtime_value <- mkSyncRegToCC(0,slow_clock,slow_reset); - rule synchronize_clint_data; - clint_mtip_int.send(slow_peripherals.mtip_int); - clint_msip_int.send(slow_peripherals.msip_int); - clint_mtime_value<=slow_peripherals.mtime; - endrule - rule connect_msip_mtip_from_clint; - core.clint_msip(clint_msip_int.read); - core.clint_mtip(clint_mtip_int.read); + rule synchronize_clint_data; + clint_mtip_int.send(slow_peripherals.mtip_int); + clint_msip_int.send(slow_peripherals.msip_int); + clint_mtime_value<=slow_peripherals.mtime; + endrule + rule connect_msip_mtip_from_clint; + core.clint_msip(clint_msip_int.read); + core.clint_mtip(clint_mtip_int.read); core.clint_mtime(clint_mtime_value); - endrule - `endif - `ifdef PLIC - Reg#(Tuple2#(Bool,Bool)) plic_interrupt_note <- + endrule + `endif + `ifdef PLIC + Reg#(Tuple2#(Bool,Bool)) plic_interrupt_note <- mkSyncRegToCC(tuple2(False,False), slow_clock,slow_reset); - rule synchronize_interrupts; - let note <- slow_peripherals.intrpt_note; - plic_interrupt_note<=note; - endrule - rule rl_send_external_interrupt_to_csr; - core.set_external_interrupt(plic_interrupt_note); - endrule - `endif + rule synchronize_interrupts; + let note <- slow_peripherals.intrpt_note; + plic_interrupt_note<=note; + endrule + rule rl_send_external_interrupt_to_csr; + core.set_external_interrupt(plic_interrupt_note); + endrule + `endif - `ifdef VME - interface proc_ifc = vme.proc_ifc; - interface proc_dbus = vme.proc_dbus; - `endif - `ifdef FlexBus + `ifdef VME + interface proc_ifc = vme.proc_ifc; + interface proc_dbus = vme.proc_dbus; + `endif + `ifdef FlexBus interface flexbus_out = flexbus.flexbus_side; - `endif - method Action boot_sequence(Bit#(1) bootseq) = + `endif + method Action boot_sequence(Bit#(1) bootseq) = core.boot_sequence(bootseq); - `ifdef SDRAM - interface sdram_out=sdram.ifc_sdram_out; - `endif - `ifdef DDR - interface master=fabric.v_to_slaves - [fromInteger(valueOf(Sdram_slave_num))]; - `endif - interface slow_ios=slow_peripherals.slow_ios; + `ifdef SDRAM + interface sdram_out=sdram.ifc_sdram_out; + `endif + `ifdef DDR + interface master=fabric.v_to_slaves + [fromInteger(valueOf(Sdram_slave_num))]; + `endif + interface slow_ios=slow_peripherals.slow_ios; {6} - endmodule + endmodule endpackage diff --git a/src/bsv/peripheral_gen/base.py b/src/bsv/peripheral_gen/base.py index 3e6fbde..b1af594 100644 --- a/src/bsv/peripheral_gen/base.py +++ b/src/bsv/peripheral_gen/base.py @@ -125,10 +125,11 @@ class PBase(object): bname = self.axibase(name, ifacenum) bend = self.axiend(name, ifacenum) name = self.axi_slave_name(name, ifacenum) - return """\ - if(addr>=`{0} && addr<=`{1}) - return tuple2(True,fromInteger(valueOf({2}))); - else""".format(bname, bend, name) + template = """\ +if(addr>=`{0} && addr<=`{1}) + return tuple2(True,fromInteger(valueOf({2}))); +else""" + return template.format(bname, bend, name) def mk_pincon(self, name, count): # TODO: really should be using bsv.interface_decl.Interfaces @@ -140,7 +141,7 @@ class PBase(object): pname = p['name'] #n = "{0}{1}".format(self.name, self.mksuffix(name, count)) n = name # "{0}{1}".format(self.name, self.mksuffix(name, count)) - ret.append(" //%s %s" % (n, str(p))) + ret.append("//%s %s" % (n, str(p))) sname = self.peripheral.iname().format(count) sname = "{0}.{1}".format(sname, pname) ps = "pinmux.peripheral_side.%s" % sname @@ -177,7 +178,7 @@ class PBase(object): n_ = '{0}.{1}'.format(n_, fname) n_ = self.ifname_tweak(pname, 'in', n_) ret.append("mkConnection({1}, {0});".format(ps_, n_)) - return '\n'.join(li(ret, 6)) + return '\n'.join(ret) def mk_cellconn(self, *args): return '' @@ -199,7 +200,7 @@ class PBase(object): print "PBase __mk_connection", self.name, aname if not con: return '' - return li(txt.format(con, aname, fabricname), 8) + return txt.format(con, aname, fabricname) def __mk_master_connection(self, con, aname): txt = "mkConnection (slow_fabric.v_to_slaves\n" + \ @@ -209,7 +210,7 @@ class PBase(object): print "PBase __mk_connection", self.name, aname if not con: return '' - return li(txt.format(con, aname), 8) + return txt.format(con, aname) def mk_connection(self, count, fabricname, typ, name=None): if name is None: @@ -256,7 +257,7 @@ class PBase(object): plic = mkplic_rule.format(name, plic_obj, irq_offs) res.append(plic) irq_offs += 1 # increment to next irq - return ('\n'.join(li(res, 5)), irq_offs) + return ('\n'.join(res), irq_offs) def mk_ext_ifacedef(self, iname, inum): return '' @@ -270,7 +271,7 @@ class PBase(object): sname = pname else: sname = self.peripheral.iname().format(count) - template = " interface {0}{3} = {2}{1};" + template = "interface {0}{3} = {2}{1};" return template.format(pname, sname, prefix, suffix) def extifinstance2(self, name, count): @@ -338,9 +339,9 @@ typedef TAdd#(AxiExp1_slave_num,1) Num_Slow_Slaves; """ pinmux_cellrule = """\ - rule connect_select_lines_pinmux; +rule connect_select_lines_pinmux; {0} - endrule +endrule """ @@ -415,7 +416,7 @@ class PeripheralInterfaces(object): for (name, count) in self.ifacecount: #print "slowimport", name, self.data[name].slowimport ret.append(self.data[name].slowimport()) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 4)) def extfastifinstance(self, *args): ret = [] @@ -426,7 +427,7 @@ class PeripheralInterfaces(object): if self.is_on_fastbus(name, i): continue ret.append(self.data[name].extfastifinstance(name, i)) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def extifinstance2(self, *args): ret = [] @@ -434,7 +435,7 @@ class PeripheralInterfaces(object): for i in range(count): iname = self.data[name].iname().format(i) ret.append(self.data[name].extifinstance2(name, i)) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def extifinstance(self, *args): ret = [] @@ -444,7 +445,7 @@ class PeripheralInterfaces(object): if not self.is_on_fastbus(name, i): continue ret.append(self.data[name].extifinstance(name, i)) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def extifdecl(self, *args): ret = [] @@ -460,7 +461,7 @@ class PeripheralInterfaces(object): for (name, count) in self.ifacecount: for i in range(count): ret.append(self.data[name].slowifdeclmux(name, i)) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def fastifdecl(self, *args): ret = [] @@ -470,7 +471,7 @@ class PeripheralInterfaces(object): if self.is_on_fastbus(name, i): continue ret.append(self.data[name].fastifdecl(name, i)) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 4)) def slowifdecl(self, *args): ret = [] @@ -536,7 +537,7 @@ class PeripheralInterfaces(object): if self.is_on_fastbus(name, i): continue ret.append(self.data[name].axi_addr_map(i)) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def mkfast_peripheral(self, *args): ret = [] @@ -549,7 +550,7 @@ class PeripheralInterfaces(object): print name, count, x suffix = self.data[name].mksuffix(name, i) ret.append(x.format(suffix)) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def mkslow_peripheral(self, *args): ret = [] @@ -562,7 +563,7 @@ class PeripheralInterfaces(object): print name, count, x suffix = self.data[name].mksuffix(name, i) ret.append(x.format(suffix)) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def mk_fast_connection(self, *args): ret = [] @@ -575,7 +576,7 @@ class PeripheralInterfaces(object): print "txt", txt print self.data[name].mk_connection ret.append(txt) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 4)) def mk_connection(self, *args): ret = [] @@ -588,7 +589,7 @@ class PeripheralInterfaces(object): print "txt", txt print self.data[name].mk_connection ret.append(txt) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def mk_cellconn(self): ret = [] @@ -602,8 +603,8 @@ class PeripheralInterfaces(object): continue (txt, cellcount) = res ret.append(txt) - ret = '\n'.join(list(filter(None, ret))) - return pinmux_cellrule.format(ret) + ret = li('\n'.join(list(filter(None, ret))), 4) + return li(pinmux_cellrule.format(ret), 4) def mk_pincon(self): ret = [] @@ -613,7 +614,7 @@ class PeripheralInterfaces(object): continue txt = self.data[name].mk_pincon(name, i) ret.append(txt) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 4)) def mk_dma_irq(self): ret = [] @@ -670,7 +671,7 @@ class PeripheralInterfaces(object): continue txt = self.data[name].mk_ext_ifacedef(name, i) ret.append(txt) - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 8)) def mk_plic(self): ret = [] @@ -685,7 +686,7 @@ class PeripheralInterfaces(object): (txt, irq_offs) = res ret.append(txt) self.num_slow_irqs = irq_offs - return '\n'.join(list(filter(None, ret))) + return '\n'.join(li(list(filter(None, ret)), 4)) def mk_sloirqsdef(self): return " `define NUM_SLOW_IRQS {0}".format(self.num_slow_irqs) diff --git a/src/bsv/peripheral_gen/eint.py b/src/bsv/peripheral_gen/eint.py index 3e25401..ba80e5f 100644 --- a/src/bsv/peripheral_gen/eint.py +++ b/src/bsv/peripheral_gen/eint.py @@ -5,11 +5,11 @@ class eint(PBase): def slowimport(self): size = len(self.peripheral.pinspecs) - return " `define NUM_EINTS %d" % size + return "`define NUM_EINTS %d" % size def mkslow_peripheral(self, size=0): size = len(self.peripheral.pinspecs) - return " Wire#(Bit#(%d)) wr_interrupt <- mkWire();" % size + return "Wire#(Bit#(%d)) wr_interrupt <- mkWire();" % size def axi_slave_name(self, name, ifacenum, typ=''): return '' @@ -30,16 +30,16 @@ class eint(PBase): ret = [PBase.mk_pincon(self, name, count)] size = len(self.peripheral.pinspecs) ret.append(eint_pincon_template.format(size)) - ret.append(" rule con_%s%d_io_in;" % (name, count)) - ret.append(" wr_interrupt <= ({") + ret.append("rule con_%s%d_io_in;" % (name, count)) + ret.append(" wr_interrupt <= ({") for idx, p in enumerate(self.peripheral.pinspecs): pname = p['name'] sname = self.peripheral.pname(pname).format(count) ps = "pinmux.peripheral_side.eint.%s" % sname comma = '' if idx == size - 1 else ',' ret.append(" {0}{1}".format(ps, comma)) - ret.append(" });") - ret.append(" endrule") + ret.append(" });") + ret.append("endrule") return '\n'.join(ret) diff --git a/src/bsv/peripheral_gen/gpio.py b/src/bsv/peripheral_gen/gpio.py index 6ed41b6..1e48768 100644 --- a/src/bsv/peripheral_gen/gpio.py +++ b/src/bsv/peripheral_gen/gpio.py @@ -4,9 +4,9 @@ from bsv.peripheral_gen.base import PBase class gpio(PBase): def slowimport(self): - return " import pinmux::*;\n" + \ - " import mux::*;\n" + \ - " import gpio::*;\n" + return "import pinmux::*;\n" + \ + "import mux::*;\n" + \ + "import gpio::*;\n" def extifinstance2(self, name, count): template = "interface pad_config{0} = {1}.pad_config;" @@ -37,8 +37,8 @@ class gpio(PBase): def mkslow_peripheral(self, size=0): print "gpioslow", self.peripheral, dir(self.peripheral) size = len(self.peripheral.pinspecs) - return " MUX#(%d) mux{0} <- mkmux();\n" % size + \ - " GPIO#(%d) gpio{0} <- mkgpio();" % size + return "MUX#(%d) mux{0} <- mkmux();\n" % size + \ + "GPIO#(%d) gpio{0} <- mkgpio();" % size def mk_connection(self, count, fabricname, typ): print "GPIO mk_conn", self.name, count @@ -63,7 +63,7 @@ class gpio(PBase): def mk_cellconn(self, cellnum, name, count): ret = [] bank = self.mksuffix(name, count) - txt = " pinmux.mux_lines.cell{0}_mux(mux{1}.mux_config.mux[{2}]);" + txt = "pinmux.mux_lines.cell{0}_mux(mux{1}.mux_config.mux[{2}]);" for p in self.peripheral.pinspecs: ret.append(txt.format(cellnum, bank, p['name'][1:])) cellnum += 1 @@ -80,7 +80,7 @@ class gpio(PBase): # special-case for gpio in, store in a temporary vector ret = [] plen = len(self.peripheral.pinspecs) - template = " mkConnection({0}.{1},\n\t\t\t{2}_{1});" + template = "mkConnection({0}.{1},\n\t\t\t{2}_{1});" ps = "pinmux.peripheral_side.%s" % name n = "{0}.func.gpio".format(name) for ptype in ['out', 'out_en', 'in']: diff --git a/src/bsv/peripheral_gen/jtag.py b/src/bsv/peripheral_gen/jtag.py index 042d802..abd374f 100644 --- a/src/bsv/peripheral_gen/jtag.py +++ b/src/bsv/peripheral_gen/jtag.py @@ -4,27 +4,26 @@ from bsv.peripheral_gen.base import PBase class jtag(PBase): def slowimport(self): - return " import jtagtdm::*;\n" + return "import jtagtdm::*;\n" def extfastifinstance(self, name, count): return self._extifinstance(name, count, "_out", "", True) - def fastifdecl(self, name, count): # YUK! - return " Ifc_jtagdtm jtag{0}_out;".format(count); + return "Ifc_jtagdtm jtag{0}_out;".format(count); def mkfast_peripheral(self): return """\ - Ifc_jtagdtm jtag{0} <-mkjtagdtm(clocked_by tck, reset_by trst); - rule drive_tmp_scan_outs; - jtag{0}.scan_out_1_i(1'b0); - jtag{0}.scan_out_2_i(1'b0); - jtag{0}.scan_out_3_i(1'b0); - jtag{0}.scan_out_4_i(1'b0); - jtag{0}.scan_out_5_i(1'b0); - endrule +Ifc_jtagdtm jtag{0} <-mkjtagdtm(clocked_by tck, reset_by trst); +rule drive_tmp_scan_outs; + jtag{0}.scan_out_1_i(1'b0); + jtag{0}.scan_out_2_i(1'b0); + jtag{0}.scan_out_3_i(1'b0); + jtag{0}.scan_out_4_i(1'b0); + jtag{0}.scan_out_5_i(1'b0); +endrule """ def axi_slave_name(self, name, ifacenum, typ=''): return '' diff --git a/src/bsv/peripheral_gen/nspi.py b/src/bsv/peripheral_gen/nspi.py index 16526e1..c92df0f 100644 --- a/src/bsv/peripheral_gen/nspi.py +++ b/src/bsv/peripheral_gen/nspi.py @@ -10,20 +10,20 @@ class nspi(PBase): assert masteronly, "Only master only %s supported for now" % name def slowimport(self): - return " import %(n)s :: *;" % self.ifndict + return "import %(n)s :: *;" % self.ifndict def irq_name(self): return "%(n)s{0}_isint" % self.ifndict def slowifdecl(self): - return " interface %(N)s_out %(n)s{0}_out;\n" + \ - " method Bit#(1) %s;" % self.irq_name + return "interface %(N)s_out %(n)s{0}_out;\n" + \ + "method Bit#(1) %s;" % self.irq_name def num_axi_regs32(self): return 13 def mkslow_peripheral(self, size=0): - return " Ifc_%(n)s %(n)s{0} <- mk%(n)s();" % self.ifndict + return "Ifc_%(n)s %(n)s{0} <- mk%(n)s();" % self.ifndict def _mk_connection(self, name=None, count=0): return "%(n)s{0}.slave" % self.ifndict @@ -42,7 +42,7 @@ class nspi(PBase): ret = [PBase.mk_pincon(self, name, count)] # special-case for gpio in, store in a temporary vector plen = len(self.peripheral.pinspecs) - template = " mkConnection({0}.{1},\n\t\t\t{2}.{1});" + template = "mkConnection({0}.{1},\n\t\t\t{2}.{1});" sname = self.peripheral.iname().format(count) name = self.get_iname(count) ps = "pinmux.peripheral_side.%s" % sname @@ -59,8 +59,8 @@ class nspi(PBase): def mk_ext_ifacedef(self, iname, inum): name = self.get_iname(inum) - return " method {0}_isint = {0}.interrupts[5];".format(name) + return "method {0}_isint = {0}.interrupts[5];".format(name) def slowifdeclmux(self, name, count): sname = self.get_iname(count) - return " method Bit#(1) %s_isint;" % sname + return "method Bit#(1) %s_isint;" % sname diff --git a/src/bsv/peripheral_gen/pwm.py b/src/bsv/peripheral_gen/pwm.py index b5354f6..fd5c3e0 100644 --- a/src/bsv/peripheral_gen/pwm.py +++ b/src/bsv/peripheral_gen/pwm.py @@ -4,16 +4,16 @@ from bsv.peripheral_gen.base import PBase class pwm(PBase): def slowimport(self): - return " import pwm::*;" + return "import pwm::*;" def slowifdecl(self): - return " interface PWMIO pwm{0}_io;" + return "interface PWMIO pwm{0}_io;" def num_axi_regs32(self): return 4 def mkslow_peripheral(self, size=0): - return " Ifc_PWM_bus pwm{0} <- mkPWM_bus(sp_clock);" + return "Ifc_PWM_bus pwm{0} <- mkPWM_bus(sp_clock);" def _mk_connection(self, name=None, count=0): return "pwm{0}.axi4_slave" diff --git a/src/bsv/peripheral_gen/quart.py b/src/bsv/peripheral_gen/quart.py index 75778a3..51e1803 100644 --- a/src/bsv/peripheral_gen/quart.py +++ b/src/bsv/peripheral_gen/quart.py @@ -4,14 +4,14 @@ from bsv.peripheral_gen.base import PBase class quart(PBase): def slowimport(self): - return " import Uart16550 :: *;" + return "import Uart16550 :: *;" def irq_name(self): return "quart{0}_intr" def slowifdecl(self): - return " interface RS232_PHY_Ifc quart{0}_coe;\n" + \ - " method Bit#(1) %s;" % self.irq_name() + return "interface RS232_PHY_Ifc quart{0}_coe;\n" + \ + "method Bit#(1) %s;" % self.irq_name() def get_clock_reset(self, name, count): return "slow_clock,slow_reset" # XXX TODO: change to uart_clock/reset @@ -20,8 +20,8 @@ class quart(PBase): return 8 def mkslow_peripheral(self, size=0): - return " // XXX XXX TODO: change to uart_clock/reset" + \ - " Uart16550_AXI4_Lite_Ifc quart{0} <- \n" + \ + return "// XXX TODO: change to uart_clock/reset" + \ + "Uart16550_AXI4_Lite_Ifc quart{0} <- \n" + \ " mkUart16550(clocked_by sp_clock,\n" + \ " reset_by sp_reset, sp_clock, sp_reset);" @@ -40,15 +40,15 @@ class quart(PBase): def __disabled_mk_pincon(self, name, count): ret = [PBase.mk_pincon(self, name, count)] - ret.append(" rule con_%s%d_io_in;" % (name, count)) - ret.append(" {0}{1}.coe_rs232.modem_input(".format(name, count)) + ret.append("rule con_%s%d_io_in;" % (name, count)) + ret.append(" {0}{1}.coe_rs232.modem_input(".format(name, count)) for idx, pname in enumerate(['rx', 'cts']): sname = self.peripheral.pname(pname).format(count) ps = "pinmux.peripheral_side.%s" % sname ret.append(" {0},".format(ps)) ret.append(" 1'b1,1'b0,1'b1") - ret.append(" );") - ret.append(" endrule") + ret.append(" );") + ret.append("endrule") return '\n'.join(ret) @@ -67,18 +67,18 @@ class quart(PBase): def mk_ext_ifacedef(self, iname, inum): name = self.get_iname(inum) - return " method {0}_intr = {0}.irq;".format(name) + return "method {0}_intr = {0}.irq;".format(name) def slowifdeclmux(self, name, count): sname = self.peripheral.iname().format(count) - return " method Bit#(1) %s_intr;" % sname + return "method Bit#(1) %s_intr;" % sname uart_plic_template = """\ - // PLIC {0} synchronisation with irq {1} - SyncBitIfc#(Bit#(1)) {0}_interrupt <- - mkSyncBitToCC(sp_clock, uart_reset); - rule plic_synchronize_{0}_interrupt_{1}; - {0}_interrupt.send({0}.irq); - endrule +// PLIC {0} synchronisation with irq {1} +SyncBitIfc#(Bit#(1)) {0}_interrupt <- + mkSyncBitToCC(sp_clock, uart_reset); +rule plic_synchronize_{0}_interrupt_{1}; + {0}_interrupt.send({0}.irq); +endrule """ diff --git a/src/bsv/peripheral_gen/rgbttl.py b/src/bsv/peripheral_gen/rgbttl.py index 9ac4b38..f72c9bf 100644 --- a/src/bsv/peripheral_gen/rgbttl.py +++ b/src/bsv/peripheral_gen/rgbttl.py @@ -4,7 +4,7 @@ from bsv.peripheral_gen.base import PBase class rgbttl(PBase): def slowimport(self): - return " import rgbttl_dummy :: *;" + return "import rgbttl_dummy :: *;" def has_axi_master(self): return True @@ -14,7 +14,7 @@ class rgbttl(PBase): def mkfast_peripheral(self): sz = len(self.peripheral.pinspecs) - 4 # subtract CK, DE, HS, VS - return " Ifc_rgbttl_dummy lcd{0} <- mkrgbttl_dummy();" + return "Ifc_rgbttl_dummy lcd{0} <- mkrgbttl_dummy();" def _mk_connection(self, name=None, count=0): return "lcd{0}.slave" @@ -29,7 +29,7 @@ class rgbttl(PBase): # special-case for gpio in, store in a temporary vector sname = self.peripheral.iname().format(count) plen = len(self.peripheral.pinspecs) - template = " mkConnection({0}.{1},\n\t\t\t{2}.{1});" + template = "mkConnection({0}.{1},\n\t\t\t{2}.{1});" name = self.get_iname(count) ps = "pinmux.peripheral_side.%s" % sname n = "{0}".format(name) diff --git a/src/bsv/peripheral_gen/sdmmc.py b/src/bsv/peripheral_gen/sdmmc.py index e963eb7..cb83ebd 100644 --- a/src/bsv/peripheral_gen/sdmmc.py +++ b/src/bsv/peripheral_gen/sdmmc.py @@ -4,13 +4,13 @@ from bsv.peripheral_gen.base import PBase class sdmmc(PBase): def slowimport(self): - return " import sdcard_dummy :: *;" + return "import sdcard_dummy :: *;" def num_axi_regs32(self): return 13 def mkslow_peripheral(self): - return " Ifc_sdcard_dummy sd{0} <- mksdcard_dummy();" + return "Ifc_sdcard_dummy sd{0} <- mksdcard_dummy();" def _mk_connection(self, name=None, count=0): return "sd{0}.slave" @@ -24,7 +24,7 @@ class sdmmc(PBase): ret = [PBase.mk_pincon(self, name, count)] # special-case for gpio in, store in a temporary vector plen = len(self.peripheral.pinspecs) - template = " mkConnection({0}.{1},\n\t\t\t{2}.{1});" + template = "mkConnection({0}.{1},\n\t\t\t{2}.{1});" sname = self.peripheral.iname().format(count) name = self.get_iname(count) ps = "pinmux.peripheral_side.%s" % sname diff --git a/src/bsv/peripheral_gen/twi.py b/src/bsv/peripheral_gen/twi.py index 7aaf291..02d3718 100644 --- a/src/bsv/peripheral_gen/twi.py +++ b/src/bsv/peripheral_gen/twi.py @@ -4,20 +4,20 @@ from bsv.peripheral_gen.base import PBase class twi(PBase): def slowimport(self): - return " import I2C_top :: *;" + return "import I2C_top :: *;" def irq_name(self): return "twi{0}_isint" def slowifdecl(self): - return " interface I2C_out twi{0}_out;\n" + \ - " method Bit#(1) %s;" % self.irq_name() + return "interface I2C_out twi{0}_out;\n" + \ + "method Bit#(1) %s;" % self.irq_name() def num_axi_regs32(self): return 8 def mkslow_peripheral(self, size=0): - return " I2C_IFC twi{0} <- mkI2CController();" + return "I2C_IFC twi{0} <- mkI2CController();" def _mk_connection(self, name=None, count=0): return "twi{0}.slave_i2c_axi" @@ -45,8 +45,8 @@ class twi(PBase): def mk_ext_ifacedef(self, iname, inum): name = self.get_iname(inum) - return " method {0}_isint = {0}.isint;".format(name) + return "method {0}_isint = {0}.isint;".format(name) def slowifdeclmux(self, name, inum): sname = self.get_iname(inum) - return " method Bit#(1) %s_isint;" % sname + return "method Bit#(1) %s_isint;" % sname diff --git a/src/bsv/peripheral_gen/uart.py b/src/bsv/peripheral_gen/uart.py index a5eaacd..86dba41 100644 --- a/src/bsv/peripheral_gen/uart.py +++ b/src/bsv/peripheral_gen/uart.py @@ -4,19 +4,19 @@ from bsv.peripheral_gen.base import PBase class uart(PBase): def slowimport(self): - return " import Uart_bs :: *;\n" + \ - " import RS232_modified::*;" + return "import Uart_bs :: *;\n" + \ + "import RS232_modified::*;" def slowifdecl(self): - return " interface RS232 uart{0}_coe;\n" + \ - " method Bit#(1) uart{0}_intr;" + return "interface RS232 uart{0}_coe;\n" + \ + "method Bit#(1) uart{0}_intr;" def num_axi_regs32(self): return 8 def mkslow_peripheral(self, size=0): - return " Ifc_Uart_bs uart{0} <- \n" + \ - " mkUart_bs(clocked_by sp_clock,\n" + \ + return "Ifc_Uart_bs uart{0} <- \n" + \ + " mkUart_bs(clocked_by sp_clock,\n" + \ " reset_by sp_reset, sp_clock, sp_reset);" def _mk_connection(self, name=None, count=0): -- 2.30.2