-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Simple Framework for Creating Test ELFs (#29)
Created a framework for building RISC-V assembly tests for testing Atlas. The framework uses magic memory to end simulation, which has not been implemented in Atlas yet, so the `stop_sim_on_wfi` parameter is required for these tests to end properly. Created ELFs used in Atlas's regression should be checked in to the `test/sim/workloads`dir.
- Loading branch information
1 parent
72b5f08
commit 974ebda
Showing
11 changed files
with
175 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cmake_minimum_required(VERSION 3.27.6) | ||
|
||
project(riscv_assembly_tests ASM) | ||
|
||
# Unset these variables to prevent include of Mac SDK | ||
set(CMAKE_OSX_SYSROOT "/") | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET "") | ||
|
||
if(NOT RISCV_TOOLCHAIN) | ||
message(FATAL_ERROR "You must supply a -DRISCV_TOOLCHAIN=/path") | ||
else() | ||
message("-- Using RISCV_TOOLCHAIN: ${RISCV_TOOLCHAIN}") | ||
if(EXISTS ${RISCV_TOOLCHAIN}/bin/riscv64-unknown-elf-as) | ||
set(CMAKE_ASM_COMPILER "${RISCV_TOOLCHAIN}/bin/riscv64-unknown-elf-as") | ||
set(CMAKE_C_COMPILER "${RISCV_TOOLCHAIN}/bin/riscv64-unknown-elf-gcc") | ||
set(CMAKE_CXX_COMPILER "${RISCV_TOOLCHAIN}/bin/riscv64-unknown-elf-g++") | ||
set(CMAKE_LINKER "${RISCV_TOOLCHAIN}/bin/riscv64-unknown-elf-ld") | ||
elseif(EXISTS ${RISCV_TOOLCHAIN}//bin/riscv64-unknown-linux-gnu-as) | ||
set(CMAKE_ASM_COMPILER "${RISCV_TOOLCHAIN}/bin/riscv64-unknown-linux-gnu-as") | ||
set(CMAKE_C_COMPILER "${RISCV_TOOLCHAIN}/bin/riscv64-unknown-linux-gnu-gcc") | ||
set(CMAKE_CXX_COMPILER "${RISCV_TOOLCHAIN}/bin/riscv64-unknown-linux-gnu-g++") | ||
set(CMAKE_LINKER "${RISCV_TOOLCHAIN}/bin/riscv64-unknown-linux-gnu-ld") | ||
else() | ||
message(FATAL_ERROR "Cannot find tools in the given RISCV_TOOLCHAIN") | ||
endif() | ||
endif() | ||
|
||
set(BASE_DIR ${PROJECT_SOURCE_DIR}) | ||
|
||
# Don't test compilers. The riscv toolchain's linker does not support the option '-search_paths_first' | ||
set(CMAKE_C_COMPILER_WORKS 1) | ||
#set(CMAKE_C_FLAGS "-march=rv64gc") | ||
#set(CMAKE_LINK_C_FLAGS "") | ||
set(CMAKE_CXX_COMPILER_WORKS 1) | ||
#set(CMAKE_CXX_FLAGS "-march=rv64gc") | ||
#set(CMAKE_LINK_CXX_FLAGS "") | ||
|
||
# Linker setup | ||
set(LINKER_SCRIPT ${BASE_DIR}/common/main.ld) | ||
set(CMAKE_ASM_LINKER_FLAGS "-T ${LINKER_SCRIPT} -e main") | ||
set(CMAKE_ASM_LINK_EXECUTABLE "${CMAKE_LINKER} ${CMAKE_ASM_LINKER_FLAGS} <OBJECTS> -o <TARGET>") | ||
|
||
include_directories(common) | ||
|
||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Build directions: | ||
``` | ||
mkdir build | ||
cd build | ||
cmake .. -DRISCV_TOOLCHAIN=<path to the install of RISCV toolsuite> | ||
make | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Test: [test name] | ||
* ISA: [isa string required] | ||
* Description: [description of test] | ||
*/ | ||
|
||
.include "host.s" | ||
.include "macros.s" | ||
|
||
.section .text | ||
.global main | ||
|
||
// Insert your test in main | ||
main: | ||
|
||
// Jump or fall through here if test is successful | ||
pass: | ||
test_pass | ||
|
||
// Jump here if test is unsuccessful | ||
fail: | ||
test_fail | ||
|
||
.section .data | ||
data: | ||
.fill 64, 4, 0xFFFFFFFF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.section .tohost,"aw" | ||
.globl tohost | ||
.globl fromhost | ||
|
||
tohost: | ||
.dword 0 | ||
fromhost: | ||
.dword 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* Test: nop.elf | ||
* ISA: rv64i | ||
* Description: Stream of nops. | ||
*/ | ||
|
||
.macro test_pass | ||
li x1, 1 | ||
la x2, tohost | ||
sw x1, 0(x2) | ||
wfi | ||
.endm | ||
|
||
.macro test_fail | ||
li x1, 2 | ||
la x2, tohost | ||
sw x1, 0(x2) | ||
wfi | ||
.endm | ||
|
||
.macro start_tracepoint | ||
xor x0, x0, x0 | ||
.endm | ||
|
||
.macro stop_tracepoint | ||
xor x0, x1, x1 | ||
.endm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
OUTPUT_ARCH("riscv") | ||
|
||
SECTIONS | ||
{ | ||
. = 0x80000000; | ||
.text : { *(.text) } | ||
. = ALIGN(0x1000); | ||
.tohost : { *(.tohost) } | ||
. = ALIGN(0x1000); | ||
.data : { *(.data) } | ||
. = ALIGN(0x1000); | ||
.bss : { *(.bss) } | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
project (BASE_TESTS) | ||
|
||
set (CMAKE_ASM_FLAGS "-march=rv64i_zicsr_zifencei") | ||
|
||
add_subdirectory (nop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project(nop_test) | ||
|
||
add_executable (nop.elf nop.s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Test: nop.elf | ||
* ISA: rv64i | ||
* Description: Stream of nops. | ||
*/ | ||
|
||
.include "host.s" | ||
.include "macros.s" | ||
|
||
.section .text | ||
.global main | ||
|
||
main: | ||
.rept 1000 | ||
nop | ||
.endr | ||
|
||
pass: | ||
test_pass | ||
|
||
fail: | ||
test_fail | ||
|
||
.section .data | ||
data: | ||
.fill 64, 4, 0xFFFFFFFF |