First throw at UART.
This commit is contained in:
@@ -14,8 +14,8 @@ module addr_decode
|
|||||||
assign o_rom_cs = i_addr >= 16'hf000 && i_addr <= 16'hffff;
|
assign o_rom_cs = i_addr >= 16'hf000 && i_addr <= 16'hffff;
|
||||||
assign o_timer_cs = i_addr >= 16'heff8 && i_addr <= 16'heffb;
|
assign o_timer_cs = i_addr >= 16'heff8 && i_addr <= 16'heffb;
|
||||||
assign o_multiplier_cs = i_addr >= 16'heff0 && i_addr <= 16'heff7;
|
assign o_multiplier_cs = i_addr >= 16'heff0 && i_addr <= 16'heff7;
|
||||||
assign o_divider_cs = i_addr >= 16'hefe7 && i_addr <= 16'hefef;
|
assign o_divider_cs = i_addr >= 16'hefe8 && i_addr <= 16'hefef;
|
||||||
assign o_uart_cs = i_addr >= 16'hefe5 && i_addr <= 16'hefe6;
|
assign o_uart_cs = i_addr >= 16'hefe6 && i_addr <= 16'hefe7;
|
||||||
assign o_leds_cs = i_addr == 16'hefff;
|
assign o_leds_cs = i_addr == 16'hefff;
|
||||||
assign o_sdram_cs = i_addr < 16'h8000;
|
assign o_sdram_cs = i_addr < 16'h8000;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -4,9 +4,9 @@ input integer index;//Mode type
|
|||||||
input integer val_; //Port A index, Port B Index, Number of Items in Loop, Port A Start, Port B Start, reserved
|
input integer val_; //Port A index, Port B Index, Number of Items in Loop, Port A Start, Port B Start, reserved
|
||||||
case (index)
|
case (index)
|
||||||
0: bram_ini_table=
|
0: bram_ini_table=
|
||||||
(val_== 0)?256'h008d0000d000a9000ef000e90008d00001000a9000ef000e80008d000c8000a9:
|
(val_== 0)?256'h006500048000fd00080000cb000ef000e60008d000ff0000b000bd00000000a2:
|
||||||
(val_== 1)?256'h0ef000ff0008d000ef000ec000ad000ef000eb0008d00000000a9000ef000ea0:
|
(val_== 1)?256'h0000000000021000640006c000720006f00077000200002c0006f0006c0006c0:
|
||||||
(val_== 2)?256'h00000000000000000000000000000000000000000000000000e300080000cb00:
|
(val_== 2)?256'h0000000000000000000000000000000000000000000000000000000000000000:
|
||||||
(val_== 3)?256'h0000000000000000000000000000000000000000000000000000000000000000:
|
(val_== 3)?256'h0000000000000000000000000000000000000000000000000000000000000000:
|
||||||
(val_== 4)?256'h0000000000000000000000000000000000000000000000000000000000000000:
|
(val_== 4)?256'h0000000000000000000000000000000000000000000000000000000000000000:
|
||||||
(val_== 5)?256'h0000000000000000000000000000000000000000000000000000000000000000:
|
(val_== 5)?256'h0000000000000000000000000000000000000000000000000000000000000000:
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
a9
|
a2
|
||||||
c8
|
|
||||||
8d
|
|
||||||
e8
|
|
||||||
ef
|
|
||||||
a9
|
|
||||||
01
|
|
||||||
8d
|
|
||||||
e9
|
|
||||||
ef
|
|
||||||
a9
|
|
||||||
0d
|
|
||||||
8d
|
|
||||||
ea
|
|
||||||
ef
|
|
||||||
a9
|
|
||||||
00
|
00
|
||||||
8d
|
bd
|
||||||
eb
|
0b
|
||||||
ef
|
|
||||||
ad
|
|
||||||
ec
|
|
||||||
ef
|
|
||||||
8d
|
|
||||||
ff
|
ff
|
||||||
|
8d
|
||||||
|
e6
|
||||||
ef
|
ef
|
||||||
cb
|
cb
|
||||||
80
|
80
|
||||||
e3
|
fd
|
||||||
|
48
|
||||||
|
65
|
||||||
|
6c
|
||||||
|
6c
|
||||||
|
6f
|
||||||
|
2c
|
||||||
|
20
|
||||||
|
77
|
||||||
|
6f
|
||||||
|
72
|
||||||
|
6c
|
||||||
|
64
|
||||||
|
21
|
||||||
|
00
|
||||||
|
00
|
||||||
|
00
|
||||||
|
00
|
||||||
|
00
|
||||||
00
|
00
|
||||||
00
|
00
|
||||||
00
|
00
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<efx:project name="super6502" description="" last_change_date="Wed January 11 2023 21:04:23" location="/home/byron/Projects/super6502/hw/efinix_fpga" sw_version="2022.2.322" last_run_state="pass" last_run_tool="efx_pgm" last_run_flow="bitstream" config_result_in_sync="true" design_ood="sync" place_ood="sync" route_ood="sync" xmlns:efx="http://www.efinixinc.com/enf_proj" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.efinixinc.com/enf_proj enf_proj.xsd">
|
<efx:project name="super6502" description="" last_change_date="Thu January 12 2023 12:02:15" location="/home/byron/Projects/super6502/hw/efinix_fpga" sw_version="2022.2.322" last_run_state="pass" last_run_tool="efx_pgm" last_run_flow="bitstream" config_result_in_sync="true" design_ood="sync" place_ood="sync" route_ood="sync" xmlns:efx="http://www.efinixinc.com/enf_proj" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.efinixinc.com/enf_proj enf_proj.xsd">
|
||||||
<efx:device_info>
|
<efx:device_info>
|
||||||
<efx:family name="Trion"/>
|
<efx:family name="Trion"/>
|
||||||
<efx:device name="T20F256"/>
|
<efx:device name="T20F256"/>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
TARGETS=stacktest runram timer timer_irq multiplier divider
|
TARGETS=stacktest runram timer timer_irq multiplier divider uart
|
||||||
SRC=$(wildcard *.s)
|
SRC=$(wildcard *.s)
|
||||||
DIR=../ip/bram
|
DIR=../ip/bram
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
$(TARGETS): $(SRC)
|
$(TARGETS): $(SRC)
|
||||||
cl65 --cpu 65c02 -C link.ld -l $@.list $@.s
|
cl65 --cpu 65c02 -t none -C link.ld -l $@.list $@.s
|
||||||
xxd -ps $@ | fold -w 2 > $@.hex
|
xxd -ps $@ | fold -w 2 > $@.hex
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|||||||
28
hw/efinix_fpga/test_programs/uart.s
Normal file
28
hw/efinix_fpga/test_programs/uart.s
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
.code
|
||||||
|
|
||||||
|
UART_TX = $efe6
|
||||||
|
UART_RX = UART_TX
|
||||||
|
UART_STATUS = $efe7
|
||||||
|
UART_CONTROL = UART_STATUS
|
||||||
|
|
||||||
|
main:
|
||||||
|
ldx #$00
|
||||||
|
loop:
|
||||||
|
lda string,x
|
||||||
|
sta UART_TX
|
||||||
|
|
||||||
|
end:
|
||||||
|
wai
|
||||||
|
bra end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string:
|
||||||
|
.asciiz "Hello, world!"
|
||||||
|
|
||||||
|
|
||||||
|
.segment "VECTORS"
|
||||||
|
|
||||||
|
.addr main
|
||||||
|
.addr main
|
||||||
|
.addr main
|
||||||
@@ -14,7 +14,7 @@ module uart_wrapper(
|
|||||||
output logic irqb
|
output logic irqb
|
||||||
);
|
);
|
||||||
|
|
||||||
logic status, control;
|
logic [7:0] status, control;
|
||||||
|
|
||||||
logic tx_busy, rx_busy;
|
logic tx_busy, rx_busy;
|
||||||
|
|
||||||
@@ -44,23 +44,29 @@ uart u_uart(
|
|||||||
|
|
||||||
enum bit [1:0] {READY, WAIT, TRANSMIT} state, next_state;
|
enum bit [1:0] {READY, WAIT, TRANSMIT} state, next_state;
|
||||||
|
|
||||||
always_ff @(negedge clk) begin
|
always_ff @(posedge clk_50) begin
|
||||||
if (reset) begin
|
if (reset) begin
|
||||||
state = READY;
|
state = READY;
|
||||||
irqb <= '1;
|
irqb <= '1;
|
||||||
end else begin
|
end else begin
|
||||||
state <= next_state;
|
state <= next_state;
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
case (addr)
|
always_ff @(negedge clk) begin
|
||||||
1'b0: begin
|
status[0] <= status[0] | rx_data_valid;
|
||||||
tx_data <= i_data;
|
|
||||||
end
|
|
||||||
|
|
||||||
1'b1: begin
|
if (cs & ~rwb) begin
|
||||||
control <= i_data;
|
case (addr)
|
||||||
end
|
1'b0: begin
|
||||||
endcase
|
tx_data <= i_data;
|
||||||
|
end
|
||||||
|
|
||||||
|
1'b1: begin
|
||||||
|
control <= i_data;
|
||||||
|
end
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -83,13 +89,14 @@ always_comb begin
|
|||||||
|
|
||||||
case (state)
|
case (state)
|
||||||
READY: begin
|
READY: begin
|
||||||
if (~rwb && addr == 1'b0) begin //write to transmit
|
if (cs & ~rwb && addr == 1'b0) begin //write to transmit
|
||||||
tx_en = 1'b1;
|
tx_en = 1'b1;
|
||||||
next_state = WAIT;
|
next_state = WAIT;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
WAIT: begin
|
WAIT: begin
|
||||||
|
tx_en = 1'b1;
|
||||||
if (tx_busy) begin
|
if (tx_busy) begin
|
||||||
next_state = TRANSMIT;
|
next_state = TRANSMIT;
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user