1 Commits

Author SHA1 Message Date
Byron Lathi
21efb8ace8 New sw folders 2024-10-14 23:48:16 -07:00
11 changed files with 198 additions and 3 deletions

1
.gitignore vendored
View File

@@ -8,6 +8,7 @@
*.map
*.list
*.bin
*.hex
*.o

View File

@@ -1,4 +1,4 @@
ROM_TARGET=test_code/loop_test
ROM_TARGET=bootloader
INIT_HEX=hw/super6502_fpga/init_hex.mem
HEX=sw/$(ROM_TARGET)/$(notdir $(ROM_TARGET)).bin

View File

@@ -23,7 +23,7 @@ all: waves
waves: $(TB_NAME)
# ./$(TB_NAME) -fst
./obj_dir/Vsim_top
./obj_dir/Vsim_top | tee run.log
$(TB_NAME): $(SUPER6502_FPGA_SOURCES) $(SIM_SOURCES) $(COPY_FILES) $(SD_IMAGE)
# $(IVERILOG) -g2005-sv $(FLAGS) -s $@ -o $@ $(INCLUDE) $(SUPER6502_FPGA_SOURCES) $(SIM_SOURCES) -I ../../

View File

@@ -197,8 +197,12 @@ initial begin
button_resetn <= '0;
repeat(10) @(clk_cpu);
button_resetn <= '1;
repeat(20000) @(posedge clk_cpu);
repeat(2000) @(posedge clk_cpu);
$finish();
end
always @(posedge w_cpu0_sync) begin
$display("[%t] CPU Executed %x:%x", $time(), w_cpu0_addr, w_cpu0_data_from_dut);
end
endmodule

19
sw/Makefile Normal file
View File

@@ -0,0 +1,19 @@
SD_IMAGE = sd_image.bin
BOOTLOADER = bootloader/bootloader.bin
all: $(SD_IMAGE) $(BOOTLOADER)
$(BOOTLOADER):
$(MAKE) -C bootloader bootloader.bin
$(SD_IMAGE):
dd if=/dev/zero of=$@ bs=1M count=256
/sbin/mkfs.vfat $@
udisksctl loop-setup --file $@
udisksctl mount -b /dev/loop1
udisksctl unmount -b /dev/loop1
udisksctl loop-delete -b /dev/loop1
clean:
rm -rf $(SD_IMAGE)
rm -rf $(BOOTLOADER)

38
sw/bootloader/Makefile Normal file
View File

@@ -0,0 +1,38 @@
CC=../toolchain/cc65/bin/cl65
LD=../toolchain/cc65/bin/cl65
CFLAGS=-T -t none -I. --cpu "65C02"
LDFLAGS=-C link.ld -m $(NAME).map
NAME=bootloader
BIN=$(NAME).bin
HEX=$(NAME).hex
LISTS=lists
SRCS=$(wildcard *.s) $(wildcard *.c)
SRCS+=$(wildcard **/*.s) $(wildcard **/*.c)
OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS)))
OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS)))
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,25 @@
.export _init, _nmi_int, _irq_int
.segment "VECTORS"
.addr _nmi_int ; NMI vector
.addr _init ; Reset vector
.addr _irq_int ; IRQ/BRK vector
SDRAM= $200
.code
_nmi_int:
_irq_int:
_init:
lda #$00
@start:
sta SDRAM
cmp SDRAM
bne @end
ina
bra @start
@end: bra @end

30
sw/bootloader/link.ld Normal file
View File

@@ -0,0 +1,30 @@
MEMORY
{
RAM: start = $0000, size = $200;
ROM: start = $F000, size = $1000, file = %O;
}
SEGMENTS {
ZEROPAGE: load = RAM, type = zp, define = yes;
DATA: load = ROM, type = rw, define = 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
}

39
sw/kernel/Makefile Normal file
View File

@@ -0,0 +1,39 @@
CC=../toolchain/cc65/bin/cl65
LD=../toolchain/cc65/bin/cl65
CFLAGS=-T -t none -I. --cpu "65C02"
LDFLAGS=-C link.ld -m $(NAME).map
NAME=bootloader
BIN=$(NAME).bin
HEX=$(NAME).hex
LISTS=lists
SRCS=$(wildcard *.s) $(wildcard *.c)
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

9
sw/kernel/kernel.s Normal file
View File

@@ -0,0 +1,9 @@
.segment "ENTRY"
.addr main
.code
main:
bra main

30
sw/kernel/link.ld Normal file
View File

@@ -0,0 +1,30 @@
MEMORY
{
RAM: start = $0000, size = $200;
KERNEL: start = $8000, size = $7000, file = %O;
}
SEGMENTS {
ZEROPAGE: load = RAM, type = zp, define = yes;
ENTRY: load = KERNEL, type = ro, start = $8000;
DATA: load = KERNEL, type = rw, define = yes;
CODE: load = KERNEL, type = ro;
RODATA: load = KERNEL, type = ro;
}
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
}