wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
WaveformSimulator Class Reference

Drives the circuit simulation across the waveform's time columns. More...

#include <WaveformSimulator.h>

Public Member Functions

void sweep (const QVector< GraphicElementInput * > &inputs, const QVector< GraphicElement * > &outputs, int inputPorts, 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< StatuscaptureInputs (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().

Detailed Description

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 30 of file WaveformSimulator.h.

Constructor & Destructor Documentation

◆ WaveformSimulator()

WaveformSimulator::WaveformSimulator ( Scene * externalScene,
Simulation * simulation )

Constructs the driver for externalScene and its simulation.

Definition at line 16 of file WaveformSimulator.cpp.

Member Function Documentation

◆ captureInputs()

QVector< Status > WaveformSimulator::captureInputs ( const QVector< GraphicElementInput * > & inputs,
int inputPorts )
static

Snapshots the live output-port state of every input element.

Parameters
inputsInput elements to snapshot.
inputPortsTotal number of output ports across inputs (snapshot size).
Returns
Port-indexed states, to be restored after a sweep via restoreInputs().

Definition at line 22 of file WaveformSimulator.cpp.

◆ restoreInputs()

void WaveformSimulator::restoreInputs ( const QVector< GraphicElementInput * > & inputs,
const QVector< Status > & saved )
static

Restores input-port states previously captured by captureInputs().

Definition at line 38 of file WaveformSimulator.cpp.

References qCDebug.

Referenced by BewavedDolphin::run(), and BewavedDolphin::saveToTxt().

◆ sweep()

void WaveformSimulator::sweep ( const QVector< GraphicElementInput * > & inputs,
const QVector< GraphicElement * > & outputs,
int inputPorts,
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.

Parameters
inputsInput elements, in row order.
outputsOutput elements, in row order.
inputPortsNumber of input rows (offset of the first output row).
columnsNumber of time-step columns to sweep.
readInputReturns the input bit at (row, col) from the waveform model.
writeOutputStores the computed output bit at (row, col) into the model.

Resets every element's sequential state before sweeping. Does not restore inputs — the caller pairs this with restoreInputs().

Definition at line 58 of file WaveformSimulator.cpp.

References qCDebug, and GraphicElement::Type.


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