riscv

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 911bfb87f7a8b5c9560a96cb4aad24d928a64053
parent 77c753a76dc481afb44b3b8596ac00f4cf4e5a63
Author: Brian Swetland <swetland@frotz.net>
Date:   Wed, 23 Oct 2019 10:51:52 -0700

compliance: scripts to checkout and run riscv-compliance

Diffstat:
Acompliance/compliance_io.h | 36++++++++++++++++++++++++++++++++++++
Acompliance/compliance_test.h | 46++++++++++++++++++++++++++++++++++++++++++++++
Acompliance/makefile.inc | 30++++++++++++++++++++++++++++++
Acompliance/run.sh | 6++++++
Acompliance/setup.sh | 10++++++++++
5 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/compliance/compliance_io.h b/compliance/compliance_io.h @@ -0,0 +1,36 @@ +// RISC-V Compliance IO Test Header File + +/* + * Copyright (c) 2005-2018 Imperas Software Ltd., www.imperas.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _COMPLIANCE_IO_H +#define _COMPLIANCE_IO_H + +//----------------------------------------------------------------------- +// RV IO Macros (Non functional) +//----------------------------------------------------------------------- + +#define RVTEST_IO_INIT +#define RVTEST_IO_WRITE_STR(_SP, _STR) +#define RVTEST_IO_CHECK() +#define RVTEST_IO_ASSERT_GPR_EQ(_SP, _R, _I) +#define RVTEST_IO_ASSERT_SFPR_EQ(_F, _R, _I) +#define RVTEST_IO_ASSERT_DFPR_EQ(_D, _R, _I) + +#endif // _COMPLIANCE_IO_H diff --git a/compliance/compliance_test.h b/compliance/compliance_test.h @@ -0,0 +1,46 @@ +// RISC-V Compliance Test Header File +// Copyright (c) 2017, Codasip Ltd. All Rights Reserved. +// See LICENSE for license details. +// +// Description: Common header file for RV32I tests + +#ifndef _COMPLIANCE_TEST_H +#define _COMPLIANCE_TEST_H + +#include "riscv_test.h" + +//----------------------------------------------------------------------- +// RV Compliance Macros +//----------------------------------------------------------------------- + +#define RV_COMPLIANCE_RV32M \ + RVTEST_RV32M \ + +#if 0 +#define RV_COMPLIANCE_HALT \ + RVTEST_PASS \ + +#define RV_COMPLIANCE_CODE_BEGIN \ + RVTEST_CODE_BEGIN \ + +#else +#define RV_COMPLIANCE_HALT .long 0x0000000b; +#define RV_COMPLIANCE_CODE_BEGIN \ +.section .text.init; \ +.align 6; \ +.globl _start; \ +_start: \ +begin_testcode: \ + +#endif + +#define RV_COMPLIANCE_CODE_END \ + RVTEST_CODE_END \ + +#define RV_COMPLIANCE_DATA_BEGIN \ + RVTEST_DATA_BEGIN \ + +#define RV_COMPLIANCE_DATA_END \ + RVTEST_DATA_END \ + +#endif diff --git a/compliance/makefile.inc b/compliance/makefile.inc @@ -0,0 +1,30 @@ +TARGET_SIM ?= /work/riscv/riscv/bin/rvsim +ifeq ($(shell command -v $(TARGET_SIM) 2> /dev/null),) + $(error Target simulator executable '$(TARGET_SIM)` not found) +endif + +RUN_TARGET=\ + $(TARGET_SIM) \ + $(work_dir_isa)/$<.bin \ + -dump=$(work_dir_isa)/$(*).signature.output \ + -from=$$(grep begin_signature $(work_dir_isa)/$<.map | awk '{print $$1}') \ + -to=$$(grep end_signature $(work_dir_isa)/$<.map | awk '{print $$1}') \ + 2> $(work_dir_isa)/$@ 1>&2 + +RISCV_PREFIX ?= riscv32-unknown-elf- +RISCV_GCC ?= $(RISCV_PREFIX)gcc +RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump +RISCV_OBJCOPY ?= $(RISCV_PREFIX)objcopy +RISCV_NM ?= $(RISCV_PREFIX)nm +RISCV_GCC_OPTS ?= -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles + +COMPILE_TARGET=\ + $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) \ + -I$(ROOTDIR)/riscv-test-env/ \ + -I$(ROOTDIR)/riscv-test-env/p/ \ + -I$(TARGETDIR)/$(RISCV_TARGET)/ \ + -T$(ROOTDIR)/riscv-test-env/p/link.ld $$< \ + -o $(work_dir_isa)/$$@; \ + $$(RISCV_OBJDUMP) -D $(work_dir_isa)/$$@ > $(work_dir_isa)/$$@.objdump; \ + $$(RISCV_OBJCOPY) -O binary $(work_dir_isa)/$$@ $(work_dir_isa)/$$@.bin; \ + $$(RISCV_NM) $(work_dir_isa)/$$@ > $(work_dir_isa)/$$@.map diff --git a/compliance/run.sh b/compliance/run.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +export RVSIM=`pwd`/../bin/rvsim +export TOOLCHAIN=`pwd`/../../toolchains/riscv32-elf-7.3.0-Linux-x86_64/bin/riscv32-elf- + +make -C rvc RISCV_TARGET=rvsim RISCV_PREFIX=${TOOLCHAIN} TARGET_SIM=${RVSIM} diff --git a/compliance/setup.sh b/compliance/setup.sh @@ -0,0 +1,10 @@ +#!/bin/sh -e + +git clone git@github.com:riscv/riscv-compliance.git rvc + +mkdir -p rvc/riscv-target/rvsim/device/rv32i + +ln -s ../../../compliance_io.h rvc/riscv-target/rvsim/compliance_io.h +ln -s ../../../compliance_test.h rvc/riscv-target/rvsim/compliance_test.h +ln -s ../../../../../makefile.inc rvc/riscv-target/rvsim/device/rv32i/Makefile.include +