The simulator can be obtained from the HWSystem.
The current simulator is implemented as a cycle based simulator. You basically call the method clk to advance the number of clocks you want.
import py4hw
sys = py4hw.HWSystem()
sim = sys.getSimulator()
sim.clk(1)
The simulator object has the following fields and methods
| Field | Description |
|---|---|
| total_clks | The number of clocks run from the initial time of the session |
| sys | The HWSystem associated with the simulator |
| listeners | A list of the objects that listen to simulator events |
| Method | Description |
|---|---|
| init | Constructor |
| propagateAll | Propagates all combinational circuits |
| topologicalSort | We segment the circuit by clock drivers. Sorts all the elements of the circuit so that cycle-base simulation is possible. Clockables do not require any order. Propagatables must be sorted in propagation order, so when we insert we should check if there are elements in the list that depend on the current item, and in this case we should place it before them |
| getOrCreateClockDriverSimulator | get a clock driver simulator |
| findFirstDependentPosition | We look at the outputs of the provided circuit and find all the dependent cells, then we locate them in |
| clk | Advance a number of clock cycles |
| _clk_cycle | Advance one clock cycle |
| stop | Stop the simulation |
| addListener | Add a listener of the simulator events |
| _notifyListeners | Notify the listeners of a simulator event |