You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document and demonstrate independent Python models for multiple VHDL instances #8
Add an example showing how multiple instances of the same VHDL component can run the same Python model with independent state.
The bridge runs one Python interpreter per simulation. Without explicit sessions, all calls use the default namespace, so loading multiple models with identical function and variable names can overwrite definitions or share state unintentionally.
The example should:
Instantiate the same VHDL model component twice.
Create a distinct session in each instance using new_session(model_entity'instance_name).
Load the same Python file into each session with exec_file.
Pass the session explicitly to every Python operation.
Drive the instances with different inputs and verify that their Python state remains independent.
Use a small stateful model, such as an accumulator or counter, so accidental sharing produces a clear test failure. Ensure file loading occurs after test_runner_setup when using testbench-relative paths.
Extend the documentation to explain:
Sessions isolate Python namespaces within a shared interpreter.
Sessions with the same identity refer to the same namespace; a fixed session name therefore does not isolate repeated component instances.
'instance_name provides a distinct hierarchical identity for each component instance.
Imported modules, sys.modules, sys.path, and other process-wide resources remain shared.
State held in an imported module’s globals is not isolated by sessions.
An alternative is to import a model class and create one object per session, keeping mutable model state on self.
Include a short example of the class-based approach alongside the runnable exec_file example, and mention that non-default sessions currently require NVC, GHDL, or Questa.
Acceptance criteria:
The runnable example verifies independent state for two instances of the same component.
Documentation covers both session-local file execution and per-instance Python objects.
Activity