Skip to content
Snippets Groups Projects
Commit b01fc354 authored by Alban Gruin's avatar Alban Gruin
Browse files

Add a Makefile to build tacle-bench for the CVA6 processor

parent fbc195b1
No related branches found
No related tags found
No related merge requests found
bench/build/
# Copyright (c) 2020 Thales.
#
# Copyright and related rights are licensed under the Apache
# License, Version 2.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law
# or agreed to in writing, software, hardware and materials distributed under
# this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#
# Author: Sebastien Jacq - sjthales on github.com
# Kevin Eyssartier - EyssartK on github.com
#
# Additional contributions by:
#
#
# script Name: Software application makefile
# Project Name: CVA6 softcore
# Language: Makefile
#
# Description: Makefile to compile software application for CVA6 platform
#
# =========================================================================== #
# Revisions :
# Date Version Author Description
# 2020-10-06 0.1 S.Jacq Created
# 2020-10-06 0.1 k.Eyssartier Created
# =========================================================================== #
XLEN ?= 32
utils_dir= ./utils
src_dir = ./kernel
bsp_dir = ./bsp
#--------------------------------------------------------------------
# Sources
#--------------------------------------------------------------------
kernels = \
binarysearch \
bitcount \
bitonic \
bsort \
complex_updates \
cosf \
countnegative \
cubic \
deg2rad \
fac \
fft \
filterbank \
fir2dim \
iir \
insertsort \
isqrt \
jfdctint \
lms \
matrix1 \
md5 \
minver \
prime \
rad2deg \
recursion \
st
sequentials = \
adpcm_dec \
adpcm_enc \
cjpeg_transupp \
cjpeg_wrbmp \
dijkstra \
fmref \
g723_enc \
gsm_dec \
h264_dec \
huff_dec \
huff_enc \
ndes \
petrinet \
statemate
bmarks = $(addprefix kernel/,$(kernels)) $(addprefix sequential/,$(sequentials))
#--------------------------------------------------------------------
# Build rules
#--------------------------------------------------------------------
RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_OBJCOPY ?= $(RISCV_PREFIX)objcopy
RISCV_AR ?= $(RISCV_PREFIX)ar
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump
SRC_BSP_C = $(wildcard $(bsp_dir)/hal/*.c) $(wildcard $(bsp_dir)/drivers/uart/*.c)
SRC_BSP_S = $(wildcard $(bsp_dir)/hal/*.S)
OBJ_BSP_C = $(addprefix build/,$(SRC_BSP_C:.c=.o))
OBJ_BSP_S = $(addprefix build/,$(SRC_BSP_S:.S=.o))
OBJ_BSP = $(OBJ_BSP_S) $(OBJ_BSP_C)
BSP_INCS = -Ibsp/config -Ibsp/drivers/uart -Ibsp/hal
INCS = $(BSP_INCS)
FLAGS_STR := "$(RISCV_CFLAGS) $(RISCV_LDFLAGS) "
CFLAGS ?= -DPREALLOCATE=1 -fvisibility=hidden -DSTDIO_THRU_UART -O3 -mcmodel=medany -static -Wall -pedantic
RISCV_CFLAGS := -DPERFORMANCE_RUN=1 \
-DITERATIONS=3 \
-DFLAGS_STR=\"$(FLAGS_STR)\" \
-Wno-unknown-pragmas \
-DPREALLOCATE=1 -fvisibility=hidden -DSTDIO_THRU_UART -O3 -mcmodel=medany -static -Wall -pedantic
RISCV_LDFLAGS = -Lbuild/ -lcva6 -static -nostartfiles -T bsp/config/link.ld
DIR_GUARD = @if [ ! -d $(@D) ]; then echo " MKDIR $(@D)"; \
mkdir -p $(@D); fi
all: $(bmarks)
define generate_rules =
$(1)_SRC_DIR = $(1)/
$(1)_SRC_FILES = $$(shell find $$($(1)_SRC_DIR) -name "*.c")
$(1)_OBJ_FILES = $$(addprefix build/,$$($(1)_SRC_FILES:.c=.o))
ALL_OBJ += $$($(1)_OBJ_FILES)
$(1): build/artifacts/$(1).riscv
$(1): build/artifacts/$(1).D
$(1): build/artifacts/$(1).hex
$(1): build/artifacts/$(1).bin
$(1): build/mem/$(1).mem
build/artifacts/$(1).riscv: build/libcva6.a $$($(1)_OBJ_FILES)
$$(DIR_GUARD)
@echo " LD $$@"
@$$(RISCV_GCC) $$(RISCV_CFLAGS) -o $$@ $$^ $$(RISCV_LDFLAGS)
endef
$(foreach bmark,$(bmarks),$(eval $(call generate_rules,$(bmark))))
build/artifacts/%.D: build/artifacts/%.riscv
$(DIR_GUARD)
@echo " OBJCOPY $< -> $@"
@$(RISCV_OBJDUMP) -D $< > $@
build/artifacts/%.hex: build/artifacts/%.riscv
$(DIR_GUARD)
@echo " OBJCOPY $< -> $@"
@$(RISCV_OBJCOPY) -O ihex $< $@
build/artifacts/%.bin: build/artifacts/%.riscv
$(DIR_GUARD)
@echo " OBJCOPY $< -> $@"
@$(RISCV_OBJCOPY) -O binary $< $@
build/libcva6.a: $(OBJ_BSP)
$(DIR_GUARD)
@echo " AR $< -> $@"
@$(RISCV_AR) rcs build/libcva6.a $(OBJ_BSP)
build/%.o: %.c
$(DIR_GUARD)
@echo " CC $< -> $@"
@$(RISCV_GCC) $(INCS) -o $@ -c $< $(RISCV_CFLAGS)
build/%.o: %.S
$(DIR_GUARD)
@echo " AS $< -> $@"
@$(RISCV_GCC) -o $@ -c $< $(CFLAGS)
build/mem/%.mem: build/artifacts/%.bin
$(DIR_GUARD)
@echo " BIN2MEM $< -> $@"
@$(utils_dir)/bin2mem.py $< $@
clean:
@echo " RM build/"
@rm -rf build/
.PHONY: all clean
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment