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
27 changes: 26 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,29 @@ build-hw.log
profile-ips.log
magia_venv/
modelsim.ini
# sw/tests/*/

sw/tests/*/build/
sw/tests/*/logs/
sw/tests/*/work/
sw/tests/*/work
sw/tests/*/transcript
sw/tests/*/*.log

sw/tests/*/*/build/
sw/tests/*/*/logs/
sw/tests/*/*/work/
sw/tests/*/*/work
sw/tests/*/*/transcript
sw/tests/*/*/*.log

spatz/bootrom/*.elf
spatz/bootrom/*.bin
spatz/bootrom/*.dump
spatz/bootrom/*.hex

spatz/sw/bin/*.elf
spatz/sw/bin/*.bin
spatz/sw/bin/*.dump
spatz/sw/bin/*.o

spatz/sw/headers_bin/*.h
2 changes: 2 additions & 0 deletions Bender.local
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ overrides:
register_interface : { git: "https://github.com/pulp-platform/register_interface.git", rev: e25b36670ff7aab3402f40efcc2b11ee0f31cf19 }
idma : { git: "https://github.com/pulp-platform/iDMA.git" , rev: c12caf59bb482fe44b27361f6924ad346b2d22fe }
tech_cells_generic : { git: "https://github.com/pulp-platform/tech_cells_generic.git", version: 0.2.13 }
cluster_icache : { git: "https://github.com/pulp-platform/cluster_icache.git" , rev: f88227d287251812b54c77fbfa608aa6dcd92b31 }
axi_riscv_atomics : { git: "https://github.com/pulp-platform/axi_riscv_atomics.git" , version: 0.8.2 }
43 changes: 40 additions & 3 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ package:
dependencies:
redmule : { git: "https://github.com/pulp-platform/redmule.git" , rev: 944d4a4d45fe05147cfbf7f872af677578f3b15c } # branch: fc/ooo-mux
cv32e40x : { git: "https://github.com/pulp-platform/cv32e40x.git" , rev: a90101211048ba1a16cedbe4db963ab6e12569d7 } # branch: vi/redmule_scaleup
cv32e40p : { git: "https://github.com/pulp-platform/cv32e40p.git" , rev: 37a82d337ba60129c333d104c29e816d0698b53b }
idma : { git: "https://github.com/pulp-platform/iDMA.git" , rev: a6b190c7991331432afa9a2899d032bc1b176830 }
cv32e40p : { git: "https://github.com/pulp-platform/cv32e40p.git" , rev: f5241403d5d65dbe1fffacd7035dd7ae1359c8ef } # branch: lb/magia_core
spatz : { git: "https://github.com/pulp-platform/spatz.git" , rev: 9380883fd36a4794d7f31e2c22e3fed3202aeb81 } # branch: lb/magia-spatz_cc
idma : { git: "https://github.com/pulp-platform/iDMA.git" , rev: a6b190c7991331432afa9a2899d032bc1b176830 } # branch: vi/redmule_scaleup
hwpe-stream : { git: "https://github.com/pulp-platform/hwpe-stream.git" , version: 1.6 }
hwpe-ctrl : { git: "https://github.com/pulp-platform/hwpe-ctrl.git" , version: 3.0.0 }
hci : { git: "https://github.com/pulp-platform/hci.git" , version: 2.3.0 }
cluster_icache : { git: "https://github.com/pulp-platform/cluster_icache.git" , rev: 917ecbf908bdaa22c5713bbcff277d142506bb16 } # branch: michaero/astral
cluster_icache : { git: "https://github.com/pulp-platform/cluster_icache.git" , rev: f88227d287251812b54c77fbfa608aa6dcd92b31 } # branch: lb/magia-spatz
fpnew : { git: "https://github.com/pulp-platform/cvfpu.git" , rev: "pulp-v0.1.3" }
fpu_ss : { git: "https://github.com/pulp-platform/fpu_ss.git" , rev: 8e2eff774d9d38a1e17a46bd56a0936dac9522f0 } # branch: vi/bender_manifest
obi : { git: "https://github.com/pulp-platform/obi.git" , rev: 528dc65303d5ffb02fbc254324c6b53eac0dd6e5 } # branch: lb/fix_atop_resolver
Expand Down Expand Up @@ -69,6 +70,14 @@ sources:
- hw/tile/converters/hci2obi.sv
- hw/tile/converters/xif_if2struct.sv
- hw/tile/converters/obi2hwpe_ctrl.sv
- hw/tile/converters/tcdm2hci.sv
- hw/tile/converters/tcdm2obi.sv
- hw/tile/converters/tcdm2hci_atomic.sv
- hw/tile/converters/reqrsp2obi.sv
- hw/tile/converters/tcdm64_to_dual_hci32.sv
- hw/tile/converters/tcdm64_to_dual_tcdm32.sv
- hw/tile/converters/tcdm64_to_dual_hci32_atomic.sv
- hw/tile/converters/reqrsp64_to_obi32.sv
- hw/tile/xbar_periph_bus_if.sv
- hw/tile/cluster_event_map.sv
- hw/tile/magia_event_unit.sv
Expand All @@ -84,7 +93,11 @@ sources:
- hw/tile/idma_ctrl_mm.sv
- hw/tile/fractal_sync_xif_inst_decoder.sv
- hw/tile/obi_slave_fsync.sv
- hw/tile/obi_slave_ctrl_spatz.sv
- hw/tile/spatz_bootrom.sv
- hw/tile/spatz_cc_wrapper.sv
- hw/tile/core_data_demux_eu_direct.sv
- hw/tile/eu_direct_cut.sv
- hw/tile/magia_redmule_wrap.sv
- hw/tile/magia_tile.sv
# MAGIA DV
Expand Down Expand Up @@ -121,6 +134,14 @@ sources:
- hw/tile/converters/hci2obi.sv
- hw/tile/converters/xif_if2struct.sv
- hw/tile/converters/obi2hwpe_ctrl.sv
- hw/tile/converters/tcdm2hci.sv
- hw/tile/converters/tcdm2obi.sv
- hw/tile/converters/tcdm2hci_atomic.sv
- hw/tile/converters/reqrsp2obi.sv
- hw/tile/converters/tcdm64_to_dual_hci32.sv
- hw/tile/converters/tcdm64_to_dual_tcdm32.sv
- hw/tile/converters/tcdm64_to_dual_hci32_atomic.sv
- hw/tile/converters/reqrsp64_to_obi32.sv
- hw/tile/xbar_periph_bus_if.sv
- hw/tile/cluster_event_map.sv
- hw/tile/magia_event_unit.sv
Expand All @@ -136,7 +157,11 @@ sources:
- hw/tile/idma_ctrl_mm.sv
- hw/tile/fractal_sync_xif_inst_decoder.sv
- hw/tile/obi_slave_fsync.sv
- hw/tile/obi_slave_ctrl_spatz.sv
- hw/tile/spatz_bootrom.sv
- hw/tile/spatz_cc_wrapper.sv
- hw/tile/core_data_demux_eu_direct.sv
- hw/tile/eu_direct_cut.sv
- hw/tile/magia_redmule_wrap.sv
- hw/tile/magia_tile.sv
# MAGIA
Expand Down Expand Up @@ -172,6 +197,14 @@ sources:
- hw/tile/converters/hci2obi.sv
- hw/tile/converters/xif_if2struct.sv
- hw/tile/converters/obi2hwpe_ctrl.sv
- hw/tile/converters/tcdm2hci.sv
- hw/tile/converters/tcdm2obi.sv
- hw/tile/converters/tcdm2hci_atomic.sv
- hw/tile/converters/reqrsp2obi.sv
- hw/tile/converters/tcdm64_to_dual_hci32.sv
- hw/tile/converters/tcdm64_to_dual_tcdm32.sv
- hw/tile/converters/tcdm64_to_dual_hci32_atomic.sv
- hw/tile/converters/reqrsp64_to_obi32.sv
- hw/tile/xbar_periph_bus_if.sv
- hw/tile/cluster_event_map.sv
- hw/tile/magia_event_unit.sv
Expand All @@ -187,7 +220,11 @@ sources:
- hw/tile/idma_ctrl_mm.sv
- hw/tile/fractal_sync_xif_inst_decoder.sv
- hw/tile/obi_slave_fsync.sv
- hw/tile/obi_slave_ctrl_spatz.sv
- hw/tile/spatz_bootrom.sv
- hw/tile/spatz_cc_wrapper.sv
- hw/tile/core_data_demux_eu_direct.sv
- hw/tile/eu_direct_cut.sv
- hw/tile/magia_redmule_wrap.sv
- hw/tile/magia_tile.sv
# MAGIA
Expand Down
102 changes: 79 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# Paths to folders
ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
core ?= CV32E40X
core ?= CV32E40P

MAGIA_DIR ?= $(shell pwd)

Expand All @@ -43,7 +43,7 @@ XLEN ?= 32
ifeq ($(core), CV32E40X)
XTEN = imafc
else
XTEN = imfcxpulpv2
XTEN = imcxgap9
endif
ABI ?= ilp
XABI ?= f
Expand All @@ -55,7 +55,9 @@ XABI ?= f
#endif

TEST_DIR := sw/tests
TEST_SRCS = $(TEST_DIR)/$(test).c
# Auto-detect test location in any subdirectory
TEST_SUBDIR = $(filter-out .,$(shell find $(TEST_DIR) -name "$(test).c" -printf "%P\n" 2>/dev/null | head -1 | xargs dirname 2>/dev/null))
TEST_SRCS = $(TEST_DIR)/$(if $(TEST_SUBDIR),$(TEST_SUBDIR)/)$(test).c

compile_script ?= scripts/compile.tcl
compile_script_synth ?= scripts/synth_compile.tcl
Expand Down Expand Up @@ -104,6 +106,7 @@ endif
INC += -Isw
INC += -Isw/inc
INC += -Isw/utils
INC += -Ispatz/sw/headers_bin

BOOTSCRIPT := sw/kernel/crt0.S
LINKSCRIPT := sw/kernel/link.ld
Expand All @@ -114,15 +117,23 @@ OBJDUMP=$(ISA)$(XLEN)-unknown-elf-objdump
CC_OPTS=-march=$(ARCH)$(XLEN)$(XTEN) -mabi=$(ABI)$(XLEN)$(XABI) -D__$(ISA)__ -O2 -g -Wextra -Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wundef -fdata-sections -ffunction-sections -MMD -MP
LD_OPTS=-march=$(ARCH)$(XLEN)$(XTEN) -mabi=$(ABI)$(XLEN)$(XABI) -D__$(ISA)__ -MMD -MP -nostartfiles -nostdlib -Wl,--gc-sections

# Spatz embedded binary support (via header)
SPATZ_SW_DIR := spatz/sw

# Auto-detect which Spatz tasks are used by looking for *_TASK symbols in CV32 code
# Example: HELLO_WORLD_TASK → hello_world_task
SPATZ_TASKS := $(shell grep -oP '\b(?!SPATZ_)[A-Z][A-Z0-9_]*_TASK\b' $(TEST_SRCS) 2>/dev/null | tr '[:upper:]' '[:lower:]' | awk '!seen[$$0]++')

# Setup build object dirs
CRT=$(TEST_DIR)/$(test)/build/crt0.o
OBJ=$(TEST_DIR)/$(test)/build/verif.o
BIN=$(TEST_DIR)/$(test)/build/verif
DUMP=$(TEST_DIR)/$(test)/build/verif.dump
ODUMP=$(TEST_DIR)/$(test)/build/verif.objdump
ITB=$(TEST_DIR)/$(test)/build/verif.itb
STIM_INSTR=$(TEST_DIR)/$(test)/build/stim_instr.txt
STIM_DATA=$(TEST_DIR)/$(test)/build/stim_data.txt
TEST_BUILD_DIR = $(TEST_DIR)/$(if $(TEST_SUBDIR),$(TEST_SUBDIR)/)$(test)
CRT=$(TEST_BUILD_DIR)/build/crt0.o
OBJ=$(TEST_BUILD_DIR)/build/verif.o
BIN=$(TEST_BUILD_DIR)/build/verif
DUMP=$(TEST_BUILD_DIR)/build/verif.dump
ODUMP=$(TEST_BUILD_DIR)/build/verif.objdump
ITB=$(TEST_BUILD_DIR)/build/verif.itb
STIM_INSTR=$(TEST_BUILD_DIR)/build/stim_instr.txt
STIM_DATA=$(TEST_BUILD_DIR)/build/stim_data.txt
VSIM_INI=modelsim.ini
VSIM_LIBS=work

Expand All @@ -131,25 +142,40 @@ $(STIM_INSTR) $(STIM_DATA): $(BIN)
objcopy --srec-len 1 --output-target=srec $(BIN) $(BIN).s19 && \
scripts/parse_s19.pl $(BIN).s19 > $(BIN).txt && \
$(BASE_PYTHON) scripts/s19tomem.py $(BIN).txt $(STIM_INSTR) $(STIM_DATA)
cd $(TEST_DIR)/$(test) && \
cd $(TEST_BUILD_DIR) && \
ln -sfn $(ROOT_DIR)/$(INI_PATH) $(VSIM_INI) && \
ln -sfn $(ROOT_DIR)/$(WORK_PATH) $(VSIM_LIBS)

# Build Spatz binary with auto-detected tasks (only if tasks are used)
# Generate test-specific header: test_name_task_bin.h
.PHONY: spatz-header
spatz-header:
@if [ -n "$(SPATZ_TASKS)" ]; then \
echo "[SPATZ] Auto-detected tasks: $(SPATZ_TASKS)"; \
$(MAKE) -C $(SPATZ_SW_DIR) task="$(SPATZ_TASKS)" TEST_NAME=$(test) SPATZ_RVD=$(SPATZ_RVD) SPATZ_VLEN=$(SPATZ_VLEN) SPATZ_N_IPU=$(SPATZ_N_IPU) SPATZ_N_FPU=$(SPATZ_N_FPU) SPATZ_XDIVSQRT=$(SPATZ_XDIVSQRT) SPATZ_XDMA=$(SPATZ_XDMA) SPATZ_RVF=$(SPATZ_RVF) SPATZ_RVV=$(SPATZ_RVV) all; \
else \
echo "[SPATZ] No Spatz tasks detected - skipping Spatz compilation"; \
fi

$(BIN): $(CRT) $(OBJ)
@if [ -n "$(SPATZ_TASKS)" ]; then \
echo "[CV32-LINK] Linking with embedded Spatz binary (tasks: $(SPATZ_TASKS))"; \
else \
echo "[CV32-LINK] Linking without Spatz binary"; \
fi
$(LD) $(LD_OPTS) -o $(BIN) $(CRT) $(OBJ) -T$(LINKSCRIPT)

$(CRT):
cd $(TEST_DIR) && \
mkdir -p $(test) && \
cd $(test) && \
mkdir -p build
mkdir -p $(TEST_BUILD_DIR)/build
$(CC) $(CC_OPTS) -c $(BOOTSCRIPT) -o $(CRT)

# Compile CV32 test (depends on spatz-header only if tasks detected)
ifneq ($(SPATZ_TASKS),)
$(OBJ): spatz-header
endif

$(OBJ):
cd $(TEST_DIR) && \
mkdir -p $(test) && \
cd $(test) && \
mkdir -p build
mkdir -p $(TEST_BUILD_DIR)/build
$(CC) $(CC_OPTS) -c $(TEST_SRCS) $(FLAGS) $(INC) -o $(OBJ)

SHELL := /bin/bash
Expand All @@ -176,7 +202,7 @@ all: $(STIM_INSTR) $(STIM_DATA) dis objdump itb
# Run the simulation
run: $(CRT)
ifeq ($(gui), 0)
cd $(TEST_DIR)/$(test); \
cd $(TEST_BUILD_DIR); \
$(QUESTA) vsim -c vopt_tb $(questa_run_fast_flag) -l transcript -do "run -a" \
+INST_HEX=$(inst_hex_name) \
+DATA_HEX=$(data_hex_name) \
Expand All @@ -188,7 +214,7 @@ ifeq ($(gui), 0)
) \
+itb_file=$(itb_file)
else
cd $(TEST_DIR)/$(test); \
cd $(TEST_BUILD_DIR); \
$(QUESTA) vsim vopt_tb $(questa_run_flag) -l transcript \
-do "add log -r sim:/$(tb)/*" \
-do "source $(WAVES)" \
Expand Down Expand Up @@ -234,6 +260,7 @@ bender_targs += -t cv32e40p_include_tracer
# Targets needed to avoid error even though the module is not used
bender_targs += -t snitch_cluster
bender_targs += -t idma_test
bender_targs += -t spatz

#ifeq ($(REDMULE_COMPLEX),1)
# tb := redmule_complex_tb
Expand All @@ -258,6 +285,31 @@ else
bender_targs += -t redmule_hwpe
endif

# Define for Spatz target
bender_defs += -D TARGET_SPATZ
SPATZ_RVD ?= 0 # 0: 32-bit TCDM (ELEN=32), 1: 64-bit TCDM (ELEN=64)
SPATZ_VLEN ?= 256 # Vector length in bits (128, 256, 512, ...)
SPATZ_NRVREG ?= 32 # Number of vector registers (RISC-V standard=32)
SPATZ_NR_VRF_BANKS ?= 4 # Number of VRF banks (banking parallelism: 2, 4, 8)
SPATZ_N_IPU ?= 1 # Number of Integer Processing Units (1-8)
SPATZ_N_FPU ?= 4 # Number of Floating Point Units (1-8)
SPATZ_NR_PARALLEL_INSTR ?= 4 # Number of parallel vector instructions (scoreboard depth)
SPATZ_XDIVSQRT ?= 0 # 0: FP div/sqrt disabled, 1: enabled (increases area)
SPATZ_XDMA ?= 0 # 0: DMA disabled, 1: enabled
SPATZ_RVF ?= 1 # 0: single-precision FP disabled, 1: enabled
SPATZ_RVV ?= 1 # 0: vector extension disabled, 1: enabled
bender_defs += -D SPATZ_RVD=$(SPATZ_RVD)
bender_defs += -D SPATZ_VLEN=$(SPATZ_VLEN)
bender_defs += -D SPATZ_NRVREG=$(SPATZ_NRVREG)
bender_defs += -D SPATZ_NR_VRF_BANKS=$(SPATZ_NR_VRF_BANKS)
bender_defs += -D SPATZ_N_IPU=$(SPATZ_N_IPU)
bender_defs += -D SPATZ_N_FPU=$(SPATZ_N_FPU)
bender_defs += -D SPATZ_NR_PARALLEL_INSTR=$(SPATZ_NR_PARALLEL_INSTR)
bender_defs += -D SPATZ_XDIVSQRT=$(SPATZ_XDIVSQRT)
bender_defs += -D SPATZ_XDMA=$(SPATZ_XDMA)
bender_defs += -D SPATZ_RVF=$(SPATZ_RVF)
bender_defs += -D SPATZ_RVV=$(SPATZ_RVV)

update-ips:
$(BENDER) update
$(BENDER) script vsim \
Expand Down Expand Up @@ -308,7 +360,11 @@ clean-sdk:
rm -rf $(SW)/pulp-sdk

clean:
rm -rf $(TEST_DIR)/$(test)
rm -rf $(TEST_BUILD_DIR)
@if [ -d "$(SPATZ_SW_DIR)" ]; then \
echo "[CLEAN] Cleaning Spatz..."; \
$(MAKE) -C $(SPATZ_SW_DIR) clean; \
fi

dis:
$(OBJDUMP) -d -S $(BIN) > $(DUMP)
Expand Down
Loading
Loading