diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-04-21 19:59:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-21 19:59:56 -0400 |
commit | 1250359dfcbcad18c0a1078290f95479aa23e26a (patch) | |
tree | c53fa2bfd360a3bdcfbb2a4c6029e454d91456e1 | |
parent | 282e2644ef0470133184fdf9900cf2565ec5332b (diff) | |
parent | 98b9786ccab6fdee37a779fdd55b58176abf12d9 (diff) |
Merge pull request #58 from bdunahu/bdunahu
[WIP] Add tab bar, multi-level cache display
-rw-r--r-- | gui/dynamicwaysentry.cc | 2 | ||||
-rw-r--r-- | gui/gui.cc | 60 | ||||
-rw-r--r-- | gui/gui.h | 45 | ||||
-rw-r--r-- | gui/gui.ui | 186 | ||||
-rw-r--r-- | gui/resources/styles.qss | 23 | ||||
-rw-r--r-- | gui/worker.cc | 16 | ||||
-rw-r--r-- | gui/worker.h | 4 |
7 files changed, 210 insertions, 126 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 @@ -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( @@ -233,32 +230,29 @@ void GUI::onWorkerWriteBackInfo(const std::vector<int> 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(); } } -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."; } @@ -267,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)) { @@ -351,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"); @@ -375,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( @@ -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 @@ -22,83 +22,74 @@ <item> <layout class="QVBoxLayout" name="storage_pipe_separator"> <item> - <layout class="QHBoxLayout" name="storage_view"> - <item> - <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> - <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> - <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> + <widget class="QTabWidget" name="storage"> + <property name="minimumSize"> + <size> + <width>700</width> + <height>0</height> + </size> + </property> + <property name="currentIndex"> + <number>-1</number> + </property> + </widget> </item> <item> <layout class="QHBoxLayout" name="pipe_view"> <item> + <widget class="QGroupBox" name="groupBox"> + <property name="maximumSize"> + <size> + <width>120</width> + <height>16777215</height> + </size> + </property> + <property name="title"> + <string> </string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set> + </property> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>s1</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>s2</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>s3</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>alias</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_14"> + <property name="text"> + <string>dead</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> <widget class="QGroupBox" name="Fetch"> <property name="minimumSize"> <size> @@ -114,6 +105,27 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> + <widget class="QLabel" name="label_17"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_15"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> <widget class="DigitLabel" name="fetch_bits"> <property name="text"> <string/> @@ -146,6 +158,27 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> + <widget class="QLabel" name="label_20"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_19"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_18"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> <widget class="DigitLabel" name="decode_bits"> <property name="text"> <string/> @@ -314,6 +347,13 @@ </property> </widget> </item> + <item> + <widget class="QLabel" name="write_squashed"> + <property name="text"> + <string/> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss index dbaa623..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 { @@ -107,14 +105,27 @@ 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; + border: 0px; +} + +QTabBar::tab:selected { + color: "#000200"; + background-color: "#00cc00"; + border: 0px; + padding: 2px; +} + +QTabBar::tab:!selected { + border: 0px; + padding: 2px; +} + 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"; diff --git a/gui/worker.cc b/gui/worker.cc index ba0723e..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 @@ -67,21 +69,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); |