-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Complaince Testing framework for ibex
- Loading branch information
1 parent
fb32236
commit 3121a25
Showing
15 changed files
with
451 additions
and
44 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,14 @@ | ||
[RISCOF] | ||
ReferencePlugin=sail_cSim | ||
ReferencePluginPath=./dv/riscv_compliance/plugin-sail_cSim | ||
DUTPlugin=ibex | ||
DUTPluginPath=./dv/riscv_compliance/plugin-ibex | ||
|
||
[ibex] | ||
pluginpath=./dv/riscv_compliance/plugin-ibex | ||
ispec=./dv/riscv_compliance/plugin-ibex/ibex_isa.yaml | ||
pspec=./dv/riscv_compliance/plugin-ibex/ibex_platform.yaml | ||
target_run=1 | ||
|
||
[sail_cSim] | ||
pluginpath=./dv/riscv_compliance/plugin-sail_cSim |
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,16 @@ | ||
# Pre-build SAIL RISC-V Model Binaries | ||
|
||
SAIL RISC-V is the Golden reference model simulator for the formal specification of the RISC-V Architecture. The binaries are build by following the [instructions](https://riscof.readthedocs.io/en/stable/installation.html#install-plugin-models) available in RISCOF documentation. | ||
|
||
These binaries are build for both 32-bit and 64-bit architecture: | ||
|
||
- `riscv_sim_RV32` | ||
- `riscv_sim_RV64` | ||
|
||
> :warning: SAIL model binaries must be available in the `$PATH` variable. To do that: | ||
- Extract `sail-riscv.tar.gz` using | ||
|
||
tar -xzf sail-riscv.tar.gz sail-riscv | ||
- Binaries will be extracted in the directory named `sail-riscv`. Export the path of this directory to `$PATH` variable | ||
|
||
export PATH=/path/to/sail-riscv:$PATH |
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
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,17 @@ | ||
OUTPUT_ARCH( "riscv" ) | ||
ENTRY(rvtest_entry_point) | ||
|
||
SECTIONS | ||
{ | ||
. = 0x80000000; | ||
.text.init : { *(.text.init) } | ||
. = ALIGN(0x1000); | ||
.tohost : { *(.tohost) } | ||
. = ALIGN(0x1000); | ||
.text : { *(.text) } | ||
. = ALIGN(0x1000); | ||
.data : { *(.data) } | ||
.data.string : { *(.data.string)} | ||
.bss : { *(.bss) } | ||
_end = .; | ||
} |
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,61 @@ | ||
#ifndef _COMPLIANCE_MODEL_H | ||
#define _COMPLIANCE_MODEL_H | ||
|
||
#define TESTUTIL_BASE 0x2000000 | ||
#define TESTUTIL_ADDR_HALT (TESTUTIL_BASE + 0x0) | ||
#define TESTUTIL_ADDR_BEGIN_SIGNATURE (TESTUTIL_BASE + 0x4) | ||
#define TESTUTIL_ADDR_END_SIGNATURE (TESTUTIL_BASE + 0x8) | ||
|
||
// RV_COMPLIANCE_HALT | ||
#define RVMODEL_HALT \ | ||
/* tell simulation about location of begin_signature */ \ | ||
la t0, begin_signature; \ | ||
li t1, TESTUTIL_ADDR_BEGIN_SIGNATURE; \ | ||
sw t0, 0(t1); \ | ||
/* tell simulation about location of end_signature */ \ | ||
la t0, end_signature; \ | ||
li t1, TESTUTIL_ADDR_END_SIGNATURE; \ | ||
sw t0, 0(t1); \ | ||
/* dump signature and terminate simulation */ \ | ||
li t0, 1; \ | ||
li t1, TESTUTIL_ADDR_HALT; \ | ||
sw t0, 0(t1); \ | ||
nop; \ | ||
li gp, 1; \ | ||
SWSIG(0, TESTNUM); \ | ||
ecall; | ||
|
||
// #define RVMODEL_BOOT \ | ||
// .fill 31, 4, 0x00000013; | ||
|
||
#define RVMODEL_DATA_BEGIN \ | ||
.align 4; \ | ||
.global begin_signature; \ | ||
begin_signature: | ||
|
||
#define RVMODEL_DATA_END \ | ||
.align 4; \ | ||
.global end_signature; \ | ||
end_signature: | ||
|
||
#define RVMODEL_BOOT \ | ||
.section.text.init; \ | ||
.align 4; \ | ||
.fill 31, 4, 0x00000013; \ | ||
.globl _start; \ | ||
_start: | ||
|
||
#define LOCAL_IO_WRITE_STR(_STR) RVMODEL_IO_WRITE_STR(x31, _STR) | ||
#define RVMODEL_IO_WRITE_STR(_SP, _STR) | ||
#define LOCAL_IO_PUSH(_SP) | ||
#define LOCAL_IO_POP(_SP) | ||
#define RVMODEL_IO_ASSERT_GPR_EQ(_SP, _R, _I) | ||
#define RVMODEL_IO_ASSERT_SFPR_EQ(_F, _R, _I) | ||
#define RVMODEL_IO_ASSERT_DFPR_EQ(_D, _R, _I) | ||
|
||
#define RVMODEL_SET_MSW_INT | ||
#define RVMODEL_CLEAR_MSW_INT | ||
#define RVMODEL_CLEAR_MTIMER_INT | ||
#define RVMODEL_CLEAR_MEXT_INT | ||
|
||
#endif // _COMPLIANCE_MODEL_H |
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,29 @@ | ||
hart_ids: [0] | ||
hart0: | ||
ISA: RV32IMCZicsr_Zifencei | ||
physical_addr_sz: 32 | ||
User_Spec_Version: '2.3' | ||
supported_xlen: [32] | ||
misa: | ||
reset-val: 0x40001104 | ||
rv32: | ||
accessible: true | ||
mxl: | ||
implemented: true | ||
type: | ||
warl: | ||
dependency_fields: [] | ||
legal: | ||
- mxl[1:0] in [0x1] | ||
wr_illegal: | ||
- Unchanged | ||
extensions: | ||
implemented: true | ||
type: | ||
warl: | ||
dependency_fields: [] | ||
legal: | ||
- extensions[25:0] bitmask [0x0001104, 0x0000000] | ||
wr_illegal: | ||
- Unchanged | ||
|
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,4 @@ | ||
nmi: | ||
label: nmi_vector | ||
reset: | ||
label: reset_vector |
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,92 @@ | ||
import os | ||
import logging | ||
|
||
import riscof.utils as utils | ||
from riscof.pluginTemplate import pluginTemplate | ||
|
||
logger = logging.getLogger() | ||
|
||
class ibex(pluginTemplate): | ||
__model__ = "ibex" | ||
__version__ = "XXX" | ||
|
||
def __init__(self, *args, **kwargs): | ||
sclass = super().__init__(*args, **kwargs) | ||
config = kwargs.get('config') | ||
if config is None: | ||
print("Please enter input file paths in configuration.") | ||
raise SystemExit(1) | ||
#self.dut_exe = os.path.join(config['PATH'] if 'PATH' in config else "","serv") | ||
#self.num_jobs = str(config['jobs'] if 'jobs' in config else 1) | ||
self.pluginpath=os.path.abspath(config['pluginpath']) | ||
self.isa_spec = os.path.abspath(config['ispec']) | ||
self.platform_spec = os.path.abspath(config['pspec']) | ||
if 'target_run' in config and config['target_run']=='0': | ||
self.target_run = False | ||
else: | ||
self.target_run = True | ||
return sclass | ||
|
||
def initialise(self, suite, work_dir, archtest_env): | ||
self.compile_cmd = 'riscv64-unknown-elf-gcc -march={0} \ | ||
-static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -g\ | ||
-T '+self.pluginpath+'/env/link.ld\ | ||
-I '+self.pluginpath+'/env/\ | ||
-I ' + archtest_env + ' {1} -o {2} {3}' | ||
self.objcopy_cmd = 'riscv64-unknown-elf-objcopy -O binary {0} {1}.bin' | ||
self.objdump_cmd = 'riscv64-unknown-elf-objdump -D {0} > {1}.disass' | ||
self.vmem_cmd = 'srec_cat {0}.bin -binary -offset 0x0000 -byte-swap 4 -o {0}.vmem -vmem' | ||
self.simulate_cmd = './build/lowrisc_ibex_ibex_riscv_compliance_3.5/sim-verilator/Vibex_riscv_compliance \ | ||
--term-after-cycles=100000 \ | ||
--raminit={0}/{1}.vmem \ | ||
> {0}/signature.stdout' | ||
self.sigdump_cmd = 'grep \"^SIGNATURE: \" signature.stdout | sed \'s/SIGNATURE: 0x//\' > DUT-ibex.signature' | ||
|
||
buil_ibex = 'fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_riscv_compliance --RV32E=0 --RV32M=ibex_pkg::RV32MNone' | ||
utils.shellCommand(buil_ibex).run() | ||
|
||
def build(self, isa_yaml, platform_yaml): | ||
ispec = utils.load_yaml(isa_yaml)['hart0'] | ||
self.xlen = ('64' if 64 in ispec['supported_xlen'] else '32') | ||
self.isa = 'rv' + self.xlen | ||
if "I" in ispec["ISA"]: | ||
self.isa += 'i' | ||
if "M" in ispec["ISA"]: | ||
self.isa += 'm' | ||
if "F" in ispec["ISA"]: | ||
self.isa += 'f' | ||
if "D" in ispec["ISA"]: | ||
self.isa += 'd' | ||
if "C" in ispec["ISA"]: | ||
self.isa += 'c' | ||
self.compile_cmd = self.compile_cmd+' -mabi='+('lp64 ' if 64 in ispec['supported_xlen'] else 'ilp32 ') | ||
|
||
def runTests(self, testList): | ||
for testname in testList: | ||
testentry = testList[testname] | ||
test = testentry['test_path'] | ||
test_dir = testentry['work_dir'] | ||
file_name = 'ibex-{0}'.format(test.rsplit('/',1)[1][:-2]) | ||
|
||
elf = '{0}.elf'.format(file_name) | ||
compile_macros= ' -D' + " -D".join(testentry['macros']) | ||
marchstr = testentry['isa'].lower() | ||
|
||
compile_run = self.compile_cmd.format(marchstr, test, elf, compile_macros) | ||
utils.shellCommand(compile_run).run(cwd=test_dir) | ||
|
||
objcopy_run = self.objcopy_cmd.format(elf,file_name) | ||
utils.shellCommand(objcopy_run).run(cwd=test_dir) | ||
|
||
objdump_run = self.objdump_cmd.format(elf,file_name) | ||
utils.shellCommand(objdump_run).run(cwd=test_dir) | ||
|
||
vmem_run = self.vmem_cmd.format(file_name) | ||
utils.shellCommand(vmem_run).run(cwd=test_dir) | ||
|
||
sim_run = self.simulate_cmd.format(test_dir,file_name) | ||
utils.shellCommand(sim_run).run() | ||
|
||
utils.shellCommand(self.sigdump_cmd).run(cwd=test_dir) | ||
if not self.target_run: | ||
raise SystemExit |
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,17 @@ | ||
OUTPUT_ARCH( "riscv" ) | ||
ENTRY(rvtest_entry_point) | ||
|
||
SECTIONS | ||
{ | ||
. = 0x80000000; | ||
.text.init : { *(.text.init) } | ||
. = ALIGN(0x1000); | ||
.tohost : { *(.tohost) } | ||
. = ALIGN(0x1000); | ||
.text : { *(.text) } | ||
. = ALIGN(0x1000); | ||
.data : { *(.data) } | ||
.data.string : { *(.data.string)} | ||
.bss : { *(.bss) } | ||
_end = .; | ||
} |
Oops, something went wrong.