From c00703033380d68eeff47c40a9c7dc5f8cd7fb1f Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 13:06:44 -0400 Subject: Report status correctly when steps have finished running --- gui/gui.cc | 5 ++++- gui/gui.h | 2 ++ gui/worker.cc | 1 + gui/worker.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gui/gui.cc b/gui/gui.cc index b4feda6..28876ba 100644 --- a/gui/gui.cc +++ b/gui/gui.cc @@ -72,6 +72,8 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI) connect(worker, &Worker::wb_info, this, &GUI::onWorkerWriteBackInfo); + connect(worker, &Worker::steps_done, this, &GUI::onWorkerStepsDone); + // Display cache connect(worker, &Worker::storage, this, &GUI::onWorkerShowStorage); @@ -139,7 +141,6 @@ void GUI::on_worker_refresh_gui(int cycles, int pc) { ui->p_counter->set_value(pc); ui->cycle_counter->set_value(cycles); - this->set_status(get_waiting, "idle"); } void GUI::onWorkerFetchInfo(const InstrDTO *i) @@ -215,6 +216,8 @@ void GUI::onWorkerWriteBackInfo(const InstrDTO *i) } } +void GUI::onWorkerStepsDone() { this->set_status(get_waiting, "idle"); } + void GUI::onWorkerShowStorage(const QVector> &data, int i) { this->tab_boxes.at(i)->set_data(data); diff --git a/gui/gui.h b/gui/gui.h index 830d852..8e0b5b4 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -68,6 +68,8 @@ class GUI : public QMainWindow void onWorkerWriteBackInfo(const InstrDTO *); + void onWorkerStepsDone(); + void onWorkerShowStorage(const QVector> &data, int i); void onWorkerShowRegisters(const std::array &data); diff --git a/gui/worker.cc b/gui/worker.cc index 0ba364b..dd7b637 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -72,6 +72,7 @@ void Worker::runSteps(int steps) { this->ct->run_for(steps); this->update(); + emit steps_done(); } void Worker::update() diff --git a/gui/worker.h b/gui/worker.h index c62f4ed..5ffb6ef 100644 --- a/gui/worker.h +++ b/gui/worker.h @@ -72,6 +72,7 @@ class Worker : public QObject void ex_info(const InstrDTO *); void mm_info(const InstrDTO *); void wb_info(const InstrDTO *); + void steps_done(); void finished(); private: -- cgit v1.2.3 From ad0557059bb83da52e1a5bd7ea608a29a4ab6346 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 13:53:21 -0400 Subject: Use spinboxes to select cache levels --- gui/cachewaysselector.cc | 59 +++++++++++++++++++++++++ gui/cachewaysselector.h | 50 +++++++++++++++++++++ gui/dynamicwaysentry.cc | 99 ------------------------------------------ gui/dynamicwaysentry.h | 51 ---------------------- gui/gui.cc | 18 +++----- gui/gui.ui | 110 ++++++++--------------------------------------- gui/messages.h | 3 -- 7 files changed, 134 insertions(+), 256 deletions(-) create mode 100644 gui/cachewaysselector.cc create mode 100644 gui/cachewaysselector.h delete mode 100644 gui/dynamicwaysentry.cc delete mode 100644 gui/dynamicwaysentry.h diff --git a/gui/cachewaysselector.cc b/gui/cachewaysselector.cc new file mode 100644 index 0000000..f0314e5 --- /dev/null +++ b/gui/cachewaysselector.cc @@ -0,0 +1,59 @@ +// 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 . + +#include "cachewaysselector.h" +#include +#include +#include +#include + +CacheWaysSelector::CacheWaysSelector(QWidget *parent) : QWidget(parent) +{ + QVBoxLayout *v; + QHBoxLayout *l; + QSpinBox *sb; + QLabel *b; + int i; + + v = new QVBoxLayout(this); + + for (i = 1; i <= 6; ++i) { + l = new QHBoxLayout(this); + + b = new QLabel(QString("L%1 2^").arg(i), this); + + sb = new QSpinBox; + sb->setRange(-1, 4); + sb->setValue(-1); + + l->addWidget(b); + l->addWidget(sb); + + v->addLayout(l); + this->sbs.append(sb); + } + v->addStretch(); +} + +QList CacheWaysSelector::values() const +{ + QList r; + for (const QSpinBox *sb : this->sbs) { + r.append(sb->value()); + } + return r; +} diff --git a/gui/cachewaysselector.h b/gui/cachewaysselector.h new file mode 100644 index 0000000..4612b0c --- /dev/null +++ b/gui/cachewaysselector.h @@ -0,0 +1,50 @@ +// 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 . + +#ifndef CACHEWAYSSELECTOR_H +#define CACHEWAYSSELECTOR_H + +#include +#include + +class CacheWaysSelector : public QWidget +{ + Q_OBJECT + + public: + /** + * Constructor. + * This class provides a simple group of labeled spinboxs meant for + * selecting cache ways. + * @param The parent widget. + * @param a newly allocated CacheWaysSelector + */ + explicit CacheWaysSelector(QWidget *parent = nullptr); + + /** + * @return the values in the spinboxes. + */ + QList values() const; + + private: + /** + * A list of spinboxes. + */ + QList sbs; +}; + +#endif // CACHEWAYSSELECTOR_H diff --git a/gui/dynamicwaysentry.cc b/gui/dynamicwaysentry.cc deleted file mode 100644 index cbd5342..0000000 --- a/gui/dynamicwaysentry.cc +++ /dev/null @@ -1,99 +0,0 @@ -// 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 . - -#include "dynamicwaysentry.h" -#include -#include -#include -#include -#include -#include - -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(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 deleted file mode 100644 index 26b8b3e..0000000 --- a/gui/dynamicwaysentry.h +++ /dev/null @@ -1,51 +0,0 @@ -// 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 . - -#ifndef DYNAMICWAYSENTRY_H -#define DYNAMICWAYSENTRY_H - - -#include -#include -#include -#include -#include - -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 fields; - QStringList entries; - void add_field(); - void remove_last_field(); -}; - -#endif // DYNAMICWAYSENTRY_H diff --git a/gui/gui.cc b/gui/gui.cc index 28876ba..2581c4c 100644 --- a/gui/gui.cc +++ b/gui/gui.cc @@ -18,7 +18,7 @@ #include "gui.h" #include "./ui_gui.h" #include "digitlabeldelegate.h" -#include "dynamicwaysentry.h" +#include "cachewaysselector.h" #include "messages.h" #include "storageview.h" #include "util.h" @@ -304,21 +304,15 @@ void GUI::on_config_clicked() { std::vector ways; QStringList entries; - signed int i; - DynamicWaysEntry *dwe = ui->cache_way_selector; + CacheWaysSelector *cws = ui->cache_ways_selector; - for (const QString &s : dwe->get_entries()) { + for (int i : cws->values()) { - if (s.isEmpty()) + // invalid + if (i == -1) continue; - i = dwe->parse_valid_way(s); - if (i >= 0) { - ways.push_back((unsigned int)i); - } else { - this->set_status(get_bad_cache, "angry"); - return; - } + ways.push_back((unsigned int)i); } if (this->p.empty()) { diff --git a/gui/gui.ui b/gui/gui.ui index 67cca60..c20b3f6 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -6,7 +6,7 @@ 0 0 - 1499 + 1522 621 @@ -25,7 +25,7 @@ - 700 + 800 0 @@ -45,7 +45,7 @@ - + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop @@ -380,90 +380,18 @@ QLayout::SizeConstraint::SetMinimumSize - - - - Qt::Orientation::Vertical - - - - - - - QLayout::SizeConstraint::SetMinimumSize - - - - - - 16777215 - 16777215 - - - - C1 2^ - - - - - - - - 16777215 - 16777215 - - - - C2 2^ - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - C3 2^ - - - - - - - - 16777215 - 16777215 - - - - C4 2^ - - - - - - - - - - 0 - 0 - - - - + + + + Ways Selector (powers of 2) + + + + + + @@ -674,17 +602,17 @@ - - DynamicWaysEntry - QWidget -
dynamicwaysentry.h
- 1 -
DigitLabel QLabel
digitlabel.h
+ + CacheWaysSelector + QWidget +
cachewaysselector.h
+ 1 +
diff --git a/gui/messages.h b/gui/messages.h index 461c461..0c38751 100644 --- a/gui/messages.h +++ b/gui/messages.h @@ -35,8 +35,6 @@ const std::vector load_file = { const std::vector no_instructions = { "NO PROGRAM PROVIDED", "NOTHING TO DO, GIVING UP", "INSTRUCTIONS MISSING", "404 INSTRUCTIONS NOT FOUND"}; -const std::vector bad_cache = { - "WAYS CANNOT BE BELOW 0 OR ABOVE 4"}; const std::vector no_pipeline = { "SIMULATION READY: NO PIPE", "PIPE OFF, SIMULATION READY"}; const std::vector no_cache = { @@ -59,7 +57,6 @@ 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 -- cgit v1.2.3 From 8954fab5b430623e2052753fae20707b878b858c Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 14:33:26 -0400 Subject: Fix styles --- gui/cachewaysselector.cc | 3 +-- gui/gui.ui | 7 ------- gui/resources/styles.qss | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/gui/cachewaysselector.cc b/gui/cachewaysselector.cc index f0314e5..14dae6f 100644 --- a/gui/cachewaysselector.cc +++ b/gui/cachewaysselector.cc @@ -32,7 +32,7 @@ CacheWaysSelector::CacheWaysSelector(QWidget *parent) : QWidget(parent) v = new QVBoxLayout(this); for (i = 1; i <= 6; ++i) { - l = new QHBoxLayout(this); + l = new QHBoxLayout; b = new QLabel(QString("L%1 2^").arg(i), this); @@ -46,7 +46,6 @@ CacheWaysSelector::CacheWaysSelector(QWidget *parent) : QWidget(parent) v->addLayout(l); this->sbs.append(sb); } - v->addStretch(); } QList CacheWaysSelector::values() const diff --git a/gui/gui.ui b/gui/gui.ui index c20b3f6..57a7974 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -375,13 +375,6 @@
- - - - QLayout::SizeConstraint::SetMinimumSize - - - diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss index a61035e..758978c 100644 --- a/gui/resources/styles.qss +++ b/gui/resources/styles.qss @@ -4,6 +4,8 @@ color: "#00cc00"; background-color: "#000200"; border: 0px solid "#000200"; + selection-background-color: "#00cc00"; + selection-color: "#000200"; } QStatusBar { @@ -50,6 +52,52 @@ QGroupBox::title { QLabel { } +QSpinBox { + padding-right: 15px; /* make room for the arrows */ + border: none; +} + +QSpinBox::up-button { + color: "#000200"; + background-color: "#00cc00"; + subcontrol-origin: border; + subcontrol-position: top right; /* position at the top right corner */ + + width: 16px; + border: none; + subcontrol-origin: border; +} + +QSpinBox::up-arrow { + width: 7px; + height: 7px; +} + +QSpinBox::up-button:pressed { + color: "#00cc00"; + background-color: "#000200"; +} + +QSpinBox::down-button { + color: "#000200"; + background-color: "#00cc00"; + subcontrol-origin: border; + subcontrol-position: bottom right; /* position at bottom right corner */ + + width: 16px; + border: none; +} + +QSpinBox::down-arrow { + width: 7px; + height: 7px; +} + +QSpinBox::down-button:pressed { + color: "#00cc00"; + background-color: "#000200"; +} + QTableView { border: 0px; selection-background-color: transparent; -- cgit v1.2.3 From e1ac80f5f07c26a8423382cd306a1c1d07bf4c85 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 14:55:33 -0400 Subject: Make spinbox arrows visible --- gui/resources.qrc | 2 ++ gui/resources/arrow_down.png | Bin 0 -> 228 bytes gui/resources/arrow_up.png | Bin 0 -> 221 bytes gui/resources/styles.qss | 12 +++++++----- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 gui/resources/arrow_down.png create mode 100644 gui/resources/arrow_up.png diff --git a/gui/resources.qrc b/gui/resources.qrc index 569cc22..8fea0ee 100644 --- a/gui/resources.qrc +++ b/gui/resources.qrc @@ -1,6 +1,8 @@ + resources/arrow_down.png + resources/arrow_up.png resources/styles.qss resources/idle.png resources/angry.png diff --git a/gui/resources/arrow_down.png b/gui/resources/arrow_down.png new file mode 100644 index 0000000..80b1753 Binary files /dev/null and b/gui/resources/arrow_down.png differ diff --git a/gui/resources/arrow_up.png b/gui/resources/arrow_up.png new file mode 100644 index 0000000..69b65af Binary files /dev/null and b/gui/resources/arrow_up.png differ diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss index 758978c..ea85e00 100644 --- a/gui/resources/styles.qss +++ b/gui/resources/styles.qss @@ -69,6 +69,13 @@ QSpinBox::up-button { } QSpinBox::up-arrow { + image: url(:/resources/arrow_up.png); + width: 7px; + height: 7px; +} + +QSpinBox::down-arrow { + image: url(:/resources/arrow_down.png); width: 7px; height: 7px; } @@ -88,11 +95,6 @@ QSpinBox::down-button { border: none; } -QSpinBox::down-arrow { - width: 7px; - height: 7px; -} - QSpinBox::down-button:pressed { color: "#00cc00"; background-color: "#000200"; -- cgit v1.2.3 From 599593ff229cfcead87a9fa87b4eaa13f0e280b5 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 14:58:35 -0400 Subject: Make spinbox arrows invert colors when pressed --- gui/resources.qrc | 2 ++ gui/resources/arrow_down_pressed.png | Bin 0 -> 234 bytes gui/resources/arrow_up_pressed.png | Bin 0 -> 227 bytes gui/resources/styles.qss | 16 ++++++++++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 gui/resources/arrow_down_pressed.png create mode 100644 gui/resources/arrow_up_pressed.png diff --git a/gui/resources.qrc b/gui/resources.qrc index 8fea0ee..66cd6e4 100644 --- a/gui/resources.qrc +++ b/gui/resources.qrc @@ -3,6 +3,8 @@ resources/arrow_down.png resources/arrow_up.png + resources/arrow_down_pressed.png + resources/arrow_up_pressed.png resources/styles.qss resources/idle.png resources/angry.png diff --git a/gui/resources/arrow_down_pressed.png b/gui/resources/arrow_down_pressed.png new file mode 100644 index 0000000..0981cf2 Binary files /dev/null and b/gui/resources/arrow_down_pressed.png differ diff --git a/gui/resources/arrow_up_pressed.png b/gui/resources/arrow_up_pressed.png new file mode 100644 index 0000000..98d50ac Binary files /dev/null and b/gui/resources/arrow_up_pressed.png differ diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss index ea85e00..c6d8daa 100644 --- a/gui/resources/styles.qss +++ b/gui/resources/styles.qss @@ -74,8 +74,8 @@ QSpinBox::up-arrow { height: 7px; } -QSpinBox::down-arrow { - image: url(:/resources/arrow_down.png); +QSpinBox::up-arrow:pressed { + image: url(:/resources/arrow_up_pressed.png); width: 7px; height: 7px; } @@ -100,6 +100,18 @@ QSpinBox::down-button:pressed { background-color: "#000200"; } +QSpinBox::down-arrow { + image: url(:/resources/arrow_down.png); + width: 7px; + height: 7px; +} + +QSpinBox::down-arrow:pressed { + image: url(:/resources/arrow_down_pressed.png); + width: 7px; + height: 7px; +} + QTableView { border: 0px; selection-background-color: transparent; -- cgit v1.2.3 From 51f66c58ae8a21951d2406b3a36e96c9beb391a2 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 15:04:24 -0400 Subject: Make the storage display bigger --- gui/gui.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/gui.ui b/gui/gui.ui index 57a7974..e571a0f 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -25,7 +25,7 @@ - 800 + 1500 0 -- cgit v1.2.3 From d9832fa5f24dc0e7df41b61e5d0181adbb4edf77 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 15:09:55 -0400 Subject: Adjust storage display size --- gui/gui.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/gui.ui b/gui/gui.ui index e571a0f..18d5da1 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -25,7 +25,7 @@ - 1500 + 1250 0 -- cgit v1.2.3