From e06c0eeaa03a8fa78b4c2092eb34b721212d0251 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Sun, 12 Nov 2023 04:04:56 +0000 Subject: [PATCH] Made the build system simplify the microcode so that yosys understands and synthesises it! Now gnome_sort.asm almost works! --- .gitignore | 1 + boot_code/colored_led.asm | 12 ++++++++++-- system/Makefile | 7 +++++-- system/decoder.v | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f588e07..0ac0597 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ boot_code/*.txt system/boot_code.bin system/boot_code.txt system/obj_dir/ +system/simplified_ucode.txt tools/*svg diff --git a/boot_code/colored_led.asm b/boot_code/colored_led.asm index 7055c3e..0b41e93 100644 --- a/boot_code/colored_led.asm +++ b/boot_code/colored_led.asm @@ -1,4 +1,7 @@ +INCLUDE dos_layer.asm + .org 0x100 +mov sp,#STACK MAIN_LOOP: MOV DL,#0xF0 @@ -16,11 +19,14 @@ out byte #0xB0 MOV SI,#RESERVED MOV DI,#RESERVED MOV AL,#0x68 ; 'h' -MOV [DI],AL +STOSB MOV AL,#0x00 MOV AL,[SI] -out byte #0xA5 +MOV AH,#0x02 +MOV DL,AL +INT #0x21 + MOV AL,#0x65 out byte #0xA5 MOV AL,#0x6c @@ -47,6 +53,8 @@ MOV AX,#0x0100 JMP AX RESERVED: DB 0x48 ; 'H' +.BLKB 200 +STACK: .ORG 0xFFF0 MOV AX,#0x0100 diff --git a/system/Makefile b/system/Makefile index 4397a85..45d13f7 100644 --- a/system/Makefile +++ b/system/Makefile @@ -71,8 +71,11 @@ ECP5_TARGETS+=abc.history # created from yosys EXTRA_SYNTHESIS_SOURCES=peripherals/I2C_driver.v peripherals/ascii_to_HD44780_driver.v peripherals/pcf8574_for_HD44780.v +simplified_ucode.txt:ucode.txt + ${Q}tr 'x' '0' < $^ | sed 's@//.*@@' | grep ^@ |sort | sed 's/.* .//;s/ $$//' | tr -d _ > $@ + #TODO: we are relying on yosys to trim the input program txt file and hope its enough for the whole program... -synth_ecp5.json: ${SOURCES} ${TOP_LEVEL_SOURCE} fpga_config/${FPGA_BOARD}/fpga_top.v ${EXTRA_SYNTHESIS_SOURCES} ${INCLUDES} ../boot_code/colored_led.txt +synth_ecp5.json: ${SOURCES} ${TOP_LEVEL_SOURCE} fpga_config/${FPGA_BOARD}/fpga_top.v ${EXTRA_SYNTHESIS_SOURCES} ${INCLUDES} ../boot_code/colored_led.txt simplified_ucode.txt ${QUIET_YOSYS} ${Q} yosys -q -D BUILTIN_RAM=512 -D NOT_FULL -p 'read -sv '"${SOURCES} ${TOP_LEVEL_SOURCE} fpga_config/${FPGA_BOARD}/fpga_top.v ${EXTRA_SYNTHESIS_SOURCES} ; synth_ecp5 -json $@ -top fpga_top" @@ -101,4 +104,4 @@ upload: upload_orangecrab .PHONY: clean clean: $(call QUIET_CLEAN,system) - ${Q}rm -rf ${SYSTEM_VVP} *.fst boot_code.txt boot_code.bin *memdump *memdumptxt obj_dir *json ${ECP5_TARGETS} + ${Q}rm -rf ${SYSTEM_VVP} *.fst boot_code.txt boot_code.bin *memdump *memdumptxt obj_dir *json simplified_ucode.txt ${ECP5_TARGETS} diff --git a/system/decoder.v b/system/decoder.v index eabc2fc..175832e 100644 --- a/system/decoder.v +++ b/system/decoder.v @@ -214,7 +214,7 @@ initial begin end `else //TODO: don't have it hard coded - $readmemb("ucode.txt",ucode_rom,0,`UCODE_SIZE-1); + $readmemb("simplified_ucode.txt",ucode_rom,0,`UCODE_SIZE-1); `endif end