split out slow memory map to separate file
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 28 Jul 2018 04:43:10 +0000 (05:43 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 28 Jul 2018 04:43:10 +0000 (05:43 +0100)
src/bsv/bsv_lib/slow_peripherals_template.bsv
src/bsv/pinmux_generator.py

index de2aaf921f8db990f7480317117afec841c2cf5a..636197e77c2fd43d9372170ba1d323e26cd4bd7d 100644 (file)
@@ -7,14 +7,10 @@ package slow_peripherals;
        import AXI4_Types::*;
        import Semi_FIFOF::*;
        import AXI4Lite_AXI4_Bridge::*;
+       import slow_memory_map::*;
        `include "instance_defines.bsv"
-    /* ==== define the AXI Addresses ==== */
-{2}
     /* ==== define the number of slow peripheral irqs ==== */
 {11}
-    /*====== AXI4 Lite slave declarations =======*/
-
-{3}
        /*===========================*/
        /*=== package imports ===*/
        import Clocks::*;
@@ -61,27 +57,6 @@ package slow_peripherals;
        endinterface
        /*================================*/
 
-       function SlowTuple2#(Bool, Bit#(TLog#(Num_Slow_Slaves)))
-                     fn_address_mapping (Bit#(`ADDR) addr);
-        `ifdef CLINT
-            if(addr>=`ClintBase && addr<=`ClintEnd)
-                return tuple2(True,fromInteger(valueOf(CLINT_slave_num)));
-            else
-        `endif
-        `ifdef PLIC
-            if(addr>=`PLICBase && addr<=`PLICEnd)
-                return tuple2(True,fromInteger(valueOf(Plic_slave_num)));
-            else
-        `endif
-        `ifdef AXIEXP
-            if(addr>=`AxiExp1Base && addr<=`AxiExp1End)
-                return tuple2(True,fromInteger(valueOf(AxiExp1_slave_num)));
-            else
-        `endif
-{4}
-        return tuple2(False,?);
-       endfunction
-
        (*synthesize*)
        module mkslow_peripherals#(Clock fast_clock, Reset fast_reset,
                                Clock uart_clock, Reset uart_reset
index 12fdecc35b4856064cf914865a3f20f04f0b9e34..6cf1f2df13c52821bd70e2908683c6a446267d9b 100644 (file)
@@ -86,6 +86,8 @@ def pinmuxgen(pth=None, verify=True):
     idef = os.path.join(bp, 'instance_defines.bsv')
     slow = os.path.join(bp, 'slow_peripherals.bsv')
     slowt = os.path.join(cwd, 'slow_peripherals_template.bsv')
+    slowmf = os.path.join(bp, 'slow_memory_map.bsv')
+    slowmt = os.path.join(cwd, 'slow_tuple2_template.bsv')
     soc = os.path.join(bp, 'socgen.bsv')
     soct = os.path.join(cwd, 'soc_template.bsv')
 
@@ -94,14 +96,16 @@ def pinmuxgen(pth=None, verify=True):
     write_bvp(bvp, p, ifaces)
     write_bus(bus, p, ifaces)
     write_instances(idef, p, ifaces)
-    write_slow(slow, slowt, p, ifaces, iocells)
+    write_slow(slow, slowt, slowmf, slowmt, p, ifaces, iocells)
     write_soc(soc, soct, p, ifaces, iocells)
 
 
-def write_slow(slow, slowt, p, ifaces, iocells):
+def write_slow(slow, slowt, slowmf, slowmt, p, ifaces, iocells):
     """ write out the slow_peripherals.bsv file.
         joins all the peripherals together into one AXI Lite interface
     """
+    with open(slowmt) as bsv_file:
+        slowmt = bsv_file.read()
     with open(slowt) as bsv_file:
         slowt = bsv_file.read()
     imports = ifaces.slowimport()
@@ -125,6 +129,8 @@ def write_slow(slow, slowt, p, ifaces, iocells):
                                     pincon, inst, mkplic,
                                     numsloirqs, ifacedef,
                                     inst2))
+    with open(slowmf, "w") as bsv_file:
+        bsv_file.write(slowmt.format(regdef, slavedecl, fnaddrmap))
 
 
 def write_soc(soc, soct, p, ifaces, iocells):