diff options
author | bd <bdunahu@operationnull.com> | 2025-04-26 03:39:28 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-26 03:39:28 -0400 |
commit | a78163745b43a0c420ae4ea5792def30a94420eb (patch) | |
tree | 9cc23cfec1a7e524822d604e95e237034b31a95e | |
parent | c98a0c26c4ccb5c4ae0e9f5810be910a7b299037 (diff) |
Partial cache size generation, full cache display
-rw-r--r-- | gui/gui.cc | 26 | ||||
-rw-r--r-- | gui/gui.h | 5 | ||||
-rw-r--r-- | gui/util.cc | 16 | ||||
-rw-r--r-- | gui/util.h | 8 | ||||
-rw-r--r-- | gui/worker.cc | 8 | ||||
-rw-r--r-- | gui/worker.h | 5 |
6 files changed, 47 insertions, 21 deletions
@@ -20,10 +20,11 @@ #include "dynamicwaysentry.h" #include "messages.h" #include "storageview.h" +#include "util.h" +#include <QHeaderView> #include <QPixmap> #include <QString> #include <QTableView> -#include <QHeaderView> GUI::GUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::GUI) { @@ -332,6 +333,8 @@ void GUI::on_config_clicked() else this->set_status(get_initialize, "happy"); + this->curr_cache_levels = ways.size(); + emit sendConfigure(ways, this->p, is_pipelined); make_tabs(2 + ways.size()); } @@ -339,31 +342,32 @@ void GUI::on_config_clicked() void GUI::make_tabs(int num) { int i; - QStringList xTra; StorageView *e; QTableView *t; QString n; - xTra = {"Registers", "DRAM"}; - ui->storage->clear(); this->tab_boxes.clear(); qDeleteAll(this->tab_boxes); for (i = 0; i < num; ++i) { - e = new StorageView(10, this); + // make the name + if (i == 0) { + n = "Registers"; + e = new StorageView(0, this); + } else if (i == 1) { + n = "DRAM"; + e = new StorageView(MEM_LINES, this); + } else { + n = QString("L%1").arg(i - 1); + e = new StorageView(cache_size_mapper(this->curr_cache_levels, i), this); + } t = new QTableView; t->setModel(e); t->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - // make the name - if (i < xTra.size()) - n = xTra[i]; - else - n = QString("L%1").arg(i - 1); - ui->storage->addTab(t, n); this->tab_boxes.push_back(e); } @@ -102,6 +102,11 @@ class GUI : public QMainWindow bool ready; /** + * The current number of cache levels. + */ + int curr_cache_levels; + + /** * The list of storage displays. */ std::vector<StorageView *> tab_boxes; diff --git a/gui/util.cc b/gui/util.cc new file mode 100644 index 0000000..ee75e56 --- /dev/null +++ b/gui/util.cc @@ -0,0 +1,16 @@ +#include "util.h" + +int cache_size_mapper(int total_levels, int level) +{ + const int y_min = 4; + const int y_max = 12; + double f, r; + + if (total_levels <= 1) + return 8; + + f = level / total_levels; + r = y_min + f * (y_max - y_min); + + return r; +} diff --git a/gui/util.h b/gui/util.h new file mode 100644 index 0000000..87c33f6 --- /dev/null +++ b/gui/util.h @@ -0,0 +1,8 @@ +/** + * Given `total_levels', returns an integer between 4 and 12 which is a linear map of `level' onto `total_levels'. + * This is used for generating cache sizes given a number of levels. + * @param the total number of cache levels, zero-indexed. + * @param a numberedcache level, zero-indexed. + * @return an integer between 4-12, linearly scaled with level. + */ +int cache_size_mapper(int total_levels, int level); diff --git a/gui/worker.cc b/gui/worker.cc index 6419b73..93ccbea 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -17,6 +17,7 @@ #include "worker.h" #include "storage.h" +#include "util.h" Worker::Worker(QObject *parent) : QObject(parent) {} @@ -39,10 +40,6 @@ void Worker::configure( this->s.clear(); this->ct_mutex.lock(); - if (ways.size() != 0) { - // TODO optimal proper sizes - this->size_inc = ((MEM_LINE_SPEC * 0.75) / ways.size()); - } d = new Dram(DRAM_DELAY); s = static_cast<Storage *>(d); @@ -51,7 +48,8 @@ void Worker::configure( for (i = ways.size(); i > 0; --i) { s = static_cast<Storage *>(new Cache( - s, this->size_inc * (i), ways.at(i - 1), CACHE_DELAY + i)); + s, cache_size_mapper(ways.size() - 1, i), ways.at(i - 1), + CACHE_DELAY + i)); this->s.push_front(s); } diff --git a/gui/worker.h b/gui/worker.h index c0e72d3..c62f4ed 100644 --- a/gui/worker.h +++ b/gui/worker.h @@ -50,11 +50,6 @@ class Worker : public QObject Controller *ct = nullptr; QMutex ct_mutex; - /** - * The size each progressive cache level increases by. - */ - unsigned int size_inc; - public: explicit Worker(QObject *parent = nullptr); ~Worker(); |