CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
simulator.Simulator Class Reference
Inheritance diagram for simulator.Simulator:
Inheritance graph
[legend]
Collaboration diagram for simulator.Simulator:
Collaboration graph
[legend]

Public Member Functions

 __init__ (self, SourceFiles sources, Path run_dir, bool debug, Optional[Callable[[str], None]] run_stdout_callback=None, Optional[Callable[[str], None]] run_stderr_callback=None, Optional[Callable[[str], None]] compile_stdout_callback=None, Optional[Callable[[str], None]] compile_stderr_callback=None, bool make_default_logs=True, Optional[Dict[str, str]] macro_definitions=None)
 
List[List[str]] compile_commands (self)
 
int compile (self)
 
List[str] run_command (self, bool gui)
 
SimProcess run_proc (self, bool gui=False)
 
int run (self, str inner_command, bool gui=False, bool server_only=False)
 

Static Public Member Functions

Dict[str, str] get_env ()
 

Public Attributes

 sources
 
 run_dir
 
 debug
 
 macro_definitions
 

Static Public Attributes

bool UsesStderr = True
 

Protected Member Functions

int|tuple[subprocess.Popen, List[threading.Thread]] _start_process_with_callbacks (self, List[str] cmd, Optional[Dict[str, str]] env, Optional[Path] cwd, Optional[Callable[[str], None]] stdout_cb, Optional[Callable[[str], None]] stderr_cb, bool wait)
 

Protected Attributes

 _compile_stdout_cb
 
 _compile_stdout_log
 
 _compile_stderr_cb
 
 _compile_stderr_log
 
 _run_stdout_cb
 
 _run_stdout_log
 
 _run_stderr_cb
 
 _run_stderr_log
 

Detailed Description

Definition at line 107 of file simulator.py.

Constructor & Destructor Documentation

◆ __init__()

simulator.Simulator.__init__ (   self,
SourceFiles  sources,
Path  run_dir,
bool  debug,
Optional[Callable[[str], None]]   run_stdout_callback = None,
Optional[Callable[[str], None]]   run_stderr_callback = None,
Optional[Callable[[str], None]]   compile_stdout_callback = None,
Optional[Callable[[str], None]]   compile_stderr_callback = None,
bool   make_default_logs = True,
Optional[Dict[str, str]]   macro_definitions = None 
)
Simulator base class.

Optional sinks can be provided for capturing output. If not provided,
the simulator will write to log files in `run_dir`.

Args:
  sources: SourceFiles describing RTL/DPI inputs.
  run_dir: Directory where build/run artifacts are placed.
  debug: Enable cosim debug mode.
  run_stdout_callback: Line-based callback for runtime stdout.
  run_stderr_callback: Line-based callback for runtime stderr.
  compile_stdout_callback: Line-based callback for compile stdout.
  compile_stderr_callback: Line-based callback for compile stderr.
  make_default_logs: If True and corresponding callback is not supplied,
    create log file and emit via internally-created callback.
  macro_definitions: Optional dictionary of macro definitions to be defined
    during compilation.

Reimplemented in verilator.Verilator, and questa.Questa.

Definition at line 114 of file simulator.py.

Referenced by synth.LongestPathCollection.merge().

Member Function Documentation

◆ _start_process_with_callbacks()

int | tuple[subprocess.Popen, List[threading.Thread]] simulator.Simulator._start_process_with_callbacks (   self,
List[str]  cmd,
Optional[Dict[str, str]]  env,
Optional[Path]  cwd,
Optional[Callable[[str], None]]  stdout_cb,
Optional[Callable[[str], None]]  stderr_cb,
bool  wait 
)
protected
Start a subprocess and stream its stdout/stderr to callbacks.

If wait is True, blocks until process completes and returns its exit code.
If wait is False, returns the Popen object (threads keep streaming).

Definition at line 295 of file simulator.py.

References print().

Referenced by simulator.Simulator.compile(), and simulator.Simulator.run_proc().

◆ compile()

int simulator.Simulator.compile (   self)

◆ compile_commands()

List[List[str]] simulator.Simulator.compile_commands (   self)
Compile the sources. Returns the exit code of the simulation compiler.

Reimplemented in questa.Questa, and verilator.Verilator.

Definition at line 195 of file simulator.py.

Referenced by simulator.Simulator.compile().

◆ get_env()

Dict[str, str] simulator.Simulator.get_env ( )
static
Get the environment variables to locate shared objects.

Definition at line 185 of file simulator.py.

◆ run()

int simulator.Simulator.run (   self,
str  inner_command,
bool   gui = False,
bool   server_only = False 
)
Start the simulation then run the command specified. Kill the simulation
when the command exits.

Reimplemented in questa.Questa.

Definition at line 351 of file simulator.py.

References print(), and simulator.Simulator.run_proc().

◆ run_command()

List[str] simulator.Simulator.run_command (   self,
bool  gui 
)
Return the command to run the simulation.

Reimplemented in questa.Questa, and verilator.Verilator.

Definition at line 227 of file simulator.py.

Referenced by Python.setup.CustomBuild.run(), setup.CustomBuild.run(), and simulator.Simulator.run_proc().

◆ run_proc()

SimProcess simulator.Simulator.run_proc (   self,
bool   gui = False 
)
Run the simulation process. Returns the Popen object and the port which
  the simulation is listening on.

If user-provided stdout/stderr sinks were supplied in the constructor,
they are used. Otherwise, log files are created in `run_dir`.

Definition at line 231 of file simulator.py.

References simulator.Simulator._run_stderr_cb, simulator.Simulator._run_stdout_cb, simulator.Simulator._start_process_with_callbacks(), esi::CliParser.debug, esi::Logger.debug(), esi::Logger.debug(), simulator.Simulator.debug, simulator.is_port_open(), questa.Questa.run_command(), simulator.Simulator.run_command(), verilator.Verilator.run_command(), and simulator.Simulator.run_dir.

Referenced by simulator.Simulator.run().

Member Data Documentation

◆ _compile_stderr_cb

simulator.Simulator._compile_stderr_cb
protected

Definition at line 177 of file simulator.py.

Referenced by simulator.Simulator.compile().

◆ _compile_stderr_log

simulator.Simulator._compile_stderr_log
protected

Definition at line 177 of file simulator.py.

Referenced by simulator.Simulator.compile().

◆ _compile_stdout_cb

simulator.Simulator._compile_stdout_cb
protected

Definition at line 175 of file simulator.py.

Referenced by simulator.Simulator.compile().

◆ _compile_stdout_log

simulator.Simulator._compile_stdout_log
protected

Definition at line 175 of file simulator.py.

Referenced by simulator.Simulator.compile().

◆ _run_stderr_cb

simulator.Simulator._run_stderr_cb
protected

Definition at line 181 of file simulator.py.

Referenced by simulator.Simulator.run_proc().

◆ _run_stderr_log

simulator.Simulator._run_stderr_log
protected

Definition at line 181 of file simulator.py.

◆ _run_stdout_cb

simulator.Simulator._run_stdout_cb
protected

Definition at line 179 of file simulator.py.

Referenced by simulator.Simulator.run_proc().

◆ _run_stdout_log

simulator.Simulator._run_stdout_log
protected

Definition at line 179 of file simulator.py.

◆ debug

simulator.Simulator.debug

◆ macro_definitions

simulator.Simulator.macro_definitions

◆ run_dir

simulator.Simulator.run_dir

◆ sources

simulator.Simulator.sources

◆ UsesStderr

bool simulator.Simulator.UsesStderr = True
static

Definition at line 112 of file simulator.py.

Referenced by simulator.Simulator.compile().


The documentation for this class was generated from the following file: