25 argparser = argparse.ArgumentParser(
26 description=
"Wrap a 'inner_cmd' in an ESI cosimulation environment.",
27 formatter_class=argparse.RawDescriptionHelpFormatter,
28 epilog=textwrap.dedent(
"""
30 - For Verilator, libEsiCosimDpiServer.so must be in the dynamic
31 library runtime search path (LD_LIBRARY_PATH) and link time path
32 (LIBRARY_PATH). If it is installed to a standard location (e.g.
33 /usr/lib), this should be handled automatically.
34 - This script needs to sit in the same directory as the ESI support
35 SystemVerilog (e.g. Cosim_DpiPkg.sv, Cosim_MMIO.sv, etc.). It can,
36 however, be soft linked to a different location.
37 - The simulator executable(s) must be in your PATH.
40 argparser.add_argument(
44 help=
"Name of the RTL simulator to use or path to an executable.")
45 argparser.add_argument(
"--rundir",
47 help=
"Directory in which simulation should be run.")
48 argparser.add_argument(
50 default=
"ESI_Cosim_Top",
51 help=
"Name of the 'top' module to use in the simulation.")
52 argparser.add_argument(
"--no-compile",
54 help=
"Do not run the compile.")
55 argparser.add_argument(
"--debug",
57 help=
"Enable debug output.")
58 argparser.add_argument(
61 help=
"Save waveform dumps (format depends on simulator). Requires --debug."
63 argparser.add_argument(
"--gui",
65 help=
"Run the simulator in GUI mode (if supported).")
66 argparser.add_argument(
"--source",
67 help=
"Directories containing the source files.",
70 argparser.add_argument(
"inner_cmd",
71 nargs=argparse.REMAINDER,
72 help=
"Command to run in the simulation environment.")
74 argparser.add_argument(
77 help=
"Only run the cosim server, and do not run any inner command.")
80 argparser.print_help()
82 args = argparser.parse_args(args[1:])
85 if args.save_waveform
and not args.debug:
86 print(
"ERROR: --save-waveform requires --debug to be enabled",
90 sources = SourceFiles(args.top)
91 sources.add_dir(Path(args.source))
93 sim = get_simulator(args.sim, sources, Path(args.rundir), args.debug,
95 if not args.no_compile:
99 return sim.run(args.inner_cmd[1:], gui=args.gui, server_only=args.server_only)