Add UART interrupts
Currently an interrupt is triggered any time there is any activity on the UART_RXD line, but later it will only trigger once there is data ready to be read.
This commit is contained in:
@@ -117,6 +117,8 @@ SevenSeg segs(
|
|||||||
.HEX0(HEX0), .HEX1(HEX1), .HEX2(HEX2), .HEX3(HEX3), .HEX4(HEX4), .HEX5(HEX5)
|
.HEX0(HEX0), .HEX1(HEX1), .HEX2(HEX2), .HEX3(HEX3), .HEX4(HEX4), .HEX5(HEX5)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
logic uart_irq;
|
||||||
|
|
||||||
uart uart(
|
uart uart(
|
||||||
.clk_50(clk_50),
|
.clk_50(clk_50),
|
||||||
.clk(clk),
|
.clk(clk),
|
||||||
@@ -127,6 +129,7 @@ uart uart(
|
|||||||
.addr(cpu_addr[1:0]),
|
.addr(cpu_addr[1:0]),
|
||||||
.RXD(UART_RXD),
|
.RXD(UART_RXD),
|
||||||
.TXD(UART_TXD),
|
.TXD(UART_TXD),
|
||||||
|
.irq(uart_irq),
|
||||||
.data_out(uart_data_out)
|
.data_out(uart_data_out)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -135,8 +138,13 @@ always_ff @(posedge clk_50) begin
|
|||||||
irq_data_out <= '0;
|
irq_data_out <= '0;
|
||||||
else if (irq_cs && ~cpu_rwb)
|
else if (irq_cs && ~cpu_rwb)
|
||||||
irq_data_out <= irq_data_out & cpu_data_in;
|
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
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,13 @@ module uart(
|
|||||||
|
|
||||||
output logic TXD,
|
output logic TXD,
|
||||||
|
|
||||||
|
output logic irq,
|
||||||
output logic [7:0] data_out
|
output logic [7:0] data_out
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Temporary!
|
||||||
|
assign irq = ~RXD;
|
||||||
|
|
||||||
//Handle reading and writing registers
|
//Handle reading and writing registers
|
||||||
|
|
||||||
logic [7:0] tx_buf;
|
logic [7:0] tx_buf;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define BUTTON (1 << 0)
|
#define BUTTON (1 << 0)
|
||||||
|
#define UART (1 << 1)
|
||||||
|
|
||||||
void irq_int();
|
void irq_int();
|
||||||
void nmi_int();
|
void nmi_int();
|
||||||
|
|||||||
Reference in New Issue
Block a user