Add quick uart irq test

This commit is contained in:
Byron Lathi
2023-11-28 17:45:20 -08:00
parent db4848b6fe
commit 3524892f80
6 changed files with 163 additions and 1 deletions

View File

@@ -11,7 +11,7 @@ TEST_PROGRAM?=$(REPO_TOP)/sw/test_code/$(TEST_PROGRAM_NAME)/$(TEST_PROGRAM_NAME)
STANDALONE_TB= interrupt_controller_tb mapper_tb rtc_tb uart_irq_tb
CODE_TB= interrupt_controller_code_tb mapper_code_tb rtc_code_tb \
devices_setup_code_tb
devices_setup_code_tb uart_irq_code_tb
#TODO implement something like sources.list

View File

@@ -0,0 +1,36 @@
`timescale 1ns/1ps
module uart_irq_code_tb();
sim_top u_sim_top();
always begin
if (
u_sim_top.w_cpu_addr == 16'h0 &&
u_sim_top.w_cpu_we == '1
) begin
if (u_sim_top.w_cpu_data_from_cpu == 8'h6d) begin
$display("Good finish!");
$finish();
end else begin
$display("Bad finish!");
$finish_and_return(-1);
end
end
# 1;
end
initial begin
repeat(15000) @(posedge u_sim_top.r_clk_cpu)
u_sim_top.u_sim_uart.tx_en = 1;
@(posedge u_sim_top.r_clk_cpu);
u_sim_top.u_sim_uart.tx_data = 8'hAA;
repeat (100) @(posedge u_sim_top.r_clk_cpu);
$finish();
end
always @(u_sim_top.u_dut.u_rtc.r_output) begin
$display("counter: %d", u_sim_top.u_dut.u_rtc.r_output);
end
endmodule

View File

@@ -0,0 +1,42 @@
CC=../../cc65/bin/cl65
LD=../../cc65/bin/cl65
CFLAGS=-T -t none -I. --cpu "65C02"
LDFLAGS=-C link.ld -m $(NAME).map
NAME=uart_irq_test
DEVICES=$(REPO_TOP)/sw/kernel/devices
BIN=$(NAME).bin
HEX=$(NAME).hex
LISTS=lists
SRCS=$(wildcard *.s) $(wildcard *.c)
SRCS+=$(DEVICES)/interrupt_controller.s
SRCS+=$(wildcard **/*.s) $(wildcard **/*.c)
OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS)))
OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS)))
# Make sure the kernel linked to correct address, no relocation!
all: $(HEX)
$(HEX): $(BIN)
objcopy --input-target=binary --output-target=verilog $(BIN) $(HEX)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
%.o: %.c $(LISTS)
$(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@
%.o: %.s $(LISTS)
$(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@
$(LISTS):
mkdir -p $(addprefix $(LISTS)/,$(sort $(dir $(SRCS))))
.PHONY: clean
clean:
rm -rf $(OBJS) $(BIN) $(HEX) $(LISTS) $(NAME).map

View File

@@ -0,0 +1,35 @@
MEMORY
{
ZP: start = $0, size = $100, type = rw, define = yes;
SDRAM: start = $9200, size = $4d00, type = rw, define = yes;
ROM: start = $F000, size = $1000, file = %O;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, define = yes;
DATA: load = ROM, type = rw, define = yes, run = SDRAM;
BSS: load = SDRAM, type = bss, define = yes;
HEAP: load = SDRAM, type = bss, optional = yes;
STARTUP: load = ROM, type = ro;
ONCE: load = ROM, type = ro, optional = yes;
CODE: load = ROM, type = ro;
RODATA: load = ROM, type = ro;
VECTORS: load = ROM, type = ro, start = $FFFA;
}
FEATURES {
CONDES: segment = STARTUP,
type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__;
CONDES: segment = STARTUP,
type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__;
}
SYMBOLS {
# Define the stack size for the application
__STACKSIZE__: value = $0200, type = weak;
__STACKSTART__: type = weak, value = $0800; # 2k stack
}

View File

@@ -0,0 +1,35 @@
.export _init, nmi_int, irq_int
.autoimport
.import _init_interrupt_controller
.zeropage
finish: .res 1
.code
nmi_int:
irq_int:
lda #$6d
sta $00
_init:
ldx #$ff
txs
LDA #<(__STACKSTART__ + __STACKSIZE__)
STA sp
LDA #>(__STACKSTART__ + __STACKSIZE__)
STA sp+1
; enable interrupt 0
lda #$00
jsr pusha
lda #$1
jsr _enable_irq
cli
@end: bra @end

View File

@@ -0,0 +1,14 @@
; ---------------------------------------------------------------------------
; vectors.s
; ---------------------------------------------------------------------------
;
; Defines the interrupt vector table.
.import _init
.import nmi_int, irq_int
.segment "VECTORS"
.addr nmi_int ; NMI vector
.addr _init ; Reset vector
.addr irq_int ; IRQ/BRK vector