diff options
author | bd <bdunahu@operationnull.com> | 2025-04-18 21:56:45 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-18 21:56:45 -0400 |
commit | 1613c52e8e52a5c1a2a8120fcfa7ed3a011fbdf1 (patch) | |
tree | a5d2a424fc2f3bfb0b6638366ccc6fb4fc80e68f | |
parent | 04d8976223821833ef9d93ae03b8058626d4e1e6 (diff) |
Remove/comment out a lot of code in charge of loading
-rw-r--r-- | gui/gui.cc | 78 | ||||
-rw-r--r-- | gui/gui.h | 12 | ||||
-rw-r--r-- | gui/gui.ui | 49 | ||||
-rw-r--r-- | gui/worker.cc | 89 | ||||
-rw-r--r-- | gui/worker.h | 19 |
5 files changed, 24 insertions, 223 deletions
@@ -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;i<ways.size();i++) { - // qDebug() << "ways: " << ways[i] << " size: " << size[i]; - // } -} - void GUI::on_enable_pipeline_checkbox_checkStateChanged(const Qt::CheckState &arg1) { - //TODO: handle pipeline enabling if(arg1 == Qt::CheckState::Checked) { qDebug() << "enable pipeline checkbox checked."; is_pipelined = true; @@ -311,19 +264,6 @@ void GUI::on_enable_pipeline_checkbox_checkStateChanged(const Qt::CheckState &ar } } -void GUI::on_enabl_cache_checkbox_checkStateChanged(const Qt::CheckState &arg1) -{ - //TODO: handle cache enabling - if(arg1 == Qt::CheckState::Checked) { - qDebug() << "enable cache checkbox checked."; - is_cache_enabled = true; - } else { - qDebug() << "enable cache checkbox unchecked."; - is_cache_enabled = false; - } - -} - void GUI::on_step_btn_clicked() { qDebug() << "Run step button clicked."; @@ -336,9 +276,3 @@ void GUI::on_save_program_state_btn_clicked() //TODO: save program state qDebug() << "save program state button is clicked."; } - -void GUI::on_Configure_Btn_clicked() -{ - emit sendConfigure(ways, size, is_pipelined, is_cache_enabled); - QMessageBox::information(ui->register_table, "Pipeline Configuration", "Pipeline and memory subsystem configured successfully!"); -} @@ -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<int> ways; - std::vector<int> size; signals: void sendRefreshDram(); @@ -36,7 +33,6 @@ signals: void sendRefreshRegisters(); void sendRunSteps(int steps); void sendLoadProgram(std::vector<signed int> program); - void sendConfigure(std::vector<int> ways, std::vector<int> 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(); @@ -452,60 +452,17 @@ <item> <layout class="QVBoxLayout" name="verticalLayout_27"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <item> - <widget class="QPushButton" name="set_levels_btn"> - <property name="text"> - <string>Cache Levels</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="cache_levels_dropdwn"/> - </item> - <item> - <widget class="QLineEdit" name="cache_size_inp"> - <property name="placeholderText"> - <string>size</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="cache_ways_inp"> - <property name="placeholderText"> - <string>ways</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="set_cache_btn"> - <property name="text"> - <string>Cache Conf</string> - </property> - </widget> - </item> - </layout> + <widget class="QLineEdit" name="way_box_1"/> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_10"> <item> - <widget class="QPushButton" name="Configure_Btn"> - <property name="text"> - <string>Configure</string> - </property> - </widget> - </item> - <item> <widget class="QCheckBox" name="enable_pipeline_checkbox"> <property name="text"> <string>Enable Pipeline</string> </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="enabl_cache_checkbox"> - <property name="text"> - <string>Enable Cache</string> + <property name="checked"> + <bool>true</bool> </property> </widget> </item> 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<int> ways, std::vector<int> 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;i<ways.size();i++) { - if(i==0){ - Cache* cache = new Cache(this->d, 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<int> ways) { - this->cache_ways = ways; -} - -void Worker::setSize(std::vector<int> size) { - this->cache_size = size; -} - -std::vector<int> Worker::getWays() { - return this->cache_ways; -} - -std::vector<int> 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<signed int> 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<<size)); - } + // 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<<size)); + // } } void Worker::refreshRegisters() @@ -94,16 +35,12 @@ void Worker::runSteps(int steps) { qDebug() << "Running for " << steps << "steps"; this->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<<size)); - } - 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()); + // 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<Cache*> c; - std::vector<int> cache_ways; - std::vector<int> cache_size; - bool cache_enabled = false; - Dram *d; + std::vector<Storage*> s; + std::vector<Stage*> 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<int> getWays(); - std::vector<int> getSize(); - void setWays(std::vector<int> ways); - void setSize(std::vector<int> size); public slots: - void doWork(); void refreshDram(); - void loadProgram(std::vector<signed int> p); - void configure(std::vector<int> ways, std::vector<int> size, bool is_pipelined, bool is_cache_enabled); void refreshCache(); void refreshRegisters(); void runSteps(int steps); |