2023-02-16 23:26:32 +00:00
|
|
|
.PRECIOUS:${BOOT_CODE}
|
2023-02-16 01:46:22 +00:00
|
|
|
QUIET=1
|
|
|
|
|
|
|
|
ifeq "${QUIET}" "1"
|
|
|
|
QUIET_AS = @echo ' AS '$@;
|
|
|
|
QUIET_VVP = @echo ' VVP '$@;
|
|
|
|
QUIET_IVERILOG = @echo ' IVERILOG '$@;
|
|
|
|
QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
|
|
|
|
Q = @
|
|
|
|
MAKEOPTS=--no-print-directory
|
|
|
|
.SILENT:
|
|
|
|
else
|
|
|
|
Q =
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2023-02-16 23:26:32 +00:00
|
|
|
.PHONY: run wave disas
|
|
|
|
run: $(subst .txt,.run,${BOOT_CODE})
|
2023-02-16 01:46:22 +00:00
|
|
|
wave: $(subst .txt,.wave,${BOOT_CODE})
|
|
|
|
disas: $(subst .txt,.disas,${BOOT_CODE})
|
|
|
|
|
2023-02-16 23:26:32 +00:00
|
|
|
|
2023-02-16 01:46:22 +00:00
|
|
|
# Assembling code
|
|
|
|
%.txt:%.bin
|
2023-02-24 17:36:41 +00:00
|
|
|
${Q}dd if=/dev/zero bs=1 count=32768 of="$(subst .bin,.stage,$<)" status=none
|
2023-02-16 01:46:22 +00:00
|
|
|
${Q}dd if="$<" of="$(subst .bin,.stage,$<)" conv=notrunc,nocreat status=none
|
|
|
|
${Q}xxd -ps -c 2 "$(subst .bin,.stage,$<)" > "$@"
|
|
|
|
${Q}rm "$(subst .bin,.stage,$<)"
|
|
|
|
|
2023-02-22 01:51:14 +00:00
|
|
|
ifeq "${NO_ASM}" "0"
|
2023-02-16 01:46:22 +00:00
|
|
|
%.bin:%.asm
|
|
|
|
${QUIET_AS}
|
|
|
|
${Q}as86 -0 "$<" -b "$@"
|
2023-02-22 01:51:14 +00:00
|
|
|
endif
|
2023-02-16 01:46:22 +00:00
|
|
|
|
|
|
|
# Running simulation
|
|
|
|
%.lx2 %.memdump: %.txt ${SYSTEM_VVP}
|
|
|
|
${QUIET_VVP}
|
2023-02-19 16:22:23 +00:00
|
|
|
${Q}vvp "${SYSTEM_VVP}" -lxt2 +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.lx2,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)" +MICROCODE="${MICROCODE}"
|
2023-02-16 01:46:22 +00:00
|
|
|
${Q}grep -v '^//' "$(subst .txt,.memdumptxt,$<)" | xxd -ps -c 2 -r > "$(subst .txt,.memdump,$<)"
|
|
|
|
${Q}rm "$(subst .txt,.memdumptxt,$<)"
|
|
|
|
|
2023-02-16 23:26:32 +00:00
|
|
|
%.run: %.txt ${SYSTEM_VVP}
|
|
|
|
${QUIET_VVP}
|
2023-02-19 16:22:23 +00:00
|
|
|
${Q}vvp -i "${SYSTEM_VVP}" +BOOT_CODE="$<" +MICROCODE="${MICROCODE}"
|
2023-02-16 23:26:32 +00:00
|
|
|
|
2023-02-16 01:46:22 +00:00
|
|
|
%.disas: %.bin
|
|
|
|
objdump -D -b binary -m i8086 $^ | less
|
|
|
|
|
|
|
|
# Tools
|
|
|
|
%.wave : %.lx2
|
|
|
|
gtkwave "$<" "${GTKWSAVE}"
|