summaryrefslogtreecommitdiff
path: root/gui/gui.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-19 03:37:43 -0400
committerbd <bdunahu@operationnull.com>2025-04-19 03:37:43 -0400
commitbb3d940fb4ce0dd3efc56b934a7b4ea8ffab4b13 (patch)
tree857e9ee14530e4492c6e6f612bce227a3197fd48 /gui/gui.cc
parent327ba8b631436cf21866c05c6c7cae239fe54a5c (diff)
GUI validate program
Diffstat (limited to 'gui/gui.cc')
-rw-r--r--gui/gui.cc54
1 files changed, 51 insertions, 3 deletions
diff --git a/gui/gui.cc b/gui/gui.cc
index a36920b..3a1027a 100644
--- a/gui/gui.cc
+++ b/gui/gui.cc
@@ -1,5 +1,6 @@
#include "gui.h"
#include "./ui_gui.h"
+#include "dynamicwaysentry.h"
#include "messages.h"
GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI)
@@ -43,6 +44,11 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI)
connect(
worker, &Worker::register_storage, this, &GUI::onWorkerShowRegisters);
+ // Configure pipeline
+ connect(
+ this, &GUI::sendConfigure, worker, &Worker::configure,
+ Qt::QueuedConnection);
+
// // Refresh DRAM from worker thread
// connect(this, &GUI::sendRefreshDram, worker, &Worker::refreshDram,
// Qt::QueuedConnection);
@@ -56,7 +62,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI)
this, &GUI::sendRefreshRegisters, worker, &Worker::refreshRegisters,
Qt::QueuedConnection);
- // Advance controller by somes steps
+ // Advance controller by some steps
connect(
this, &GUI::sendRunSteps, worker, &Worker::runSteps,
Qt::QueuedConnection);
@@ -269,7 +275,7 @@ void GUI::on_upload_intructions_btn_clicked()
}
if (this->p.empty())
- this->set_status(get_no_instructions);
+ this->set_status(get_no_instructions);
else
this->set_status(get_load_file);
@@ -297,6 +303,8 @@ void GUI::on_enable_pipeline_checkbox_checkStateChanged(
void GUI::on_step_btn_clicked()
{
qDebug() << "Run step button clicked.";
+ if (!this->ready)
+ return this->on_config_clicked();
int steps = step_values[ui->step_slider->value()];
emit sendRunSteps(steps);
}
@@ -307,7 +315,47 @@ void GUI::on_save_program_state_btn_clicked()
qDebug() << "save program state button is clicked.";
}
+void GUI::on_config_clicked()
+{
+ 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);
+ return;
+ }
+ }
+
+ if (this->p.empty()) {
+ this->set_status(get_no_instructions);
+ return;
+ }
+
+ this->ready = true;
+
+ // say something snarky
+ if (!is_pipelined)
+ this->set_status(get_no_pipeline);
+ else if (ways.size() == 0)
+ this->set_status(get_no_cache);
+ else
+ this->set_status(get_initialize);
+
+ emit sendConfigure(ways, is_pipelined);
+}
+
void GUI::set_status(const std::function<std::string()> &func)
{
- this->status_label->setText("COMPUTER SAYS: \"" + QString::fromStdString(func()) + "\"");
+ this->status_label->setText(
+ "COMPUTER SAYS: \"" + QString::fromStdString(func()) + "\"");
}