|
wiRedPanda
Logic Circuit Simulator
|
Drives the circuit simulation across the waveform's time columns. More...
#include <WaveformSimulator.h>
Public Member Functions | |
| void | sweep (const QVector< DolphinModelBuilder::Row > &rows, int columns, const std::function< bool(int row, int col)> &readInput, const std::function< void(int row, int col, int value)> &writeOutput) const |
| Runs the simulation across columns time steps. | |
| WaveformSimulator (Scene *externalScene, Simulation *simulation) | |
| Constructs the driver for externalScene and its simulation. | |
Static Public Member Functions | |
| static QVector< Status > | captureInputs (const QVector< GraphicElementInput * > &inputs, int inputPorts) |
| Snapshots the live output-port state of every input element. | |
| static void | restoreInputs (const QVector< GraphicElementInput * > &inputs, const QVector< Status > &saved) |
| Restores input-port states previously captured by captureInputs(). | |
Drives the circuit simulation across the waveform's time columns.
Extracted from BewavedDolphin: this owns the circuit-coupled sweep logic — resetting sequential state, applying input values per time step, advancing the simulation, and reading back output statuses — while leaving the waveform model and its presentation to the caller via read/write callbacks.
Definition at line 31 of file WaveformSimulator.h.
| WaveformSimulator::WaveformSimulator | ( | Scene * | externalScene, |
| Simulation * | simulation ) |
Constructs the driver for externalScene and its simulation.
Definition at line 19 of file WaveformSimulator.cpp.
|
static |
Snapshots the live output-port state of every input element.
| inputs | Input elements to snapshot. |
| inputPorts | Total number of output ports across inputs (snapshot size). |
Definition at line 25 of file WaveformSimulator.cpp.
|
static |
Restores input-port states previously captured by captureInputs().
Definition at line 41 of file WaveformSimulator.cpp.
References qCDebug.
Referenced by BewavedDolphin::run(), and BewavedDolphin::saveToTxt().
| void WaveformSimulator::sweep | ( | const QVector< DolphinModelBuilder::Row > & | rows, |
| int | columns, | ||
| const std::function< bool(int row, int col)> & | readInput, | ||
| const std::function< void(int row, int col, int value)> & | writeOutput ) const |
Runs the simulation across columns time steps.
| rows | The table's row layout, in display order (DolphinModelBuilder::Row). |
| columns | Number of time-step columns to sweep. |
| readInput | Returns the input bit at (row, col) from the waveform model. |
| writeOutput | Stores the computed output bit at (row, col) into the model. |
Takes the row descriptors rather than the element vectors plus a row offset: a row's index, its element and its port all come from one place, so the sweep cannot drift out of step with the snapshot API (see DolphinModelBuilder::Row). Resets every element's sequential state before sweeping. Does not restore inputs — the caller pairs this with restoreInputs().
Definition at line 82 of file WaveformSimulator.cpp.
References DolphinModelBuilder::Input, DolphinModelBuilder::Output, qCDebug, and GraphicElement::Type.