diff options
author | bd <bdunahu@operationnull.com> | 2025-04-18 19:31:17 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-18 19:31:17 -0400 |
commit | 5e96476ae29a104df1c4526ba1037dc830207d56 (patch) | |
tree | d265a50df61bda586a819dc0305e5dccb2611f98 /gui | |
parent | 80063914f09975f24451ce1acb9875cea0d2d384 (diff) |
Use a slider for step amount
Diffstat (limited to 'gui')
-rw-r--r-- | gui/gui.cc | 13 | ||||
-rw-r--r-- | gui/gui.h | 2 | ||||
-rw-r--r-- | gui/gui.ui | 348 | ||||
-rw-r--r-- | gui/worker.cc | 6 | ||||
-rw-r--r-- | gui/worker.h | 2 |
5 files changed, 250 insertions, 121 deletions
@@ -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() @@ -35,7 +35,6 @@ signals: void sendRefreshCache(); void sendRefreshRegisters(); void sendRunSteps(int steps); - void sendRunStep(); void sendLoadProgram(std::vector<signed int> program); void sendConfigure(std::vector<int> ways, std::vector<int> size, bool is_pipelined, bool is_cache_enabled); @@ -82,6 +81,7 @@ private: Ui::GUI *ui; QThread workerThread; Worker *worker; + QVector<int> step_values = {1, 5, 10, 50, 250, 1000, 10000}; const std::map<Mnemonic, QString> mnemonicNameMap = { {Mnemonic::ADD, "ADD"}, {Mnemonic::SUB, "SUB"}, @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>1359</width> - <height>638</height> + <height>621</height> </rect> </property> <property name="windowTitle"> @@ -16,8 +16,108 @@ <widget class="QWidget" name="centralwidget"> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0" columnstretch="0,0,0,0"> - <item row="1" column="0" colspan="4"> + <layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0" columnstretch="0,3,0,1,0"> + <item row="0" column="1"> + <layout class="QVBoxLayout" name="verticalLayout_19" stretch="1,0,3"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_20"> + <item> + <widget class="QLabel" name="label_5"> + <property name="font"> + <font> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Registers</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_25"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="register_table"/> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line_26"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_21"> + <item> + <widget class="QLabel" name="label_6"> + <property name="font"> + <font> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Cache</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_27"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="cache_table"/> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line_28"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_22"> + <item> + <widget class="QLabel" name="label_10"> + <property name="font"> + <font> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>DRAM</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_29"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="dram_table"/> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </item> + <item row="1" column="0" colspan="5"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QGroupBox" name="Fetch"> @@ -43,6 +143,13 @@ </widget> </item> <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + </widget> + </item> + <item> <widget class="QGroupBox" name="Decode"> <property name="title"> <string>Decode</string> @@ -66,6 +173,13 @@ </widget> </item> <item> + <widget class="Line" name="line_2"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + </widget> + </item> + <item> <widget class="QGroupBox" name="Execute"> <property name="title"> <string>Execute</string> @@ -113,6 +227,13 @@ </widget> </item> <item> + <widget class="Line" name="line_3"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + </widget> + </item> + <item> <widget class="QGroupBox" name="Memory"> <property name="title"> <string>Memory</string> @@ -160,6 +281,13 @@ </widget> </item> <item> + <widget class="Line" name="line_4"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + </widget> + </item> + <item> <widget class="QGroupBox" name="WriteBack"> <property name="title"> <string>Write Back</string> @@ -206,9 +334,61 @@ </layout> </widget> </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <widget class="QLabel" name="label_14"> + <property name="font"> + <font> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Run</string> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="step_slider"> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>6</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TickPosition::NoTicks</enum> + </property> + <property name="tickInterval"> + <number>1</number> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="step_btn"> + <property name="text"> + <string>Step</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line_6"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + </widget> + </item> </layout> </item> - <item row="0" column="2"> + <item row="0" column="3"> <layout class="QVBoxLayout" name="verticalLayout_23"> <item> <layout class="QVBoxLayout" name="verticalLayout_24"> @@ -225,6 +405,13 @@ </widget> </item> <item> + <widget class="Line" name="line_33"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> + <item> <layout class="QVBoxLayout" name="verticalLayout_25"> <item> <widget class="QPushButton" name="upload_intructions_btn"> @@ -246,6 +433,13 @@ </item> </layout> </item> + <item> + <widget class="Line" name="line_34"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> </layout> </item> <item> @@ -263,6 +457,13 @@ </widget> </item> <item> + <widget class="Line" name="line_35"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> + <item> <layout class="QVBoxLayout" name="verticalLayout_27"> <item> <layout class="QHBoxLayout" name="horizontalLayout_9"> @@ -331,49 +532,32 @@ <item> <layout class="QVBoxLayout" name="verticalLayout_28"> <item> - <widget class="QLabel" name="label_14"> - <property name="font"> - <font> - <bold>true</bold> - </font> + <widget class="Line" name="line_36"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> </property> - <property name="text"> - <string>Run</string> + </widget> + </item> + <item> + <widget class="Line" name="line_37"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> </property> </widget> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_29"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <item> - <widget class="QLineEdit" name="number_steps_inp"> - <property name="placeholderText"> - <string># Steps</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="run_steps_btn"> - <property name="text"> - <string>Run Steps</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QPushButton" name="step_btn"> - <property name="text"> - <string>Step</string> - </property> - </widget> - </item> - </layout> + <layout class="QVBoxLayout" name="verticalLayout_29"/> </item> </layout> </item> <item> + <widget class="Line" name="line_38"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> + <item> <layout class="QVBoxLayout" name="verticalLayout_30"> <item> <widget class="QLabel" name="label_15"> @@ -388,6 +572,13 @@ </widget> </item> <item> + <widget class="Line" name="line_39"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + </item> + <item> <widget class="QLabel" name="cycles_label"> <property name="text"> <string>Clock Cycles</string> @@ -405,70 +596,12 @@ </item> </layout> </item> - <item row="0" column="1"> - <layout class="QVBoxLayout" name="verticalLayout_19" stretch="1,3"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_20"> - <item> - <widget class="QLabel" name="label_5"> - <property name="font"> - <font> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Registers</string> - </property> - </widget> - </item> - <item> - <widget class="QTextEdit" name="register_table"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_21"> - <item> - <widget class="QLabel" name="label_6"> - <property name="font"> - <font> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Cache</string> - </property> - </widget> - </item> - <item> - <widget class="QTextEdit" name="cache_table"/> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_22"> - <item> - <widget class="QLabel" name="label_10"> - <property name="font"> - <font> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>DRAM</string> - </property> - </widget> - </item> - <item> - <widget class="QTextEdit" name="dram_table"/> - </item> - </layout> - </item> - </layout> - </item> - </layout> + <item row="0" column="2"> + <widget class="Line" name="line_5"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + </widget> </item> </layout> </item> @@ -485,17 +618,6 @@ </property> </widget> <widget class="QStatusBar" name="statusbar"/> - <widget class="QToolBar" name="toolBar"> - <property name="windowTitle"> - <string>toolBar</string> - </property> - <attribute name="toolBarArea"> - <enum>TopToolBarArea</enum> - </attribute> - <attribute name="toolBarBreak"> - <bool>false</bool> - </attribute> - </widget> </widget> <resources/> <connections/> 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<int> ways, std::vector<int> 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); |