CIRCT 24.0.0git
Loading...
Searching...
No Matches
Classes | Functions | Variables
simulator Namespace Reference

Classes

class  SimProcess
 
class  Simulator
 
class  SourceFiles
 

Functions

bool is_port_open (port)
 
List[str] supported_simulators ()
 
bool is_simulator_available (str name)
 
List[str] available_simulators ()
 
Dict[str, Optional[str]] load_macro_definitions (Path path)
 
Simulator get_simulator (str name, SourceFiles sources, Path rundir, bool debug, bool save_waveform=False, Optional[Dict[str, Optional[str]]] macro_definitions=None)
 

Variables

 _thisdir = Path(__file__).parent
 
 CosimCollateralDir = _thisdir
 
tuple _SUPPORTED_SIMULATORS = ("verilator", "questa")
 

Function Documentation

◆ available_simulators()

List[str] simulator.available_simulators ( )
Return the known simulator backends available in this environment.

Definition at line 53 of file simulator.py.

◆ get_simulator()

Simulator simulator.get_simulator ( str  name,
SourceFiles  sources,
Path  rundir,
bool  debug,
bool   save_waveform = False,
Optional[Dict[str, Optional[str]]]   macro_definitions = None 
)
Create a simulator backend.

Args:
  name: Simulator backend name.
  sources: SourceFiles describing RTL/DPI inputs.
  rundir: Directory where build/run artifacts are placed.
  debug: Enable cosim debug mode.
  save_waveform: Save simulator waveforms when debug mode is enabled.
  macro_definitions: Optional mapping of macro names to values. A value of
    None defines the macro without assigning a value.

Definition at line 572 of file simulator.py.

◆ is_port_open()

bool simulator.is_port_open (   port)
Check if a TCP port is open locally.

Definition at line 22 of file simulator.py.

◆ is_simulator_available()

bool simulator.is_simulator_available ( str  name)
Return True if the requested simulator backend is usable.

This checks the executable and environment conventions used by the Python
cosim backends, so pytest callers can skip simulator-backed tests before
generating or compiling hardware collateral.

Definition at line 35 of file simulator.py.

◆ load_macro_definitions()

Dict[str, Optional[str]] simulator.load_macro_definitions ( Path  path)
Read RTL macro definitions from a JSON file.

The file must hold an object mapping macro name to value, where null defines
the macro without assigning one::

    {"SPB_256BIT_DATA": "1", "SYNTHESIS": null}

This lets a source generator that only discovers its macros while running --
a build system reading its own project description, for instance -- hand them
to the simulator without the caller having to know them up front.

Args:
  path: The JSON file to read.

Returns:
  The macro mapping, suitable for `get_simulator`'s `macro_definitions`.

Raises:
  FileNotFoundError: If *path* does not exist.
  ValueError: If *path* is not a JSON object of name/value pairs.

Definition at line 528 of file simulator.py.

Referenced by test_macro_definitions.TestLoadMacroDefinitions.test_invalid_json_raises(), test_macro_definitions.TestLoadMacroDefinitions.test_loads_and_normalizes_scalar_values(), test_macro_definitions.TestLoadMacroDefinitions.test_missing_file_raises(), test_macro_definitions.TestLoadMacroDefinitions.test_non_object_json_raises(), and test_macro_definitions.TestLoadMacroDefinitions.test_non_scalar_value_raises().

◆ supported_simulators()

List[str] simulator.supported_simulators ( )
Return the simulator backends known to the ESI cosim runtime.

Definition at line 30 of file simulator.py.

Variable Documentation

◆ _SUPPORTED_SIMULATORS

tuple simulator._SUPPORTED_SIMULATORS = ("verilator", "questa")
protected

Definition at line 19 of file simulator.py.

◆ _thisdir

simulator._thisdir = Path(__file__).parent
protected

Definition at line 17 of file simulator.py.

◆ CosimCollateralDir

simulator.CosimCollateralDir = _thisdir

Definition at line 18 of file simulator.py.