`ifdef PLIC
Ifc_PLIC_AXI plic <- mkplicperipheral();
Wire#(Bit#(TLog#(`INTERRUPT_PINS))) interrupt_id <- mkWire();
- Vector#(32, FIFO#(bit)) ff_gateway_queue <- replicateM(mkFIFO);
+ Vector#(`INTERRUPT_PINS, FIFO#(bit)) ff_gateway_queue <- replicateM(mkFIFO);
`endif
`ifdef AXIEXP
Ifc_AxiExpansion axiexp1 <- mkAxiExpansion();
`ifdef verbose $display("Dequeing the FIFO -- PLIC Interrupt Serviced id: %d",id); `endif
endrule
- for(Integer i=0; i <32; i=i+1) begin
+ for(Integer i=0; i <`NUM_INTERRUPTS; i=i+1) begin
rule deq_gateway_queue;
if(interrupt_id==fromInteger(i)) begin
ff_gateway_queue[i].deq;
end
endrule
end
- /* for connectin inputs from pinmux as itnerrupts
- rule connect_pinmux_eint;
- wr_interrupt<= pinmux.peripheral_side.eint_input;
- endrule
- */
// NEEL EDIT OVER
/*=======================================================*/
/*=================== PLIC Connections ==================== */
`endif
end
*/
- rule rl_connect_i2c0_to_plic;
- `ifdef I2C0
- if(i2c0.isint()==1'b1) begin
- ff_gateway_queue[8].enq(1);
- plic.ifc_external_irq[8].irq_frm_gateway(True);
- end
- `else
- ff_gateway_queue[8].enq(0);
- `endif
- endrule
-
- rule rl_connect_i2c1_to_plic;
- `ifdef I2C1
- if(i2c1.isint()==1'b1) begin
- ff_gateway_queue[9].enq(1);
- plic.ifc_external_irq[9].irq_frm_gateway(True);
- end
- `else
- ff_gateway_queue[9].enq(0);
- `endif
- endrule
-
- rule rl_connect_i2c0_timerint_to_plic;
- `ifdef I2C0
- if(i2c0.timerint()==1'b1) begin
- ff_gateway_queue[10].enq(1);
- plic.ifc_external_irq[10].irq_frm_gateway(True);
- end
- `else
- ff_gateway_queue[10].enq(0);
- `endif
- endrule
-
- rule rl_connect_i2c1_timerint_to_plic;
- `ifdef I2C1
- if(i2c1.timerint()==1'b1) begin
- ff_gateway_queue[11].enq(1);
- plic.ifc_external_irq[11].irq_frm_gateway(True);
- end
- `else
- ff_gateway_queue[11].enq(0);
- `endif
- endrule
-
- rule rl_connect_i2c0_isber_to_plic;
- `ifdef I2C0
- if(i2c0.isber()==1'b1) begin
- ff_gateway_queue[12].enq(1);
- plic.ifc_external_irq[12].irq_frm_gateway(True);
- end
- `else
- ff_gateway_queue[12].enq(0);
- `endif
- endrule
-
- rule rl_connect_i2c1_isber_to_plic;
- `ifdef I2C1
- if(i2c1.isber()==1'b1) begin
- ff_gateway_queue[13].enq(1);
- plic.ifc_external_irq[13].irq_frm_gateway(True);
- end
- `else
- ff_gateway_queue[13].enq(0);
- `endif
- endrule
-
+{10}
for(Integer i = 14; i < 20; i=i+1) begin
rule rl_connect_qspi0_to_plic;
`ifdef QSPI0
def pinname_tweak(self, pname, typ, txt):
return txt
+ def num_irqs(self):
+ return 0
+
+ def mk_plic(self, inum, irq_offs):
+ res = []
+ print "mk_plic", self.name, inum, irq_offs
+ niq = self.num_irqs()
+ if niq == 0:
+ return ('', irq_offs)
+ for idx in range(niq):
+ name = "{0}{1}".format(self.name, self.mksuffix(self.name, inum))
+ plic_obj = self.plic_object(name, idx)
+ print "plic_obj", name, idx, plic_obj
+ plic = mkplic_rule.format(self.name, plic_obj, irq_offs)
+ res.append(plic)
+ irq_offs += 1 # increment to next irq
+ return ('\n'.join(res), irq_offs)
+
+mkplic_rule = \
+"""
+ rule rl_connect_{0}_to_plic_{2};
+ if({1} == 1'b1) begin
+ ff_gateway_queue[{2}].enq(1);
+ plic.ifc_external_irq[{2}].irq_frm_gateway(True);
+ end
+ endrule
+"""
class uart(PBase):
return " interface I2C_out twi{0}_out;\n" + \
" method Bit#(1) twi{0}_isint;"
+ def num_irqs(self):
+ return 3
+
def num_axi_regs32(self):
return 8
return "pack({0})".format(txt)
return txt
+ def plic_object(self, pname, idx):
+ return ["{0}.isint()",
+ "{0}.timerint()",
+ "{0}.isber()"
+ ][idx].format(pname)
+
class eint(PBase):
self.slow.peripheral = self
for fname in ['slowimport',
'slowifinstance', 'slowifdecl', 'slowifdeclmux',
- 'mkslow_peripheral',
+ 'mkslow_peripheral', 'mk_plic',
'mk_connection', 'mk_cellconn', 'mk_pincon']:
fn = CallFn(self, fname)
setattr(self, fname, types.MethodType(fn, self))
return '\n'.join(list(filter(None, ret)))
+ def mk_plic(self):
+ ret = []
+ irq_offs = 8 # XXX: DMA scovers 0-7?
+ for (name, count) in self.ifacecount:
+ for i in range(count):
+ res = self.data[name].mk_plic(i, irq_offs)
+ if not res:
+ continue
+ (txt, irq_offs) = res
+ ret.append(txt)
+ return '\n'.join(list(filter(None, ret)))
+
+
class PFactory(object):
def getcls(self, name):
for k, v in {'uart': uart,
mkcellcon = ifaces.mk_cellconn()
pincon = ifaces.mk_pincon()
inst = ifaces.slowifinstance()
+ mkplic = ifaces.mk_plic()
with open(slow, "w") as bsv_file:
bsv_file.write(template.format(imports, ifdecl, regdef, slavedecl,
fnaddrmap, mkslow, mkcon, mkcellcon,
- pincon, inst))
+ pincon, inst, mkplic))
def write_bus(bus, p, ifaces):