project tests refactoring
This commit is contained in:
36
tests/runtime/nlTest/Makefile
Normal file
36
tests/runtime/nlTest/Makefile
Normal file
@@ -0,0 +1,36 @@
|
||||
RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain
|
||||
VORTEX_RT_PATH ?= $(realpath ../../../runtime)
|
||||
|
||||
CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc
|
||||
AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar
|
||||
DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump
|
||||
CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy
|
||||
|
||||
CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wstack-usage=1024 -ffreestanding -nostartfiles -fdata-sections -ffunction-sections
|
||||
CFLAGS += -I$(VORTEX_RT_PATH)/include -I$(VORTEX_RT_PATH)/../hw
|
||||
|
||||
LDFLAGS += -lm -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld -Wl,--gc-sections $(VORTEX_RT_PATH)/libvortexrt.a
|
||||
|
||||
PROJECT = vx_nl_main
|
||||
|
||||
SRCS = vx_nl_main.c
|
||||
|
||||
all: $(PROJECT).elf $(PROJECT).hex $(PROJECT).dump
|
||||
|
||||
$(PROJECT).dump: $(PROJECT).elf
|
||||
$(DP) -D $(PROJECT).elf > $(PROJECT).dump
|
||||
|
||||
$(PROJECT).hex: $(PROJECT).elf
|
||||
$(CP) -O ihex $(PROJECT).elf $(PROJECT).hex
|
||||
|
||||
$(PROJECT).elf: $(SRCS)
|
||||
$(CC) $(CFLAGS) $(SRCS) $(LDFLAGS) -o $(PROJECT).elf
|
||||
|
||||
run: $(PROJECT).hex
|
||||
(cd ../../../hw/simulate/obj_dir && ./VVortex ../../../tests/runtime/nlTest/$(PROJECT).hex)
|
||||
|
||||
.depend: $(SRCS)
|
||||
$(CC) $(CFLAGS) -MM $^ > .depend;
|
||||
|
||||
clean:
|
||||
rm -rf *.elf *.hex *.dump .depend
|
||||
26
tests/runtime/nlTest/vx_nl_main.c
Normal file
26
tests/runtime/nlTest/vx_nl_main.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <vx_print.h>
|
||||
|
||||
const int Num = 9;
|
||||
const float fNum = 9.0f;
|
||||
|
||||
int fibonacci(int n) {
|
||||
if (n <= 1)
|
||||
return n;
|
||||
return fibonacci(n-1) + fibonacci(n-2);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int fib = fibonacci(Num);
|
||||
float isq = 1.0f / sqrt(fNum);
|
||||
vx_printf("fibonacci(%d) = %d\n", Num, fib);
|
||||
vx_printf("invAqrt(%f) = %f\n", fNum, isq);
|
||||
vx_prints("Passed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
107442
tests/runtime/nlTest/vx_nl_main.dump
Normal file
107442
tests/runtime/nlTest/vx_nl_main.dump
Normal file
File diff suppressed because it is too large
Load Diff
BIN
tests/runtime/nlTest/vx_nl_main.elf
Executable file
BIN
tests/runtime/nlTest/vx_nl_main.elf
Executable file
Binary file not shown.
5851
tests/runtime/nlTest/vx_nl_main.hex
Normal file
5851
tests/runtime/nlTest/vx_nl_main.hex
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user