diff --git a/Makefile b/Makefile index 13d18c37a..b83437833 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ all: make install - make compile make regression # install copies over the Makefile.include from riscv-isa-sim @@ -11,11 +10,6 @@ install: 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 -compile: - make -C addins/riscv-arch-test - make -C addins/riscv-arch-test XLEN=32 - cd addins/riscv-arch-test; exe2memfile.pl work/*/*/*.elf - regression: make -C wally-pipelined/regression diff --git a/examples/C/simple/Makefile b/examples/C/simple/Makefile new file mode 100644 index 000000000..66fe7d7bc --- /dev/null +++ b/examples/C/simple/Makefile @@ -0,0 +1,14 @@ +TARGET = simple + +$(TARGET).objdump: $(TARGET) + riscv64-unknown-elf-objdump -S -D $(TARGET) > $(TARGET).objdump + +$(TARGET): $(TARGET).c + riscv64-unknown-elf-gcc -g -o $(TARGET) -march=rv64gc -mabi=lp64d -mcmodel=medany \ + -O $(TARGET).c +# -O -T../../link/linkc.ld $(TARGET).c +# -nostartfiles -nostdlib $(TARGET).c +# -nostartfiles -nostdlib -T../../link/link.ld $(TARGET).c + +clean: + rm -f $(TARGET) $(TARGET).objdump diff --git a/examples/C/simple/simple.c b/examples/C/simple/simple.c new file mode 100644 index 000000000..d610f2999 --- /dev/null +++ b/examples/C/simple/simple.c @@ -0,0 +1,14 @@ +// simple.C +// David_Harris@hmc.edu 24 December 2021 +// Simple illustration of compiling C code + +long sum(long N) { + long result, i; + result = 0; + for (i=1; i<=N; i++) result = result + i; + return result; +} + +int main(void) { + return sum(4); +} \ No newline at end of file diff --git a/examples/asm/example/Makefile b/examples/asm/example/Makefile index 081f342c7..0cb8448fd 100644 --- a/examples/asm/example/Makefile +++ b/examples/asm/example/Makefile @@ -1,2 +1,9 @@ +example.objdump: example + riscv64-unknown-elf-objdump -D example > example.objdump + example: example.S - riscv64-unknown-elf-gcc -o example example.S + riscv64-unknown-elf-gcc -o example -march=rv32i -mabi=ilp32 -mcmodel=medany \ + -nostartfiles -nostdlib -T../../link/link.ld example.S + +clean: + rm -f example example.objdump diff --git a/examples/asm/example/example b/examples/asm/example/example deleted file mode 100755 index a9b740479..000000000 Binary files a/examples/asm/example/example and /dev/null differ diff --git a/examples/asm/example/example.S b/examples/asm/example/example.S index f487950a5..1205fad4a 100644 --- a/examples/asm/example/example.S +++ b/examples/asm/example/example.S @@ -1,67 +1,7 @@ -// example.s -// David_Harris@hmc.edu 5 December 2021 - .section .text.init -//.globl rvtest_entry_point -//rvtest_entry_point: - -.globl main -main: +.globl rvtest_entry_point +rvtest_entry_point: li a0, 42 self_loop: j self_loop - -.end - -/* -#include "model_test.h" -#include "arch_test.h" -RVTEST_ISA("RV32I") - -.section .text.init -.globl rvtest_entry_point -rvtest_entry_point: -RVMODEL_BOOT -RVTEST_CODE_BEGIN - -#ifdef TEST_CASE_1 - -RVTEST_CASE(0,"//check ISA:=regex(.*32.*);check ISA:=regex(.*I.*);def TEST_CASE_1=True;",add) - -RVTEST_SIGBASE( x3,signature_x3_1) - -inst_0: -// rs2 == rd != rs1, rs1==x4, rs2==x24, rd==x24, rs1_val > 0 and rs2_val > 0, rs2_val == 1, rs1_val == (2**(xlen-1)-1), rs1_val != rs2_val, rs1_val == 2147483647 -// opcode: add ; op1:x4; op2:x24; dest:x24; op1val:0x7fffffff; op2val:0x1 -TEST_RR_OP(add, x24, x4, x24, 0x80000000, 0x7fffffff, 0x1, x3, 0, x18) - - -80000000 : - -.section .text.init -.globl rvtest_entry_point -rvtest_entry_point: -RVMODEL_BOOT -RVTEST_CODE_BEGIN -80000000: feedc0b7 lui ra,0xfeedc -8 - -80003220 : -#endif - - -RVTEST_CODE_END -RVMODEL_HALT -80003220: 00408093 addi ra,ra,4 -80003224: 00100093 li ra,1 - -80003228 : -80003228: 00001f17 auipc t5,0x1 -8000322c: dc1f2c23 sw ra,-552(t5) # 80004000 - -80003230 : -80003230: 0000006f j 80003230 -80003234: 0000 unimp - ... -*/ \ No newline at end of file diff --git a/examples/asm/sumtest/Makefile b/examples/asm/sumtest/Makefile new file mode 100644 index 000000000..40f51a7ae Binary files /dev/null and b/examples/asm/sumtest/Makefile differ diff --git a/examples/asm/sumtest/sum.S b/examples/asm/sumtest/sum.S new file mode 100644 index 000000000..08afefb04 Binary files /dev/null and b/examples/asm/sumtest/sum.S differ diff --git a/examples/asm/sumtest/sumtest.S b/examples/asm/sumtest/sumtest.S new file mode 100644 index 000000000..17ef77f0a --- /dev/null +++ b/examples/asm/sumtest/sumtest.S @@ -0,0 +1,38 @@ +// sumtest.S +// David_Harris@hmc.edu 24 December 2021 + +.global rvtest_entry_point +rvtest_entry_point: + la sp, topofstack # Initialize stack pointer + la t0, N # get address of N in data + ld a0, 0(t0) # load N + jal sum # call sum(N) + la t0, begin_signature # address of signature + sd a0, 0(t0) # store sum(N) in signature + +write_tohost: + la t1, tohost + li t0, 1 # 1 for success, 3 for failure + sd t0, 0(t1) # send success code + +self_loop: + j self_loop # wait + +.section .tohost +tohost: # write to HTIF + .dword 0 +fromhost: + .dword 0 + +.data +N: + .dword 4 + +begin_signature: + .fill 2,4,0xdeadbeef +end_signature: + +# Initialize stack with room for 512 bytes +.bss + .space 512 +topofstack: diff --git a/examples/asm/sumtest/sumtest.reference_output b/examples/asm/sumtest/sumtest.reference_output new file mode 100644 index 000000000..91bf6ed77 --- /dev/null +++ b/examples/asm/sumtest/sumtest.reference_output @@ -0,0 +1 @@ +000000000000000A diff --git a/examples/asm/test b/examples/asm/test deleted file mode 100755 index fef7868c6..000000000 Binary files a/examples/asm/test and /dev/null differ diff --git a/examples/asm/test.S b/examples/asm/test.S deleted file mode 100644 index 0399a456a..000000000 --- a/examples/asm/test.S +++ /dev/null @@ -1,22 +0,0 @@ -.globl main -.equ N, 5 - -.data -//A: .word 5, 42, −88, 2, −5033, 720, 314 -str1: .string "RISC-V" -.align 2 -B: .word 0x32A -.bss -C: .space -D: .space -.balign 4 - -.text -main: - li a0, 42 - jr ra - -.section .rodata -str2: .string "Hello" - -.end diff --git a/examples/link/link.ld b/examples/link/link.ld new file mode 100644 index 000000000..15d36f156 --- /dev/null +++ b/examples/link/link.ld @@ -0,0 +1,17 @@ +OUTPUT_ARCH( "riscv" ) +ENTRY(rvtest_entry_point) + +SECTIONS +{ + . = 0x80000000; + .text : { *(.text) } + . = ALIGN(0x1000); + .tohost : { *(.tohost) } + . = ALIGN(0x1000); + .data : { *(.data) } + .data.string : { *(.data.string)} + . = ALIGN(0x1000); + .bss : { *(.bss) } + _end = .; +} + diff --git a/examples/link/linkc.ld b/examples/link/linkc.ld new file mode 100644 index 000000000..7b2566785 --- /dev/null +++ b/examples/link/linkc.ld @@ -0,0 +1,17 @@ +OUTPUT_ARCH( "riscv" ) +ENTRY(main) + +SECTIONS +{ + . = 0x80000000; + .text : { *(.text) } + . = ALIGN(0x1000); + .tohost : { *(.tohost) } + . = ALIGN(0x1000); + .data : { *(.data) } + .data.string : { *(.data.string)} + . = ALIGN(0x1000); + .bss : { *(.bss) } + _end = .; +} + diff --git a/wally-pipelined/regression/Makefile b/wally-pipelined/regression/Makefile index ad6e427d7..01c5624a0 100644 --- a/wally-pipelined/regression/Makefile +++ b/wally-pipelined/regression/Makefile @@ -1,6 +1,16 @@ make all: - make -C ../../tests/imperas-riscv-tests/ + # Build riscv-arch-test 64 and 32-bit versions + make -C ../../addins/riscv-arch-test + make -C ../../addins/riscv-arch-test XLEN=32 + exe2memfile.pl ../../addins/riscv-arch-test/work/*/*/*.elf + + # Build wally-riscv-arch-test make -C ../../tests/wally-riscv-arch-test/ - make -C XLEN=32 ../../tests/wally-riscv-arch-test/ + make -C ../../tests/wally-riscv-arch-test/ XLEN=32 exe2memfile.pl ../../tests/wally-riscv-arch-test/work/*/*/*.elf - cd ../../tests/linux-testgen/linux-testvectors/;./tvLinker.sh + + # Build Imperas tests (if installed) + make -C ../../tests/imperas-riscv-tests/ + + # Link Linux test vectors (fix this later***) + #cd ../../tests/linux-testgen/linux-testvectors/;./tvLinker.sh