15 for (
int i = 0; i < m_outputs.size(); ++i) {
16 const Status def = (i < outputPorts.size())
17 ? outputPorts.at(i)->defaultValue()
19 m_outputs[i] = (def == Status::Unknown) ? Status::Inactive : def;
21 m_outputChanged =
true;
26 if (inputIndex >= m_connections.size()) {
29 m_connections[inputIndex] = {source, outputPort};
34 m_connections.fill({}, inputCount);
35 m_inputs.fill(Status::Inactive, inputCount);
36 m_outputs.resize(outputCount);
37 m_staged.resize(outputCount);
38 m_deferCommit =
false;
42 for (
int i = 0; i < outputCount; ++i) {
43 if (i < outputPorts.size()) {
44 const Status def = outputPorts.at(i)->defaultValue();
45 m_outputs[i] = (def == Status::Unknown) ? Status::Inactive : def;
47 m_outputs[i] = Status::Inactive;
50 m_outputChanged =
false;
55 for (
int index = 0; index < m_connections.size(); ++index) {
56 auto *pred = m_connections.at(index).sourceElement;
59 val = pred->outputValue(m_connections.at(index).sourceOutputIndex);
61 if (index < inputPorts.size() && inputPorts.at(index)->connections().size() > 1) {
65 val = (index < inputPorts.size()) ? inputPorts.at(index)->defaultValue() : Status::Unknown;
71 const bool shouldFail = allowUnknown ? (val == Status::Unknown && !pred)
72 : (val == Status::Unknown || val == Status::Error);
74 for (
auto &out : m_outputs) {
75 if (out != Status::Unknown) {
76 m_outputChanged =
true;
78 out = Status::Unknown;
82 m_inputs[index] = val;
90 for (
int i = 0; i < count; i++) {
91 if (m_inputs.at(offset + i) == Status::Active) {
92 selectValue |= (1 << i);
Per-element simulation runtime state (input/output values and the connection graph).
Abstract base class for all graphical circuit elements.
Port classes: Port (base), InputPort, and OutputPort.
bool updateInputs(bool allowUnknown, const QVector< InputPort * > &inputPorts)
Snapshots each predecessor's output into the input cache, reading inputPorts for unconnected-input de...
void reset(const QVector< OutputPort * > &outputPorts)
Resets each output slot to its port's power-on default (Unknown coerced to Inactive).
int decodeSelectValue(int offset, int count) const
Decodes count select-line statuses starting at offset into a binary index.
void initVectors(int inputCount, int outputCount, const QVector< OutputPort * > &outputPorts)
Allocates the I/O vectors and seeds outputs from outputPorts default statuses.
void connectPredecessor(int inputIndex, GraphicElement *source, int outputPort)
Records that simulation input inputIndex is driven by source output outputPort.
Abstract base class for all graphical circuit elements in wiRedPanda.