From 1613c52e8e52a5c1a2a8120fcfa7ed3a011fbdf1 Mon Sep 17 00:00:00 2001 From: bd Date: Fri, 18 Apr 2025 21:56:45 -0400 Subject: Remove/comment out a lot of code in charge of loading --- gui/gui.cc | 78 ++++----------------------------------------------- gui/gui.h | 12 -------- gui/gui.ui | 49 ++------------------------------ gui/worker.cc | 89 +++++++++-------------------------------------------------- gui/worker.h | 19 ++----------- 5 files changed, 24 insertions(+), 223 deletions(-) (limited to 'gui') diff --git a/gui/gui.cc b/gui/gui.cc index b3dc666..39163ea 100644 --- a/gui/gui.cc +++ b/gui/gui.cc @@ -1,6 +1,5 @@ #include "gui.h" #include "./ui_gui.h" -// #include "byteswap.h" GUI::GUI(QWidget *parent) : QMainWindow(parent) @@ -8,16 +7,13 @@ GUI::GUI(QWidget *parent) { ui->setupUi(this); - ui->enabl_cache_checkbox->setChecked(true); - ui->enable_pipeline_checkbox->setChecked(true); - worker = new Worker(); worker->moveToThread(&workerThread); // Connect worker thread lifecycle - connect(&workerThread, &QThread::started, worker, &Worker::doWork); + // connect(&workerThread, &QThread::started, worker, &Worker::doWork); - // Display clock cycles and PC + // display clock cycles and PC connect(worker, &Worker::clock_cycles, this, &GUI::onWorkerClockCycles); connect(worker, &Worker::if_info, this, &GUI::onWorkerFetchInfo); @@ -39,17 +35,11 @@ GUI::GUI(QWidget *parent) // Display registers connect(worker, &Worker::register_storage, this, &GUI::onWorkerShowRegisters); - // Refresh DRAM from worker thread - connect(this, &GUI::sendRefreshDram, worker, &Worker::refreshDram, Qt::QueuedConnection); - - // Load program from worker thread - connect(this, &GUI::sendLoadProgram, worker, &Worker::loadProgram, Qt::QueuedConnection); - - // 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); - // Refresh Cache from worker thread - connect(this, &GUI::sendRefreshCache, worker, &Worker::refreshCache, Qt::QueuedConnection); + // // Refresh Cache from worker thread + // connect(this, &GUI::sendRefreshCache, worker, &Worker::refreshCache, Qt::QueuedConnection); // Refresh Registers from worker thread connect(this, &GUI::sendRefreshRegisters, worker, &Worker::refreshRegisters, Qt::QueuedConnection); @@ -257,51 +247,14 @@ void GUI::on_upload_intructions_btn_clicked() QMessageBox::information(ui->register_table, "File Upload", "Instructions loaded successfully!"); } - void GUI::on_upload_program_state_btn_clicked() { //TODO:Upload and set program state ( have to decide how to use this) qDebug() << "upload program state button is clicked."; } -void GUI::on_set_levels_btn_clicked() -{ - qDebug() << "Set levels button clicked."; - bool ok; - int value = QInputDialog::getInt(this, "Enter Value", "Enter value:", - 0, - 0, 10, 1, &ok); - if (ok) { - cache_levels = value; - ui->cache_levels_dropdwn->clear(); // Clear previous entries - for (int i = 0; i < cache_levels; ++i) { - ui->cache_levels_dropdwn->addItem(QString::number(i)); - ways.push_back(2); - size.push_back(5); - } - } else { - qDebug() << "User cancelled input."; - } -} - -void GUI::on_set_cache_btn_clicked() { - int current_cache = ui->cache_levels_dropdwn->currentIndex(); - // qDebug() << "current cache: " << current_cache; - int prevWays = ways[current_cache]; - int prevSize = size[current_cache]; - QString cache_ways = ui->cache_ways_inp->text(); - QString cache_size = ui->cache_size_inp->text(); - ways[current_cache] = cache_ways.isEmpty() ? prevWays : cache_ways.toInt(); - size[current_cache] = cache_size.isEmpty() ? prevSize : cache_size.toInt(); - QMessageBox::information(ui->register_table, "Cache Configuration", "Cache" + QString::number(current_cache) + " values set successfully! Please click on Configure button to configure the pipeline or configure other caches."); - // for(int i=0;iregister_table, "Pipeline Configuration", "Pipeline and memory subsystem configured successfully!"); -} diff --git a/gui/gui.h b/gui/gui.h index 618f2b5..aaa0ede 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -25,10 +25,7 @@ public: GUI(QWidget *parent = nullptr); ~GUI(); bool is_pipelined = false; - bool is_cache_enabled = false; - int cache_levels = 0; std::vector ways; - std::vector size; signals: void sendRefreshDram(); @@ -36,7 +33,6 @@ signals: void sendRefreshRegisters(); void sendRunSteps(int steps); void sendLoadProgram(std::vector program); - void sendConfigure(std::vector ways, std::vector size, bool is_pipelined, bool is_cache_enabled); private slots: void onWorkerClockCycles(int value, int pc); @@ -63,16 +59,8 @@ private slots: void on_upload_program_state_btn_clicked(); - void on_Configure_Btn_clicked(); - - void on_set_levels_btn_clicked(); - - void on_set_cache_btn_clicked(); - void on_enable_pipeline_checkbox_checkStateChanged(const Qt::CheckState &arg1); - void on_enabl_cache_checkbox_checkStateChanged(const Qt::CheckState &arg1); - void on_step_btn_clicked(); void on_save_program_state_btn_clicked(); diff --git a/gui/gui.ui b/gui/gui.ui index ae853a2..d731e99 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -452,60 +452,17 @@ - - - - - Cache Levels - - - - - - - - - - size - - - - - - - ways - - - - - - - Cache Conf - - - - + - - - - Configure - - - Enable Pipeline - - - - - - Enable Cache + + true diff --git a/gui/worker.cc b/gui/worker.cc index 3c2c952..1d87fd3 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -2,86 +2,27 @@ Worker::Worker(QObject *parent) : QObject(parent) {} -void Worker::configure(std::vector ways, std::vector size, bool is_pipelined, bool is_cache_enabled) { - this->d = new Dram(ways.size()+10); - setWays(ways); - setSize(size); - qDebug() << "is cache enabled:" << is_cache_enabled; - qDebug() << "is pipelined:" << is_pipelined; - this->cache_enabled = is_cache_enabled; - if (!is_cache_enabled || ways.size() == 0) { - this->ct = new Controller(wb_stage, this->d, is_pipelined); - } else { - // 0th index cache has largest delay - for(int i=0;id, size[i], ways[i], ways.size()); - this->c.push_back(cache); - } else { - Cache* cache = new Cache(this->c[i-1], size[i], ways[i], ways.size()-i); - this->c.push_back(cache); - } - } - this->ct = new Controller(wb_stage, this->c.at(ways.size()-1), is_pipelined); - } - emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc()); -} - -void Worker::setWays(std::vector ways) { - this->cache_ways = ways; -} - -void Worker::setSize(std::vector size) { - this->cache_size = size; -} - -std::vector Worker::getWays() { - return this->cache_ways; -} - -std::vector Worker::getSize() { - return this->cache_size; -} - -void Worker::doWork() -{ - qDebug() << "Initializing..."; - - this->if_stage = new IF(nullptr); - this->id_stage = new ID(if_stage); - this->ex_stage = new EX(id_stage); - this->mm_stage = new MM(ex_stage); - this->wb_stage = new WB(mm_stage); -} - Worker::~Worker() { emit finished(); qDebug() << "Worker destructor called in thread:" << QThread::currentThread(); delete this->ct; - for(Cache *cache: this->c) { - delete cache; - } -} - -void Worker::loadProgram(std::vector p) { - this->d->load(p); } void Worker::refreshDram() { qDebug() << "Refreshing Dram"; - emit dram_storage(this->d->view(0, 255)); + // emit dram_storage(this->d->view(0, 255)); } void Worker::refreshCache() { qDebug() << "Refreshing Cache"; - if(getWays().size() > 0) { - unsigned int size = this->c.at(getWays().size()-1)->get_size(); - emit cache_storage(this->c.at(getWays().size()-1)->view(0, 1< 0) { + // unsigned int size = this->c.at(getWays().size()-1)->get_size(); + // emit cache_storage(this->c.at(getWays().size()-1)->view(0, 1<ct->run_for(steps); - emit dram_storage(this->d->view(0, 255)); - if(this->cache_enabled && getWays().size() > 0) { - unsigned int size = this->c.at(getWays().size()-1)->get_size(); - emit cache_storage(this->c.at(getWays().size()-1)->view(0, 1<ct->get_gprs()); - 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()); - emit ex_info(this->ex_stage->stage_info()); - emit mm_info(this->mm_stage->stage_info()); - emit wb_info(this->wb_stage->stage_info()); + // emit dram_storage(this->d->view(0, 255)); + // emit register_storage(this->ct->get_gprs()); + // 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()); + // emit ex_info(this->ex_stage->stage_info()); + // emit mm_info(this->mm_stage->stage_info()); + // emit wb_info(this->wb_stage->stage_info()); } diff --git a/gui/worker.h b/gui/worker.h index f0ce7a3..53e4851 100644 --- a/gui/worker.h +++ b/gui/worker.h @@ -18,31 +18,16 @@ class Worker : public QObject { Q_OBJECT private: - std::vector c; - std::vector cache_ways; - std::vector cache_size; - bool cache_enabled = false; - Dram *d; + std::vector s; + std::vector p; Controller *ct; - ID *id_stage; - IF *if_stage; - EX *ex_stage; - MM *mm_stage; - WB *wb_stage; public: explicit Worker(QObject *parent = nullptr); ~Worker(); - std::vector getWays(); - std::vector getSize(); - void setWays(std::vector ways); - void setSize(std::vector size); public slots: - void doWork(); void refreshDram(); - void loadProgram(std::vector p); - void configure(std::vector ways, std::vector size, bool is_pipelined, bool is_cache_enabled); void refreshCache(); void refreshRegisters(); void runSteps(int steps); -- cgit v1.2.3