diff --git a/Makefile b/Makefile index 961c2234d..108fa3ffb 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ install: cp ${RISCV}/riscv-isa-sim/arch_test_target/spike/Makefile.include addins/riscv-arch-test/ sed -i '/export TARGETDIR ?=/c\export TARGETDIR ?= ${RISCV}/riscv-isa-sim/arch_test_target' addins/riscv-arch-test/Makefile.include echo export RISCV_PREFIX = riscv64-unknown-elf- >> addins/riscv-arch-test/Makefile.include - tests/linux-testgen/linux-testvectors/tvLinker.sh + # tests/linux-testgen/linux-testvectors/tvLinker.sh # needs to be run in local directory regression: make -C pipelined/regression diff --git a/examples/C/fir/Makefile b/examples/C/fir/Makefile new file mode 100644 index 000000000..b1f4738cc --- /dev/null +++ b/examples/C/fir/Makefile @@ -0,0 +1,33 @@ +TARGET = fir + +$(TARGET).objdump: $(TARGET) + riscv64-unknown-elf-objdump -S -D $(TARGET) > $(TARGET).objdump + spike $(TARGET) + +$(TARGET): $(TARGET).c Makefile + riscv64-unknown-elf-gcc -o $(TARGET) -g -O\ + -march=rv64gc -mabi=lp64d -mcmodel=medany \ + -nostdlib -static -lm -fno-tree-loop-distribute-patterns \ + -T../common/test.ld -I../common \ + $(TARGET).c ../common/crt.S ../common/syscalls.c +# Compiler flags: +# -o $(TARGET) defines the name of the output file +# -g generates debugging symbols for gdb +# -O turns on basic optimization; -O3 turns on heavy optimization; omit for no optimization +# -march=rv64gc -mabi=lp64d =mcmodel=medany generates code for RV64GC with doubles and long/ptrs = 64 bits +# -static forces static linking (no dynamic shared libraries on bare metal) +# -lm links the math library if necessary (when #include math.h) +# -nostdlib avoids inserting standard startup files and default libraries +# because we are using crt.s on bare metal +# -fno-tree-loop-distribute-patterns turns replacing loops with memcpy/memset in the std library +# -T specifies the linker file +# -I specifies the include path (e.g. for util.h) +# The last line defines the C files to compile. +# crt.S is needed as our startup file to initialize the processor +# syscalls.c implements printf through the HTIF for Spike +# other flags from riscv-tests makefiles that don't seem to be important +# -ffast-math -DPREALLOCATE=1 -std=gnu99 \ +# -fno-common -fno-builtin-printf -nostartfiles -lgcc \ + +clean: + rm -f $(TARGET) $(TARGET).objdump diff --git a/examples/C/fir/fir b/examples/C/fir/fir new file mode 100755 index 000000000..f395b2e7e Binary files /dev/null and b/examples/C/fir/fir differ diff --git a/examples/C/fir/fir.c b/examples/C/fir/fir.c new file mode 100644 index 000000000..a3d730ffb --- /dev/null +++ b/examples/C/fir/fir.c @@ -0,0 +1,43 @@ +// fir.c +// David_Harris@hmc.edu 20 January 2022 +// Finite Impulse Response Filter + +#include // supports printf +#include +#include "util.h" // supports verify + +void fir(int N, int M, double X[], double c[], double Y[]) { + int i, n; + double sum; + + for (n=0; n 1e-10) { + //printf("bad case %d\n", i); + return 1; + } + } + return 0; +} \ No newline at end of file