Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 76af88e

Browse files
committedJan 26, 2021
[dv] Add RISCOF reference model
RISC-V Compliance reference model to compare existing signatures.
1 parent 33ed08f commit 76af88e

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
 

‎dv/riscof/config.ini

+5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
[RISCOF]
2+
ReferencePlugin=rc_reference
3+
ReferencePluginPath=rc_reference
24
DUTPlugin=Ibex
35
DUTPluginPath=ibex
46

57
[Ibex]
68
pluginpath=ibex
79
ispec=ibex/ibex_small_isa.yaml
810
pspec=ibex/ibex_platform.yaml
11+
12+
[rc_reference]
13+
riscvTestSuite=reference_signature

‎dv/riscof/rc_reference/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from pkgutil import extend_path
2+
__path__ = extend_path(__path__, __name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import logging
2+
import os
3+
import shutil
4+
import string
5+
import sys
6+
7+
import riscof.utils as utils
8+
import riscof.constants as constants
9+
from riscof.pluginTemplate import pluginTemplate
10+
11+
logger = logging.getLogger()
12+
13+
class rc_reference(pluginTemplate):
14+
__model__ = "rc_reference"
15+
__version__ = "0.1.0"
16+
17+
def __init__(self, *args, **kwargs):
18+
sclass = super().__init__(*args, **kwargs)
19+
20+
config = kwargs.get('config')
21+
if config is None:
22+
print("Please enter input file paths in configuration.")
23+
raise SystemExit
24+
25+
test_suite = os.getenv('RISCV_TEST_SUITE')
26+
if test_suite is None:
27+
config_dir = kwargs.get('config_dir')
28+
test_suite_entry = config.get('riscvTestSuite')
29+
if test_suite_entry:
30+
test_suite = utils.absolute_path(config_dir, test_suite_entry)
31+
else:
32+
logger.error("Path to reference signature not set. "\
33+
"Please set envrionment variable 'RISCV_TEST_SUITE' "\
34+
"or config key 'riscvTestSuite'.")
35+
raise SystemExit
36+
self.test_suite_path = test_suite
37+
38+
return sclass
39+
40+
def initialise(self, suite, work_dir, compliance_env):
41+
self.work_dir = work_dir
42+
43+
44+
def build(self, isa_yaml, platform_yaml):
45+
return
46+
47+
def runTests(self, testList):
48+
for file in testList:
49+
testentry = testList[file]
50+
test = os.path.join(constants.root, str(file))
51+
test_dir = testentry['work_dir']
52+
53+
test_name = os.path.splitext(os.path.basename(test))[0]
54+
55+
# Extract the extension of the current test
56+
tested_extension = os.path.split(os.path.dirname(os.path.dirname(test_dir)))[1]
57+
58+
# Create the path to the reference signature based on the current
59+
# extension and a known file structure
60+
ref_sig = os.path.join(self.test_suite_path, tested_extension)
61+
ref_sig = os.path.join(ref_sig, "references")
62+
ref_sig = os.path.join(ref_sig, test_name + ".reference_output")
63+
64+
# Output file is stored in the current test output and a fixed file name
65+
test_sig = os.path.join(test_dir, "Reference-rc_reference.signature")
66+
67+
# Copy reference signature as test signature
68+
shutil.copyfile(ref_sig, test_sig)

0 commit comments

Comments
 (0)
Please sign in to comment.