From 06632f57c9047b7e54a274b6b020bcc83f5f9a64 Mon Sep 17 00:00:00 2001 From: Siddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com> Date: Fri, 18 Apr 2025 04:08:15 -0400 Subject: initialization from GUI --- gui/gui.cc | 77 ++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 22 deletions(-) (limited to 'gui/gui.cc') diff --git a/gui/gui.cc b/gui/gui.cc index 1acd17a..27e9762 100644 --- a/gui/gui.cc +++ b/gui/gui.cc @@ -45,6 +45,9 @@ GUI::GUI(QWidget *parent) // 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 Cache from worker thread connect(this, &GUI::sendRefreshCache, worker, &Worker::refreshCache, Qt::QueuedConnection); @@ -121,6 +124,7 @@ std::vector browseAndRetrieveFile(QWidget* parent) { QString filePath = QFileDialog::getOpenFileName(parent, "Open Binary File", QDir::homePath(), "Binary Files (*.bin *.rv);;All Files (*.*)"); std::vector program; + if (filePath.isEmpty()) return program; QFile file(filePath); @@ -130,14 +134,19 @@ std::vector browseAndRetrieveFile(QWidget* parent) { } while (!file.atEnd()) { - int32_t word = 0; - if (file.read(reinterpret_cast(&word), sizeof(int32_t)) == sizeof(int32_t)) { - program.push_back(static_cast(bswap_32(word))); + char bytes[4]; + if (file.read(bytes, 4) == 4) { + uint32_t word = + (static_cast(bytes[0]) << 24) | + (static_cast(bytes[1]) << 16) | + (static_cast(bytes[2]) << 8) | + (static_cast(bytes[3])); + + program.push_back(static_cast(word)); } } file.close(); - return program; } @@ -261,26 +270,39 @@ void GUI::on_upload_program_state_btn_clicked() qDebug() << "upload program state button is clicked."; } - -void GUI::on_refresh_dram_btn_clicked() -{ - qDebug() << "Refresh DRAM button clicked."; - emit sendRefreshDram(); - -} - - -void GUI::on_refresh_cache_btn_clicked() +void GUI::on_set_levels_btn_clicked() { - qDebug() << "Refresh cache button clicked."; - emit sendRefreshCache(); + 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_refresh_registers_btn_clicked() -{ - qDebug() << "Refresh registers button clicked."; - emit sendRefreshRegisters(); +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!"); +} + -- cgit v1.2.3