From 5e96476ae29a104df1c4526ba1037dc830207d56 Mon Sep 17 00:00:00 2001 From: bd Date: Fri, 18 Apr 2025 19:31:17 -0400 Subject: Use a slider for step amount --- gui/gui.cc | 13 ++- gui/gui.h | 2 +- gui/gui.ui | 348 +++++++++++++++++++++++++++++++++++++++------------------- gui/worker.cc | 6 +- gui/worker.h | 2 +- 5 files changed, 250 insertions(+), 121 deletions(-) diff --git a/gui/gui.cc b/gui/gui.cc index e2e7beb..7e3ddfe 100644 --- a/gui/gui.cc +++ b/gui/gui.cc @@ -54,8 +54,14 @@ GUI::GUI(QWidget *parent) // Refresh Registers from worker thread connect(this, &GUI::sendRefreshRegisters, worker, &Worker::refreshRegisters, Qt::QueuedConnection); - // Advance controller by 1 step - connect(this, &GUI::sendRunStep, worker, &Worker::runStep, Qt::QueuedConnection); + // Advance controller by somes steps + connect(this, &GUI::sendRunSteps, worker, &Worker::runSteps, Qt::QueuedConnection); + + // Update the step button with step amount + connect(ui->step_slider, &QSlider::valueChanged, this, [=](int index){ + int value = step_values[index]; + ui->step_btn->setText(QString("Step %1").arg(value)); + }); // Proper cleanup when worker finishes connect(worker, &Worker::finished, this, &GUI::onWorkerFinished); @@ -330,7 +336,8 @@ void GUI::on_enabl_cache_checkbox_checkStateChanged(const Qt::CheckState &arg1) void GUI::on_step_btn_clicked() { qDebug() << "Run step button clicked."; - emit sendRunStep(); + int steps = step_values[ui->step_slider->value()]; + emit sendRunSteps(steps); } void GUI::on_save_program_state_btn_clicked() diff --git a/gui/gui.h b/gui/gui.h index ee871a1..618f2b5 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -35,7 +35,6 @@ signals: void sendRefreshCache(); void sendRefreshRegisters(); void sendRunSteps(int steps); - void sendRunStep(); void sendLoadProgram(std::vector program); void sendConfigure(std::vector ways, std::vector size, bool is_pipelined, bool is_cache_enabled); @@ -82,6 +81,7 @@ private: Ui::GUI *ui; QThread workerThread; Worker *worker; + QVector step_values = {1, 5, 10, 50, 250, 1000, 10000}; const std::map mnemonicNameMap = { {Mnemonic::ADD, "ADD"}, {Mnemonic::SUB, "SUB"}, diff --git a/gui/gui.ui b/gui/gui.ui index 661e228..7198a20 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -7,7 +7,7 @@ 0 0 1359 - 638 + 621 @@ -16,8 +16,108 @@ - - + + + + + + + + + + true + + + + Registers + + + + + + + Qt::Orientation::Horizontal + + + + + + + + + + + + Qt::Orientation::Horizontal + + + + + + + + + + + + true + + + + Cache + + + + + + + Qt::Orientation::Horizontal + + + + + + + + + + + + Qt::Orientation::Vertical + + + + + + + + + + true + + + + DRAM + + + + + + + Qt::Orientation::Horizontal + + + + + + + + + + + + + @@ -42,6 +142,13 @@ + + + + Qt::Orientation::Vertical + + + @@ -65,6 +172,13 @@ + + + + Qt::Orientation::Vertical + + + @@ -112,6 +226,13 @@ + + + + Qt::Orientation::Vertical + + + @@ -159,6 +280,13 @@ + + + + Qt::Orientation::Vertical + + + @@ -206,9 +334,61 @@ + + + + + + + true + + + + Run + + + + + + + 0 + + + 6 + + + 1 + + + Qt::Orientation::Horizontal + + + QSlider::TickPosition::NoTicks + + + 1 + + + + + + + Step + + + + + + + + + Qt::Orientation::Vertical + + + - + @@ -224,6 +404,13 @@ + + + + Qt::Orientation::Horizontal + + + @@ -246,6 +433,13 @@ + + + + Qt::Orientation::Horizontal + + + @@ -262,6 +456,13 @@ + + + + Qt::Orientation::Horizontal + + + @@ -331,48 +532,31 @@ - - - - true - + + + Qt::Orientation::Horizontal - - Run + + + + + + Qt::Orientation::Horizontal - - - - - - - # Steps - - - - - - - Run Steps - - - - - - - - - Step - - - - + + + + + Qt::Orientation::Horizontal + + + @@ -387,6 +571,13 @@ + + + + Qt::Orientation::Horizontal + + + @@ -405,70 +596,12 @@ - - - - - - - - - true - - - - Registers - - - - - - - - - - - - - - - - - true - - - - Cache - - - - - - - - - - - - - - - true - - - - DRAM - - - - - - - - - - - + + + + Qt::Orientation::Vertical + + @@ -485,17 +618,6 @@ - - - toolBar - - - TopToolBarArea - - - false - - diff --git a/gui/worker.cc b/gui/worker.cc index 4465268..3c2c952 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -90,10 +90,10 @@ void Worker::refreshRegisters() emit register_storage(this->ct->get_gprs()); } -void Worker::runStep() +void Worker::runSteps(int steps) { - qDebug() << "Running for 1 step "; - this->ct->advance(WAIT); + 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(); diff --git a/gui/worker.h b/gui/worker.h index 60bbce3..f0ce7a3 100644 --- a/gui/worker.h +++ b/gui/worker.h @@ -45,7 +45,7 @@ public slots: void configure(std::vector ways, std::vector size, bool is_pipelined, bool is_cache_enabled); void refreshCache(); void refreshRegisters(); - void runStep(); + void runSteps(int steps); signals: void clock_cycles(int value, int pc); -- cgit v1.2.3