20 : m_externalScene(externalScene)
21 , m_simulation(simulation)
27 QVector<Status> oldValues(inputPorts);
30 for (
auto *input : std::as_const(inputs)) {
31 for (
int port = 0; port < input->outputSize(); ++port) {
33 oldValues[oldIndex] = input->outputPort(port)->status();
43 qCDebug(zero) <<
"Restoring old values to inputs, prior to simulation.";
49 for (
auto *input : std::as_const(inputs)) {
50 for (
int port = 0; port < input->outputSize(); ++port) {
51 const Status savedStatus = saved.at(portIndex++);
59 if (savedStatus != Status::Active && savedStatus != Status::Inactive) {
60 if (
auto *outPort = input->outputPort(port)) {
61 outPort->setStatus(savedStatus);
66 const bool oldValue = (savedStatus == Status::Active);
67 if (input->outputSize() > 1) {
73 input->setOn(oldValue, port);
76 input->setOn(oldValue);
83 const std::function<
bool(
int row,
int col)> &readInput,
84 const std::function<
void(
int row,
int col,
int value)> &writeOutput)
const
87 qCDebug(zero) <<
"Creating class to pause main window simulator while creating waveform.";
100 QVector<Status> liveState;
101 for (
auto *elm : m_externalScene->elements()) {
103 elm->saveSimState(liveState);
106 auto restoreLiveState = qScopeGuard([
this, &liveState] {
108 for (
auto *elm : m_externalScene->elements()) {
110 elm->restoreSimState(liveState, cursor);
118 qCDebug(zero) <<
"Resetting simulation state of all elements.";
119 for (
auto *elm : m_externalScene->elements()) {
121 elm->resetSimState();
129 for (
int column = 0; column < columns; ++column) {
130 qCDebug(four) <<
"Itr: " << column <<
", rows: " << rows.size();
132 for (
int row = 0; row < rows.size(); ++row) {
133 const auto &descriptor = rows.at(row);
138 auto *input = qobject_cast<GraphicElementInput *>(descriptor.element);
140 input->setWaveformValue(readInput(row, column), descriptor.port);
144 qCDebug(four) <<
"Updating the values of the circuit logic based on current input values.";
145 m_simulation->update();
148 qCDebug(four) <<
"Setting the computed output values to the waveform results.";
149 for (
int row = 0; row < rows.size(); ++row) {
150 const auto &descriptor = rows.at(row);
154 const int value =
static_cast<int>(descriptor.element->inputPort(descriptor.port)->status());
155 writeOutput(row, column, value);
Common logging utilities, the Pandaception error type, and helper macros.
#define qCDebug(category)
Abstract base class for all graphical circuit elements.
Port classes: Port (base), InputPort, and OutputPort.
Main circuit editing scene with undo/redo and user interaction.
RAII guard that temporarily stops the simulation while in scope.
RAII guard that disables the visual refresh throttle while in scope.
Synchronous cycle-based simulation engine with event-driven clock support.
Main circuit editing scene.
RAII guard that stops the simulation on construction and restarts it on destruction.
RAII guard that disables the visual refresh throttle for the duration of its scope.
Manages the digital circuit simulation loop.