11# Copyright (C) 2025 ETH Zurich and University of Bologna
22#
3- # Licensed under the Solderpad Hardware License, Version 0.51
4- # (the "License"); you may not use this file except in compliance
3+ # Licensed under the Solderpad Hardware License, Version 0.51
4+ # (the "License"); you may not use this file except in compliance
55# with the License. You may obtain a copy of the License at
66#
77# http://www.apache.org/licenses/LICENSE-2.0
1515#
1616# Authors: Victor Isachi <victor.isachi@unibo.it>
1717# Alberto Dequino <alberto.dequino@unibo.it>
18- #
18+ #
1919# Magia-sdk Makefile
2020
2121SHELL := /bin/bash
2222
23+ CMAKE_BUILDDIR ?= build
2324BUILD_DIR ?= ../sw/tests/$(test )
2425MAGIA_DIR ?= ../
2526GVSOC_DIR ?= ./gvsoc
2627CURR_DIR ?= $(shell pwd)
2728GVSOC_ABS_PATH ?= $(CURR_DIR ) /gvsoc
28- BIN_ABS_PATH ?= $(CURR_DIR ) /build /bin
29+ BIN_ABS_PATH ?= $(CURR_DIR ) /$( CMAKE_BUILDDIR ) /bin
2930BIN ?= $(BUILD_DIR ) /build/verif
3031build_mode ?= update
3132fsync_mode ?= stall
@@ -51,7 +52,10 @@ tiles_2 := $(shell echo $$(( $(tiles) * $(tiles) )))
5152tiles_log := $(shell awk 'BEGIN { printf "% .0f", log($(tiles_2 ) ) /log(2) }')
5253tiles_log_real := $(shell awk 'BEGIN { printf "% .0f", log($(tiles ) ) /log(2) }')
5354
54- .PHONY : gvsoc
55+ GVRUN ?= $(GVSOC_DIR ) /install/bin/gvrun
56+ GVRUN_ARGS ?= --work-dir $(GVSOC_ABS_PATH ) /Documents/test --attr magia/n_tiles_x=$(tiles ) --attr magia/n_tiles_y=$(tiles )
57+
58+ .PHONY : gvsoc build
5559
5660clean :
5761 rm -rf build/
@@ -79,13 +83,13 @@ ifeq ($(compiler), GCC_MULTILIB)
7983 sed -i -E 's/^# add_subdirectory\(flatatt\)/add_subdirectory\(flatatt\)/' ./tests/magia/mesh/CMakeLists.txt
8084 sed -i -E 's/^\/\/# include "utils\/attention_utils.h"/#include "utils\/attention_utils.h"/' ./targets/$(target_platform)/include/tile.h
8185endif
82- cmake -DTARGET_PLATFORM=$(target_platform) -DEVAL=$(eval) -DSTALLING=$(stalling) -DFSYNC_MM=$(fsync_mm) -DIDMA_MM=$(idma_mm) -DREDMULE_MM=$(redmule_mm) -DCOMPILER=$(compiler) -DPROFILE_CMP=$(profile_cmp) -DPROFILE_CMI=$(profile_cmi) -DPROFILE_CMO=$(profile_cmo) -DPROFILE_SNC=$(profile_snc) -B build --trace-expand
83- cmake --build build --verbose
86+ cmake -DTARGET_PLATFORM=$(target_platform) -DEVAL=$(eval) -DSTALLING=$(stalling) -DFSYNC_MM=$(fsync_mm) -DIDMA_MM=$(idma_mm) -DREDMULE_MM=$(redmule_mm) -DCOMPILER=$(compiler) -DPROFILE_CMP=$(profile_cmp) -DPROFILE_CMI=$(profile_cmi) -DPROFILE_CMO=$(profile_cmo) -DPROFILE_SNC=$(profile_snc) -B $(CMAKE_BUILDDIR) --trace-expand
87+ cmake --build $(CMAKE_BUILDDIR) --verbose
8488
8589set_mesh :
8690ifeq ($(tiles ) , 1)
8791 $(eval mesh_dv=0)
88- endif
92+ endif
8993
9094run : set_mesh
9195 @echo ' Magia is available at https://github.com/pulp-platform/MAGIA.git'
@@ -94,23 +98,23 @@ run: set_mesh
9498ifndef test
9599 $(error Proper formatting is: make run test=<test_name> platform=rtl|gvsoc)
96100endif
97- ifeq (,$(wildcard ./build /bin/$(test ) ) )
101+ ifeq (,$(wildcard $( CMAKE_BUILDDIR ) /bin/$(test ) ) )
98102 $(error No test found with name: $(test))
99103endif
100104ifndef platform
101105 $(error Proper formatting is: make run test=<test_name> platform=rtl|gvsoc)
102106endif
103107ifeq ($(platform ) , gvsoc)
104- $(GVSOC_DIR)/install/bin/gvrun --target magia_v2 --work-dir $(GVSOC_ABS_PATH)/Documents/test -- param binary=$(BIN_ABS_PATH)/$(test) run --attr magia/n_tiles_x=$(tiles) --attr magia/n_tiles_y=$(tiles )
108+ $(GVRUN) --target magia_v2 --param binary=$(BIN_ABS_PATH)/$(test) run $(GVRUN_ARGS )
105109else ifeq ($(platform), rtl)
106110 mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && mkdir -p build
107111 cp ./build/bin/$(test) $(BUILD_DIR)/build/verif
108112 objcopy --srec-len 1 --output-target=srec $(BIN) $(BIN).s19
109113 scripts/parse_s19.pl $(BIN).s19 > $(BIN).txt
110- python3 scripts/s19tomem.py $(BIN).txt $(BUILD_DIR)/build/stim_instr.txt $(BUILD_DIR)/build/stim_data.txt
114+ python3 scripts/s19tomem.py $(BIN).txt $(BUILD_DIR)/build/stim_instr.txt $(BUILD_DIR)/build/stim_data.txt
111115 cd $(BUILD_DIR) && \
112116 cp -sf ../../../sim/modelsim.ini modelsim.ini && \
113- ln -sfn ../../../sim/work work
117+ ln -sfn ../../../sim/work work
114118 riscv32-unknown-elf-objdump -d -S -Mmarch=$(ISA) $(BIN) > $(BIN).dump
115119 riscv32-unknown-elf-objdump -d -l -s -Mmarch=$(ISA) $(BIN) > $(BIN).objdump
116120 python3 scripts/objdump2itb.py $(BIN).objdump > $(BIN).itb
@@ -175,5 +179,3 @@ gvsoc_init:
175179 git checkout lz/magia-v2-core && \
176180 cd ../pulp && \
177181 git checkout lz/magia-v2-pulp
178-
179-
0 commit comments