28  argparser = argparse.ArgumentParser(
 
   29      description=
"Wrap a 'inner_cmd' in an ESI cosimulation environment.",
 
   30      formatter_class=argparse.RawDescriptionHelpFormatter,
 
   31      epilog=textwrap.dedent(
""" 
   33          - For Verilator, libEsiCosimDpiServer.so must be in the dynamic 
   34          library runtime search path (LD_LIBRARY_PATH) and link time path 
   35          (LIBRARY_PATH). If it is installed to a standard location (e.g. 
   36          /usr/lib), this should be handled automatically. 
   37          - This script needs to sit in the same directory as the ESI support 
   38          SystemVerilog (e.g. Cosim_DpiPkg.sv, Cosim_MMIO.sv, etc.). It can, 
   39          however, be soft linked to a different location. 
   40          - The simulator executable(s) must be in your PATH. 
   43  argparser.add_argument(
 
   47      help=
"Name of the RTL simulator to use or path to an executable.")
 
   48  argparser.add_argument(
"--rundir",
 
   50                         help=
"Directory in which simulation should be run.")
 
   51  argparser.add_argument(
 
   53      default=
"ESI_Cosim_Top",
 
   54      help=
"Name of the 'top' module to use in the simulation.")
 
   55  argparser.add_argument(
"--no-compile",
 
   57                         help=
"Do not run the compile.")
 
   58  argparser.add_argument(
"--debug",
 
   60                         help=
"Enable debug output.")
 
   61  argparser.add_argument(
"--gui",
 
   63                         help=
"Run the simulator in GUI mode (if supported).")
 
   64  argparser.add_argument(
"--source",
 
   65                         help=
"Directories containing the source files.",
 
   68  argparser.add_argument(
"inner_cmd",
 
   69                         nargs=argparse.REMAINDER,
 
   70                         help=
"Command to run in the simulation environment.")
 
   72  argparser.add_argument(
 
   75      help=
"Only run the cosim server, and do not run any inner command.")
 
   78    argparser.print_help()
 
   80  args = argparser.parse_args(args[1:])
 
   82  sources = SourceFiles(args.top)
 
   83  sources.add_dir(Path(args.source))
 
   85  if args.sim == 
"verilator":
 
   86    sim = Verilator(sources, Path(args.rundir), args.debug)
 
   87  elif args.sim == 
"questa":
 
   88    sim = Questa(sources, Path(args.rundir), args.debug)
 
   90    print(
"Unknown simulator: " + args.sim)
 
   91    print(
"Supported simulators: ")
 
   96  if not args.no_compile:
 
  100  return sim.run(args.inner_cmd[1:], gui=args.gui, server_only=args.server_only)