Add register file view in Editor tab
MODIFY
src/edittab.cpp
src/edittab.cpp
@@ -51,6 +51,10 @@ EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent)
connect(m_buildAction, &QAction::triggered, this, &EditTab::compile);
m_toolbar->addAction(m_buildAction);
+ connect(RipesSettings::getObserver(RIPES_SETTING_EDITORREGS), &SettingObserver::modified,
+ [=](const QVariant& val) { m_ui->registers->setVisible(val.toBool()); });
+ RipesSettings::getObserver(RIPES_SETTING_EDITORREGS)->trigger();
+
connect(m_ui->enableEditor, &QPushButton::clicked, this, &EditTab::enableAssemblyInput);
connect(m_ui->codeEditor, &CodeEditor::timedTextChanged, this, &EditTab::sourceCodeChanged);
@@ -79,6 +83,10 @@ EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent)
sourceTypeChanged();
enableEditor();
+ m_ui->splitter->setStretchFactor(0, 2);
+ m_ui->splitter->setStretchFactor(1, 2);
+ m_ui->splitter->setStretchFactor(2, 0);
+
// State preservation
connect(RipesSettings::getObserver(RIPES_GLOBALSIGNAL_QUIT), &SettingObserver::modified, [=] {
RipesSettings::setValue(RIPES_SETTING_SOURCECODE, m_ui->codeEditor->document()->toPlainText());

MODIFY
src/edittab.ui
src/edittab.ui
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <widget class="QStackedWidget" name="stackedWidget_2">
- <property name="currentIndex">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
- <widget class="QWidget" name="page_3">
- <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="childrenCollapsible">
- <bool>false</bool>
- </property>
<widget class="QWidget" name="verticalLayoutWidget">
<layout class="QVBoxLayout" name="editorLayout">
<item>
</item>
</layout>
</widget>
+ <widget class="RegisterContainerWidget" name="registers" native="true"/>
</widget>
</item>
</layout>
</widget>
- <widget class="QWidget" name="page_4"/>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
<customwidgets>
<customwidget>
<class>CodeEditor</class>
<extends>QPlainTextEdit</extends>
<header>programviewer.h</header>
</customwidget>
+ <customwidget>
+ <class>RegisterContainerWidget</class>
+ <extends>QWidget</extends>
+ <header>registercontainerwidget.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>

MODIFY
src/isa/isainfo.h
src/isa/isainfo.h
@@ -13,9 +13,15 @@ namespace Ripes {
enum class ISA { RV32I, RV64I };
const static std::map<ISA, QString> ISAFamilyNames = {{ISA::RV32I, "RISC-V"}, {ISA::RV64I, "RISC-V"}};
enum class RegisterFileType { GPR, FPR, CSR };
-const static std::map<RegisterFileType, QString> s_RegsterFileName = {{RegisterFileType::GPR, "GPR"},
- {RegisterFileType::FPR, "FPR"},
- {RegisterFileType::CSR, "CSR"}};
+struct RegisterFileName {
+ QString shortName;
+ QString longName;
+};
+
+const static std::map<RegisterFileType, RegisterFileName> s_RegsterFileName = {
+ {RegisterFileType::GPR, {"GPR", "General purpose registers"}},
+ {RegisterFileType::FPR, {"FPR", "Floating-point registers"}},
+ {RegisterFileType::CSR, {"CSR", "Control and status registers"}}};
class ISAInfoBase {
public:

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -90,7 +90,6 @@ ProcessorTab::ProcessorTab(QToolBar* controlToolbar, QToolBar* additionalToolbar
m_stageModel = new PipelineDiagramModel(this);
updateInstructionModel();
- m_ui->registerContainerWidget->initialize();
connect(ProcessorHandler::get(), &ProcessorHandler::procStateChangedNonRun, this, &ProcessorTab::updateStatistics);
connect(ProcessorHandler::get(), &ProcessorHandler::procStateChangedNonRun, this,
&ProcessorTab::updateInstructionLabels);
@@ -349,7 +348,6 @@ void ProcessorTab::processorSelection() {
loadProcessorToWidget(diag.getSelectedLayout());
m_vsrtlWidget->reset();
updateInstructionModel();
- m_ui->registerContainerWidget->initialize();
// Retrigger value display action if enabled
if (m_displayValuesAction->isChecked()) {

MODIFY
src/registercontainerwidget.cpp
src/registercontainerwidget.cpp
@@ -11,6 +11,8 @@ RegisterContainerWidget::RegisterContainerWidget(QWidget* parent)
m_ui->setupUi(this);
connect(ProcessorHandler::get(), &ProcessorHandler::procStateChangedNonRun, this,
&RegisterContainerWidget::updateView);
+ connect(ProcessorHandler::get(), &ProcessorHandler::processorChanged, this, &RegisterContainerWidget::initialize);
+ initialize();
}
RegisterContainerWidget::~RegisterContainerWidget() {
@@ -22,7 +24,9 @@ void RegisterContainerWidget::initialize() {
for (const auto& rfid : ProcessorHandler::getProcessor()->registerFiles()) {
auto registerWidget = new RegisterWidget(rfid, this);
- m_ui->tabWidget->insertTab(m_ui->tabWidget->count(), registerWidget, s_RegsterFileName.at(rfid));
+ const unsigned tabIdx = m_ui->tabWidget->count();
+ m_ui->tabWidget->insertTab(tabIdx, registerWidget, s_RegsterFileName.at(rfid).shortName);
+ m_ui->tabWidget->setTabToolTip(tabIdx, s_RegsterFileName.at(rfid).longName);
registerWidget->initialize();
}
updateView();

MODIFY
src/registercontainerwidget.h
src/registercontainerwidget.h
@@ -15,10 +15,9 @@ public:
explicit RegisterContainerWidget(QWidget* parent = nullptr);
~RegisterContainerWidget();
+private:
void initialize();
void updateView();
-
-private:
Ui::RegisterContainerWidget* m_ui;
};

MODIFY
src/ripessettings.cpp
src/ripessettings.cpp
@@ -26,6 +26,7 @@ const std::map<QString, QVariant> s_defaultSettings = {
{RIPES_SETTING_ASSEMBLER_DATASTART, 0x10000000},
{RIPES_SETTING_ASSEMBLER_BSSSTART, 0x11000000},
{RIPES_SETTING_PERIPHERALS_START, static_cast<unsigned>(0xF0000000)},
+ {RIPES_SETTING_EDITORREGS, true},
{RIPES_SETTING_PIPEDIAGRAM_MAXCYCLES, 100},
{RIPES_SETTING_CACHE_MAXCYCLES, 10000},

MODIFY
src/ripessettings.h
src/ripessettings.h
@@ -45,6 +45,7 @@ namespace Ripes {
#define RIPES_SETTING_SOURCECODE ("sourcecode")
#define RIPES_SETTING_DARKMODE ("darkmode")
#define RIPES_SETTING_AUTOCLOCK_INTERVAL ("autoclock_interval")
+#define RIPES_SETTING_EDITORREGS ("editor_regs")
#define RIPES_SETTING_HAS_SAVEFILE ("has_savefile")
#define RIPES_SETTING_SAVEPATH ("savepath")

MODIFY
src/settingsdialog.cpp
src/settingsdialog.cpp
@@ -286,6 +286,11 @@ QWidget* SettingsDialog::createEditorPage() {
indentSpinbox->setRange(0, 100);
appendToLayout({indentLabel, indentSpinbox}, pageLayout, "Indent size (in spaces) of tab characters.");
+ auto [regsLabel, regsCheckbox] =
+ createSettingsWidgets<QCheckBox>(RIPES_SETTING_EDITORREGS, "Show registers in editor tab");
+ appendToLayout({regsLabel, regsCheckbox}, pageLayout,
+ "Show (or hide) a view of the processor register file(s) in the editor tab.");
+
return pageWidget;
}

Add register file view in Editor tab