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
|
|
|
|
${Q}dd if=/dev/zero bs=1 count=16384 of="$(subst .bin,.stage,$<)" status=none
|
|
|
|
${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,$<)"
|
|
|
|
|
|
|
|
%.bin:%.asm
|
|
|
|
${QUIET_AS}
|
|
|
|
${Q}as86 -0 "$<" -b "$@"
|
|
|
|
|
|
|
|
# Running simulation
|
|
|
|
%.lx2 %.memdump: %.txt ${SYSTEM_VVP}
|
|
|
|
${QUIET_VVP}
|
|
|
|
${Q}vvp "${SYSTEM_VVP}" -lxt2 +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.lx2,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)"
|
|
|
|
${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}
|
|
|
|
${Q}vvp "${SYSTEM_VVP}" +BOOT_CODE="$<"
|
|
|
|
|
2023-02-16 01:46:22 +00:00
|
|
|
%.disas: %.bin
|
|
|
|
objdump -D -b binary -m i8086 $^ | less
|
|
|
|
|
|
|
|
# Tools
|
|
|
|
%.wave : %.lx2
|
|
|
|
gtkwave "$<" "${GTKWSAVE}"
|