12#include <QCoreApplication>
92 const QVector<MappedPinSystemVerilog> &
inputMap()
const {
return m_inputMap; }
94 const QVector<MappedPinSystemVerilog> &
outputMap()
const {
return m_outputMap; }
102 static QString highLow(
Status val);
104 static QString removeForbiddenChars(
const QString &input);
106 static bool isSimpleIdentifier(
const QString &expr);
111 QString otherPortName(
Port *port);
113 QString otherPortNameImpl(
Port *port, QSet<Port *> &visited);
115 QString ensureSimpleSignal(
const QString &expr);
120 void assignVariablesRec(
const QVector<GraphicElement *> &elements);
122 void collectICTypes(
const QVector<GraphicElement *> &elements);
124 void declareAuxVariables();
126 void declareAuxVariablesRec(
const QVector<GraphicElement *> &elements);
128 void declareInputs();
130 void declareOutputs();
135 void emitSequentialBlock(
const QString &typeName,
136 const QString &clk,
const QString &rawPrst,
const QString &rawClr,
137 const std::function<
void()> &emitPresetBody,
138 const std::function<
void()> &emitClearBody,
139 const std::function<
void()> &emitNormalBody);
144 void generateICModules();
151 static QSet<GraphicElement *> findFeedbackElements(
const QVector<GraphicElement *> &elements);
158 QString generateLogicExpressionImpl(
GraphicElement *elm, QSet<Port *> &visited);
168 QHash<Port *, QString> m_varMap;
169 QHash<QString, InputPort *> m_txInputPorts;
170 QHash<QString, ICModuleInfo> m_icModules;
171 QHash<IC *, QString> m_instanceNames;
172 QStringList m_availablePins;
174 QTextStream m_stream;
175 QVector<MappedPinSystemVerilog> m_inputMap;
176 QVector<MappedPinSystemVerilog> m_outputMap;
177 const QVector<GraphicElement *> m_elements;
178 bool m_generatingICModule =
false;
179 int m_globalCounter = 1;
180 QSet<GraphicElement *> m_feedbackElements;
Central enumeration types for element types, groups, and signal status.
Abstract base class for all graphical circuit elements in wiRedPanda.
Graphic element representing an Integrated Circuit (sub-circuit) box.
QString m_varName
Generated internal signal name.
QString m_pin
Top-level module port name.
MappedPinSystemVerilog(GraphicElement *elm, const QString &pin, const QString &varName, Port *port, const int portNumber=0)
Constructs a pin mapping.
MappedPinSystemVerilog()=default
GraphicElement * m_elm
Owning graphic element.
int m_portNumber
Port index within the element.
Port * m_port
Source port in the circuit graph.
Abstract base class for circuit element ports (connection endpoints).
const QVector< MappedPinSystemVerilog > & inputMap() const
Returns the mapped input pins after generation.
SystemVerilogCodeGen(const QString &fileName, const QVector< GraphicElement * > &elements)
Constructs the code generator for the given output fileName and circuit elements.
void generate()
Generates the SystemVerilog output file for the circuit.
const QVector< MappedPinSystemVerilog > & outputMap() const
Returns the mapped output pins after generation.
const QString & moduleName() const
Returns the top-level module name derived from the file name.
Metadata for a single IC module during SystemVerilog hierarchical generation.
QString sourceFile
Original .panda file path (or blob name).
QString moduleName
Generated module identifier.
QVector< QString > inputNames
Port names for the module's inputs.
QVector< QString > outputNames
Port names for the module's outputs.
IC * prototypeIC
Representative IC element (used to inspect sub-circuit).
bool generated
True once the module body has been emitted.