Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SW] Initial support for compilation in Linux environment #312

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
665b6ae
Rename CSRs in ara dispatcher
MaistoV Jun 19, 2024
193f385
Stall Ara upon operations on vector CSRs
MaistoV Jun 19, 2024
d5e2fb2
Change "errors" to "exceptions"
MaistoV Jun 19, 2024
e4c2466
Extend and fix Ara exception reporting from VLSU
MaistoV Jun 19, 2024
2c9d5ba
Set vstart=0 for succesful vector instructions
MaistoV Jun 19, 2024
26af2ec
[hardware] Fix vstart handling in dispatcher
mp-17 Jun 19, 2024
7bcfcbf
[hardware] :bug: Fix reshuffling bug in dispatcher
mp-17 Dec 19, 2023
7b0191a
[hardware] :bug: Fix eew_q update during reshuffle
mp-17 Mar 10, 2024
7d6da86
[hardware] :bug: Suboptimal fix to reshuffle with LMUL > 1
mp-17 Mar 10, 2024
4733f20
[hardware] :bug: Fix reshuffle
mp-17 Mar 12, 2024
a8426f3
[hardware] :bug: Consider LMUL when deciding if to reshuffle vd
mp-17 Mar 15, 2024
2fed184
[hardware] Bump CVA6
mp-17 Jun 19, 2024
dd0047b
Refactoring addrgen
MaistoV Jun 19, 2024
b6363d2
Extensions and bug fixes
MaistoV Jun 19, 2024
fc8dd42
Update submodules
MaistoV Sep 13, 2023
310c4da
Supporting vstart CSR for operand read, VALU, VLSU
MaistoV Oct 18, 2023
9dd870f
tmp commit Adding MMU logic
MaistoV Oct 18, 2023
d0a026a
tmp commit (MMU stub)
MaistoV Oct 26, 2023
37faafa
tmp commit (Extending Ara for MMU stub exceptions
MaistoV Dec 4, 2023
a3d46d2
[hardware] :bug: Fix end addr computation in addrgen
mp-17 Mar 17, 2024
09b927f
[hardware] Support VLD and VST with vstart > 0
mp-17 Dec 11, 2023
a9411ea
[hardware] :bug: Flush st-opqueue and reset st-requester upon exception
mp-17 Dec 7, 2023
929bcac
[hardware] :bug: Reshuffle before a vst with vstart > 0
mp-17 Jun 24, 2024
22031a1
[hardware] :bug: Fix packet count hw
mp-17 Jun 24, 2024
62f6d5a
[hardware] :bug: Fix case when ld exception is not on the first beat
mp-17 Mar 6, 2024
0532ffb
[hardware] :bug: Fix case when st exception is not on the first beat
mp-17 Mar 6, 2024
9be56e9
[hardware] :bug: Stop Ara frontend until idle after an exception
mp-17 Mar 6, 2024
f12be75
[hardware] :bug: Signal mem op done passing from VLDU and VSTU
mp-17 Mar 9, 2024
699a2c9
[hardware] :bug: Don't use vstart to drop elements for slides
mp-17 Mar 6, 2024
097049f
[hardware] :bug: Fix addr check on AXI transactions
mp-17 Mar 6, 2024
404ce2f
[hardware] Fix verilator lint
mp-17 Jun 24, 2024
9067762
[hardware] Compress accelerator MMU interface
mp-17 Jun 24, 2024
11be9ed
[hardware] Fix rebase errors
mp-17 Jun 18, 2024
e385500
[Bender] Bump CVA6
mp-17 Feb 16, 2024
0a994f9
[apps] Extended sw build for Linux
MaistoV Sep 12, 2023
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
4 changes: 2 additions & 2 deletions Bender.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ packages:
Git: https://github.com/pulp-platform/common_verification.git
dependencies: []
cva6:
revision: ee89dcc00e6c1a1f4cf97ee1835e950fcfdeebb5
revision: e0dbbbf1a82377ae6db19d2e1ac87bddfdf5052a
version: null
source:
Git: https://github.com/pulp-platform/cva6.git
Git: https://github.com/mp-17/cva6.git
dependencies:
- axi
- common_cells
Expand Down
3 changes: 1 addition & 2 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package:
dependencies:
axi: { git: "https://github.com/pulp-platform/axi.git", version: 0.39.1 }
common_cells: { git: "https://github.com/pulp-platform/common_cells.git", version: 1.22.1 }
cva6: { git: "https://github.com/pulp-platform/cva6.git", rev: ee89dcc00e6c1a1f4cf97ee1835e950fcfdeebb5 } # pulp-v1
cva6: { git: "https://github.com/mp-17/cva6.git", rev: e0dbbbf1a82377ae6db19d2e1ac87bddfdf5052a } # rebase/pulp-v1-os
tech_cells_generic: { git: "https://github.com/pulp-platform/tech_cells_generic.git", version: 0.2.13 }
apb: { git: "https://github.com/pulp-platform/apb.git", version: 0.2.4 }

Expand All @@ -28,7 +28,6 @@ sources:

# Sources
# Level 1
- hardware/src/axi_to_mem.sv
- hardware/src/ctrl_registers.sv
- hardware/src/cva6_accel_first_pass_decoder.sv
- hardware/src/ara_dispatcher.sv
Expand Down
2 changes: 2 additions & 0 deletions apps/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
bin
common/link.ld
*.o*
data.S*
29 changes: 20 additions & 9 deletions apps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ APPS_DIR := $(ROOT_DIR)
COMMON_DIR := $(ROOT_DIR)/common
TESTS_DIR := $(ROOT_DIR)/riscv-tests/isa

# Build environment for Linux
LINUX ?= 0
ifeq ($(LINUX), 1)
include $(COMMON_DIR)/linux.mk
endif

# This will overwrite the ROOT_DIR variable from the included makefile
include $(COMMON_DIR)/runtime.mk
include $(COMMON_DIR)/riscv_tests.mk
Expand All @@ -33,9 +39,9 @@ BINARIES := $(filter-out bin/benchmarks, $(addprefix bin/,$(APPS)))
CVA6_EXTENSIONS := rv64ui rv64uc rv64um rv64uf rv64ud rv64si
# Atomics are messy, since there is currently no memory region capable of handling them
# CVA6_EXTENSIONS := rv64ua
CVA6_BINARIES := $(addprefix bin/, $(cva6_tests))
CVA6_BINARIES := $(addsuffix $(IS_LINUX_EXTENSION), $(addprefix bin/, $(cva6_tests)))
ARA_EXTENSIONS := rv64uv
ARA_BINARIES := $(addprefix bin/, $(ara_tests))
ARA_BINARIES := $(addsuffix $(IS_LINUX_EXTENSION), $(addprefix bin/, $(ara_tests)))

# FFT requires special treatment because of its header files
ifeq ($(ENV_DEFINES),)
Expand Down Expand Up @@ -98,14 +104,18 @@ endef
$(foreach app,$(APPS),$(eval $(call app_compile_template_spike,$(app))))

define app_compile_template
bin/$1: $1/data.S.o $(addsuffix .o, $(shell find $(1) -name "*.c" -o -name "*.S")) $(RUNTIME_LLVM) linker_script
bin/$1: $1/data.S.o$$(IS_LINUX_EXTENSION) $(addsuffix .o$$(IS_LINUX_EXTENSION), $(shell find $(1) -name "*.c" -o -name "*.S")) $(RUNTIME_LLVM) linker_script
mkdir -p bin/
$$(RISCV_CC) -Iinclude $(RISCV_CCFLAGS) -o $$@ $$(addsuffix .o, $$(shell find $(1) -name "*.c" -o -name "*.S")) $(RUNTIME_LLVM) $$(RISCV_LDFLAGS) -T$$(CURDIR)/common/link.ld
$$(RISCV_OBJDUMP) $$(RISCV_OBJDUMP_FLAGS) -D $$@ > $$@.dump
$$(RISCV_STRIP) $$@ -S --strip-unneeded
$$(RISCV_CC) $(RISCV_CCFLAGS) -o $$@$$(IS_LINUX_EXTENSION) $$(addsuffix .o$$(IS_LINUX_EXTENSION), $$(shell find $(1) -name "*.c" -o -name "*.S")) $(RUNTIME_LLVM) $$(RISCV_LDFLAGS) $$(LD_FLAGS)
$$(RISCV_OBJDUMP) $$(RISCV_OBJDUMP_FLAGS) -D $$@$$(IS_LINUX_EXTENSION) > $$@$$(IS_LINUX_EXTENSION).dump
# Don't strip symbols for Linux build since need them for debug
if [ "$$(IS_LINUX_EXTENSION)" == "" ]; then \
$$(RISCV_STRIP) $$@$$(IS_LINUX_EXTENSION) -S --strip-unneeded; \
fi
endef
$(foreach app,$(APPS),$(eval $(call app_compile_template,$(app))))


# Make the RISC-V tests
riscv_tests: $(CVA6_BINARIES) $(ARA_BINARIES)

Expand All @@ -114,7 +124,7 @@ TESTS_$(1) := $(addprefix bin/, $($(addsuffix _ara_tests, $1)))

bin/$(1)-ara-%: $(TESTS_DIR)/$(1)/%.$(2) $(RUNTIME_GCC) linker_script
mkdir -p bin/
$$(RISCV_CC_GCC) -Iinclude -I$$(TESTS_DIR)/macros/scalar -I$$(TESTS_DIR)/macros/vector $$(RISCV_CCFLAGS_GCC) $$(RISCV_LDFLAGS_GCC) -o $$@ $$< $(RUNTIME_GCC) -T$$(CURDIR)/common/link.ld
$$(RISCV_CC_GCC) -Iinclude -I$$(TESTS_DIR)/macros/scalar -I$$(TESTS_DIR)/macros/vector $$(RISCV_CCFLAGS_GCC) $$(RISCV_LDFLAGS_GCC) -o $$@ $$< $(RUNTIME_GCC) $$(LD_FLAGS)
$$(RISCV_OBJDUMP) $$(RISCV_OBJDUMP_FLAGS) -D $$@ > $$@.dump
$$(RISCV_STRIP) $$@ -S --strip-unneeded
endef
Expand All @@ -124,7 +134,7 @@ TESTS_$(1) := $(addprefix bin/, $($(addsuffix _ara_tests, $1)))

bin/$(1)-ara-%: $(TESTS_DIR)/$(1)/%.$(2) $(RUNTIME_LLVM) linker_script
mkdir -p bin/
$$(RISCV_CC) -Iinclude -I$$(TESTS_DIR)/macros/scalar -I$$(TESTS_DIR)/macros/vector $$(RISCV_CCFLAGS) $$(RISCV_LDFLAGS) -o $$@ $$< $(RUNTIME_LLVM) -T$$(CURDIR)/common/link.ld
$$(RISCV_CC) -Iinclude -I$$(TESTS_DIR)/macros/scalar -I$$(TESTS_DIR)/macros/vector $$(RISCV_CCFLAGS) $$(RISCV_LDFLAGS) -o $$@ $$< $(RUNTIME_LLVM) $$(LD_FLAGS)
$$(RISCV_OBJDUMP) $$(RISCV_OBJDUMP_FLAGS) -D $$@ > $$@.dump
$$(RISCV_STRIP) $$@ -S --strip-unneeded
endef
Expand Down Expand Up @@ -172,13 +182,14 @@ benchmarks_clean:

.PHONY: clean
clean: riscv_tests_spike_clean benchmarks_clean
rm -vf bin/*
rm -vf $(BINARIES)
rm -vf $(CVA6_BINARIES)
rm -vf $(ARA_BINARIES)
rm -vf $(addsuffix .dump,$(BINARIES))
rm -vf $(addsuffix .dump,$(CVA6_BINARIES))
rm -vf $(addsuffix .dump,$(ARA_BINARIES))
rm -vf $(addsuffix /main.c.o,$(APPS))
rm -vf $(addsuffix /main.c.o$(IS_LINUX_EXTENSION),$(APPS))
rm -vf $(RUNTIME_GCC)
rm -vf $(RUNTIME_LLVM)
rm -vf $(RUNTIME_SPIKE)
Expand Down
47 changes: 47 additions & 0 deletions apps/common/linux.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
IS_LINUX_EXTENSION := .linux

CVA6_SDK ?= /usr/scratch/fenga3/vmaisto/cva6-sdk_fork_backup
ROOTFS_DEST ?= $(CVA6_SDK)/rootfs/ara/apps/bin
cp_to_rootfs:
mkdir -p $(ROOTFS_DEST)
@echo "[Copying binaries to rootfs directory $(ROOTFS_DEST)]"
cp -v bin/*.linux $(ROOTFS_DEST)

# Set the runtime variables to empty, the Linux libs will takcare of that
LD_FLAGS :=
RUNTIME_GCC ?= common/util-gcc.c.o
RUNTIME_LLVM ?= common/util-llvm.c.o


# Override
INSTALL_DIR ?= $(ARA_DIR)/install
GCC_INSTALL_DIR ?= $(CVA6_SDK)/buildroot/output/host/
LLVM_INSTALL_DIR ?= $(INSTALL_DIR)/riscv-llvm

RISCV_XLEN ?= 64
RISCV_ARCH ?= rv$(RISCV_XLEN)gcv
RISCV_ABI ?= lp64d
RISCV_TARGET ?= riscv$(RISCV_XLEN)-buildroot-linux-gnu-

# Don't use LLVM
RISCV_PREFIX ?= $(GCC_INSTALL_DIR)/bin/$(RISCV_TARGET)
RISCV_CC ?= $(RISCV_PREFIX)gcc
RISCV_CXX ?= $(RISCV_PREFIX)g++
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump
RISCV_OBJCOPY ?= $(RISCV_PREFIX)objcopy
RISCV_AS ?= $(RISCV_PREFIX)as
RISCV_AR ?= $(RISCV_PREFIX)ar
RISCV_LD ?= $(RISCV_PREFIX)ld
RISCV_STRIP ?= $(RISCV_PREFIX)strip

# Override flags
# LLVM_FLAGS ?= -march=rv64gcv_zfh_zvfh0p1 -mabi=$(RISCV_ABI) -mno-relax -fuse-ld=lld
LLVM_FLAGS ?= -march=rv64gcv -mabi=$(RISCV_ABI)
LLVM_V_FLAGS ?= #+no-optimized-zero-stride-load
# RISCV_FLAGS ?= $(LLVM_FLAGS) $(LLVM_V_FLAGS) -mcmodel=medany -I$(CURDIR)/common -std=gnu99 -O3 -ffast-math -fno-common -fno-builtin-printf $(DEFINES) $(RISCV_WARNINGS)
RISCV_FLAGS ?= -g $(LLVM_FLAGS) $(LLVM_V_FLAGS) -I$(CURDIR)/common -std=gnu99 -O0 $(DEFINES) $(RISCV_WARNINGS)
RISCV_CCFLAGS ?= $(RISCV_FLAGS) #-ffunction-sections -fdata-sections
RISCV_CXXFLAGS ?= $(RISCV_FLAGS) -ffunction-sections -fdata-sections
RISCV_LDFLAGS ?= #-static -nostartfiles -lm -Wl,--gc-sections

RISCV_OBJDUMP_FLAGS ?= -S
5 changes: 5 additions & 0 deletions apps/common/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
//
///////////////////////////////////////////////////////////////////////////////

#ifdef __linux__
#include <stdio.h>
#else // ! __linux__

#ifndef _PRINTF_H_
#define _PRINTF_H_

Expand Down Expand Up @@ -100,4 +104,5 @@ int fctprintf(void (*out)(char character, void *arg), void *arg,
}
#endif

#endif // __linux__
#endif // _PRINTF_H_
22 changes: 14 additions & 8 deletions apps/common/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
asm volatile( \
"csrs mstatus, %[bits];" ::[bits] "r"(0x00000600 & (0x00000600 >> 1)))

// SoC-level CSR, put in memory for Linux build
#ifdef __linux__
int64_t event_trigger;
int64_t timer;
uint64_t hw_cnt_en_reg;
#else // ! __linux__
extern int64_t event_trigger;
extern int64_t timer;
// SoC-level CSR
extern uint64_t hw_cnt_en_reg;
#endif // __linux__

// Return the current value of the cycle counter
inline int64_t get_cycle_count() {
int64_t get_cycle_count() {
int64_t cycle_count;
// The fence is needed to be sure that Ara is idle, and it is not performing
// the last vector stores when we read mcycle with stop_timer()
Expand All @@ -31,26 +37,26 @@ inline int64_t get_cycle_count() {
#define HW_CNT_READY hw_cnt_en_reg = 1;
#define HW_CNT_NOT_READY hw_cnt_en_reg = 0;
// Start and stop the counter
inline void start_timer() { timer = -get_cycle_count(); }
inline void stop_timer() { timer += get_cycle_count(); }
void start_timer() { timer = -get_cycle_count(); }
void stop_timer() { timer += get_cycle_count(); }

// Get the value of the timer
inline int64_t get_timer() { return timer; }
int64_t get_timer() { return timer; }
#else
#define HW_CNT_READY ;
#define HW_CNT_NOT_READY ;
// Start and stop the counter
inline void start_timer() {
void start_timer() {
while (0)
;
}
inline void stop_timer() {
void stop_timer() {
while (0)
;
}

// Get the value of the timer
inline int64_t get_timer() { return 0; }
int64_t get_timer() { return 0; }
#endif

#endif // _RUNTIME_H_
12 changes: 8 additions & 4 deletions apps/common/runtime.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ISA_SIM_MOD_INSTALL_DIR ?= $(INSTALL_DIR)/riscv-isa-sim-mod
RISCV_XLEN ?= 64
RISCV_ARCH ?= rv$(RISCV_XLEN)gcv
RISCV_ABI ?= lp64d
RISCV_TARGET ?= riscv$(RISCV_XLEN)-unknown-elf
RISCV_TARGET ?= riscv$(RISCV_XLEN)-unknown-elf-

# Use LLVM
RISCV_PREFIX ?= $(LLVM_INSTALL_DIR)/bin/
Expand All @@ -56,7 +56,9 @@ RISCV_LD ?= $(RISCV_PREFIX)ld.lld
RISCV_STRIP ?= $(RISCV_PREFIX)llvm-strip

# Use gcc to compile scalar riscv-tests
RISCV_CC_GCC ?= $(GCC_INSTALL_DIR)/bin/$(RISCV_TARGET)-gcc
RISCV_CC_GCC ?= $(GCC_INSTALL_DIR)/bin/$(RISCV_TARGET)gcc
RISCV_OBJCOPY_GCC ?= $(GCC_INSTALL_DIR)/bin/$(RISCV_TARGET)objcopy
RISCV_OBJDUMP_GCC ?= $(GCC_INSTALL_DIR)/bin/$(RISCV_TARGET)objdump

# Benchmark with spike
spike_env_dir ?= $(ARA_DIR)/apps/riscv-tests
Expand Down Expand Up @@ -111,6 +113,8 @@ RUNTIME_GCC ?= common/crt0-gcc.S.o common/printf-gcc.c.o common/string-gcc.c.o
RUNTIME_LLVM ?= common/crt0-llvm.S.o common/printf-llvm.c.o common/string-llvm.c.o common/serial-llvm.c.o common/util-llvm.c.o
RUNTIME_SPIKE ?= $(spike_env_dir)/benchmarks/common/crt.S.o.spike $(spike_env_dir)/benchmarks/common/syscalls.c.o.spike common/util.c.o.spike

LD_FLAGS ?= -T$(CURDIR)/common/link.ld

.INTERMEDIATE: $(RUNTIME_GCC) $(RUNTIME_LLVM)

%-gcc.S.o: %.S
Expand All @@ -125,10 +129,10 @@ RUNTIME_SPIKE ?= $(spike_env_dir)/benchmarks/common/crt.S.o.spike $(spike_env_di
%-llvm.c.o: %.c
$(RISCV_CC) $(RISCV_CCFLAGS) -c $< -o $@

%.S.o: %.S
%.S.o$(IS_LINUX_EXTENSION): %.S
$(RISCV_CC) $(RISCV_CCFLAGS) -c $< -o $@

%.c.o: %.c
%.c.o$(IS_LINUX_EXTENSION): %.c
$(RISCV_CC) $(RISCV_CCFLAGS) -c $< -o $@

%.S.o.spike: %.S patch-spike-crt0
Expand Down
2 changes: 0 additions & 2 deletions apps/dropout/kernel/dropout.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
// Use asm, by default
#undef INTRINSICS

#include "runtime.h"

#ifndef SPIKE
#include "printf.h"
#endif
Expand Down
11 changes: 11 additions & 0 deletions apps/dropout/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@

#include "kernel/dropout.h"

#include <stdint.h>
#include <string.h>

#include "runtime.h"

#ifndef SPIKE
#include "printf.h"
#else
#include <stdio.h>
#endif

extern const unsigned int N;
extern const float SCALE;
extern const float I[] __attribute__((aligned(4 * NR_LANES)));
Expand Down
1 change: 0 additions & 1 deletion apps/gemv/kernel/gemv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// Author: Chi Zhang, ETH Zurich <chizhang@iis.ee.ethz.ch>

#include "gemv.h"
#include "runtime.h"
#include "util.h"
#include <math.h>
#include <stdbool.h>
Expand Down
4 changes: 1 addition & 3 deletions apps/jacobi2d/kernel/jacobi2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ WITH ACCESS OR USE OF THE SOFTWARE.

#define _JACOBI2D_H_

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <riscv_vector.h>

#include "runtime.h"
#include "util.h"

// The vector algorithm seems not to be parametrized on the data type
// So, don't change this parameter if also the vector implementation is used
#define DATA_TYPE double
Expand Down
12 changes: 6 additions & 6 deletions apps/riscv-tests/benchmarks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ bmarks = \
# Build rules
#--------------------------------------------------------------------

RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_PREFIX ?= /usr/scratch/fenga3/vmaisto/cva6-sdk_fork/buildroot/output/host/bin/riscv64-buildroot-linux-gnu-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lm -lgcc -T $(src_dir)/common/test.ld
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -std=gnu99 -O2 -ffast-math -fPIC
RISCV_LINK ?= $(RISCV_GCC) $(incs)
RISCV_LINK_OPTS ?=
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes -S
RISCV_SIM ?= spike --isa=rv$(XLEN)gc

incs += -I$(src_dir)/../env -I$(src_dir)/common $(addprefix -I$(src_dir)/, $(bmarks))
objs :=

define compile_template
$(1).riscv: $(wildcard $(src_dir)/$(1)/*) $(wildcard $(src_dir)/common/*)
$$(RISCV_GCC) $$(incs) $$(RISCV_GCC_OPTS) -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/common/*.c) $(wildcard $(src_dir)/common/*.S) $$(RISCV_LINK_OPTS)
$$(RISCV_GCC) $$(incs) $$(RISCV_GCC_OPTS) -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/common/*.c) $$(RISCV_LINK_OPTS)
endef

$(foreach bmark,$(bmarks),$(eval $(call compile_template,$(bmark))))
Expand Down
Loading
Loading