2023-02-16 23:26:32 +00:00
|
|
|
.PRECIOUS:${BOOT_CODE}
|
2023-03-04 08:37:43 +00:00
|
|
|
|
2023-02-16 01:46:22 +00:00
|
|
|
QUIET=1
|
2023-03-04 08:37:43 +00:00
|
|
|
# QUIET: 1=clean, non-verbose output
|
|
|
|
# 2=normal make output
|
|
|
|
|
|
|
|
SIM=VERILATOR
|
|
|
|
# SIM: VERILATOR: use Verilator
|
|
|
|
# ICARUS: use Icarus Verilog
|
|
|
|
|
2023-03-05 00:10:55 +00:00
|
|
|
NUMACTL=#numactl -m 0 -C 0,1 --
|
|
|
|
|
2023-02-16 01:46:22 +00:00
|
|
|
|
|
|
|
ifeq "${QUIET}" "1"
|
2023-03-04 08:37:43 +00:00
|
|
|
QUIET_AS = @echo ' AS '$@;
|
2023-03-05 23:11:18 +00:00
|
|
|
QUIET_CC = @echo ' CC '$@;
|
2023-03-04 08:37:43 +00:00
|
|
|
QUIET_VVP = @echo ' VVP '$@;
|
|
|
|
QUIET_IVERILOG = @echo ' IVERILOG '$@;
|
|
|
|
QUIET_VERILATOR = @echo ' VERILATOR '$@;
|
|
|
|
QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
|
|
|
|
QUIET_VERILATOR_RUN = @printf ' %s %s\n' $1 $2;
|
2023-02-16 01:46:22 +00:00
|
|
|
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
|
2023-03-04 08:37:43 +00:00
|
|
|
ifeq "${SIM}" "ICARUS"
|
2023-03-05 00:10:55 +00:00
|
|
|
%.fst %.memdump: %.txt ${SYSTEM_VVP} ${MICROCODE}
|
2023-02-16 01:46:22 +00:00
|
|
|
${QUIET_VVP}
|
2023-03-05 00:10:55 +00:00
|
|
|
${Q}vvp "${SYSTEM_VVP}" -fst +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.fst,$<)" +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-03-04 08:37:43 +00:00
|
|
|
%.run: %.txt ${SYSTEM_VVP} ${MICROCODE}
|
2023-02-16 23:26:32 +00:00
|
|
|
${QUIET_VVP}
|
2023-02-19 16:22:23 +00:00
|
|
|
${Q}vvp -i "${SYSTEM_VVP}" +BOOT_CODE="$<" +MICROCODE="${MICROCODE}"
|
2023-03-04 08:37:43 +00:00
|
|
|
else ifeq "${SIM}" "VERILATOR"
|
2023-03-05 00:10:55 +00:00
|
|
|
%.fst %.memdump: %.txt ${VERILATOR_BIN} ${MICROCODE}
|
2023-03-04 08:37:43 +00:00
|
|
|
$(call QUIET_VERILATOR_RUN,$(word 2,$^),$<)
|
2023-03-05 00:10:55 +00:00
|
|
|
${Q}"${VERILATOR_BIN}" +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.fst,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)" +MICROCODE="${MICROCODE}"
|
2023-03-04 08:37:43 +00:00
|
|
|
${Q}grep -v '^//' "$(subst .txt,.memdumptxt,$<)" | xxd -ps -c 2 -r > "$(subst .txt,.memdump,$<)"
|
|
|
|
${Q}rm "$(subst .txt,.memdumptxt,$<)"
|
|
|
|
|
|
|
|
%.run: %.txt ${VERILATOR_BIN} ${MICROCODE}
|
|
|
|
$(call QUIET_VERILATOR_RUN,$(word 2,$^),$<)
|
2023-03-05 00:10:55 +00:00
|
|
|
${Q} ${NUMACTL} "${VERILATOR_BIN}" +BOOT_CODE="$<" +MICROCODE="${MICROCODE}"
|
2023-03-04 08:37:43 +00:00
|
|
|
endif
|
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
|
2023-03-05 00:10:55 +00:00
|
|
|
%.wave : %.fst
|
2023-02-16 01:46:22 +00:00
|
|
|
gtkwave "$<" "${GTKWSAVE}"
|