def main() -> int: parser = argparse.ArgumentParser() parser.add_argument('--start_seed', type=int, default=1) parser.add_argument('--test', required=True) parser.add_argument('--iterations', type=int, default=0) parser.add_argument('--ibex-config', required=True) args = parser.parse_args() if args.iterations < 0: raise RuntimeError('Bad --iterations argument: must be non-negative') if args.start_seed < 0: raise RuntimeError('Bad --start_seed argument: must be non-negative') # Get all the tests that match --test, scaling as necessary with the # --iterations argument. matched_list = [] # type: _TestEntries testlist = os.path.join(_CORE_IBEX, 'riscv_dv_extension', 'testlist.yaml') process_regression_list(testlist, args.test, args.iterations, matched_list, _RISCV_DV_ROOT) if not matched_list: raise RuntimeError("Cannot find {} in {}".format(args.test, testlist)) # Filter tests by the chosen configuration matched_list = filter_tests_by_config(args.ibex_config, matched_list) # Print the tests crossed by seeds, one to a line, in the format TEST.SEED. for test in matched_list: name = test['test'] iterations = test['iterations'] assert isinstance(name, str) and isinstance(iterations, int) assert iterations > 0 for iteration in range(iterations): print('{}.{}'.format(name, args.start_seed + iteration)) return 0
def get_test_entry(testname: str) -> TestEntry: matched_list = [] # type: TestEntries testlist = os.path.join(_CORE_IBEX, 'riscv_dv_extension', 'testlist.yaml') process_regression_list(testlist, 'all', 0, matched_list, _RISCV_DV_ROOT) for entry in matched_list: if entry['test'] == testname: return entry raise RuntimeError('No matching test entry for {!r}'.format(testname))
def main(): '''Entry point when run as a script''' # Parse input arguments parser = argparse.ArgumentParser() parser.add_argument("--o", type=str, default="out", help="Output directory name") parser.add_argument("--testlist", help="Regression testlist", default=os.path.join(_CORE, 'riscv_dv_extension', 'testlist.yaml')) parser.add_argument("--test", type=str, default="all", help="Test name, 'all' means all tests in the list") parser.add_argument("--simulator", type=str, default="vcs", help="RTL simulator to use (default: vcs)") parser.add_argument("--simulator_yaml", help="RTL simulator setting YAML", default=os.path.join(_CORE, 'yaml', 'rtl_simulation.yaml')) parser.add_argument("--iss", default="spike", choices=['spike', 'ovpsim'], help="Instruction set simulator") parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", help="Verbose logging") parser.add_argument("--cmp_opts", type=str, default="", help="Compile options for the generator") parser.add_argument("--sim_opts", type=str, default="", help="Simulation options for the generator") parser.add_argument("--en_cov", action='store_true', help="Enable coverage dump") parser.add_argument("--en_wave", action='store_true', help="Enable waveform dump") parser.add_argument("--steps", type=str, default="all", help="Run steps: compile,sim,compare,cov") parser.add_argument("--lsf_cmd", type=str, help=("LSF command. Run locally if lsf " "command is not specified")) sg = (parser. add_argument_group('Seeds and iterations', 'If none of the arguments in this section are ' 'used, a random starting seed will be picked and ' 'passed as --start_seed. The number of ' 'iterations for each test will be read from the ' 'configuration.')) sg.add_argument("--seed", type=read_seed, metavar='S', help=("Randomization seed for the only iteration of each " "test. Implies --iterations=1. Equivalently, pass " "--start_seed and set iterations to 1.")) sg.add_argument("--start_seed", type=read_seed, metavar='S', help=("Randomization seed for the first iteration of each " "test. Following iterations will use seeds S+1, " "S+2, and so on.")) sg.add_argument("--iterations", type=int, help="Override the iteration count in the test list") args = parser.parse_args() setup_logging(args.verbose) # If args.lsf_cmd is an empty string return an error message and exit from # the script, as doing nothing will result in arbitrary simulation timeouts # and errors later on in the run flow. # TODO (Haroon): test lsf command and make it functional. '''if args.lsf_cmd == "": logging.error("The LSF command passed in is an empty string.") return RET_FAIL''' # Create the output directory output_dir = ("%s/rtl_sim" % args.o) bin_dir = ("%s/instr_gen/asm_tests" % args.o) subprocess.run(["mkdir", "-p", output_dir]) steps = { 'compile': args.steps == "all" or 'compile' in args.steps, 'sim': args.steps == "all" or 'sim' in args.steps, 'compare': args.steps == "all" or 'compare' in args.steps, 'cov': args.steps == "all" or 'cov' in args.steps } compile_cmds = [] sim_cmd = "" matched_list = [] seed_gen = None if steps['compile'] or steps['sim']: enables = { 'cov_opts': args.en_cov, 'wave_opts': args.en_wave } compile_cmds, sim_cmd = get_simulator_cmd(args.simulator, args.simulator_yaml, enables) if steps['sim'] or steps['compare']: seed_gen = SeedGen(args.seed, args.start_seed) if seed_gen.fixed: if not args.iterations: args.iterations = 1 if args.iterations != 1: logging.error('Cannot set multiple --iterations with a ' 'fixed seed.') return RET_FAIL process_regression_list(args.testlist, args.test, args.iterations or 0, matched_list, _RISCV_DV_ROOT) if not matched_list: raise RuntimeError("Cannot find %s in %s" % (args.test, args.testlist)) # Compile TB if steps['compile']: rtl_compile(compile_cmds, output_dir, args.lsf_cmd, args.cmp_opts) # Run RTL simulation if steps['sim']: rtl_sim(sim_cmd, matched_list, seed_gen, args.sim_opts, output_dir, bin_dir, args.lsf_cmd) # Compare RTL & ISS simulation result. if steps['compare']: compare(matched_list, args.iss, args.o) # Generate merged coverage directory and load it into appropriate GUI if steps['cov']: gen_cov(args.o, args.simulator, args.lsf_cmd) return RET_SUCCESS
def main(): '''Entry point when run as a script''' # Parse input arguments parser = argparse.ArgumentParser() parser.add_argument("--o", type=str, default="out", help="Output directory name") parser.add_argument("--testlist", help="Regression testlist", default=os.path.join(_CORE_IBEX, 'riscv_dv_extension', 'testlist.yaml')) parser.add_argument("--test", type=str, default="all", help="Test name, 'all' means all tests in the list") parser.add_argument("--seed", type=int, help=("Randomization seed; random if not specified")) parser.add_argument("--iterations", type=int, default=0, help="Override the iteration count in the test list") parser.add_argument("--simulator", type=str, default="vcs", help="RTL simulator to use (default: vcs)") parser.add_argument("--simulator_yaml", help="RTL simulator setting YAML", default=os.path.join(_CORE_IBEX, 'yaml', 'rtl_simulation.yaml')) parser.add_argument("--iss", default="spike", choices=['spike', 'ovpsim'], help="Instruction set simulator") parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", help="Verbose logging") parser.add_argument("--cmp_opts", type=str, default="", help="Compile options for the generator") parser.add_argument("--sim_opts", type=str, default="", help="Simulation options for the generator") parser.add_argument("--en_cov", action='store_true', help="Enable coverage dump") parser.add_argument("--en_wave", action='store_true', help="Enable waveform dump") parser.add_argument("--steps", type=str, default="all", help="Run steps: compile,sim,compare") parser.add_argument("--lsf_cmd", type=str, help=("LSF command. Run locally if lsf " "command is not specified")) args = parser.parse_args() setup_logging(args.verbose) parser.set_defaults(verbose=False) # Create the output directory output_dir = ("%s/rtl_sim" % args.o) bin_dir = ("%s/instr_gen/asm_tests" % args.o) subprocess.run(["mkdir", "-p", output_dir]) steps = { 'compile': args.steps == "all" or 'compile' in args.steps, 'sim': args.steps == "all" or 'sim' in args.steps, 'compare': args.steps == "all" or 'compare' in args.steps } compile_cmds = [] sim_cmd = "" matched_list = [] if steps['compile'] or steps['sim']: enables = {'cov_opts': args.en_cov, 'wave_opts': args.en_wave} compile_cmds, sim_cmd = get_simulator_cmd(args.simulator, args.simulator_yaml, enables) if steps['sim'] or steps['compare']: process_regression_list(args.testlist, args.test, args.iterations, matched_list, _RISCV_DV_ROOT) if not matched_list: raise RuntimeError("Cannot find %s in %s" % (args.test, args.testlist)) # Compile TB if steps['compile']: rtl_compile(compile_cmds, output_dir, args.lsf_cmd, args.cmp_opts) # Run RTL simulation if steps['sim']: check_return_code = True # Don't check return code for IUS sims, as a failure will short circuit # the entire simulation flow check_return_code = True if args.simulator == "ius": check_return_code = False logging.debug("Disable return code checking for %s simulator" % args.simulator) # Pick a seed: either the one we were given, or pick one at random. In # the latter case, print it out so the user can see what's going on. if args.seed is None or args.seed < 0: seed = random.getrandbits(32) logging.info("Random seed chosen: {}".format(seed)) else: seed = args.seed rtl_sim(sim_cmd, matched_list, seed, args.sim_opts, output_dir, bin_dir, args.lsf_cmd, check_return_code) # Compare RTL & ISS simulation result.; if steps['compare']: if not compare(matched_list, args.iss, args.o): return RET_FAIL return RET_SUCCESS