add jtag through pinmux
[pinmux.git] / src / bsv / pinmux_generator.py
index a90d90543749087d2dfe0b88f102de3b98983509..ae39958ed2e05a3bcb3a296fd46ca1fb41f36975 100644 (file)
@@ -72,8 +72,20 @@ 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 ['AXI4_Lite_Types.bsv', 'Semi_FIFOF.bsv', 
-                  'gpio.bsv',  'mux.bsv']:
+    for fname in ['AXI4_Lite_Types.bsv', 'Semi_FIFOF.bsv',
+                  'gpio.bsv', 'mux.bsv',
+                  'AXI4_Types.bsv', 'defined_types.bsv',
+                  'AXI4_Fabric.bsv', 'Uart16550.bsv',
+                  'AXI4_Lite_Fabric.bsv', 'ConcatReg.bsv',
+                  'Uart_bs.bsv', 'RS232_modified.bsv',
+                  'AXI4Lite_AXI4_Bridge.bsv',
+                  'I2C_top.bsv', 'I2C_Defs.bsv',
+                  'plic.bsv', 'Cur_Cycle.bsv',
+                  'ClockDiv.bsv', 'axi_addr_generator.bsv',
+                  'jtagdtm_new.bsv', 'jtagdefines.bsv',
+                  'sdcard_dummy.bsv',
+                  'pwm.bsv', 'qspi.bsv', 'qspi.defs',
+                  ]:
         shutil.copyfile(os.path.join(cwd, fname),
                         os.path.join(bl, fname))
 
@@ -82,12 +94,37 @@ def pinmuxgen(pth=None, verify=True):
     ptp = os.path.join(bp, 'PinTop.bsv')
     bvp = os.path.join(bp, 'bus.bsv')
     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')
 
     write_pmp(pmp, p, ifaces, iocells)
     write_ptp(ptp, p, ifaces)
     write_bvp(bvp, p, ifaces)
     write_bus(bus, p, ifaces)
     write_instances(idef, p, ifaces)
+    write_slow(slow, slowt, p, ifaces, iocells)
+
+
+def write_slow(slow, template, p, ifaces, iocells):
+    """ write out the slow_peripherals.bsv file.
+        joins all the peripherals together into one AXI Lite interface
+    """
+    with open(template) as bsv_file:
+        template = bsv_file.read()
+    imports = ifaces.slowimport()
+    ifdecl = ifaces.slowifdeclmux()
+    regdef = ifaces.axi_reg_def()
+    slavedecl = ifaces.axi_slave_idx()
+    fnaddrmap = ifaces.axi_addr_map()
+    mkslow = ifaces.mkslow_peripheral()
+    mkcon = ifaces.mk_connection()
+    mkcellcon = ifaces.mk_cellconn()
+    pincon = ifaces.mk_pincon()
+    inst = ifaces.slowifinstance()
+    with open(slow, "w") as bsv_file:
+        bsv_file.write(template.format(imports, ifdecl, regdef, slavedecl,
+                                       fnaddrmap, mkslow, mkcon, mkcellcon,
+                                       pincon, inst))
 
 
 def write_bus(bus, p, ifaces):
@@ -348,11 +385,33 @@ def write_bvp(bvp, p, ifaces):
         bsv_file.write(axi4_lite.format(gpiodecl, gpiocfg))
     # ##################################################
 
-def write_instances(idef,  p, ifaces):
+
+def write_instances(idef, p, ifaces):
     with open(idef, 'w') as bsv_file:
         txt = '''\
-    `define ADDR {0}
-    `define DATA {1}
-    `define USERSPACE 0
+`define ADDR {0}
+`define PADDR {0}
+`define DATA {1}
+`define Reg_width {1}
+`define USERSPACE 0
+
+// TODO: work out if these are needed
+`define PWM_AXI4Lite
+`define PRFDEPTH 6
+`define VADDR 39
+`define DCACHE_BLOCK_SIZE 4
+`define DCACHE_WORD_SIZE 8
+`define PERFMONITORS                            64
+`define DCACHE_WAYS 4
+`define DCACHE_TAG_BITS 20      // tag_bits = 52
+`define PLIC
+       `define PLICBase                'h0c000000
+       `define PLICEnd         'h10000000
+`define INTERRUPT_PINS 64
+
+`define BAUD_RATE 130
+`ifdef simulate
+  `define BAUD_RATE 5 //130 //
+`endif
 '''
         bsv_file.write(txt.format(p.ADDR_WIDTH, p.DATA_WIDTH))