From 812a0036787bea3833bdbf2684a706d4a7165cf1 Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 21 Apr 2025 17:09:00 -0400 Subject: Add tab bar --- gui/gui.cc | 2 + gui/gui.ui | 227 +++++++++++++++++++++++++++++++++-------------- gui/resources/styles.qss | 13 ++- 3 files changed, 173 insertions(+), 69 deletions(-) diff --git a/gui/gui.cc b/gui/gui.cc index 294a7d0..30c4a07 100644 --- a/gui/gui.cc +++ b/gui/gui.cc @@ -233,11 +233,13 @@ void GUI::onWorkerWriteBackInfo(const std::vector info) { if (!info.empty()) { ui->write_mnemonic->setText(mnemonicToString((Mnemonic)info[0])); + ui->write_squashed->setText(QString::number(info[1])); 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_squashed->clear(); ui->write_s1->clear(); ui->write_s2->clear(); ui->write_s3->clear(); diff --git a/gui/gui.ui b/gui/gui.ui index dbb3a33..e81bca9 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -24,80 +24,128 @@ - - - - - - true - - - - Registers - - - - - - - + - - - - - - true - - - - DRAM - - - - - - - - 500 - 0 - - - - - + + + + 700 + 0 + + + + 0 + + + + Registers + + + + + + + + + + DRAM + + + + + + + 500 + 0 + + + + + + + + + Level 1 + + + + + + + 500 + 0 + + + + + + + - - - - - - true - - - - Cache - - - - - - - - 500 - 0 - - - - - + + + + + + + + + 120 + 16777215 + + + + + + + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop + + + + + + s1 + + + + + + + s2 + + + + + + + s3 + + + + + + + alias + + + + + + + dead + + + + + + @@ -113,6 +161,27 @@ Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop + + + + + + + + + + + + + + + + + + + + + @@ -145,6 +214,27 @@ Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop + + + + + + + + + + + + + + + + + + + + + @@ -314,6 +404,13 @@ + + + + + + + diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss index dbaa623..ee92867 100644 --- a/gui/resources/styles.qss +++ b/gui/resources/styles.qss @@ -107,14 +107,19 @@ QCheckBox::indicator { QCheckBox::indicator:unchecked { } -/* QCheckBox::indicator:unchecked:pressed { */ -/* image: url(:/images/checkbox_unchecked_pressed.png); */ -/* } */ - QCheckBox::indicator:checked { background: "#00cc00"; } +QTabWidget::tab-bar { + alignment: center; +} + +QTabBar::tab:selected { + color: "#000200"; + background-color: "#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"; -- cgit v1.2.3 From efc4ce2d15aeb54dccf9493c11de9bb8467033c1 Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 21 Apr 2025 18:55:26 -0400 Subject: Untested multi-cache-view --- gui/dynamicwaysentry.cc | 2 +- gui/gui.cc | 58 +++++++++++++++++++++++++++++++++---------------- gui/gui.h | 45 ++++++++++++++++++++++---------------- gui/gui.ui | 46 +-------------------------------------- gui/worker.cc | 14 +++++++----- gui/worker.h | 4 +--- 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 labels = this->findChildren(); - for (DigitLabel* label : labels) { + QList labels = this->findChildren(); + 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 info) } } -void GUI::onWorkerShowDram( - const std::vector> data) -{ - displayTableHTML(ui->dram_table, data); -} - -void GUI::onWorkerShowCache( - const std::vector> data) +void GUI::onWorkerShowStorage( + const std::vector> 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 &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 &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 info); - void - onWorkerShowDram(const std::vector> data); - - void onWorkerShowCache( - const std::vector> data); + void onWorkerShowStorage( + const std::vector> data, int i); void onWorkerShowRegisters(const std::array &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(); @@ -116,6 +103,11 @@ class GUI : public QMainWindow */ bool ready; + /** + * The list of storage displays. + */ + std::vector tab_text_boxes; + /** * Whether or not numerical values are currently displaying in hex. */ @@ -132,12 +124,11 @@ class GUI : public QMainWindow QLabel *avatar; /** - * The currently loaded program. + * The next simulation's program. */ std::vector 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 &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 @@ - 0 + -1 - - - Registers - - - - - - - - - - DRAM - - - - - - - 500 - 0 - - - - - - - - - Level 1 - - - - - - - 500 - 0 - - - - - - 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> data); - void - cache_storage(const std::vector> data); + storage(const std::vector> data, int i); void register_storage(const std::array data); void if_info(const std::vector info); void id_info(const std::vector info); -- cgit v1.2.3 From 55656e22b924ffb431eeb0e6baa74069a8159baf Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 21 Apr 2025 19:04:05 -0400 Subject: Properly clear storage objects in worker.cc when re-initializing --- gui/worker.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gui/worker.cc b/gui/worker.cc index 2f10c7c..2652fce 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -38,6 +38,8 @@ void Worker::configure( Stage *old; int i; + this->s.clear(); + this->ct_mutex.lock(); if (ways.size() != 0) { // TODO optimal proper sizes -- cgit v1.2.3 From a13aca599a7a326997e3f1cfda851b6736c26a12 Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 21 Apr 2025 19:10:22 -0400 Subject: CSS changes to make storage display more readable --- gui/resources/styles.qss | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss index ee92867..76d0311 100644 --- a/gui/resources/styles.qss +++ b/gui/resources/styles.qss @@ -59,7 +59,6 @@ QLineEdit { } QTextEdit, QListView { - font-size: 10pt; } QPushButton { @@ -91,7 +90,6 @@ QMenuBar { QMenuBar::item { padding: 1px 4px; background: transparent; - border-radius: 4px; } QCheckBox { @@ -113,11 +111,19 @@ QCheckBox::indicator:checked { QTabWidget::tab-bar { alignment: center; + border: 0px; } QTabBar::tab:selected { color: "#000200"; background-color: "#00cc00"; + border: 0px; + padding: 2px; +} + +QTabBar::tab:!selected { + border: 0px; + padding: 2px; } QSlider::groove:horizontal { -- cgit v1.2.3 From 98b9786ccab6fdee37a779fdd55b58176abf12d9 Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 21 Apr 2025 19:18:32 -0400 Subject: Remove unnecessary layout UI elements --- gui/gui.ui | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/gui/gui.ui b/gui/gui.ui index 0326217..a21a200 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -22,30 +22,17 @@ - - - - - - - - - 700 - 0 - - - - -1 - - - - - - - - - - + + + + 700 + 0 + + + + -1 + + -- cgit v1.2.3