diff --git a/hw/fpga/super6502.sv b/hw/fpga/super6502.sv index c564854..af0eae9 100644 --- a/hw/fpga/super6502.sv +++ b/hw/fpga/super6502.sv @@ -117,6 +117,8 @@ SevenSeg segs( .HEX0(HEX0), .HEX1(HEX1), .HEX2(HEX2), .HEX3(HEX3), .HEX4(HEX4), .HEX5(HEX5) ); +logic uart_irq; + uart uart( .clk_50(clk_50), .clk(clk), @@ -127,6 +129,7 @@ uart uart( .addr(cpu_addr[1:0]), .RXD(UART_RXD), .TXD(UART_TXD), + .irq(uart_irq), .data_out(uart_data_out) ); @@ -135,8 +138,13 @@ always_ff @(posedge clk_50) begin irq_data_out <= '0; else if (irq_cs && ~cpu_rwb) irq_data_out <= irq_data_out & cpu_data_in; - else if (~button_1) - irq_data_out <= {irq_data_out[7:1], ~button_1}; + + else begin + if (~button_1) + irq_data_out[0] <= '1; + if (uart_irq) + irq_data_out[1] <= '1; + end end diff --git a/hw/fpga/uart.sv b/hw/fpga/uart.sv index 9c86ffb..2c3e9a0 100644 --- a/hw/fpga/uart.sv +++ b/hw/fpga/uart.sv @@ -12,9 +12,13 @@ module uart( output logic TXD, + output logic irq, output logic [7:0] data_out ); +//Temporary! +assign irq = ~RXD; + //Handle reading and writing registers logic [7:0] tx_buf; diff --git a/sw/interrupt.h b/sw/interrupt.h index ebd5951..d0231aa 100644 --- a/sw/interrupt.h +++ b/sw/interrupt.h @@ -4,6 +4,7 @@ #include #define BUTTON (1 << 0) +#define UART (1 << 1) void irq_int(); void nmi_int(); diff --git a/sw/irq.c b/sw/irq.c index 3aec0c1..a7f7287 100644 --- a/sw/irq.c +++ b/sw/irq.c @@ -17,4 +17,8 @@ void handle_irq() { puts("Button Interrupt!\n"); irq_set_status(status & ~BUTTON); } + if (status & UART) { + puts("UART Interrupt!\n"); + irq_set_status(status & ~UART); + } } \ No newline at end of file