`ifdef UART1
interface RS232 uart1_coe;
`endif
- `ifdef PLIC
- (*always_ready,always_enabled*)
- method Action gpio_in (Vector#(`IONum,Bit#(1)) inp);
- (*always_ready,always_enabled*)
- method Vector#(`IONum,Bit#(1)) gpio_out;
- (*always_ready,always_enabled*)
- method Vector#(`IONum,Bit#(1)) gpio_out_en;
- `endif
`ifdef I2C0
interface I2C_out i2c0_out;
`endif
interface Ifc_slow_peripherals;
interface AXI4_Slave_IFC#(`PADDR,`Reg_width,`USERSPACE) axi_slave;
interface SP_ios slow_ios;
+ method Action external_int(Bit#(32) in);
`ifdef CLINT
method Bit#(1) msip_int;
method Bit#(1) mtip_int;
`ifdef PLIC
if(addr>=`PLICBase && addr<=`PLICEnd)
return tuple2(True,fromInteger(valueOf(Plic_slave_num)));
- else if(addr>=`GPIOBase && addr<=`GPIOEnd)
- return tuple2(True,fromInteger(valueOf(GPIO_slave_num)));
else
`endif
`ifdef I2C0
Uart16550_AXI4_Lite_Ifc uart0 <- mkUart16550(clocked_by uart_clock, reset_by uart_reset, sp_clock, sp_reset);
`endif
`ifdef UART1
- Ifc_Uart_bs uart1 <- mkUart_bs(clocked_by uart_clock, reset_by uart_reset,sp_clock, sp_reset);
+ //Ifc_Uart_bs uart1 <- mkUart_bs(clocked_by uart_clock, reset_by uart_reset,sp_clock, sp_reset);
+ Ifc_Uart_bs uart1 <- mkUart_bs(clocked_by sp_clock, reset_by sp_reset,sp_clock, sp_reset);
`endif
`ifdef CLINT
Ifc_clint clint <- mkclint();
`ifdef PLIC
Ifc_PLIC_AXI plic <- mkplicperipheral();
Wire#(Bit#(TLog#(`INTERRUPT_PINS))) interrupt_id <- mkWire();
- Vector#(`INTERRUPT_PINS, FIFO#(bit)) ff_gateway_queue <- replicateM(mkFIFO);
- GPIO gpio <- mkgpio;
+ Vector#(32, FIFO#(bit)) ff_gateway_queue <- replicateM(mkFIFO);
`endif
`ifdef I2C0
I2C_IFC i2c0 <- mkI2CController();
Ifc_pinmux pinmux <- mkpinmux; // mandatory
MUX#(3) muxa <- mkmux(); // mandatory. number depends on the number of instances required.
GPIO#(3) gpioa <- mkgpio(); // optional. depends the number of IO pins declared before.
+ Wire#(Bit#(32)) wr_interrupt <- mkWire();
// NEEL EDIT OVER
/*=======================================================*/
`ifdef PLIC
mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(Plic_slave_num))],
plic.axi4_slave_plic); //
- mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(GPIO_slave_num))],
- gpio.axi_slave); //
`endif
`ifdef I2C0
mkConnection (slow_fabric.v_to_slaves [fromInteger(valueOf(I2c0_slave_num))],
v_to_slaves[fromInteger(valueOf(Gpioa_slave_num))],
gpioa.axi_slave);
rule connect_select_lines_pinmux;// mandatory
- pinmux.cell0_mux(muxa.mux_config[0]);
- pinmux.cell1_mux(muxa.mux_config[1]);
- pinmux.cell2_mux(muxa.mux_config[2]);
+ pinmux.mux_lines.cell0_mux(muxa.mux_config.mux[0]);
+ pinmux.mux_lines.cell1_mux(muxa.mux_config.mux[1]);
+ pinmux.mux_lines.cell2_mux(muxa.mux_config.mux[2]);
+ endrule
+ rule connect_i2c0_scl;
+ pinmux.peripheral_side.twi_scl_out(i2c0.out.scl_out);
+ pinmux.peripheral_side.twi_scl_outen(pack(i2c0.out.scl_out_en));
+ endrule
+ rule connect_i2c0_scl_in;
+ i2c0.out.scl_in(pinmux.peripheral_side.twi_scl_in);
+ endrule
+ rule connect_i2c0_sda;
+ pinmux.peripheral_side.twi_sda_out(i2c0.out.sda_out);
+ pinmux.peripheral_side.twi_sda_outen(pack(i2c0.out.sda_out_en));
+ endrule
+ rule connect_i2c0_sda_in;
+ i2c0.out.sda_in(pinmux.peripheral_side.twi_sda_in);
endrule
rule connect_uart1tx;
- pinmux.peripheral_side.uart_tx(uart1.coe_rs232.rs232.sout);
+ pinmux.peripheral_side.uart_tx(uart1.coe_rs232.sout);
endrule
rule connect_uart1rx;
- uart1.coe_rs232.rs232.sin(pinmux.peripheral_side.uart_rx);
+ uart1.coe_rs232.sin(pinmux.peripheral_side.uart_rx);
endrule
rule connect_gpioa;
pinmux.peripheral_side.gpioa_a0_out(gpioa.func.gpio_out[0]);
pinmux.peripheral_side.gpioa_a0_outen(gpioa.func.gpio_out_en[0]);
+ pinmux.peripheral_side.gpioa_a1_out(gpioa.func.gpio_out[1]);
+ pinmux.peripheral_side.gpioa_a1_outen(gpioa.func.gpio_out_en[1]);
+ pinmux.peripheral_side.gpioa_a2_out(gpioa.func.gpio_out[2]);
+ pinmux.peripheral_side.gpioa_a2_outen(gpioa.func.gpio_out_en[2]);
Vector#(3,Bit#(1)) temp;
temp[0]=pinmux.peripheral_side.gpioa_a0_in;
temp[1]=pinmux.peripheral_side.gpioa_a1_in;
temp[2]=pinmux.peripheral_side.gpioa_a2_in;
- gpioa.pad_config.gpio_in(temp);
+ gpioa.func.gpio_in(temp);
endrule
+ for(Integer i=0;i<32;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);
+ endrule
+ end
+ rule rl_completion_msg_from_plic;
+ let id <- plic.intrpt_completion;
+ interrupt_id <= id;
+ `ifdef verbose $display("Dequeing the FIFO -- PLIC Interrupt Serviced id: %d",id); `endif
+ endrule
+
+ for(Integer i=0; i <32; i=i+1) begin
+ rule deq_gateway_queue;
+ if(interrupt_id==fromInteger(i)) begin
+ ff_gateway_queue[i].deq;
+ `ifdef $display($time,"Dequeing the Interrupt request for ID: %d",i); `endif
+ end
+ endrule
+ end
// NEEL EDIT OVER
/*=======================================================*/
/*=================== PLIC Connections ==================== */
- `ifdef PLIC
+ `ifdef PLIC_main
/*TODO DMA interrupt need to be connected to the plic
for(Integer i=1; i<8; i=i+1) begin
`ifdef DMA
`ifdef UART1
interface uart1_coe=uart1.coe_rs232;
`endif
- `ifdef PLIC
- method Action gpio_in (Vector#(`IONum,Bit#(1)) inp)=gpio.gpio_in(inp);
- method Vector#(`IONum,Bit#(1)) gpio_out=gpio.gpio_out;
- method Vector#(`IONum,Bit#(1)) gpio_out_en=gpio.gpio_out_en;
- `endif
`ifdef I2C0
interface i2c0_out=i2c0.out;
`endif
// NEEL EDIT
interface iocell_side=pinmux.iocell_side;
interface pad_configa= gpioa.pad_config;
+ method Action external_int(Bit#(32) in);
+ wr_interrupt<= in;
+ endmethod
// NEEL EDIT OVER
/*===================================*/
endmodule