2023-02-16 23:26:32 +00:00
|
|
|
.PRECIOUS:${BOOT_CODE}
|
2023-03-04 08:37:43 +00:00
|
|
|
|
2023-11-02 00:29:14 +00:00
|
|
|
########## BUILD OPTIONS ##########
|
|
|
|
|
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
|
|
|
|
|
2023-11-02 00:29:14 +00:00
|
|
|
####### SIMULATION OPTIONS ########
|
|
|
|
|
2023-03-04 08:37:43 +00:00
|
|
|
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-11-02 00:29:14 +00:00
|
|
|
######## SYNTHESIS OPTIONS ########
|
|
|
|
|
|
|
|
FPGA_BOARD=OrangeCrab_r0.2.1
|
|
|
|
# BOARD: the options are the directories in system/fpga_config/.
|
|
|
|
# Select the one you have
|
|
|
|
|
|
|
|
#### ECP5 specific ####
|
|
|
|
ECP5_DEVICE=25F
|
|
|
|
# ECP5_DEVICE: 25F: Create bitstream for the LFE5U-25F
|
|
|
|
# 85F: Create bitstream for the LFE5U-85F
|
|
|
|
ECP5_PACKAGE=CSFBGA285
|
|
|
|
# ECP5_PACKAGE: CSFBGA285: The one used in OrangeCrab
|
|
|
|
|
2023-11-01 06:08:12 +00:00
|
|
|
VERSION="v0.2.0"
|
2023-11-01 06:03:53 +00:00
|
|
|
COMMIT=$(shell git log --pretty=format:'%H' -1 |cat)
|
2023-02-16 01:46:22 +00:00
|
|
|
|
|
|
|
ifeq "${QUIET}" "1"
|
2023-11-02 00:29:14 +00:00
|
|
|
QUIET_AS = @echo ' AS '$@;
|
|
|
|
|
|
|
|
QUIET_VVP = @echo ' VVP '$@;
|
|
|
|
QUIET_IVERILOG = @echo ' IVERILOG '$@;
|
|
|
|
|
|
|
|
QUIET_VERILATOR = @echo ' VERILATOR '$@;
|
|
|
|
QUIET_CC = @echo ' CC '$@;
|
|
|
|
|
|
|
|
QUIET_YOSYS = @echo ' YOSYS '$@;
|
|
|
|
QUIET_NEXTPNR = @echo ' NEXTPNR '$@;
|
|
|
|
QUIET_ECPPACK = @echo ' ECPPACK '$@;
|
|
|
|
QUIET_DFU_SUFFIX = @echo ' DFU-SUFFIX '$@;
|
|
|
|
QUIET_DFU_UTIL = @echo ' DFU-UTIL '$<;
|
|
|
|
|
2023-03-04 08:37:43 +00:00
|
|
|
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})
|
|
|
|
|
|
|
|
# Assembling code
|
|
|
|
%.txt:%.bin
|
2023-03-08 07:26:28 +00:00
|
|
|
${Q}dd if=/dev/zero bs=1 count=65536 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-11-01 06:03:53 +00:00
|
|
|
${Q}vvp "${SYSTEM_VVP}" -fst +VERSION=${VERSION} +COMMIT=${COMMIT} +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-11-01 06:03:53 +00:00
|
|
|
${Q}vvp -i "${SYSTEM_VVP}" +VERSION=${VERSION} +COMMIT=${COMMIT} +BOOT_CODE="$<" +MICROCODE="${MICROCODE}"
|
2023-05-14 15:06:33 +00:00
|
|
|
%.json: %.txt ${SYSTEM_VVP} ${MICROCODE}
|
|
|
|
${QUIET_VVP}
|
2023-11-01 06:03:53 +00:00
|
|
|
${Q}vvp -i "${SYSTEM_VVP}" +VERSION=${VERSION} +COMMIT=${COMMIT} +STATS="$@" +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-11-01 06:03:53 +00:00
|
|
|
${Q}"${VERILATOR_BIN}" +VERSION=${VERSION} +COMMIT=${COMMIT} +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,$<)"
|
|
|
|
|
2023-05-14 15:06:33 +00:00
|
|
|
%.json: %.txt ${VERILATOR_BIN} ${MICROCODE}
|
|
|
|
$(call QUIET_VERILATOR_RUN,$(word 2,$^),$<)
|
2023-11-01 06:03:53 +00:00
|
|
|
${Q} ${NUMACTL} "${VERILATOR_BIN}" +VERSION=${VERSION} +COMMIT=${COMMIT} +STATS=$@ +BOOT_CODE="$<" +MICROCODE="${MICROCODE}"
|
2023-03-04 08:37:43 +00:00
|
|
|
%.run: %.txt ${VERILATOR_BIN} ${MICROCODE}
|
|
|
|
$(call QUIET_VERILATOR_RUN,$(word 2,$^),$<)
|
2023-11-01 06:03:53 +00:00
|
|
|
${Q} ${NUMACTL} "${VERILATOR_BIN}" +VERSION=${VERSION} +COMMIT=${COMMIT} +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}"
|