summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbd <bdunaisky@umass.edu>2025-04-21 20:01:34 +0000
committerGitHub <noreply@github.com>2025-04-21 20:01:34 +0000
commit282e2644ef0470133184fdf9900cf2565ec5332b (patch)
tree43238110a03ce678f1a68b0b4175ae023527b070
parent4a19129e8499bc187ef6e296e050cc8a20bcc2d3 (diff)
parentd933a0405b7a7dff3cf05839ac99d120cafa4d75 (diff)
Merge pull request #56 from bdunahu/dev-sid
Dev sid
-rw-r--r--gui/CMakeLists.txt2
-rw-r--r--gui/digitlabel.cc52
-rw-r--r--gui/digitlabel.h69
-rw-r--r--gui/dynamicwaysentry.cc99
-rw-r--r--gui/dynamicwaysentry.h51
-rw-r--r--gui/gui.cc544
-rw-r--r--gui/gui.h257
-rw-r--r--gui/gui.ui1030
-rw-r--r--gui/main.cc14
-rw-r--r--gui/messages.h71
-rw-r--r--gui/resources.qrc9
-rw-r--r--gui/resources/BigBlueTermPlusNerdFont-Regular.ttfbin0 -> 2261980 bytes
-rw-r--r--gui/resources/BigBlueTermPlusNerdFontMono-Regular.ttfbin0 -> 2241472 bytes
-rw-r--r--gui/resources/BigBlueTermPlusNerdFontPropo-Regular.ttfbin0 -> 2284260 bytes
-rw-r--r--gui/resources/angry.pngbin0 -> 319 bytes
-rw-r--r--gui/resources/busy.pngbin0 -> 329 bytes
-rw-r--r--gui/resources/happy.pngbin0 -> 322 bytes
-rw-r--r--gui/resources/idle.pngbin0 -> 322 bytes
-rw-r--r--gui/resources/input.txt1
-rw-r--r--gui/resources/styles.qss167
-rw-r--r--gui/worker.cc101
-rw-r--r--gui/worker.h90
-rw-r--r--inc/pipe_spec.h10
-rw-r--r--src/sim/id.cc2
-rw-r--r--src/sim/if.cc2
-rw-r--r--src/sim/stage.cc2
26 files changed, 1610 insertions, 963 deletions
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 0d73527..2c48beb 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -21,7 +21,7 @@ file(GLOB SRCS
qt_add_resources(GUI_RESOURCES "resources.qrc")
add_executable(risc_vector ${SRCS} ${GUI_RESOURCES})
-target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/inc)
+target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/inc ${PROJECT_SOURCE_DIR}/gui)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}_lib ram_lib Qt6::Widgets)
set_target_properties(risc_vector PROPERTIES
diff --git a/gui/digitlabel.cc b/gui/digitlabel.cc
new file mode 100644
index 0000000..8314943
--- /dev/null
+++ b/gui/digitlabel.cc
@@ -0,0 +1,52 @@
+// Simulator for the RISC-V[ECTOR] mini-ISA
+// Copyright (C) 2025 Siddarth Suresh
+// Copyright (C) 2025 bdunahu
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#include "digitlabel.h"
+#include "gui.h"
+
+DigitLabel::DigitLabel(QWidget *parent) : QLabel(parent) { setText(QString()); }
+
+void DigitLabel::clear()
+{
+ this->is_cleared = true;
+ setText(QString());
+}
+
+void DigitLabel::set_value(int v)
+{
+ this->is_cleared = false;
+ this->v = v;
+ update_display();
+}
+
+void DigitLabel::on_hex_toggle(bool is_hex)
+{
+ this->is_hex = is_hex;
+ update_display();
+}
+
+void DigitLabel::update_display()
+{
+ QString t;
+ if (this->is_cleared) {
+ setText(QString());
+ } else {
+ t = (this->is_hex) ? QString::number(this->v, 16).toUpper()
+ : QString::number(this->v);
+ setText(t);
+ }
+}
diff --git a/gui/digitlabel.h b/gui/digitlabel.h
new file mode 100644
index 0000000..68b01cb
--- /dev/null
+++ b/gui/digitlabel.h
@@ -0,0 +1,69 @@
+// Simulator for the RISC-V[ECTOR] mini-ISA
+// Copyright (C) 2025 Siddarth Suresh
+// Copyright (C) 2025 bdunahu
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#ifndef DIGITLABEL_H
+#define DIGITLABEL_H
+
+#include <QLabel>
+
+class DigitLabel : public QLabel
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor.
+ * @return a newly allocated DigitLabel.
+ */
+ explicit DigitLabel(QWidget *parent);
+
+ /**
+ * Sets the empty flag.
+ */
+ void clear();
+ /**
+ * @param the value to set `this->v' with.
+ */
+ void set_value(int v);
+
+ public slots:
+ /**
+ * Toggles the base this label displays in, by setting `this->is_hex'.
+ */
+ void on_hex_toggle(bool is_hex);
+
+ private:
+ /**
+ * Refreshes the display of this label, taking base into consideration..
+ */
+ void update_display();
+
+ /**
+ * The decimal value associated with this label.
+ */
+ int v;
+ /**
+ * If this digit should display in hexidecinmal.
+ */
+ int is_hex;
+ /**
+ * If this digit should not display.
+ */
+ bool is_cleared = true;
+};
+
+#endif // DIGITLABEL_H
diff --git a/gui/dynamicwaysentry.cc b/gui/dynamicwaysentry.cc
new file mode 100644
index 0000000..e1f740e
--- /dev/null
+++ b/gui/dynamicwaysentry.cc
@@ -0,0 +1,99 @@
+// Simulator for the RISC-V[ECTOR] mini-ISA
+// Copyright (C) 2025 Siddarth Suresh
+// Copyright (C) 2025 bdunahu
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#include "dynamicwaysentry.h"
+#include <QLabel>
+#include <QLineEdit>
+#include <QStringList>
+#include <QVBoxLayout>
+#include <QVector>
+#include <QWidget>
+
+DynamicWaysEntry::DynamicWaysEntry(QWidget *parent) : QWidget(parent)
+{
+ this->l = new QVBoxLayout(this);
+ this->l->setAlignment(Qt::AlignTop);
+ this->l->setSpacing(6);
+ this->l->setContentsMargins(0, 0, 0, 0);
+ this->setLayout(l);
+ this->add_field();
+}
+
+QStringList DynamicWaysEntry::get_entries() const { return this->entries; }
+
+int DynamicWaysEntry::parse_valid_way(QString t)
+{
+ bool s;
+ int i;
+ i = t.toInt(&s);
+ return (s && i >= 0 && 5 > i) ? i : -1;
+}
+
+// TODO if you enter something valid and then make it invalid,
+// the next box still shows
+void DynamicWaysEntry::on_number_enter(const QString &t)
+{
+ int i;
+ QLineEdit *sender_field;
+
+ sender_field = qobject_cast<QLineEdit *>(sender());
+ i = fields.indexOf(sender_field);
+ entries[i] = t;
+
+ if (i == this->fields.size() - 1 && !t.isEmpty() &&
+ (this->parse_valid_way(t) > 0) && fields.size() < 4)
+ add_field();
+
+ // TODO, unlink, don't trash everything after
+ if (t.isEmpty()) {
+ while (this->fields.size() > i + 1) {
+ remove_last_field();
+ }
+ while (entries.size() > fields.size()) {
+ entries.removeLast();
+ }
+ }
+}
+
+void DynamicWaysEntry::add_field()
+{
+ QLineEdit *f;
+
+ f = new QLineEdit(this);
+ f->setPlaceholderText("# ways (a power of 2)");
+
+ this->l->addWidget(f);;
+ this->fields.append(f);
+ this->entries.append(QString());
+ connect(
+ f, &QLineEdit::textChanged, this, &DynamicWaysEntry::on_number_enter);
+}
+
+void DynamicWaysEntry::remove_last_field()
+{
+ QLineEdit *f;
+
+ if (this->fields.isEmpty())
+ return;
+
+ f = this->fields.takeLast();
+ this->l->removeWidget(f);
+ f->deleteLater();
+
+ if (!this->entries.isEmpty())
+ entries.removeLast();
+}
diff --git a/gui/dynamicwaysentry.h b/gui/dynamicwaysentry.h
new file mode 100644
index 0000000..26b8b3e
--- /dev/null
+++ b/gui/dynamicwaysentry.h
@@ -0,0 +1,51 @@
+// Simulator for the RISC-V[ECTOR] mini-ISA
+// Copyright (C) 2025 Siddarth Suresh
+// Copyright (C) 2025 bdunahu
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#ifndef DYNAMICWAYSENTRY_H
+#define DYNAMICWAYSENTRY_H
+
+
+#include <QLineEdit>
+#include <QStringList>
+#include <QVBoxLayout>
+#include <QVector>
+#include <QWidget>
+
+class DynamicWaysEntry : public QWidget
+{
+ public:
+ DynamicWaysEntry(QWidget *parent = nullptr);
+ QStringList get_entries() const;
+ /**
+ * Parses a string from this entry field, if it is valid.
+ * @param a string
+ * @param -1 if the string is not suitable as a way, an integer compatible
+ * with the cache constructor otherwise.
+ */
+ int parse_valid_way(QString t);
+ private slots:
+ void on_number_enter(const QString &t);
+
+ private:
+ QVBoxLayout *l;
+ QVector<QLineEdit *> fields;
+ QStringList entries;
+ void add_field();
+ void remove_last_field();
+};
+
+#endif // DYNAMICWAYSENTRY_H
diff --git a/gui/gui.cc b/gui/gui.cc
index 7101025..294a7d0 100644
--- a/gui/gui.cc
+++ b/gui/gui.cc
@@ -17,329 +17,379 @@
#include "gui.h"
#include "./ui_gui.h"
-#include "byteswap.h"
+#include "dynamicwaysentry.h"
+#include "messages.h"
+#include <QPixmap>
+#include <QString>
-GUI::GUI(QWidget *parent)
- : QMainWindow(parent)
- , ui(new Ui::GUI)
+GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI)
{
- ui->setupUi(this);
+ ui->setupUi(this);
- ui->enabl_cache_checkbox->setChecked(true);
- ui->enable_pipeline_checkbox->setChecked(true);
+ /* setup the status bar */
+ ui->statusBar->setFixedHeight(20);
- worker = new Worker();
- worker->moveToThread(&workerThread);
+ this->avatar = new QLabel(this);
+ this->status_label = new QLabel("", this);
+ QLabel *risc_vector =
+ new QLabel("RISC V[ECTOR], CS535 UMASS AMHERST", this);
- // Connect worker thread lifecycle
- connect(&workerThread, &QThread::started, worker, &Worker::doWork);
+ avatar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ avatar->setObjectName("avatar_label");
+ status_label->setObjectName("msg_label");
+ risc_vector->setObjectName("info_label");
+ ui->statusBar->setSizeGripEnabled(false);
- // Display clock cycles and PC
- connect(worker, &Worker::clock_cycles, this, &GUI::onWorkerClockCycles);
+ this->set_status(get_waiting, "idle.png");
+ ui->statusBar->addWidget(avatar);
+ ui->statusBar->addWidget(status_label);
+ ui->statusBar->addPermanentWidget(risc_vector);
- connect(worker, &Worker::if_info, this, &GUI::onWorkerFetchInfo);
+ worker = new Worker();
+ worker->moveToThread(&workerThread);
- connect(worker, &Worker::id_info, this, &GUI::onWorkerDecodeInfo);
+ // find all the labels
+ QList<DigitLabel*> labels = this->findChildren<DigitLabel*>();
+ for (DigitLabel* label : labels) {
+ connect(this, &GUI::hex_toggled, label, &DigitLabel::on_hex_toggle);
+ }
+ emit this->hex_toggled(this->is_hex);
- connect(worker, &Worker::ex_info, this, &GUI::onWorkerExecuteInfo);
+ // display clock cycles and PC
+ connect(worker, &Worker::clock_cycles, this, &GUI::on_worker_refresh_gui);
- connect(worker, &Worker::mm_info, this, &GUI::onWorkerMemoryInfo);
+ connect(worker, &Worker::if_info, this, &GUI::onWorkerFetchInfo);
- connect(worker, &Worker::wb_info, this, &GUI::onWorkerWriteBackInfo);
+ connect(worker, &Worker::id_info, this, &GUI::onWorkerDecodeInfo);
- // Display dram
- connect(worker, &Worker::dram_storage, this, &GUI::onWorkerShowDram);
+ connect(worker, &Worker::ex_info, this, &GUI::onWorkerExecuteInfo);
- // Display cache
- connect(worker, &Worker::cache_storage, this, &GUI::onWorkerShowCache);
+ connect(worker, &Worker::mm_info, this, &GUI::onWorkerMemoryInfo);
- // Display registers
- connect(worker, &Worker::register_storage, this, &GUI::onWorkerShowRegisters);
+ connect(worker, &Worker::wb_info, this, &GUI::onWorkerWriteBackInfo);
- // Refresh DRAM from worker thread
- connect(this, &GUI::sendRefreshDram, worker, &Worker::refreshDram, Qt::QueuedConnection);
+ // Display dram
+ connect(worker, &Worker::dram_storage, this, &GUI::onWorkerShowDram);
- // Load program from worker thread
- connect(this, &GUI::sendLoadProgram, worker, &Worker::loadProgram, Qt::QueuedConnection);
+ // Display cache
+ connect(worker, &Worker::cache_storage, this, &GUI::onWorkerShowCache);
- // Refresh Cache from worker thread
- connect(this, &GUI::sendRefreshCache, worker, &Worker::refreshCache, Qt::QueuedConnection);
+ // Display registers
+ connect(
+ worker, &Worker::register_storage, this, &GUI::onWorkerShowRegisters);
- // Refresh Registers from worker thread
- connect(this, &GUI::sendRefreshRegisters, worker, &Worker::refreshRegisters, Qt::QueuedConnection);
+ // Configure pipeline
+ connect(
+ this, &GUI::sendConfigure, worker, &Worker::configure,
+ Qt::QueuedConnection);
- // Advance controller by #steps
- connect(this, &GUI::sendRunSteps, worker, &Worker::runSteps, Qt::QueuedConnection);
+ // Advance controller by some steps
+ connect(
+ this, &GUI::sendRunSteps, worker, &Worker::runSteps,
+ Qt::QueuedConnection);
- // Advance controller by 1 step
- connect(this, &GUI::sendRunStep, worker, &Worker::runStep, Qt::QueuedConnection);
+ // Update the step button with step amount
+ connect(ui->step_slider, &QSlider::valueChanged, this, [=](int index) {
+ int value = step_values[index];
+ ui->step_btn->setText(QString("Step %1").arg(value));
+ });
- // Proper cleanup when worker finishes
- connect(worker, &Worker::finished, this, &GUI::onWorkerFinished);
- connect(worker, &Worker::finished, &workerThread, &QThread::quit);
- connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
+ // Proper cleanup when worker finishes
+ connect(worker, &Worker::finished, this, &GUI::onWorkerFinished);
+ connect(worker, &Worker::finished, &workerThread, &QThread::quit);
+ connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
- workerThread.start(); // Start the worker thread
+ workerThread.start(); // Start the worker thread
}
GUI::~GUI()
{
- workerThread.quit();
- workerThread.wait(); // Ensure proper cleanup
- delete ui;
+ workerThread.quit();
+ workerThread.wait(); // Ensure proper cleanup
+ delete ui;
}
-void displayArrayHTML(QTextEdit *textEdit, const std::array<int, GPR_NUM> &data) {
- textEdit->setReadOnly(false);
- QString tableText = "<table border='1' cellspacing='0' cellpadding='8' style='border-collapse: collapse; width: 100%; border: 2px solid black;'>";
-
- tableText += "<tr>";
- int index = 0;
- for (int value : data) {
- tableText += QString("<td align='center' style='border: 2px solid black; min-width: 60px; padding: 10px;'>"
- "%1 <sup style='font-size: 10px; font-weight: bold; color: black;'>%2</sup>"
- "</td>")
- .arg(QString::asprintf("%04X", value))
- .arg(index);
- index++;
- }
- tableText += "</tr>";
- tableText += "</table>";
-
- textEdit->setHtml(tableText);
- textEdit->setReadOnly(true);
-}
-
-void displayTableHTML(QTextEdit *textEdit, const std::vector<std::array<signed int, LINE_SIZE>> &data) {
- textEdit->setReadOnly(false);
- QString tableText = "<table border='1' cellspacing='0' cellpadding='8' style='border-collapse: collapse; width: 100%; border: 2px solid black;'>";
-
- int index = 0;
- for (const auto &row : data) {
- tableText += "<tr>";
- for (signed int value : row) {
- tableText += QString("<td align='center' style='border: 2px solid black; min-width: 60px; padding: 10px;'>"
- "%1 <sup style='font-size: 10px; font-weight: bold; color: black;'>%2</sup>"
- "</td>")
- .arg(QString::asprintf("%04X", value))
- .arg(index);
- index++;
- }
- tableText += "</tr>";
- }
-
- tableText += "</table>";
-
- textEdit->setHtml(tableText);
- textEdit->setReadOnly(true);
+void displayArrayHTML(QTextEdit *textEdit, const std::array<int, GPR_NUM> &data)
+{
+ textEdit->setReadOnly(false);
+ QString tableText = "<table border='1' cellspacing='0' cellpadding='8' "
+ "style='border-collapse: collapse; width: 100%; "
+ "border: 2px solid black;'>";
+
+ tableText += "<tr>";
+ int index = 0;
+ for (int value : data) {
+ tableText += QString("<td align='center' style='border: 2px solid "
+ "black; min-width: 60px; padding: 10px;'>"
+ "%1 <sup style='font-size: 10px; font-weight: "
+ "bold; color: black;'>%2</sup>"
+ "</td>")
+ .arg(QString::asprintf("%04X", value))
+ .arg(index);
+ index++;
+ }
+ tableText += "</tr>";
+ tableText += "</table>";
+
+ textEdit->setHtml(tableText);
+ textEdit->setReadOnly(true);
}
-std::vector<signed int> browseAndRetrieveFile(QWidget* parent) {
- QString filePath = QFileDialog::getOpenFileName(parent, "Open Binary File", QDir::homePath(), "Binary Files (*.bin *.rv);;All Files (*.*)");
- std::vector<signed int> program;
-
- if (filePath.isEmpty()) return program;
-
- QFile file(filePath);
- if (!file.open(QIODevice::ReadOnly)) {
- QMessageBox::critical(parent, "File Upload", "Unable to open file!");
- return program;
- }
-
- while (!file.atEnd()) {
- int32_t word = 0;
- if (file.read(reinterpret_cast<char*>(&word), sizeof(int32_t)) == sizeof(int32_t)) {
- program.push_back(static_cast<signed int>(bswap_32(word)));
- }
- }
-
- file.close();
-
- return program;
+void displayTableHTML(
+ QTextEdit *textEdit,
+ const std::vector<std::array<signed int, LINE_SIZE>> &data)
+{
+ textEdit->setReadOnly(false);
+ QString tableText = "<table border='1' cellspacing='0' cellpadding='8' "
+ "style='border-collapse: collapse; width: 100%; "
+ "border: 2px solid black;'>";
+
+ int index = 0;
+ for (const auto &row : data) {
+ tableText += "<tr>";
+ for (signed int value : row) {
+ tableText += QString("<td align='center' style='border: 2px solid "
+ "black; min-width: 60px; padding: 10px;'>"
+ "%1 <sup style='font-size: 10px; font-weight: "
+ "bold; color: black;'>%2</sup>"
+ "</td>")
+ .arg(QString::asprintf("%04X", value))
+ .arg(index);
+ index++;
+ }
+ tableText += "</tr>";
+ }
+
+ tableText += "</table>";
+
+ textEdit->setHtml(tableText);
+ textEdit->setReadOnly(true);
}
-void GUI::onWorkerClockCycles(int cycles, int pc) {
- QFont font = ui->cycles_label->font();
- font.setBold(true);
- font.setItalic(true);
- font.setPointSize(14);
- ui->cycles_label->setFont(font);
- ui->cycles_label->setText("Clock Cycles: " + QString::number(cycles) + "\t\t" + "PC: " + QString::number(pc));
+void GUI::on_worker_refresh_gui(int cycles, int pc)
+{
+ ui->p_counter->set_value(pc);
+ ui->cycle_counter->set_value(cycles);
}
-void GUI::onWorkerFetchInfo(const std::vector<int> info) {
- //QString::asprintf("%04X", value)
- if(!info.empty()) {
- ui->fetch_pc->setText(QString::number(info[0]));
- ui->fetch_instruction_bits->setText(QString::asprintf("%04X", info[1]));
- } else {
- ui->fetch_pc->clear();
- ui->fetch_instruction_bits->clear();
- }
+void GUI::onWorkerFetchInfo(const std::vector<int> info)
+{
+ if (!info.empty()) {
+ ui->fetch_squashed->setText(QString::number(info[0]));
+ ui->fetch_bits->set_value(info[1]);
+ } else {
+ ui->fetch_squashed->clear();
+ ui->fetch_bits->clear();
+ }
}
-void GUI::onWorkerDecodeInfo(const std::vector<int> info) {
- if(!info.empty()) {
- // ui->decode_mnemonic->setText(mnemonicToString((Mnemonic)info[0]));
- ui->decode_pc->setText(QString::number(info[0]));
- ui->decode_s1->setText(QString::asprintf("%04X", info[1]));
- // ui->decode_s2->setText(QString::asprintf("%04X", info[3]));
- // ui->decode_s3->setText(QString::asprintf("%04X", info[4]));
- } else {
- // ui->decode_mnemonic->clear();
- ui->decode_pc->clear();
- ui->decode_s1->clear();
- // ui->decode_s2->clear();
- // ui->decode_s3->clear();
- }
+void GUI::onWorkerDecodeInfo(const std::vector<int> info)
+{
+ if (!info.empty()) {
+ ui->decode_squashed->setText(QString::number(info[0]));
+ ui->decode_bits->set_value(info[1]);
+ } else {
+ ui->decode_squashed->clear();
+ ui->decode_bits->clear();
+ }
}
-void GUI::onWorkerExecuteInfo(const std::vector<int> info) {
- if(!info.empty()) {
- ui->execute_mnemonic->setText(mnemonicToString((Mnemonic)info[0]));
- ui->execute_pc->setText(QString::number(info[1]));
- ui->execute_s1->setText(QString::asprintf("%04X", info[2]));
- ui->execute_s2->setText(QString::asprintf("%04X", info[3]));
- ui->execute_s3->setText(QString::asprintf("%04X", info[4]));
- } else {
- ui->execute_mnemonic->clear();
- ui->execute_pc->clear();
- ui->execute_s1->clear();
- ui->execute_s2->clear();
- ui->execute_s3->clear();
- }
+void GUI::onWorkerExecuteInfo(const std::vector<int> info)
+{
+ if (!info.empty()) {
+ ui->execute_mnemonic->setText(mnemonicToString((Mnemonic)info[0]));
+ ui->execute_squashed->setText(QString::number(info[1]));
+ ui->execute_s1->set_value(info[2]);
+ ui->execute_s2->set_value(info[3]);
+ ui->execute_s3->set_value(info[4]);
+ } else {
+ ui->execute_mnemonic->clear();
+ ui->execute_squashed->clear();
+ ui->execute_s1->clear();
+ ui->execute_s2->clear();
+ ui->execute_s3->clear();
+ }
}
-void GUI::onWorkerMemoryInfo(const std::vector<int> info) {
- if(!info.empty()) {
- ui->memory_mnemonic->setText(mnemonicToString((Mnemonic)info[0]));
- ui->memory_pc->setText(QString::number(info[1]));
- ui->memory_s1->setText(QString::asprintf("%04X", info[2]));
- ui->memory_s2->setText(QString::asprintf("%04X", info[3]));
- ui->memory_s3->setText(QString::asprintf("%04X", info[4]));
- } else {
- ui->memory_mnemonic->clear();
- ui->memory_pc->clear();
- ui->memory_s1->clear();
- ui->memory_s2->clear();
- ui->memory_s3->clear();
- }
+void GUI::onWorkerMemoryInfo(const std::vector<int> info)
+{
+ if (!info.empty()) {
+ std::cout << "this " << info[3] << std::endl;
+ ui->memory_mnemonic->setText(mnemonicToString((Mnemonic)info[0]));
+ ui->memory_squashed->setText(QString::number(info[1]));
+ ui->memory_s1->set_value(info[2]);
+ ui->memory_s2->set_value(info[3]);
+ ui->memory_s3->set_value(info[4]);
+ } else {
+ ui->memory_mnemonic->clear();
+ ui->memory_squashed->clear();
+ ui->memory_s1->clear();
+ ui->memory_s2->clear();
+ ui->memory_s3->clear();
+ }
}
-void GUI::onWorkerWriteBackInfo(const std::vector<int> info) {
- if(!info.empty()) {
- ui->wb_mnemonic->setText(mnemonicToString((Mnemonic)info[0]));
- ui->wb_pc->setText(QString::number(info[1]));
- ui->wb_s1->setText(QString::asprintf("%04X", info[2]));
- ui->wb_s2->setText(QString::asprintf("%04X", info[3]));
- ui->wb_s3->setText(QString::asprintf("%04X", info[4]));
- } else {
- ui->wb_mnemonic->clear();
- ui->wb_pc->clear();
- ui->wb_s1->clear();
- ui->wb_s2->clear();
- ui->wb_s3->clear();
- }
+void GUI::onWorkerWriteBackInfo(const std::vector<int> info)
+{
+ if (!info.empty()) {
+ ui->write_mnemonic->setText(mnemonicToString((Mnemonic)info[0]));
+ ui->write_s1->set_value(info[2]);
+ ui->write_s2->set_value(info[3]);
+ ui->write_s3->set_value(info[4]);
+ } else {
+ ui->write_mnemonic->clear();
+ ui->write_s1->clear();
+ ui->write_s2->clear();
+ ui->write_s3->clear();
+ }
}
-void GUI::onWorkerShowDram(const std::vector<std::array<signed int, LINE_SIZE>> data) {
- displayTableHTML(ui->dram_table, data);
+void GUI::onWorkerShowDram(
+ const std::vector<std::array<signed int, LINE_SIZE>> data)
+{
+ displayTableHTML(ui->dram_table, data);
}
-void GUI::onWorkerShowCache(const std::vector<std::array<signed int, LINE_SIZE>> data) {
- displayTableHTML(ui->cache_table, data);
+void GUI::onWorkerShowCache(
+ const std::vector<std::array<signed int, LINE_SIZE>> data)
+{
+ displayTableHTML(ui->cache_table, data);
}
-void GUI::onWorkerShowRegisters(const std::array<int, GPR_NUM> &data) {
- displayArrayHTML(ui->register_table, data);
+void GUI::onWorkerShowRegisters(const std::array<int, GPR_NUM> &data)
+{
+ displayArrayHTML(ui->register_table, data);
}
-void GUI::onWorkerFinished() {
- qDebug() << "Worker has finished processing.";
-}
+void GUI::onWorkerFinished() { qDebug() << "Worker has finished processing."; }
void GUI::on_upload_intructions_btn_clicked()
{
- qDebug() << "Upload intructions button clicked.";
- std::vector<signed int> program;
- program = browseAndRetrieveFile(ui->register_table);
- if(program.empty()){
- QMessageBox::critical(ui->register_table, "File Upload", "Invalid Program File!");
- }
- emit sendLoadProgram(program);
- emit sendRefreshDram();
- QMessageBox::information(ui->register_table, "File Upload", "Instructions loaded successfully!");
+ qDebug() << "Upload intructions button clicked.";
+
+ // why register_table?
+ QString filePath = QFileDialog::getOpenFileName(
+ ui->register_table, "Open Binary File", QDir::homePath(),
+ "Binary Files (*.bin *.rv);;All Files (*.*)");
+ QFile file(filePath);
+ if (filePath.isEmpty() || !file.open(QIODevice::ReadOnly)) {
+ this->set_status(get_no_instructions, "angry");
+ return;
+ }
+
+ this->p.clear();
+ while (!file.atEnd()) {
+ char bytes[4];
+ if (file.read(bytes, 4) == 4) {
+ uint32_t word = (static_cast<uint8_t>(bytes[0]) << 24) |
+ (static_cast<uint8_t>(bytes[1]) << 16) |
+ (static_cast<uint8_t>(bytes[2]) << 8) |
+ (static_cast<uint8_t>(bytes[3]));
+
+ this->p.push_back(static_cast<signed int>(word));
+ }
+ }
+
+ if (this->p.empty())
+ this->set_status(get_no_instructions, "angry");
+ else
+ this->set_status(get_load_file, "happy");
+
+ file.close();
}
-
void GUI::on_upload_program_state_btn_clicked()
{
- //TODO:Upload and set program state ( have to decide how to use this)
- qDebug() << "upload program state button is clicked.";
+ // TODO:Upload and set program state ( have to decide how to use this)
+ qDebug() << "upload program state button is clicked.";
}
-
-void GUI::on_refresh_dram_btn_clicked()
+void GUI::on_enable_pipeline_checkbox_checkStateChanged(
+ const Qt::CheckState &arg1)
{
- qDebug() << "Refresh DRAM button clicked.";
- emit sendRefreshDram();
-
+ this->is_pipelined = (arg1 == Qt::CheckState::Checked) ? true : false;
}
-
-void GUI::on_refresh_cache_btn_clicked()
+void GUI::on_base_toggle_checkbox_checkStateChanged(const Qt::CheckState &state)
{
- qDebug() << "Refresh cache button clicked.";
- emit sendRefreshCache();
+ this->is_hex = (state == Qt::CheckState::Checked) ? false : true;
+ emit this->hex_toggled(this->is_hex);
}
-
-void GUI::on_refresh_registers_btn_clicked()
+void GUI::on_step_btn_clicked()
{
- qDebug() << "Refresh registers button clicked.";
- emit sendRefreshRegisters();
+ qDebug() << "Run step button clicked.";
+ // try to configure first
+ if (!this->ready)
+ this->on_config_clicked();
+ // try again
+ if (!this->ready)
+ return;
+
+ this->set_status(get_running, "busy");
+ int steps = step_values[ui->step_slider->value()];
+ emit sendRunSteps(steps);
+ this->set_status(get_waiting, "idle");
}
-
-void GUI::on_enable_pipeline_checkbox_checkStateChanged(const Qt::CheckState &arg1)
+void GUI::on_save_program_state_btn_clicked()
{
- //TODO: handle pipeline enabling
- if(arg1 == Qt::CheckState::Checked) {
- qDebug() << "enable pipeline checkbox checked.";
- } else {
- qDebug() << "enable pipeline checkbox unchecked.";
- }
+ // TODO: save program state
+ qDebug() << "save program state button is clicked.";
}
-
-void GUI::on_enabl_cache_checkbox_checkStateChanged(const Qt::CheckState &arg1)
+void GUI::on_config_clicked()
{
- //TODO: handle cache enabling
- if(arg1 == Qt::CheckState::Checked) {
- qDebug() << "enable cache checkbox checked.";
- } else {
- qDebug() << "enable cache checkbox unchecked.";
- }
-
+ std::vector<unsigned int> ways;
+ QStringList entries;
+ signed int i;
+ DynamicWaysEntry *dwe = ui->cache_way_selector;
+
+ for (const QString &s : dwe->get_entries()) {
+
+ if (s.isEmpty())
+ continue;
+
+ i = dwe->parse_valid_way(s);
+ if (i != -1) {
+ ways.push_back((unsigned int)i);
+ } else {
+ this->set_status(get_bad_cache, "angry");
+ return;
+ }
+ }
+
+ if (this->p.empty()) {
+ this->set_status(get_no_instructions, "angry");
+ return;
+ }
+
+ this->ready = true;
+
+ // say something snarky
+ if (!is_pipelined)
+ this->set_status(get_no_pipeline, "angry");
+ else if (ways.size() == 0)
+ this->set_status(get_no_cache, "angry");
+ else
+ this->set_status(get_initialize, "happy");
+
+ emit sendConfigure(ways, this->p, is_pipelined);
}
-
-void GUI::on_run_steps_btn_clicked()
+void GUI::set_status(
+ const std::function<std::string()> &func, const QString &img)
{
- qDebug() << "Run steps button clicked.";
- emit sendRunSteps(ui->number_steps_inp->text().toInt());
-}
+ this->status_label->setText(
+ "-> \"" + QString::fromStdString(func()) + "\"");
+ QString img_path = ":resources/" + img;
+ QPixmap pixmap(img_path);
-void GUI::on_step_btn_clicked()
-{
- qDebug() << "Run step button clicked.";
- emit sendRunStep();
-}
-
+ if (!pixmap) {
+ return;
+ }
-void GUI::on_save_program_state_btn_clicked()
-{
- //TODO: save program state
- qDebug() << "save program state button is clicked.";
+ this->avatar->setPixmap(pixmap);
+ this->avatar->show();
}
diff --git a/gui/gui.h b/gui/gui.h
index 6e4e305..0b10145 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -18,124 +18,163 @@
#ifndef GUI_H
#define GUI_H
-#include <QMainWindow>
-#include <QThread>
-#include <QFileDialog>
+#include "worker.h"
#include <QFile>
-#include <QTextStream>
+#include <QFileDialog>
+#include <QInputDialog>
+#include <QLabel>
+#include <QMainWindow>
#include <QTextEdit>
-#include <QMessageBox>
-#include "worker.h"
+#include <QTextStream>
+#include <QThread>
+#include <functional>
QT_BEGIN_NAMESPACE
-namespace Ui {
+namespace Ui
+{
class GUI;
}
QT_END_NAMESPACE
class GUI : public QMainWindow
{
- Q_OBJECT
-
-public:
- GUI(QWidget *parent = nullptr);
- ~GUI();
-
-signals:
- void sendRefreshDram();
- void sendRefreshCache();
- void sendRefreshRegisters();
- void sendRunSteps(int steps);
- void sendRunStep();
- void sendLoadProgram(std::vector<signed int> program);
-
-private slots:
- void onWorkerClockCycles(int value, int pc);
-
- void onWorkerFetchInfo(const std::vector<int> info);
-
- void onWorkerDecodeInfo(const std::vector<int> info);
-
- void onWorkerExecuteInfo(const std::vector<int> info);
-
- void onWorkerMemoryInfo(const std::vector<int> info);
-
- void onWorkerWriteBackInfo(const std::vector<int> info);
-
- void onWorkerShowDram(const std::vector<std::array<signed int, LINE_SIZE>> data);
-
- void onWorkerShowCache(const std::vector<std::array<signed int, LINE_SIZE>> data);
-
- void onWorkerShowRegisters(const std::array<int, GPR_NUM> &data);
-
- void onWorkerFinished();
-
- void on_upload_intructions_btn_clicked();
-
- void on_upload_program_state_btn_clicked();
-
- void on_refresh_dram_btn_clicked();
-
- void on_refresh_cache_btn_clicked();
-
- void on_refresh_registers_btn_clicked();
-
- void on_enable_pipeline_checkbox_checkStateChanged(const Qt::CheckState &arg1);
-
- void on_enabl_cache_checkbox_checkStateChanged(const Qt::CheckState &arg1);
-
- void on_run_steps_btn_clicked();
-
- void on_step_btn_clicked();
-
- void on_save_program_state_btn_clicked();
-
-private:
- Ui::GUI *ui;
- QThread workerThread;
- Worker *worker;
- const std::map<Mnemonic, QString> mnemonicNameMap = {
- {Mnemonic::ADD, "ADD"},
- {Mnemonic::SUB, "SUB"},
- {Mnemonic::MUL, "MUL"},
- {Mnemonic::QUOT, "QUOT"},
- {Mnemonic::SFTR, "SFTR"},
- {Mnemonic::SFTL, "SFTL"},
- {Mnemonic::AND, "AND"},
- {Mnemonic::OR, "OR"},
- {Mnemonic::NOT, "NOT"},
- {Mnemonic::XOR, "XOR"},
- {Mnemonic::ADDV, "ADDV"},
- {Mnemonic::SUBV, "SUBV"},
- {Mnemonic::MULV, "MULV"},
- {Mnemonic::DIVV, "DIVV"},
- {Mnemonic::CMP, "CMP"},
- {Mnemonic::CEV, "CEV"},
- {Mnemonic::LOAD, "LOAD"},
- {Mnemonic::LOADV, "LOADV"},
- {Mnemonic::ADDI, "ADDI"},
- {Mnemonic::SUBI, "SUBI"},
- {Mnemonic::SFTRI, "SFTRI"},
- {Mnemonic::SFTLI, "SFTLI"},
- {Mnemonic::ANDI, "ANDI"},
- {Mnemonic::ORI, "ORI"},
- {Mnemonic::XORI, "XORI"},
- {Mnemonic::STORE, "STORE"},
- {Mnemonic::STOREV, "STOREV"},
- {Mnemonic::JMP, "JMP"},
- {Mnemonic::JRL, "JRL"},
- {Mnemonic::JAL, "JAL"},
- {Mnemonic::BEQ, "BEQ"},
- {Mnemonic::BGT, "BGT"},
- {Mnemonic::BUF, "BUF"},
- {Mnemonic::BOF, "BOF"},
- {Mnemonic::PUSH, "PUSH"},
- {Mnemonic::POP, "POP"},
- {Mnemonic::NOP, "NOP"},
- };
- QString mnemonicToString(Mnemonic mnemonic) {
- auto it = mnemonicNameMap.find(mnemonic);
- return (it != mnemonicNameMap.end()) ? it->second : "Unknown";
- }
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor.
+ * @return A newly allocated GUI object.
+ */
+ GUI(QWidget *parent = nullptr);
+ ~GUI();
+
+ /**
+ * Uses `func' to set the current status.
+ * @param a function which returns a string.
+ * @param a path to the desired avatar
+ */
+ void set_status(
+ const std::function<std::string()> &func,
+ const QString &img = "idle.png");
+
+ signals:
+ void hex_toggled(bool is_hex);
+ void sendRunSteps(int steps);
+ void sendConfigure(
+ std::vector<unsigned int> ways, vector<int> program, bool is_pipelined);
+
+ private slots:
+ void on_worker_refresh_gui(int value, int pc);
+
+ void onWorkerFetchInfo(const std::vector<int> info);
+
+ void onWorkerDecodeInfo(const std::vector<int> info);
+
+ void onWorkerExecuteInfo(const std::vector<int> info);
+
+ void onWorkerMemoryInfo(const std::vector<int> info);
+
+ void onWorkerWriteBackInfo(const std::vector<int> info);
+
+ void
+ onWorkerShowDram(const std::vector<std::array<signed int, LINE_SIZE>> data);
+
+ void onWorkerShowCache(
+ const std::vector<std::array<signed int, LINE_SIZE>> data);
+
+ void onWorkerShowRegisters(const std::array<int, GPR_NUM> &data);
+
+ void onWorkerFinished();
+
+ void on_upload_intructions_btn_clicked();
+
+ void on_upload_program_state_btn_clicked();
+
+ void
+ on_enable_pipeline_checkbox_checkStateChanged(const Qt::CheckState &arg1);
+
+ void
+ on_base_toggle_checkbox_checkStateChanged(const Qt::CheckState &state);
+
+ void on_step_btn_clicked();
+
+ void on_save_program_state_btn_clicked();
+
+ /**
+ * Validates that the user has provided a valid program and cache.
+ * If so, `this->ready' is set and the user options are passed to the
+ * worker.
+ * If not, rudely complains.
+ */
+ void on_config_clicked();
+
+ private:
+ Ui::GUI *ui;
+
+ /**
+ * Indicates if the program has been initialized.
+ */
+ bool ready;
+
+ /**
+ * Whether or not numerical values are currently displaying in hex.
+ */
+ bool is_hex = true;
+
+ /**
+ * The message displayed on the status bar.
+ */
+ QLabel *status_label;
+
+ /**
+ * The robot image displayed on the status bar.
+ */
+ QLabel *avatar;
+
+ /**
+ * The currently loaded program.
+ */
+ std::vector<signed int> p;
+
+ /**
+ * If this stage is pipelined or not.
+ */
+ bool is_pipelined = true;
+
+ /**
+ * The possible step slider values.
+ */
+ QVector<int> step_values = {1, 5, 20, 50, 250, 1000, 10000};
+
+ QThread workerThread;
+
+ Worker *worker;
+
+ const std::map<Mnemonic, QString> mnemonicNameMap = {
+ {Mnemonic::ADD, "ADD"}, {Mnemonic::SUB, "SUB"},
+ {Mnemonic::MUL, "MUL"}, {Mnemonic::QUOT, "QUOT"},
+ {Mnemonic::SFTR, "SFTR"}, {Mnemonic::SFTL, "SFTL"},
+ {Mnemonic::AND, "AND"}, {Mnemonic::OR, "OR"},
+ {Mnemonic::NOT, "NOT"}, {Mnemonic::XOR, "XOR"},
+ {Mnemonic::ADDV, "ADDV"}, {Mnemonic::SUBV, "SUBV"},
+ {Mnemonic::MULV, "MULV"}, {Mnemonic::DIVV, "DIVV"},
+ {Mnemonic::CMP, "CMP"}, {Mnemonic::CEV, "CEV"},
+ {Mnemonic::LOAD, "LOAD"}, {Mnemonic::LOADV, "LOADV"},
+ {Mnemonic::ADDI, "ADDI"}, {Mnemonic::SUBI, "SUBI"},
+ {Mnemonic::SFTRI, "SFTRI"}, {Mnemonic::SFTLI, "SFTLI"},
+ {Mnemonic::ANDI, "ANDI"}, {Mnemonic::ORI, "ORI"},
+ {Mnemonic::XORI, "XORI"}, {Mnemonic::STORE, "STORE"},
+ {Mnemonic::STOREV, "STOREV"}, {Mnemonic::JMP, "JMP"},
+ {Mnemonic::JRL, "JRL"}, {Mnemonic::JAL, "JAL"},
+ {Mnemonic::BEQ, "BEQ"}, {Mnemonic::BGT, "BGT"},
+ {Mnemonic::BUF, "BUF"}, {Mnemonic::BOF, "BOF"},
+ {Mnemonic::PUSH, "PUSH"}, {Mnemonic::POP, "POP"},
+ {Mnemonic::NOP, "NOP"},
+ };
+ QString mnemonicToString(Mnemonic mnemonic)
+ {
+ auto it = mnemonicNameMap.find(mnemonic);
+ return (it != mnemonicNameMap.end()) ? it->second : "Unknown";
+ }
};
#endif // GUI_H
diff --git a/gui/gui.ui b/gui/gui.ui
index 5e8daca..dbb3a33 100644
--- a/gui/gui.ui
+++ b/gui/gui.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>1359</width>
- <height>606</height>
+ <width>1499</width>
+ <height>621</height>
</rect>
</property>
<property name="windowTitle">
@@ -16,406 +16,313 @@
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0,0" columnstretch="0,3,0,1,0">
- <item row="0" column="1">
- <layout class="QVBoxLayout" name="verticalLayout_19" stretch="1,0,3">
+ <layout class="QGridLayout" name="gridLayout_2" rowstretch="0" columnstretch="0">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="control_separator">
<item>
- <layout class="QVBoxLayout" name="verticalLayout_20">
+ <layout class="QVBoxLayout" name="storage_pipe_separator">
<item>
- <widget class="QLabel" name="label_5">
- <property name="font">
- <font>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Registers</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_25">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTextEdit" name="register_table"/>
- </item>
- </layout>
- </item>
- <item>
- <widget class="Line" name="line_26">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_21">
+ <layout class="QHBoxLayout" name="storage_view">
<item>
- <widget class="QLabel" name="label_6">
- <property name="font">
- <font>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Cache</string>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="registers">
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="font">
+ <font>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Registers</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="register_table"/>
+ </item>
+ </layout>
</item>
<item>
- <widget class="Line" name="line_27">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="dram">
+ <item>
+ <widget class="QLabel" name="label_10">
+ <property name="font">
+ <font>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>DRAM</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="dram_table">
+ <property name="minimumSize">
+ <size>
+ <width>500</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item>
- <widget class="QTextEdit" name="cache_table"/>
+ <layout class="QVBoxLayout" name="cache">
+ <item>
+ <widget class="QLabel" name="label_6">
+ <property name="font">
+ <font>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Cache</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="cache_table">
+ <property name="minimumSize">
+ <size>
+ <width>500</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</item>
<item>
- <widget class="Line" name="line_28">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_22">
+ <layout class="QHBoxLayout" name="pipe_view">
<item>
- <widget class="QLabel" name="label_10">
- <property name="font">
- <font>
- <bold>true</bold>
- </font>
+ <widget class="QGroupBox" name="Fetch">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
</property>
- <property name="text">
- <string>DRAM</string>
+ <property name="title">
+ <string>Fetch</string>
</property>
+ <property name="alignment">
+ <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="DigitLabel" name="fetch_bits">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="fetch_squashed">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>
- <widget class="Line" name="line_29">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <widget class="QGroupBox" name="Decode">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Decode</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="DigitLabel" name="decode_bits">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="decode_squashed">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>
- <widget class="QTextEdit" name="dram_table"/>
+ <widget class="QGroupBox" name="Execute">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Execute</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="DigitLabel" name="execute_s1">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DigitLabel" name="execute_s2">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DigitLabel" name="execute_s3">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="execute_mnemonic">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="execute_squashed">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::TextFormat::MarkdownText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item row="1" column="0" colspan="5">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QGroupBox" name="Fetch">
- <property name="title">
- <string>Fetch</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLineEdit" name="fetch_instruction_bits">
- <property name="placeholderText">
- <string>Instruction Bits</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="fetch_pc">
- <property name="placeholderText">
- <string>Program Counter</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="Decode">
- <property name="title">
- <string>Decode</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLineEdit" name="decode_s1">
- <property name="placeholderText">
- <string>Instruction Bits</string>
- </property>
- </widget>
- </item>
- <!-- <item>
- <widget class="QLineEdit" name="decode_s2">
- <property name="text">
- <string/>
- </property>
- <property name="placeholderText">
- <string>Program COunte</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="decode_s3">
- <property name="placeholderText">
- <string>s3</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="decode_mnemonic">
- <property name="placeholderText">
- <string>Mnemonic</string>
- </property>
- </widget>
- </item> -->
- <item>
- <widget class="QLineEdit" name="decode_pc">
- <property name="placeholderText">
- <string>Program Counter</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="Execute">
- <property name="title">
- <string>Execute</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <widget class="QLineEdit" name="execute_s1">
- <property name="placeholderText">
- <string>s1</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="execute_s2">
- <property name="text">
- <string/>
- </property>
- <property name="placeholderText">
- <string>s2</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="execute_s3">
- <property name="placeholderText">
- <string>s3</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="execute_mnemonic">
- <property name="placeholderText">
- <string>Mnemonic</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="execute_pc">
- <property name="placeholderText">
- <string>Program Counter</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="Memory">
- <property name="title">
- <string>Memory</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <widget class="QLineEdit" name="memory_s1">
- <property name="placeholderText">
- <string>s1</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="memory_s2">
- <property name="text">
- <string/>
- </property>
- <property name="placeholderText">
- <string>s2</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="memory_s3">
- <property name="placeholderText">
- <string>s3</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="memory_mnemonic">
- <property name="placeholderText">
- <string>Mnemonic</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="memory_pc">
- <property name="placeholderText">
- <string>Program Counter</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_4">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="WriteBack">
- <property name="title">
- <string>Write Back</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_5">
- <item>
- <widget class="QLineEdit" name="wb_s1">
- <property name="placeholderText">
- <string>s1</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="wb_s2">
- <property name="text">
- <string/>
- </property>
- <property name="placeholderText">
- <string>s2</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="wb_s3">
- <property name="placeholderText">
- <string>s3</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="wb_mnemonic">
- <property name="placeholderText">
- <string>Mnemonic</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="wb_pc">
- <property name="placeholderText">
- <string>Program Counter</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- <item row="0" column="3">
- <layout class="QVBoxLayout" name="verticalLayout_23">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_24">
- <item>
- <widget class="QLabel" name="label_12">
- <property name="font">
- <font>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Upload Files</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_33">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_25">
<item>
- <widget class="QPushButton" name="upload_intructions_btn">
- <property name="text">
- <string>Upload Instruction File</string>
+ <widget class="QGroupBox" name="Memory">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Memory</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="DigitLabel" name="memory_s1">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DigitLabel" name="memory_s2">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DigitLabel" name="memory_s3">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="memory_mnemonic">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="memory_squashed">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_8">
- <item>
- <widget class="QPushButton" name="upload_program_state_btn">
- <property name="text">
- <string>Upload Program State File</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QGroupBox" name="WriteBack">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Write Back</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="DigitLabel" name="write_s1">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DigitLabel" name="write_s2">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DigitLabel" name="write_s3">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="write_mnemonic">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</item>
- <item>
- <widget class="Line" name="line_34">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout_26">
+ <layout class="QVBoxLayout" name="control_view">
<item>
<widget class="QLabel" name="label_13">
<property name="font">
@@ -429,205 +336,316 @@
</widget>
</item>
<item>
- <widget class="Line" name="line_35">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <layout class="QHBoxLayout" name="cache_controls">
+ <property name="sizeConstraint">
+ <enum>QLayout::SizeConstraint::SetMinimumSize</enum>
</property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_27">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <widget class="Line" name="line_8">
+ <property name="orientation">
+ <enum>Qt::Orientation::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="cache_way_text">
+ <property name="sizeConstraint">
+ <enum>QLayout::SizeConstraint::SetMinimumSize</enum>
+ </property>
<item>
- <widget class="QPushButton" name="refresh_dram_btn">
- <property name="text">
- <string>Refresh DRAM</string>
+ <widget class="QLabel" name="label">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
</property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="refresh_cache_btn">
<property name="text">
- <string>Refresh Cache</string>
+ <string>C1 2^</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="refresh_registers_btn">
- <property name="text">
- <string>Refresh Registers</string>
+ <widget class="QLabel" name="label_2">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
</property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_10">
- <item>
- <widget class="QPushButton" name="Reset_Btn">
<property name="text">
- <string>Reset</string>
+ <string>C2 2^</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="enable_pipeline_checkbox">
- <property name="text">
- <string>Enable Pipeline</string>
+ <widget class="QLabel" name="label_3">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
</property>
- <property name="checkable">
- <bool>false</bool>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
</property>
- <property name="checked">
- <bool>false</bool>
+ <property name="text">
+ <string>C3 2^</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="enabl_cache_checkbox">
- <property name="text">
- <string>Enable Cache</string>
+ <widget class="QLabel" name="label_4">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
</property>
- <property name="checkable">
- <bool>false</bool>
+ <property name="text">
+ <string>C4 2^</string>
</property>
</widget>
</item>
</layout>
</item>
+ <item>
+ <widget class="DynamicWaysEntry" name="cache_way_selector" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_28">
- <item>
- <widget class="Line" name="line_36">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
<item>
- <widget class="QLabel" name="label_14">
- <property name="font">
- <font>
- <bold>true</bold>
- </font>
- </property>
+ <widget class="QCheckBox" name="enable_pipeline_checkbox">
<property name="text">
- <string>Run</string>
+ <string>Enable Pipeline</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
</widget>
</item>
<item>
- <widget class="Line" name="line_37">
+ <widget class="Line" name="line">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout_29">
+ <layout class="QVBoxLayout" name="file_controls">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_29">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_24">
+ <item>
+ <widget class="QLabel" name="label_12">
+ <property name="font">
+ <font>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Upload Files</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_25">
+ <item>
+ <widget class="QPushButton" name="upload_intructions_btn">
+ <property name="text">
+ <string>Load Instructions</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="upload_program_state_btn">
+ <property name="text">
+ <string>Upload Program State</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="save_program_state_btn">
+ <property name="text">
+ <string>Save Program State</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_8"/>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Orientation::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="config">
+ <property name="text">
+ <string>Initialize!</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Orientation::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <layout class="QVBoxLayout" name="simulation_controls">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_13">
+ <item>
+ <widget class="QLabel" name="state_header">
+ <property name="font">
+ <font>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>State</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="base_toggle_checkbox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Decimal</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QLabel" name="pc">
+ <property name="text">
+ <string>PC</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DigitLabel" name="p_counter">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="cycles">
+ <property name="text">
+ <string>Cycle</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DigitLabel" name="cycle_counter">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item>
- <widget class="QLineEdit" name="number_steps_inp">
- <property name="placeholderText">
- <string># Steps</string>
+ <widget class="QSlider" name="step_slider">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>6</number>
+ </property>
+ <property name="pageStep">
+ <number>1</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TickPosition::NoTicks</enum>
+ </property>
+ <property name="tickInterval">
+ <number>1</number>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="run_steps_btn">
+ <widget class="QPushButton" name="step_btn">
+ <property name="minimumSize">
+ <size>
+ <width>400</width>
+ <height>0</height>
+ </size>
+ </property>
<property name="text">
- <string>Run Steps</string>
+ <string>Step 1</string>
</property>
</widget>
</item>
</layout>
</item>
- <item>
- <widget class="QPushButton" name="step_btn">
- <property name="text">
- <string>Step</string>
- </property>
- </widget>
- </item>
</layout>
</item>
</layout>
</item>
- <item>
- <widget class="Line" name="line_38">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_30">
- <item>
- <widget class="QLabel" name="label_15">
- <property name="font">
- <font>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Program State</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_39">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="cycles_label">
- <property name="text">
- <string>Clock Cycles</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="save_program_state_btn">
- <property name="text">
- <string>Save Current Program State</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</item>
- <item row="0" column="2">
- <widget class="Line" name="line_5">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
</layout>
</item>
</layout>
</widget>
- <widget class="QMenuBar" name="menubar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>1359</width>
- <height>26</height>
- </rect>
- </property>
- </widget>
- <widget class="QStatusBar" name="statusbar"/>
+ <widget class="QStatusBar" name="statusBar"/>
</widget>
-<resources/>
+ <customwidgets>
+ <customwidget>
+ <class>DynamicWaysEntry</class>
+ <extends>QWidget</extends>
+ <header>dynamicwaysentry.h</header>
+ <container>1</container>
+ </customwidget>
+ <customwidget>
+ <class>DigitLabel</class>
+ <extends>QLabel</extends>
+ <header location="global">digitlabel.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
<connections/>
</ui>
diff --git a/gui/main.cc b/gui/main.cc
index eb0129e..9877a3c 100644
--- a/gui/main.cc
+++ b/gui/main.cc
@@ -15,10 +15,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-#include "pipe_spec.h"
#include "gui.h"
#include "logger.h"
+#include "pipe_spec.h"
#include <QApplication>
+#include <QFile>
+#include <QFontDatabase>
#include <getopt.h>
#include <iostream>
@@ -84,6 +86,16 @@ int main(int argc, char **argv)
global_log->log(INFO, "Starting QT...");
QApplication a(argc, argv);
+
+ int fId = QFontDatabase::addApplicationFont(
+ ":/resources/BigBlueTermPlusNerdFontMono-Regular.ttf");
+ QFile ssf(":/resources/styles.qss");
+ QString f = QFontDatabase::applicationFontFamilies(fId).at(0);
+
+ ssf.open(QFile::ReadOnly);
+ QString ss = QLatin1String(ssf.readAll());
+ a.setStyleSheet(ss);
+
GUI w;
w.show();
return a.exec();
diff --git a/gui/messages.h b/gui/messages.h
new file mode 100644
index 0000000..461c461
--- /dev/null
+++ b/gui/messages.h
@@ -0,0 +1,71 @@
+// Simulator for the RISC-V[ECTOR] mini-ISA
+// Copyright (C) 2025 Siddarth Suresh
+// Copyright (C) 2025 bdunahu
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#ifndef MESSAGES_H
+#define MESSAGES_H
+#include <string>
+#include <vector>
+
+/**
+ * Humorous computer speak.
+ */
+#define RANDOM_MESSAGE(v) (v[std::rand() % v.size()])
+
+const std::vector<std::string> waiting = {
+ "WAITING FOR USER", "IDLE", "BORED", "SLEEPING",
+ "TAKING A BREAK", "IDLING", "DAYDREAMING", "WAITING FOR INPUT"};
+const std::vector<std::string> running = {
+ "COMPUTING", "WORKING", "BUSY", "RUNNING"};
+const std::vector<std::string> load_file = {
+ "FILE LOADED", "FILE PARSED", "FILE READ", "READING... DONE"};
+const std::vector<std::string> no_instructions = {
+ "NO PROGRAM PROVIDED", "NOTHING TO DO, GIVING UP", "INSTRUCTIONS MISSING",
+ "404 INSTRUCTIONS NOT FOUND"};
+const std::vector<std::string> bad_cache = {
+ "WAYS CANNOT BE BELOW 0 OR ABOVE 4"};
+const std::vector<std::string> no_pipeline = {
+ "SIMULATION READY: NO PIPE", "PIPE OFF, SIMULATION READY"};
+const std::vector<std::string> no_cache = {
+ "SIMULATION READY: NO CACHE", "CACHE OFF, SIMULATION READY"};
+const std::vector<std::string> initialize = {
+ "SIMULATION READY", "ALL MODULES LOADED, SIMULATION READY"};
+
+/**
+ * @return an unsolicited status messages
+ */
+std::string get_waiting() { return RANDOM_MESSAGE(waiting); }
+std::string get_running() { return RANDOM_MESSAGE(running); }
+
+/**
+ * @return confirmation of file upload
+ */
+std::string get_load_file() { return RANDOM_MESSAGE(load_file); }
+
+/**
+ * @return a friendly reminder that the simulation is not configured yet
+ */
+std::string get_no_instructions() { return RANDOM_MESSAGE(no_instructions); }
+std::string get_bad_cache() { return RANDOM_MESSAGE(bad_cache); }
+
+/**
+ * @return unsolicited complaints for successful initialization
+ */
+std::string get_no_pipeline() { return RANDOM_MESSAGE(no_pipeline); }
+std::string get_no_cache() { return RANDOM_MESSAGE(no_cache); }
+std::string get_initialize() { return RANDOM_MESSAGE(initialize); }
+
+#endif // MESSAGES_H
diff --git a/gui/resources.qrc b/gui/resources.qrc
index 8bfd4e7..569cc22 100644
--- a/gui/resources.qrc
+++ b/gui/resources.qrc
@@ -1,6 +1,11 @@
<!DOCTYPE RCC>
<RCC version="1.0">
- <qresource prefix="/resources">
- <file alias="input.txt">resources/input.txt</file>
+ <qresource>
+ <file>resources/styles.qss</file>
+ <file>resources/idle.png</file>
+ <file>resources/angry.png</file>
+ <file>resources/happy.png</file>
+ <file>resources/busy.png</file>
+ <file>resources/BigBlueTermPlusNerdFontMono-Regular.ttf</file>
</qresource>
</RCC>
diff --git a/gui/resources/BigBlueTermPlusNerdFont-Regular.ttf b/gui/resources/BigBlueTermPlusNerdFont-Regular.ttf
new file mode 100644
index 0000000..d8ad007
--- /dev/null
+++ b/gui/resources/BigBlueTermPlusNerdFont-Regular.ttf
Binary files differ
diff --git a/gui/resources/BigBlueTermPlusNerdFontMono-Regular.ttf b/gui/resources/BigBlueTermPlusNerdFontMono-Regular.ttf
new file mode 100644
index 0000000..1757e92
--- /dev/null
+++ b/gui/resources/BigBlueTermPlusNerdFontMono-Regular.ttf
Binary files differ
diff --git a/gui/resources/BigBlueTermPlusNerdFontPropo-Regular.ttf b/gui/resources/BigBlueTermPlusNerdFontPropo-Regular.ttf
new file mode 100644
index 0000000..c30176d
--- /dev/null
+++ b/gui/resources/BigBlueTermPlusNerdFontPropo-Regular.ttf
Binary files differ
diff --git a/gui/resources/angry.png b/gui/resources/angry.png
new file mode 100644
index 0000000..3299eb4
--- /dev/null
+++ b/gui/resources/angry.png
Binary files differ
diff --git a/gui/resources/busy.png b/gui/resources/busy.png
new file mode 100644
index 0000000..df1b36a
--- /dev/null
+++ b/gui/resources/busy.png
Binary files differ
diff --git a/gui/resources/happy.png b/gui/resources/happy.png
new file mode 100644
index 0000000..6168e89
--- /dev/null
+++ b/gui/resources/happy.png
Binary files differ
diff --git a/gui/resources/idle.png b/gui/resources/idle.png
new file mode 100644
index 0000000..f894716
--- /dev/null
+++ b/gui/resources/idle.png
Binary files differ
diff --git a/gui/resources/input.txt b/gui/resources/input.txt
deleted file mode 100644
index fc1c3cf..0000000
--- a/gui/resources/input.txt
+++ /dev/null
@@ -1 +0,0 @@
-Lorem Ipsum \ No newline at end of file
diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss
new file mode 100644
index 0000000..dbaa623
--- /dev/null
+++ b/gui/resources/styles.qss
@@ -0,0 +1,167 @@
+* {
+ font-family: "BigBlueTermPlusNerdFontMono", "monospace";
+ font-size: 20pt;
+ color: "#00cc00";
+ background-color: "#000200";
+ border: 0px solid "#000200";
+}
+
+QStatusBar {
+ font-size: 12pt;
+ color: "#000200";
+ background-color: "#00cc00";
+}
+
+QLabel#msg_label {
+ font-size: 12pt;
+ color: "#000200";
+ background-color: "#00cc00";
+}
+
+QLabel#info_label {
+ font-size: 12pt;
+ color: "#000200";
+ background-color: "#00cc00";
+}
+
+QLabel#avatar_label {
+ background-color: "#00cc00";
+}
+
+/* main window */
+QWidget {
+}
+
+QGroupBox {
+ text-decoration: underline "#00cc00";
+ font-size: 17pt;
+ border: 4px solid ;
+ border-radius: 0px;
+ margin-top: 1ex; /* leave space at the top for the title */
+}
+
+QGroupBox::title {
+ subcontrol-origin: margin;
+ subcontrol-position: top left;
+ border-radius: 0px;
+ padding: 0 2px;
+}
+
+QLabel {
+}
+
+/* text entry */
+QLineEdit {
+ font-size: 18pt;
+ border-radius: 0px;
+ padding: 0 4px;
+ selection-background-color: "#00cc00";
+}
+
+QTextEdit, QListView {
+ font-size: 10pt;
+}
+
+QPushButton {
+ color: "#000200";
+ background-color: "#00cc00";
+ border-radius: 0px;
+ padding: 1px;
+}
+
+
+QPushButton:pressed {
+ color: "#00cc00";
+ background-color: "#000200";
+}
+
+QPushButton:flat {
+ border: none; /* no border for a flat push button */
+}
+
+QPushButton:default {
+ border-color: "#00cc00";
+}
+
+QMenuBar {
+ background-color: "#00cc00";
+ spacing: 3px; /* spacing between menu bar items */
+}
+
+QMenuBar::item {
+ padding: 1px 4px;
+ background: transparent;
+ border-radius: 4px;
+}
+
+QCheckBox {
+ spacing: 5px;
+}
+
+QCheckBox::indicator {
+ width: 13px;
+ height: 13px;
+ border: 2px solid "#00cc00";
+}
+
+QCheckBox::indicator:unchecked {
+}
+
+/* QCheckBox::indicator:unchecked:pressed { */
+/* image: url(:/images/checkbox_unchecked_pressed.png); */
+/* } */
+
+QCheckBox::indicator:checked {
+ background: "#00cc00";
+}
+
+QSlider::groove:horizontal {
+ height: 10px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
+ background: "#00cc00";
+ margin: 50px 0;
+}
+
+QSlider::handle:horizontal {
+ background: "#00cc00";
+ width: 20px;
+ margin: -50px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
+ border-radius: 3px;
+}
+
+QScrollBar:horizontal {
+ border: 4px solid "#00cc00";
+}
+
+QScrollBar::handle:horizontal {
+ height: 16px;
+ background-color: "#00cc00";
+}
+
+QScrollBar::add-line:horizontal {
+ border: 4px solid "#00cc00";
+}
+
+QScrollBar::sub-line:horizontal {
+ border: 4px solid "#00cc00";
+}
+
+QScrollBar:vertical {
+ border: 4px solid "#00cc00";
+}
+
+QScrollBar::handle:vertical {
+ width: 16px;
+ background-color: "#00cc00";
+}
+
+QScrollBar::add-line:vertical {
+ border: 4px solid "#00cc00";
+}
+
+QScrollBar::sub-line:vertical {
+ border: 4px solid "#00cc00";
+}
+
+/* Local Variables: */
+/* mode: css */
+/* End: */
diff --git a/gui/worker.cc b/gui/worker.cc
index 4b5277c..ba0723e 100644
--- a/gui/worker.cc
+++ b/gui/worker.cc
@@ -16,79 +16,71 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "worker.h"
+#include "storage.h"
Worker::Worker(QObject *parent) : QObject(parent) {}
-void Worker::doWork()
-{
- qDebug() << "Initializing...";
- this->d = new Dram(0);
- this->c = new Cache(this->d, 8, 0, 0);
- this->if_stage = new IF(nullptr);
- this->id_stage = new ID(if_stage);
- this->ex_stage = new EX(id_stage);
- this->mm_stage = new MM(ex_stage);
- this->wb_stage = new WB(mm_stage);
- this->ct = new Controller(wb_stage, this->c, true);
-
- emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc());
- emit dram_storage(this->d->view(0, 255));
- emit cache_storage(this->c->view(0, 255));
- emit register_storage(this->ct->get_gprs());
-}
-
Worker::~Worker()
{
emit finished();
qDebug() << "Worker destructor called in thread:"
<< QThread::currentThread();
delete this->ct;
- delete this->c;
-}
-
-void Worker::loadProgram(std::vector<signed int> p) {
- this->d->load(p);
}
-void Worker::refreshDram()
+void Worker::configure(
+ std::vector<unsigned int> ways,
+ std::vector<signed int> program,
+ bool is_pipelined)
{
- qDebug() << "Refreshing Dram";
- emit dram_storage(this->d->view(0, 31));
-}
+ Dram *d;
+ Storage *s;
+ Stage *old;
+ int i;
-void Worker::refreshCache()
-{
- qDebug() << "Refreshing Dram";
- emit cache_storage(this->c->view(0, 255));
-}
+ this->ct_mutex.lock();
+ if (ways.size() != 0) {
+ // TODO optimal proper sizes
+ this->size_inc = ((MEM_LINE_SPEC * 0.75) / ways.size());
+ }
+ d = new Dram(DRAM_DELAY);
+ s = static_cast<Storage *>(d);
-void Worker::refreshRegisters()
-{
- qDebug() << "Refreshing Registers";
- emit register_storage(this->ct->get_gprs());
-}
+ this->s.push_front(s);
+ d->load(program);
-void Worker::runSteps(int steps)
-{
- qDebug() << "Running for steps: " << steps;
- this->ct->run_for(steps);
- emit dram_storage(this->d->view(0, 255));
- emit cache_storage(this->c->view(0, 255));
- emit register_storage(this->ct->get_gprs());
+ for (i = ways.size(); i > 0; --i) {
+ s = static_cast<Storage *>(new Cache(
+ s, this->size_inc * (i), ways.at(i - 1), CACHE_DELAY + i));
+ this->s.push_front(s);
+ }
+
+ this->if_stage = new IF(nullptr);
+ this->id_stage = new ID(if_stage);
+ this->ex_stage = new EX(id_stage);
+ this->mm_stage = new MM(ex_stage);
+ this->wb_stage = new WB(mm_stage);
+
+ old = static_cast<Stage *>(this->ct);
+ this->ct = new Controller(wb_stage, s, is_pipelined);
+ if (old)
+ delete old;
+ this->ct_mutex.unlock();
+
+ std::cout << this->ct->get_clock_cycle() << ":" << this->ct->get_pc() << std::endl;
emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc());
- emit if_info(this->if_stage->stage_info());
- emit id_info(this->id_stage->stage_info());
- emit ex_info(this->ex_stage->stage_info());
- emit mm_info(this->mm_stage->stage_info());
- emit wb_info(this->wb_stage->stage_info());
}
-void Worker::runStep()
+void Worker::runSteps(int steps)
{
- qDebug() << "Running for 1 step ";
- this->ct->run_for(1);
- emit dram_storage(this->d->view(0, 255));
- emit cache_storage(this->c->view(0, 255));
+ this->ct_mutex.lock();
+ qDebug() << "Running for " << steps << "steps";
+ this->ct->run_for(steps);
+ // TODO move these to separate functions
+ emit dram_storage(this->s.back()->view(0, 255));
+ if (this->s.size() > 1) {
+ emit cache_storage(this->s.at(0)->view(0, 1 << this->size_inc));
+ }
emit register_storage(this->ct->get_gprs());
emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc());
emit if_info(this->if_stage->stage_info());
@@ -96,4 +88,5 @@ void Worker::runStep()
emit ex_info(this->ex_stage->stage_info());
emit mm_info(this->mm_stage->stage_info());
emit wb_info(this->wb_stage->stage_info());
+ this->ct_mutex.unlock();
}
diff --git a/gui/worker.h b/gui/worker.h
index 7512b9b..62c8d84 100644
--- a/gui/worker.h
+++ b/gui/worker.h
@@ -18,56 +18,68 @@
#ifndef WORKER_H
#define WORKER_H
-#include <QObject>
-#include <QThread>
-#include <QDebug>
-
+#include "cache.h"
#include "controller.h"
#include "dram.h"
-#include "cache.h"
+#include "ex.h"
#include "id.h"
#include "if.h"
-#include "ex.h"
#include "mm.h"
#include "wb.h"
+#include <QDebug>
+#include <QMutex>
+#include <QObject>
+#include <QThread>
+#include <deque>
+
+class Worker : public QObject
+{
+ Q_OBJECT
+
+ private:
+ /**
+ * The storage objects, stored smallest to largest.
+ */
+ std::deque<Storage *> s;
+ IF *if_stage;
+ ID *id_stage;
+ EX *ex_stage;
+ MM *mm_stage;
+ WB *wb_stage;
-class Worker : public QObject {
- Q_OBJECT
+ Controller *ct = nullptr;
+ QMutex ct_mutex;
-private:
- Cache *c;
- Dram *d;
- Controller *ct;
- ID *id_stage;
- IF *if_stage;
- EX *ex_stage;
- MM *mm_stage;
- WB *wb_stage;
+ /**
+ * The size each progressive cache level increases by.
+ */
+ unsigned int size_inc;
-public:
- explicit Worker(QObject *parent = nullptr);
- ~Worker();
+ public:
+ explicit Worker(QObject *parent = nullptr);
+ ~Worker();
+ QMutex &get_ct_mutex() { return ct_mutex; }
-public slots:
- void doWork();
- void refreshDram();
- void loadProgram(std::vector<signed int> p);
- void refreshCache();
- void refreshRegisters();
- void runSteps(int steps);
- void runStep();
+ public slots:
+ void runSteps(int steps);
+ void configure(
+ std::vector<unsigned int> ways,
+ std::vector<signed int> program,
+ bool is_pipelined);
-signals:
- void clock_cycles(int value, int pc);
- void dram_storage(const std::vector<std::array<signed int, LINE_SIZE>> data);
- void cache_storage(const std::vector<std::array<signed int, LINE_SIZE>> data);
- void register_storage(const std::array<int, GPR_NUM> data);
- void if_info(const std::vector<int> info);
- void id_info(const std::vector<int> info);
- void ex_info(const std::vector<int> info);
- void mm_info(const std::vector<int> info);
- void wb_info(const std::vector<int> info);
- void finished();
+ signals:
+ void clock_cycles(int value, int pc);
+ void
+ dram_storage(const std::vector<std::array<signed int, LINE_SIZE>> data);
+ void
+ cache_storage(const std::vector<std::array<signed int, LINE_SIZE>> data);
+ void register_storage(const std::array<int, GPR_NUM> data);
+ void if_info(const std::vector<int> info);
+ void id_info(const std::vector<int> info);
+ void ex_info(const std::vector<int> info);
+ void mm_info(const std::vector<int> info);
+ void wb_info(const std::vector<int> info);
+ void finished();
};
#endif // WORKER_H
diff --git a/inc/pipe_spec.h b/inc/pipe_spec.h
index 1fa7661..0433f23 100644
--- a/inc/pipe_spec.h
+++ b/inc/pipe_spec.h
@@ -66,6 +66,16 @@
#define MAX_INT 2147483647
/**
+ * The delay on DRAM objects.
+ */
+#define DRAM_DELAY 10
+
+/**
+ * The (base) on cache objects.
+ */
+#define CACHE_DELAY 1
+
+/**
* Return the N least-significant bits from integer K using a bit mask
* @param the integer to be parsed
* @param the number of bits to be parsed
diff --git a/src/sim/id.cc b/src/sim/id.cc
index db72486..3753f83 100644
--- a/src/sim/id.cc
+++ b/src/sim/id.cc
@@ -221,7 +221,7 @@ std::vector<int> ID::stage_info()
{
std::vector<int> info;
if (this->curr_instr) {
- info.push_back(this->curr_instr->get_pc());
+ info.push_back(this->curr_instr->is_squashed());
info.push_back(this->curr_instr->get_instr_bits());
}
return info;
diff --git a/src/sim/if.cc b/src/sim/if.cc
index 279ac79..e8e7272 100644
--- a/src/sim/if.cc
+++ b/src/sim/if.cc
@@ -43,7 +43,7 @@ InstrDTO *IF::advance(Response p)
std::vector<int> IF::stage_info() {
std::vector<int> info;
if(this->curr_instr){
- info.push_back(this->curr_instr->get_pc());
+ info.push_back(this->curr_instr->is_squashed());
info.push_back(this->curr_instr->get_instr_bits());
}
return info;
diff --git a/src/sim/stage.cc b/src/sim/stage.cc
index 7936ccc..35c6936 100644
--- a/src/sim/stage.cc
+++ b/src/sim/stage.cc
@@ -76,7 +76,7 @@ std::vector<int> Stage::stage_info()
std::vector<int> info;
if (this->curr_instr) {
info.push_back(this->curr_instr->get_mnemonic());
- info.push_back(this->curr_instr->get_pc());
+ info.push_back(this->curr_instr->is_squashed());
info.push_back(this->curr_instr->get_s1());
info.push_back(this->curr_instr->get_s2());
info.push_back(this->curr_instr->get_s3());