summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-21 18:55:26 -0400
committerbd <bdunahu@operationnull.com>2025-04-21 18:55:26 -0400
commitefc4ce2d15aeb54dccf9493c11de9bb8467033c1 (patch)
tree599082f31a76228cdff6c7180ea1a9082f027a39 /gui
parent812a0036787bea3833bdbf2684a706d4a7165cf1 (diff)
Untested multi-cache-view
Diffstat (limited to 'gui')
-rw-r--r--gui/dynamicwaysentry.cc2
-rw-r--r--gui/gui.cc58
-rw-r--r--gui/gui.h45
-rw-r--r--gui/gui.ui46
-rw-r--r--gui/worker.cc14
-rw-r--r--gui/worker.h4
6 files changed, 77 insertions, 92 deletions
diff --git a/gui/dynamicwaysentry.cc b/gui/dynamicwaysentry.cc
index e1f740e..cbd5342 100644
--- a/gui/dynamicwaysentry.cc
+++ b/gui/dynamicwaysentry.cc
@@ -55,7 +55,7 @@ void DynamicWaysEntry::on_number_enter(const QString &t)
entries[i] = t;
if (i == this->fields.size() - 1 && !t.isEmpty() &&
- (this->parse_valid_way(t) > 0) && fields.size() < 4)
+ (this->parse_valid_way(t) >= 0) && fields.size() < 4)
add_field();
// TODO, unlink, don't trash everything after
diff --git a/gui/gui.cc b/gui/gui.cc
index 30c4a07..496a443 100644
--- a/gui/gui.cc
+++ b/gui/gui.cc
@@ -49,8 +49,8 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI)
worker->moveToThread(&workerThread);
// find all the labels
- QList<DigitLabel*> labels = this->findChildren<DigitLabel*>();
- for (DigitLabel* label : 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);
@@ -68,11 +68,8 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI)
connect(worker, &Worker::wb_info, this, &GUI::onWorkerWriteBackInfo);
- // Display dram
- connect(worker, &Worker::dram_storage, this, &GUI::onWorkerShowDram);
-
// Display cache
- connect(worker, &Worker::cache_storage, this, &GUI::onWorkerShowCache);
+ connect(worker, &Worker::storage, this, &GUI::onWorkerShowStorage);
// Display registers
connect(
@@ -246,21 +243,16 @@ void GUI::onWorkerWriteBackInfo(const std::vector<int> info)
}
}
-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)
+void GUI::onWorkerShowStorage(
+ const std::vector<std::array<signed int, LINE_SIZE>> data, int i)
{
- displayTableHTML(ui->cache_table, data);
+ std::cout << this->tab_text_boxes.size() << std::endl;
+ displayTableHTML(this->tab_text_boxes.at(i), data);
}
void GUI::onWorkerShowRegisters(const std::array<int, GPR_NUM> &data)
{
- displayArrayHTML(ui->register_table, data);
+ displayArrayHTML(this->tab_text_boxes.at(0), data);
}
void GUI::onWorkerFinished() { qDebug() << "Worker has finished processing."; }
@@ -269,9 +261,9 @@ void GUI::on_upload_intructions_btn_clicked()
{
qDebug() << "Upload intructions button clicked.";
- // why register_table?
+ // why ui->register_table, or now ui->storage
QString filePath = QFileDialog::getOpenFileName(
- ui->register_table, "Open Binary File", QDir::homePath(),
+ ui->storage, "Open Binary File", QDir::homePath(),
"Binary Files (*.bin *.rv);;All Files (*.*)");
QFile file(filePath);
if (filePath.isEmpty() || !file.open(QIODevice::ReadOnly)) {
@@ -353,7 +345,7 @@ void GUI::on_config_clicked()
continue;
i = dwe->parse_valid_way(s);
- if (i != -1) {
+ if (i >= 0) {
ways.push_back((unsigned int)i);
} else {
this->set_status(get_bad_cache, "angry");
@@ -377,6 +369,34 @@ void GUI::on_config_clicked()
this->set_status(get_initialize, "happy");
emit sendConfigure(ways, this->p, is_pipelined);
+ make_tabs(2 + ways.size());
+}
+
+void GUI::make_tabs(int num)
+{
+ int i;
+ QStringList names;
+ QTextEdit *e;
+ QString n;
+
+ names = {"Registers", "DRAM"};
+
+ ui->storage->clear();
+ this->tab_text_boxes.clear();
+
+ for (i = 0; i < num; ++i) {
+ e = new QTextEdit();
+ e->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+ // make the name
+ if (i < names.size())
+ n = names[i];
+ else
+ n = QString("Level %1").arg(i - 1);
+
+ ui->storage->addTab(e, n);
+ this->tab_text_boxes.push_back(e);
+ }
}
void GUI::set_status(
diff --git a/gui/gui.h b/gui/gui.h
index 0b10145..cf31142 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -48,15 +48,6 @@ class GUI : public QMainWindow
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);
@@ -76,11 +67,8 @@ class GUI : public QMainWindow
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 onWorkerShowStorage(
+ const std::vector<std::array<signed int, LINE_SIZE>> data, int i);
void onWorkerShowRegisters(const std::array<int, GPR_NUM> &data);
@@ -93,8 +81,7 @@ class GUI : public QMainWindow
void
on_enable_pipeline_checkbox_checkStateChanged(const Qt::CheckState &arg1);
- void
- on_base_toggle_checkbox_checkStateChanged(const Qt::CheckState &state);
+ void on_base_toggle_checkbox_checkStateChanged(const Qt::CheckState &state);
void on_step_btn_clicked();
@@ -117,6 +104,11 @@ class GUI : public QMainWindow
bool ready;
/**
+ * The list of storage displays.
+ */
+ std::vector<QTextEdit *> tab_text_boxes;
+
+ /**
* Whether or not numerical values are currently displaying in hex.
*/
bool is_hex = true;
@@ -132,12 +124,11 @@ class GUI : public QMainWindow
QLabel *avatar;
/**
- * The currently loaded program.
+ * The next simulation's program.
*/
std::vector<signed int> p;
-
/**
- * If this stage is pipelined or not.
+ * If the next initialized simulation is pipelined or not.
*/
bool is_pipelined = true;
@@ -176,5 +167,21 @@ class GUI : public QMainWindow
auto it = mnemonicNameMap.find(mnemonic);
return (it != mnemonicNameMap.end()) ? it->second : "Unknown";
}
+
+ /**
+ * Helper for 'on_config_clicked'.
+ * Initialized the tab component with enough views for the simulation's
+ * storage devices.
+ * @param the number of tabs required to show registers, DRAM, and cache.
+ */
+ void make_tabs(int num);
+ /**
+ * 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");
};
#endif // GUI_H
diff --git a/gui/gui.ui b/gui/gui.ui
index e81bca9..0326217 100644
--- a/gui/gui.ui
+++ b/gui/gui.ui
@@ -35,52 +35,8 @@
</size>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>-1</number>
</property>
- <widget class="QWidget" name="Registers">
- <attribute name="title">
- <string>Registers</string>
- </attribute>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <widget class="QTextEdit" name="register_table"/>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="tab">
- <attribute name="title">
- <string>DRAM</string>
- </attribute>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <widget class="QTextEdit" name="dram_table">
- <property name="minimumSize">
- <size>
- <width>500</width>
- <height>0</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="tab_2">
- <attribute name="title">
- <string>Level 1</string>
- </attribute>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QTextEdit" name="cache_table">
- <property name="minimumSize">
- <size>
- <width>500</width>
- <height>0</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
</widget>
</item>
<item>
diff --git a/gui/worker.cc b/gui/worker.cc
index ba0723e..2f10c7c 100644
--- a/gui/worker.cc
+++ b/gui/worker.cc
@@ -67,21 +67,25 @@ void Worker::configure(
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());
}
void Worker::runSteps(int steps)
{
+ unsigned long i;
+
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 storage(this->s.at(0)->view(0, 255), 1);
+
+ for (i = 1; i < s.size(); ++i)
+ emit storage(this->s.at(i - 1)->view(0, 1 << this->size_inc * i), i + 1);
+
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());
diff --git a/gui/worker.h b/gui/worker.h
index 62c8d84..95c81d5 100644
--- a/gui/worker.h
+++ b/gui/worker.h
@@ -70,9 +70,7 @@ class Worker : public QObject
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);
+ storage(const std::vector<std::array<signed int, LINE_SIZE>> data, int i);
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);