From 05e27088d358b4fc1b4f7d6b64fe4d0c88bc290c Mon Sep 17 00:00:00 2001 From: Stelios Karagiorgis Date: Wed, 30 Aug 2023 20:02:02 +0300 Subject: [PATCH 1/6] Update vsrtl_interface.h Add to set if a component as active path, active finite state machine(fsm) for this state or the component was active fsm Add also to check if a component is active path, active finite state machine(fsm) for this state or the component was active fsm --- interface/vsrtl_interface.h | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/interface/vsrtl_interface.h b/interface/vsrtl_interface.h index 3cdc941..0061ee4 100644 --- a/interface/vsrtl_interface.h +++ b/interface/vsrtl_interface.h @@ -103,6 +103,10 @@ class SimPort : public SimBase { virtual unsigned int getWidth() const = 0; virtual VSRTL_VT_U uValue() const = 0; virtual VSRTL_VT_S sValue() const = 0; + virtual bool isActivePath() const = 0; + virtual void setActivePath(bool value) = 0; + virtual bool isActiveFsm() const = 0; + virtual void setActiveFsm(bool value) = 0; template std::vector getOutputPorts() { @@ -498,6 +502,29 @@ class SimComponent : public SimBase { } m_synchronous = s; } + void setComponentActivePath(bool value){ + m_activeComp = value; + } + + bool isComponentActivePath(){ + return m_activeComp; + } + void setComponentActiveFsmCol(bool value){ + m_activeCompFsmCol = value; + } + + bool isComponentActiveFsmCol(){ + return m_activeCompFsmCol; + } + + void setComponentActiveFsm(bool value){ + m_activeCompFsm = value; + } + + bool isComponentActiveFsm(){ + return m_activeCompFsm; + } + bool isSynchronous() const { return m_synchronous != nullptr; } SimSynchronous* getSynchronous() { return m_synchronous; } @@ -513,7 +540,9 @@ class SimComponent : public SimBase { std::set, ComponentCompT> m_subcomponents; std::set> m_parameters; std::map m_specialPorts; - + bool m_activeComp = false; + bool m_activeCompFsm = false; + bool m_activeCompFsmCol = false; private: unsigned m_constantCount = 0; // Number of constants currently initialized in the component SimSynchronous* m_synchronous = nullptr; From 06ad33c6714c3db37781450b699e83eb1c3950bb Mon Sep 17 00:00:00 2001 From: Stelios Karagiorgis Date: Wed, 30 Aug 2023 20:04:44 +0300 Subject: [PATCH 2/6] Update portgrafic If a port is on the active path or FSM then it will set the colour of the port --- graphics/vsrtl_portgraphic.cpp | 47 ++++++++++++++++++++++++++++++---- graphics/vsrtl_portgraphic.h | 2 ++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/graphics/vsrtl_portgraphic.cpp b/graphics/vsrtl_portgraphic.cpp index d813169..5e0ca28 100644 --- a/graphics/vsrtl_portgraphic.cpp +++ b/graphics/vsrtl_portgraphic.cpp @@ -264,13 +264,50 @@ void PortGraphic::updatePenColor() { } else { m_pen.setWidth(WIRE_WIDTH); if (m_port->getWidth() == 1) { - if (static_cast(m_port->uValue())) { - m_pen.setColor(WIRE_BOOLHIGH_COLOR); - } else { - m_pen.setColor(WIRE_DEFAULT_COLOR); + if(!QString::fromStdString(m_port->getHierName()).contains("MIPS")){ + if (static_cast(m_port->uValue())) { + m_pen.setColor(WIRE_BOOLHIGH_COLOR); + } else { + m_pen.setColor(WIRE_DEFAULT_COLOR); + } + } + + else{ + if(m_port->isActivePath()){ + m_pen.setColor(WIRE_BOOLHIGH_COLOR); + } + else{ + if (static_cast(m_port->uValue())) { + m_pen.setColor(WIRE_BOOLHIGH_COLOR); + } else { + m_pen.setColor(WIRE_DEFAULT_COLOR); + } + } } } else { - m_pen.setColor(m_penColor); + if(QString::fromStdString(m_port->getHierName()).contains("MIPS")){ + if(m_port->isActivePath()){ + if(QString::fromStdString(m_port->getHierName()).contains("control->alu_ctrl") || QString::fromStdString(m_port->getHierName()).contains("alu_control->res") + || QString::fromStdString(m_port->getHierName()).contains("alu_control_reg->out") || QString::fromStdString(m_port->getHierName()).contains("control")){ + m_pen.setColor(WIRE_BOOLHIGH_COLOR); + }else{ + + m_pen.setColor(WIRE_HIGH_COLOR); + } + + } + else if(!m_port->isActivePath()){ + m_pen.setColor(WIRE_DEFAULT_COLOR); + } + else{ + m_pen.setColor(WIRE_DEFAULT_COLOR); + } + } + else{ + m_pen.setColor(m_penColor); + } + + } } propagateRedraw(); diff --git a/graphics/vsrtl_portgraphic.h b/graphics/vsrtl_portgraphic.h index 3863a2d..986fced 100644 --- a/graphics/vsrtl_portgraphic.h +++ b/graphics/vsrtl_portgraphic.h @@ -111,6 +111,8 @@ private slots: bool m_signalSelected = false; bool m_hoverActive = false; + bool m_activePath = false; + /** * @brief m_sourceVisible (for input ports) * true if the outport which this inputport connects to, is visible. If not, the port shall not be drawn. However, From 57c01892a799757d64eb483f0f85a18944bbfb78 Mon Sep 17 00:00:00 2001 From: Stelios Karagiorgis Date: Wed, 30 Aug 2023 20:06:24 +0300 Subject: [PATCH 3/6] Update vsrtl_port.h The changes of active path will not affect RISCV processors --- core/vsrtl_port.h | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/core/vsrtl_port.h b/core/vsrtl_port.h index b71ad1c..a37a0d4 100644 --- a/core/vsrtl_port.h +++ b/core/vsrtl_port.h @@ -12,6 +12,8 @@ #include "../interface/vsrtl_binutils.h" #include "../interface/vsrtl_interface.h" +#include "../graphics/vsrtl_label.h" + namespace vsrtl { namespace core { @@ -40,6 +42,11 @@ class PortBase : public SimPort { virtual void propagateConstant() = 0; virtual void setPortValue() = 0; virtual bool isConnected() const = 0; + virtual bool isActivePath() const = 0; + virtual void setActivePath(bool value) = 0; + virtual bool isActiveFsm() const = 0; + virtual void setActiveFsm(bool value) = 0; + /** * @brief stringValue @@ -62,6 +69,7 @@ class Port : public PortBase { Port(const std::string& name, SimComponent* parent, PortType type) : PortBase(name, parent, type) {} bool isConnected() const override { return m_inputPort != nullptr || m_propagationFunction; } + // Port connections are doubly linked void operator>>(Port& toThis) { m_outputPorts.push_back(&toThis); @@ -85,6 +93,20 @@ class Port : public PortBase { explicit operator VSRTL_VT_S() const { return signextend(m_value); } + bool isActivePath() const override { return m_activePath; } + + bool isActiveFsm() const override { return m_activeFsm; } + + void setActivePath(bool value) { + m_activePath = value; + + } + + void setActiveFsm(bool value) { + m_activeFsm = value; + } + + void setPortValue() override { auto prePropagateValue = m_value; if (m_propagationFunction) { @@ -92,12 +114,26 @@ class Port : public PortBase { } else { m_value = getInputPort>()->uValue(); } - if (m_value != prePropagateValue) { - // Signal all watcher of this port that the port value changed + QString port =QString::fromStdString(getHierName()); + + if(port.contains("MIPS")){ if (getDesign()->signalsEnabled()) { changed.Emit(); } } + else{ + if (m_value != prePropagateValue) { + // Signal all watcher of this port that the port value changed + if (getDesign()->signalsEnabled()) { + changed.Emit(); + } + } + } + + + + + } void propagate(std::vector& propagationStack) override { @@ -133,6 +169,8 @@ class Port : public PortBase { // not be the case - the entire circuit is reset when the registers are reset (to 0), and the circuit state is // then propagated. VSRTL_VT_U m_value = 0xdeadbeef; + bool m_activePath = false; + bool m_activeFsm = false; std::function m_propagationFunction = {}; }; From 82f136679ece8cf77125b0cba7a6bd58491b9f15 Mon Sep 17 00:00:00 2001 From: Stelios Karagiorgis Date: Thu, 31 Aug 2023 13:55:24 +0300 Subject: [PATCH 4/6] Update label getText rerurn the label of the port --- graphics/vsrtl_label.cpp | 18 ++++++++++++++++++ graphics/vsrtl_label.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/graphics/vsrtl_label.cpp b/graphics/vsrtl_label.cpp index 111ac0a..4a251bb 100644 --- a/graphics/vsrtl_label.cpp +++ b/graphics/vsrtl_label.cpp @@ -12,6 +12,8 @@ #include "vsrtl_labeleditdialog.h" #include "vsrtl_scene.h" +#include "../interface/vsrtl_interface.h" +#include "../VSRTL/core/vsrtl_port.h" namespace vsrtl { @@ -40,6 +42,15 @@ void Label::setText(const QString& text) { applyFormatChanges(); } +QString Label::getText() { + QString text = toPlainText(); + return text; +} + +void Label::setActive(bool value){ + m_active = value; +} + void Label::updateText() {} void Label::setPointSize(int size) { @@ -95,6 +106,13 @@ void Label::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWi if (!m_defaultColorOverridden) { setDefaultTextColor(static_cast(scene())->darkmode() ? Qt::white : Qt::black); } + if(m_active){ + setDefaultTextColor(static_cast(scene())->darkmode() ? Qt::white : Qt::black); + } + else{ + setDefaultTextColor(static_cast(scene())->darkmode() ? Qt::darkGray : Qt::white); + } + QGraphicsTextItem::paint(painter, option, w); painter->restore(); diff --git a/graphics/vsrtl_label.h b/graphics/vsrtl_label.h index 8b4dfde..49b6c08 100644 --- a/graphics/vsrtl_label.h +++ b/graphics/vsrtl_label.h @@ -2,6 +2,8 @@ #include "vsrtl_graphicsbaseitem.h" #include "vsrtl_qt_serializers.h" +#include "vsrtl_component.h" +#include "vsrtl_port.h" #include "cereal/cereal.hpp" @@ -23,6 +25,7 @@ class Label : public GraphicsBaseItem { void setHoverable(bool enabled); void setText(const QString& text); + QString getText(); void setAlignment(Qt::Alignment alignment); void setPointSize(int size); void setLocked(bool locked) override; @@ -99,10 +102,15 @@ class Label : public GraphicsBaseItem { applyFormatChanges(); } + void setActive(bool value); + + bool isActive(); + protected: void applyFormatChanges(); void editTriggered(); + bool m_active = true; bool m_hoverable = true; QFont m_font; bool m_defaultColorOverridden = false; From 2f09e8cd783ecbd4f79058ee7e015d1eafbd9aa6 Mon Sep 17 00:00:00 2001 From: Stelios Karagiorgis Date: Thu, 31 Aug 2023 13:56:24 +0300 Subject: [PATCH 5/6] Update vsrtl_component.h Add methods for component for active path and active fsm --- core/vsrtl_component.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/core/vsrtl_component.h b/core/vsrtl_component.h index 983c7d4..208900d 100644 --- a/core/vsrtl_component.h +++ b/core/vsrtl_component.h @@ -14,9 +14,13 @@ #include "../interface/vsrtl_binutils.h" #include "../interface/vsrtl_defines.h" #include "vsrtl_addressspace.h" +#include "../interface/vsrtl_interface.h" #include "vsrtl_port.h" +#include "../graphics/vsrtl_gridcomponent.h" +#include "../graphics/vsrtl_graphicsbase.h" #include "../interface/vsrtl_gfxobjecttypes.h" +#include "../graphics/vsrtl_label.h" namespace vsrtl { namespace core { @@ -61,6 +65,30 @@ class Component : public SimComponent { void setSensitiveTo(const PortBase* p) { m_sensitivityList.push_back(p); } void setSensitiveTo(const PortBase& p) { setSensitiveTo(&p); } + + bool isCompActivePath() const { return m_compActivePath; } + + void setCompActivePath(bool value) { + m_compActivePath = value; + setComponentActivePath(value); + } + + bool isCompActiveFsm() const { return m_compActiveFsm; } + + void setCompActiveFsm(bool value) { + m_compActiveFsm = value; + setComponentActiveFsm(value); + } + + bool isCompActiveFsmCol() const { return m_compActiveFsmCol; } + + void setCompActiveFsmCol(bool value) { + m_compActiveFsmCol = value; + setComponentActiveFsmCol(value); + } + + + template Port& createInputPort(const std::string& name) { return createPort(name, m_inputPorts, vsrtl::SimPort::PortType::in); @@ -258,6 +286,10 @@ class Component : public SimComponent { return ports; } + bool m_compActivePath = false; + bool m_compActiveFsm = false; + bool m_compActiveFsmCol = false; + std::vector m_sensitivityList; PropagationState m_propagationState = PropagationState::unpropagated; }; From b402c015f4f784d597bc84329c7b3c9c25b81c5f Mon Sep 17 00:00:00 2001 From: Stelios Karagiorgis Date: Thu, 31 Aug 2023 13:57:15 +0300 Subject: [PATCH 6/6] Update vsrtl_componentgraphic.cpp Set colour the component if it is active without affect RISCV processors --- graphics/vsrtl_componentgraphic.cpp | 110 ++++++++++++++++++++++------ 1 file changed, 89 insertions(+), 21 deletions(-) diff --git a/graphics/vsrtl_componentgraphic.cpp b/graphics/vsrtl_componentgraphic.cpp index 4a1e9ec..ab76119 100644 --- a/graphics/vsrtl_componentgraphic.cpp +++ b/graphics/vsrtl_componentgraphic.cpp @@ -521,33 +521,101 @@ QVariant ComponentGraphic::itemChange(QGraphicsItem::GraphicsItemChange change, } void ComponentGraphic::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* w) { - painter->save(); - QColor color; - if (static_cast(scene())->darkmode()) { - color = hasSubcomponents() && isExpanded() ? QColorConstants::DarkGray.darker() : QColor{0x80, 0x84, 0x8a}; - } else { - color = hasSubcomponents() && isExpanded() ? QColor{0xec, 0xf0, 0xf1} : QColorConstants::White; + if(QString::fromStdString(m_component->getHierName()).contains("MIPS")){ + painter->save(); + + QColor color; + if (static_cast(scene())->darkmode() ) { + color = hasSubcomponents() && isExpanded() ? QColorConstants::DarkGray.darker() : QColor{0x80, 0x84, 0x8a}; + } else { + color = hasSubcomponents() && isExpanded() ? QColor{0xec, 0xf0, 0xf1} : QColorConstants::White; + } + + QColor fillColor = (option->state & QStyle::State_Selected) ? color.darker(150) : color; + if (option->state & QStyle::State_MouseOver) + fillColor = fillColor.lighter(125); + constexpr QColor WIRE_BOOLHIGH_COLOR = {0x6E, 0xEB, 0x83}; + if(m_component->isComponentActiveFsmCol()){ + fillColor = WIRE_BOOLHIGH_COLOR; + } + + // Draw component outline + QPen oldPen = painter->pen(); + QPen pen = oldPen; + int width = COMPONENT_BORDER_WIDTH; + if (option->state & QStyle::State_Selected) + width += 1; + + if(!m_component->isComponentActivePath() && !m_component->isComponentActiveFsm() ){ + fillColor = color.darker(250); + } + + if(m_label->getText().contains("Processor")){ + fillColor = fillColor.lighter(250); + } + + if(m_component->isComponentActiveFsmCol()){ + fillColor = WIRE_BOOLHIGH_COLOR.darker(125); + } + + pen.setWidth(width); + painter->setBrush(QBrush(fillColor.darker((option->state & QStyle::State_Sunken) ? 120 : 100))); + if(!m_component->isComponentActivePath()){ + painter->setPen(pen); + painter->setPen(QColorConstants::LightGray); + } + + + if(m_component->isComponentActiveFsm()){ + painter->setPen(pen); + + painter->setPen(WIRE_BOOLHIGH_COLOR); + width += 1; + pen.setWidth(width); + } + else{ + width = COMPONENT_BORDER_WIDTH; + pen.setWidth(width); + + } + + + painter->drawPath(m_shape); + + painter->setPen(oldPen); } - QColor fillColor = (option->state & QStyle::State_Selected) ? color.darker(150) : color; - if (option->state & QStyle::State_MouseOver) - fillColor = fillColor.lighter(125); - const qreal lod = option->levelOfDetailFromTransform(painter->worldTransform()); + else{ + painter->save(); + QColor color; + if (static_cast(scene())->darkmode()) { + color = hasSubcomponents() && isExpanded() ? QColorConstants::DarkGray.darker() : QColor{0x80, 0x84, 0x8a}; + } else { + color = hasSubcomponents() && isExpanded() ? QColor{0xec, 0xf0, 0xf1} : QColorConstants::White; + } - // Draw component outline - QPen oldPen = painter->pen(); - QPen pen = oldPen; - int width = COMPONENT_BORDER_WIDTH; - if (option->state & QStyle::State_Selected) - width += 1; + QColor fillColor = (option->state & QStyle::State_Selected) ? color.darker(150) : color; + if (option->state & QStyle::State_MouseOver) + fillColor = fillColor.lighter(125); - pen.setWidth(width); - painter->setBrush(QBrush(fillColor.darker((option->state & QStyle::State_Sunken) ? 120 : 100))); - painter->setPen(pen); - painter->drawPath(m_shape); - painter->setPen(oldPen); + // Draw component outline + QPen oldPen = painter->pen(); + QPen pen = oldPen; + int width = COMPONENT_BORDER_WIDTH; + if (option->state & QStyle::State_Selected) + width += 1; + + pen.setWidth(width); + painter->setBrush(QBrush(fillColor.darker((option->state & QStyle::State_Sunken) ? 120 : 100))); + painter->setPen(pen); + painter->drawPath(m_shape); + + painter->setPen(oldPen); + + } + const qreal lod = option->levelOfDetailFromTransform(painter->worldTransform()); if (hasSubcomponents()) { if (lod >= 0.35) {