diff --git a/common.mk b/common.mk index 9d322f00..6679457e 100644 --- a/common.mk +++ b/common.mk @@ -157,6 +157,30 @@ run-binary-debug: $(output_dir) $(sim_debug) run-fast: run-asm-tests-fast run-bmark-tests-fast +######################################################################################### +# helper rules to run simulator with fast loadmem via hex files +######################################################################################### +$(binary_hex): $(output_dir) $(BINARY) + hex_bytes=$(shell readelf --segments --wide $(BINARY) | grep LOAD | tail -n 1 | tr -s [:space:] | cut -f4,6 -d' ' | tr -d x | tr [:lower:] [:upper:] | tr ' ' + | sed 's/0000000008/ibase=16;/' | bc);\ + power_2_bytes=`python -c "import math; print int(pow(2,math.ceil(math.log($$hex_bytes)/math.log(2))))"`;\ + elf2hex 64 $$power_2_bytes $(BINARY) $(shell echo "ibase=16;$(LOADMEM_ADDR)" | bc) > $(binary_hex) + +run-binary-hex: $(output_dir) $(sim) $(binary_hex) +run-binary-hex: run-binary +run-binary-hex: override LOADMEM_ADDR = 80000000 +run-binary-hex: override LOADMEM = $(binary_hex) +run-binary-hex: override SIM_FLAGS += +loadmem=$(LOADMEM) +loadmem_addr=$(LOADMEM_ADDR) +run-binary-debug-hex: $(output_dir) $(sim) $(binary_hex) +run-binary-debug-hex: run-binary-debug +run-binary-debug-hex: override LOADMEM_ADDR = 80000000 +run-binary-debug-hex: override LOADMEM = $(binary_hex) +run-binary-debug-hex: override SIM_FLAGS += +loadmem=$(LOADMEM) +loadmem_addr=$(LOADMEM_ADDR) +run-binary-fast-hex: $(output_dir) $(sim) $(binary_hex) +run-binary-fast-hex: run-binary-fast +run-binary-fast-hex: override LOADMEM_ADDR = 80000000 +run-binary-fast-hex: override LOADMEM = $(binary_hex) +run-binary-fast-hex: override SIM_FLAGS += +loadmem=$(LOADMEM) +loadmem_addr=$(LOADMEM_ADDR) + ######################################################################################### # run assembly/benchmarks rules #########################################################################################