Integrate uart controller into top level module
Adds new chip select for the UART, and a new entry in the data_out mux for the UART.
This commit is contained in:
@@ -2,11 +2,13 @@ module addr_decode(
|
|||||||
input logic [15:0] addr,
|
input logic [15:0] addr,
|
||||||
output logic ram_cs,
|
output logic ram_cs,
|
||||||
output logic rom_cs,
|
output logic rom_cs,
|
||||||
output logic hex_cs
|
output logic hex_cs,
|
||||||
|
output logic uart_cs
|
||||||
);
|
);
|
||||||
|
|
||||||
assign rom_cs = addr[15];
|
assign rom_cs = addr[15];
|
||||||
assign ram_cs = ~addr[15] && addr < 16'h7ff0;
|
assign ram_cs = ~addr[15] && addr < 16'h7ff0;
|
||||||
assign hex_cs = addr >= 16'h7ff0 && addr < 16'h7ff4;
|
assign hex_cs = addr >= 16'h7ff0 && addr < 16'h7ff4;
|
||||||
|
assign uart_cs = addr >= 16'h7ff4 && addr < 16'h7ff6;
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
@@ -40,10 +40,12 @@ assign cpu_data = cpu_rwb ? cpu_data_out : 'z;
|
|||||||
|
|
||||||
logic [7:0] rom_data_out;
|
logic [7:0] rom_data_out;
|
||||||
logic [7:0] ram_data_out;
|
logic [7:0] ram_data_out;
|
||||||
|
logic [7:0] uart_data_out;
|
||||||
|
|
||||||
logic ram_cs;
|
logic ram_cs;
|
||||||
logic rom_cs;
|
logic rom_cs;
|
||||||
logic hex_cs;
|
logic hex_cs;
|
||||||
|
logic uart_cs;
|
||||||
|
|
||||||
cpu_clk cpu_clk(
|
cpu_clk cpu_clk(
|
||||||
.inclk0(clk_50),
|
.inclk0(clk_50),
|
||||||
@@ -65,7 +67,8 @@ addr_decode decode(
|
|||||||
.addr(cpu_addr),
|
.addr(cpu_addr),
|
||||||
.ram_cs(ram_cs),
|
.ram_cs(ram_cs),
|
||||||
.rom_cs(rom_cs),
|
.rom_cs(rom_cs),
|
||||||
.hex_cs(hex_cs)
|
.hex_cs(hex_cs),
|
||||||
|
.uart_cs(uart_cs)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -74,6 +77,8 @@ always_comb begin
|
|||||||
cpu_data_out = ram_data_out;
|
cpu_data_out = ram_data_out;
|
||||||
else if (rom_cs)
|
else if (rom_cs)
|
||||||
cpu_data_out = rom_data_out;
|
cpu_data_out = rom_data_out;
|
||||||
|
else if (uart_cs)
|
||||||
|
cpu_data_out = uart_data_out;
|
||||||
else
|
else
|
||||||
cpu_data_out = 'x;
|
cpu_data_out = 'x;
|
||||||
end
|
end
|
||||||
@@ -112,11 +117,11 @@ uart uart(
|
|||||||
.rst(rst),
|
.rst(rst),
|
||||||
.rw(cpu_rwb),
|
.rw(cpu_rwb),
|
||||||
.data_in(cpu_data_in),
|
.data_in(cpu_data_in),
|
||||||
.cs(),
|
.cs(uart_cs),
|
||||||
.addr(cpu_addr[1:0]),
|
.addr(cpu_addr[1:0]),
|
||||||
.RXD(UART_RXD),
|
.RXD(UART_RXD),
|
||||||
.TXD(UART_TXD),
|
.TXD(UART_TXD),
|
||||||
.data_out()
|
.data_out(uart_data_out)
|
||||||
);
|
);
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
Reference in New Issue
Block a user