Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SUITE ?= embench
BENCHMARK ?= crc32
LINKER ?= $(realpath sw/linker/len5-sim.ld)
COPT ?= -O2
SOFTWARE_DIR ?= $(BUILD_DIR)

# RTL simulation
FIRMWARE ?= $(BUILD_DIR)/main.hex
Expand All @@ -35,6 +36,12 @@ EMBENCH_DIR := sw/benchmarks/embench/src/
EMBENCH_TESTS := $(shell find $(EMBENCH_DIR) -type d -exec basename {} \;)
EMBENCH_TESTS := $(filter-out src, $(EMBENCH_TESTS))
BENCHMARK_DIR_NAME=$(basename $BENCHMARK_DIR_PATH)
#run benchmarks parallel
PARALLEL_DIR := sw/benchmarks/${SUITE}/src/
SKIP_TESTS := src minver sglib-combined
PARALLEL_TESTS ?= $(shell find $(PARALLEL_DIR) -type d -exec basename {} \;)
PARALLEL_TESTS := $(filter-out $(SKIP_TESTS), $(PARALLEL_TESTS))
PARALLEL_JOBS := $(addprefix job_, ${PARALLEL_TESTS})
# ---------
# RTL simulation files
SIM_CORE_FILES := $(shell find . -type f -name "*.core")
Expand All @@ -45,6 +52,7 @@ SIM_CPP_FILES := $(shell find tb/verilator -type f -name "*.cpp" -o -name "*.hh"
#######################
# ----- TARGETS ----- #
#######################

# HDL source
# ----------
# Format code
Expand Down Expand Up @@ -81,7 +89,7 @@ verilator-sim: $(BUILD_DIR)/.verilator.lock $(BUILD_DIR)/main.hex | .check-fuses
$(FUSESOC_ARGS)

.PHONY: verilator-opt
verilator-opt: $(BUILD_DIR)/.verilator.lock $(BUILD_DIR)/main.hex | .check-fusesoc
verilator-opt: $(BUILD_DIR)/.verilator.lock $(SOFTWARE_DIR)/main.hex | .check-fusesoc
fusesoc run --no-export --target sim --tool verilator --run $(FUSESOC_FLAGS) polito:len5:len5 \
--log_level=$(LOG_LEVEL) \
--firmware=$(FIRMWARE) \
Expand Down Expand Up @@ -109,7 +117,30 @@ verilator-waves: $(BUILD_DIR)/sim-common/waves.fst | .check-gtkwave
questasim-sim: | app .check-fusesoc $(BUILD_DIR)/
@echo "## Running simulation with QuestaSim..."
fusesoc run --no-export --target sim --tool modelsim $(FUSESOC_FLAGS) --build polito:len5:len5 2>&1 | tee build/build.log


# Benchmarking targets
# --------------------
.PHONY: run-benchmarks
run-benchmarks: $(BUILD_DIR)/.verilator.lock $(BUILD_DIR)/$(SUITE)/logs/compiler/ $(BUILD_DIR)/$(SUITE)/logs/sim/ $(PARALLEL_JOBS)
@echo "$@ done."

$(PARALLEL_JOBS): job_%: $(BUILD_DIR)/.verilator.lock $(BUILD_DIR)/$(SUITE)/logs/compiler/ $(BUILD_DIR)/$(SUITE)/logs/sim/
@$(MAKE) run SOFTWARE_DIR=$(BUILD_DIR)/$(SUITE)/run/$*/ MAX_CYCLES=$(MAX_CYCLES) BENCHMARK=$*

.PHONY: run
run: $(BUILD_DIR)/$(SUITE)/run/$(BENCHMARK)/main.hex
@echo "## Starting the simulation of $(SUITE) benchmark $(BENCHMARK)"
@$(MAKE) verilator-opt FIRMWARE=$< MAX_CYCLES=$(MAX_CYCLES) > $(BUILD_DIR)/$(SUITE)/logs/sim/$(BENCHMARK).log 2>&1
@echo "## End of the simulation of $(SUITE) benchmark $(BENCHMARK)"

$(BUILD_DIR)/$(SUITE)/run/$(BENCHMARK)/main.hex:
@echo "## Building suite $(SUITE) benchmark $(BENCHMARK)"
@$(MAKE) -BC sw benchmark SUITE=$(SUITE) BUILD_DIR=$(SOFTWARE_DIR) BENCHMARK=$(BENCHMARK) > $(BUILD_DIR)/$(SUITE)/logs/compiler/$(BENCHMARK).log 2>&1

.PHONY: benchmark-stats
benchmark-stats: $(BUILD_DIR)/$(SUITE)/logs/compiler/ $(BUILD_DIR)/$(SUITE)/logs/sim/
@echo "## Getting the results from benchmarks"
@python3 scripts/parse_benchmarks.py -s $(SUITE) -p $(BUILD_DIR)/$(SUITE)
# Software
# --------
# Application from 'sw/applications'
Expand All @@ -135,12 +166,6 @@ benchmark-spike: | $(BUILD_DIR)/spike/
@echo "## Building suite $(SUITE) benchmark $(BENCHMARK)"
$(MAKE) -BC sw benchmark SUITE=$(SUITE) BUILD_DIR=$(BUILD_DIR)/spike BENCHMARK=$(BENCHMARK) CDEFS=-DSPIKE_CHECK

.PHONY: run-benchmarks
run-benchmarks:
@echo "## Running suite $(SUITE)"
python3 scripts/benchmarks.py -s $(SUITE) -O=2 -P=1000
rm -rf build_*

# Simple test application
.PHONY: app-helloworld
app-helloworld:
Expand Down Expand Up @@ -244,7 +269,11 @@ charts: w/benchmarks/embench/output/benchmarks.csv scripts/xheep_resultsO2.csv

# Clean-up
.PHONY: clean
clean: clean-app clean-sim
clean: clean-app clean-sim clean-run

.PHONY: clean-run
clean-run:
@rm -rf $(BUILD_DIR)/$(SUITE)

.PHONY: clean-sim
clean-sim:
Expand Down
Loading