add dma rules
[pinmux.git] / src / bsv / pinmux_generator.py
index 69a19c565468759fd0cc016bcb162a71c82cb244..0011dd006397b554950d9b6678066e7d52a58b6e 100644 (file)
@@ -40,6 +40,7 @@ header = copyright + '''
 package pinmux;
 
 import GetPut::*;
+import Vector::*;
 
 '''
 footer = '''
@@ -74,7 +75,7 @@ def pinmuxgen(pth=None, verify=True):
     shutil.copyfile(os.path.join(cwd, 'Makefile.template'),
                     os.path.join(bp, 'Makefile'))
     cwd = os.path.join(cwd, 'bsv_lib')
-    for fname in [ ]:
+    for fname in []:
         shutil.copyfile(os.path.join(cwd, fname),
                         os.path.join(bl, fname))
 
@@ -85,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')
+    soc = os.path.join(bp, 'soc.bsv')
+    soct = os.path.join(cwd, 'soc_template.bsv')
 
     write_pmp(pmp, p, ifaces, iocells)
     write_ptp(ptp, p, ifaces)
@@ -92,6 +95,7 @@ def pinmuxgen(pth=None, verify=True):
     write_bus(bus, p, ifaces)
     write_instances(idef, p, ifaces)
     write_slow(slow, slowt, p, ifaces, iocells)
+    write_soc(soc, soct, p, ifaces, iocells)
 
 
 def write_slow(slow, slowt, p, ifaces, iocells):
@@ -101,7 +105,7 @@ def write_slow(slow, slowt, p, ifaces, iocells):
     with open(slowt) as bsv_file:
         slowt = bsv_file.read()
     imports = ifaces.slowimport()
-    ifdecl = ifaces.slowifdeclmux()
+    ifdecl = ifaces.slowifdeclmux() + '\n' + ifaces.extifdecl()
     regdef = ifaces.axi_reg_def()
     slavedecl = ifaces.axi_slave_idx()
     fnaddrmap = ifaces.axi_addr_map()
@@ -109,16 +113,49 @@ def write_slow(slow, slowt, p, ifaces, iocells):
     mkcon = ifaces.mk_connection()
     mkcellcon = ifaces.mk_cellconn()
     pincon = ifaces.mk_pincon()
-    inst = ifaces.slowifinstance()
+    inst = ifaces.extifinstance()
     mkplic = ifaces.mk_plic()
     numsloirqs = ifaces.mk_sloirqsdef()
     ifacedef = ifaces.mk_ext_ifacedef()
     ifacedef = ifaces.mk_ext_ifacedef()
     with open(slow, "w") as bsv_file:
         bsv_file.write(slowt.format(imports, ifdecl, regdef, slavedecl,
-                                       fnaddrmap, mkslow, mkcon, mkcellcon,
-                                       pincon, inst, mkplic,
-                                       numsloirqs, ifacedef))
+                                    fnaddrmap, mkslow, mkcon, mkcellcon,
+                                    pincon, inst, mkplic,
+                                    numsloirqs, ifacedef))
+
+def write_soc(soc, soct, p, ifaces, iocells):
+    """ write out the soc.bsv file.
+        joins all the peripherals together as AXI Masters
+    """
+    ifaces.fastbusmode = True # side-effects... shouldn't really do this
+    with open(soct) as bsv_file:
+        soct = bsv_file.read()
+    imports = ifaces.slowimport()
+    ifdecl = ifaces.fastifdecl()
+#ifaces.slowifdeclmux() + '\n' + ifaces.extifdecl()
+    regdef = ifaces.axi_reg_def()
+    slavedecl = ifaces.axi_fastslave_idx()
+    mastdecl = ifaces.axi_master_idx()
+    fnaddrmap = ifaces.axi_addr_map()
+    mkfast = ifaces.mkfast_peripheral()
+    mkcon = ifaces.mk_fast_connection()
+    mkcellcon = ifaces.mk_cellconn()
+    pincon = ifaces.mk_pincon()
+    inst = ifaces.extfastifinstance()
+    mkplic = ifaces.mk_plic()
+    numsloirqs = ifaces.mk_sloirqsdef()
+    ifacedef = ifaces.mk_ext_ifacedef()
+    dma = ifaces.mk_dma_irq()
+    with open(soc, "w") as bsv_file:
+        bsv_file.write(soct.format(imports, ifdecl, mkfast,
+                            slavedecl, mastdecl, mkcon,
+                            inst, dma,
+                            #'', '' #regdef, slavedecl,
+                            #'', mkslow, #fnaddrmap, mkslow, mkcon, mkcellcon,
+                            #pincon, inst, mkplic,
+                            #numsloirqs, ifacedef))
+                                  ))
 
 
 def write_bus(bus, p, ifaces):
@@ -256,7 +293,7 @@ def write_pmp(pmp, p, ifaces, iocells):
 
      interface peripheral_side = interface PeripheralSide
 ''')
-        ifaces.ifacedef(bsv_file)
+        ifaces.ifacedef2(bsv_file)
         bsv_file.write("\n      endinterface;")
 
         bsv_file.write(footer)