add MK_SLOW_IRQ define
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 22 Jul 2018 04:46:04 +0000 (05:46 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 22 Jul 2018 04:46:04 +0000 (05:46 +0100)
src/bsv/bsv_lib/slow_peripherals_template.bsv
src/bsv/peripheral_gen.py
src/bsv/pinmux_generator.py

index 1eb1b939c87f494c6755fb6b66236d09be775274..fc4230e897aa474efd72c3b133614ce6b815044c 100644 (file)
@@ -10,6 +10,8 @@ package slow_peripherals;
        `include "instance_defines.bsv"
     /* ==== define the AXI Addresses ==== */
 {2}
+    /* ==== define the number of slow peripheral irqs ==== */
+{11}
     /*====== AXI4 Lite slave declarations =======*/
 
 {3}
index 622feb0bf6e2fd8eb9992ea20cfea25fdf908500..11d3b86045edc8c1ccfdeb912a01dcd7556ad9c6 100644 (file)
@@ -246,8 +246,6 @@ class quart(PBase):
 
     def mk_pincon(self, name, count):
         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("       {0}{1}.coe_rs232.modem_input(".format(name, count))
         for idx, pname in enumerate(['rx', 'cts']):
@@ -380,11 +378,11 @@ class eint(PBase):
 
 
 eint_pincon_template = '''\
-    // TODO: offset i by the number of eints already used
+    // EINT is offset at end of other peripheral interrupts
     for(Integer i=0;i<{0};i=i+ 1)begin
       rule connect_int_to_plic(wr_interrupt[i]==1);
-                ff_gateway_queue[i].enq(1);
-                plic.ifc_external_irq[i].irq_frm_gateway(True);
+                ff_gateway_queue[i+`NUM_SLOW_IRQS].enq(1);
+                plic.ifc_external_irq[i+`NUM_SLOW_IRQS].irq_frm_gateway(True);
       endrule
     end
 '''
@@ -862,8 +860,12 @@ class PeripheralInterfaces(object):
                     continue
                 (txt, irq_offs) = res
                 ret.append(txt)
+        self.num_slow_irqs = irq_offs
         return '\n'.join(list(filter(None, ret)))
 
+    def mk_sloirqsdef(self):
+        return "    `define NUM_SLOW_IRQS {0}".format(self.num_slow_irqs)
+
 
 class PFactory(object):
     def getcls(self, name):
index fb0764718fcbf6c5907f1d8a240a0c3c71a62897..0e4b1423dc04b7cf6d53ac37a3771c8edc8fe45c 100644 (file)
@@ -122,10 +122,12 @@ def write_slow(slow, template, p, ifaces, iocells):
     pincon = ifaces.mk_pincon()
     inst = ifaces.slowifinstance()
     mkplic = ifaces.mk_plic()
+    numsloirqs = ifaces.mk_sloirqsdef()
     with open(slow, "w") as bsv_file:
         bsv_file.write(template.format(imports, ifdecl, regdef, slavedecl,
                                        fnaddrmap, mkslow, mkcon, mkcellcon,
-                                       pincon, inst, mkplic))
+                                       pincon, inst, mkplic,
+                                       numsloirqs))
 
 
 def write_bus(bus, p, ifaces):