Example #1
0
File: sim.py Project: danghai/ibex
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
Example #2
0
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
Example #3
0
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("--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("-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("--en_cov",
                        action='store_true',
                        help="Enable coverage dump")
    parser.add_argument("--en_wave",
                        action='store_true',
                        help="Enable waveform dump")
    parser.add_argument("--en_cosim",
                        action='store_true',
                        help="Enable cosimulation")
    parser.add_argument("--steps",
                        type=str,
                        default="all",
                        help="Run steps: compile,cov")
    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)

    # 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.
    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)
    subprocess.run(["mkdir", "-p", output_dir])

    steps = {
        'compile': args.steps == "all" or 'compile' in args.steps,
        'cov': args.steps == "all" or 'cov' in args.steps
    }

    # Compile TB
    if steps['compile']:
        enables = {
            'cov_opts': args.en_cov,
            'wave_opts': args.en_wave,
            'cosim_opts': args.en_cosim
        }
        compile_cmds, sim_cmd = get_simulator_cmd(args.simulator,
                                                  args.simulator_yaml, enables)

        rtl_compile(compile_cmds, output_dir, args.lsf_cmd, args.cmp_opts)

    # 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