diff --git a/test/helloworld/Makefile b/test/helloworld/Makefile index 0570a84..0f25774 100644 --- a/test/helloworld/Makefile +++ b/test/helloworld/Makefile @@ -1,5 +1,7 @@ export RV_ROOT = ${PWD}/../.. -RV_DESIGN = ${RV_ROOT}/design +LLVMINSTALL = /home/colin/develop/llvm-build/install +GCC_PREFIX = /opt/riscv/bin/riscv64-unknown-elf + TEST_CFLAGS = -g -O3 -funroll-all-loops ABI = -mabi=ilp32 -march=rv32imc @@ -9,10 +11,10 @@ target = default # Allow tool override VERILATOR = verilator -GCC_PREFIX = /opt/riscv/bin/riscv64-unknown-elf TESTDIR = ${PWD} BUILD_DIR = ${TESTDIR}/build SWERV_CONFIG = ${TESTDIR}/swerv.config +RV_DESIGN = ${RV_ROOT}/design TEST = hello_world @@ -81,10 +83,13 @@ program.hex: $(OFILES) $(LINK) $(GCC_PREFIX)-cpp -I${BUILD_DIR} $< > $(BUILD_DIR)/$*.cpp.s $(GCC_PREFIX)-as $(ABI) $(BUILD_DIR)/$*.cpp.s -o $(BUILD_DIR)/$@ +##################### llvm hex Build ##################################### + %.o : %.c ${BUILD_DIR}/defines.h - $(GCC_PREFIX)-gcc -I${BUILD_DIR} ${TEST_CFLAGS} ${ABI} -nostdlib -c $< -o $(BUILD_DIR)/$@ + $(LLVMINSTALL)/bin/clang --target=riscv32 -march=rv32gc $*.c -c -o $(BUILD_DIR)/$*.o -mno-relax + $(LLVMINSTALL)/bin/ld.lld $(BUILD_DIR)/$*.o -o $(BUILD_DIR)/$* help: @echo Possible targets: verilator help clean all verilator-build program.hex -.PHONY: help clean verilator +.PHONY: help clean verilator \ No newline at end of file diff --git a/test/helloworld/hello_world.c b/test/helloworld/hello_world.c new file mode 100644 index 0000000..2fb661b --- /dev/null +++ b/test/helloworld/hello_world.c @@ -0,0 +1,11 @@ +// #include + +int add (int a,int b){ + return a+b; +} + +int main(){ + //printf("Hello RISCV!\n"); + int a = add(1,23); + return a; +} diff --git a/test/helloworld/hello_world.s b/test/helloworld/hello_world.s index 92037a1..3a200d2 100644 --- a/test/helloworld/hello_world.s +++ b/test/helloworld/hello_world.s @@ -76,6 +76,6 @@ _finish: .data hw_data: .ascii "----------------------------------\n" -.ascii "Hello World from Colin EH1 @WDC !!\n" +.ascii "Hello World Colin.liang EH1@WDC !!\n" .ascii "----------------------------------\n" .byte 0