Trying to Build an SoC Environment with LiteX (3. Debugging the PLIC)

https://raw.githubusercontent.com/enjoy-digital/litex/master/doc/litex.png

For the first time in a while, I am connecting my own CPU core to LiteX and running simulations. The FPGA environment is coming together somehow, so I figure that if I can confirm the BIOS runs in simulation, things will be more or less fine for now.

Eventually I would like it to accept keyboard input so I can type commands, but I have not gotten that far yet.

The PLIC seems to be correctly notifying the core of the interrupt, and the core reads the CLAIM register in response, but I do not understand what happens after that. It does seem to jump to uart_isr() successfully, but how should things be processed from here? More analysis is needed.

 void uart_isr(void)
 {
     unsigned int stat, rx_produce_next;

     stat = uart_ev_pending_read();

     if(stat & UART_EV_RX) {
         while(!uart_rxempty_read()) {
             rx_produce_next = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX;
             if(rx_produce_next != rx_consume) {
                 rx_buf[rx_produce] = uart_rxtx_read();
                 rx_produce = rx_produce_next;
             }
             uart_ev_pending_write(UART_EV_RX);
             #if defined(__cva6__)
                 asm volatile("fence\n");
             #endif
         }
     }

     if(stat & UART_EV_TX) {
         uart_ev_pending_write(UART_EV_TX);
         while((tx_consume != tx_produce) && !uart_txfull_read()) {
             uart_rxtx_write(tx_buf[tx_consume]);
             tx_consume = (tx_consume + 1) & UART_RINGBUFFER_MASK_TX;
         }
     }
 }


This is an English translation of the original Japanese post: LiteXによるSoC環境構築を試行する (3. PLICのデバッグ)