diff --git a/dv/uvm/core_ibex/compare.py b/dv/uvm/core_ibex/compare.py index 370c0153..bdadeb7b 100755 --- a/dv/uvm/core_ibex/compare.py +++ b/dv/uvm/core_ibex/compare.py @@ -9,10 +9,10 @@ A script to compare an ISS and RTL run to make sure nothing has diverged. import argparse import os -import re import sys from typing import Dict, Optional, TextIO, Tuple, Union +from scripts.scripts_lib import read_test_dot_seed from scripts.test_entry import TestEntry, get_test_entry from scripts.test_run_result import TestRunResult @@ -38,22 +38,9 @@ finally: sys.path = _OLD_SYS_PATH -_TestAndSeed = Tuple[str, int] _CompareResult = Tuple[bool, Optional[str], Dict[str, str]] -def read_test_dot_seed(arg: str) -> _TestAndSeed: - '''Read a value for --test-dot-seed''' - - match = re.match(r'([^.]+)\.([0-9]+)$', arg) - if match is None: - raise argparse.ArgumentTypeError('Bad --test-dot-seed ({}): ' - 'should be of the form TEST.SEED.' - .format(arg)) - - return (match.group(1), int(match.group(2), 10)) - - def compare_test_run(test: TestEntry, idx: int, seed: int, diff --git a/dv/uvm/core_ibex/scripts/run-rtl.py b/dv/uvm/core_ibex/scripts/run-rtl.py index cded1552..b462e37e 100755 --- a/dv/uvm/core_ibex/scripts/run-rtl.py +++ b/dv/uvm/core_ibex/scripts/run-rtl.py @@ -2,31 +2,15 @@ import argparse import os -import re import subprocess import sys -from typing import Tuple from sim_cmd import get_simulator_cmd -from scripts_lib import subst_vars +from scripts_lib import read_test_dot_seed, subst_vars from test_entry import get_test_entry _CORE_IBEX = os.path.normpath(os.path.join(os.path.dirname(__file__), '..')) -_TestAndSeed = Tuple[str, int] - - -def read_test_dot_seed(arg: str) -> _TestAndSeed: - '''Read a value for --test-dot-seed''' - - match = re.match(r'([^.]+)\.([0-9]+)$', arg) - if match is None: - raise argparse.ArgumentTypeError('Bad --test-dot-seed ({}): ' - 'should be of the form TEST.SEED.' - .format(arg)) - - return (match.group(1), int(match.group(2), 10)) - def get_test_sim_cmd(base_cmd, test, idx, seed, sim_dir, bin_dir, lsf_cmd): '''Generate the command that runs a test iteration in the simulator diff --git a/dv/uvm/core_ibex/scripts/scripts_lib.py b/dv/uvm/core_ibex/scripts/scripts_lib.py index a62f02f3..3da8304c 100644 --- a/dv/uvm/core_ibex/scripts/scripts_lib.py +++ b/dv/uvm/core_ibex/scripts/scripts_lib.py @@ -3,17 +3,21 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 +import argparse import os +import re import shlex import subprocess import sys -from typing import Dict, List, Optional +from typing import Dict, List, Optional, Tuple THIS_DIR = os.path.dirname(__file__) IBEX_ROOT = os.path.join(THIS_DIR, 4 * '../') RISCV_DV_ROOT = os.path.normpath(os.path.join(IBEX_ROOT, 'vendor/google_riscv-dv')) +TestAndSeed = Tuple[str, int] + def run_one(verbose: bool, cmd: List[str], @@ -83,3 +87,15 @@ def subst_vars(string: str, var_dict: Dict[str, str]) -> str: for key, value in var_dict.items(): string = string.replace('<{}>'.format(key), value) return string + + +def read_test_dot_seed(arg: str) -> TestAndSeed: + '''Read a value for --test-dot-seed''' + + match = re.match(r'([^.]+)\.([0-9]+)$', arg) + if match is None: + raise argparse.ArgumentTypeError('Bad --test-dot-seed ({}): ' + 'should be of the form TEST.SEED.' + .format(arg)) + + return (match.group(1), int(match.group(2), 10))