diff options
author | Karel Kočí <cynerd@email.cz> | 2018-01-04 18:44:28 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2018-01-04 18:44:28 +0100 |
commit | c06242f07721a7d86dc2d9795622d6646ae6c88f (patch) | |
tree | 55a264c093ce4e7719e87c9ac187635f9f97df63 /qtmips_gui | |
parent | 5eccfdab52973f9be9e38c65c17a33e8d2428692 (diff) | |
download | qtmips-c06242f07721a7d86dc2d9795622d6646ae6c88f.tar.gz qtmips-c06242f07721a7d86dc2d9795622d6646ae6c88f.tar.bz2 qtmips-c06242f07721a7d86dc2d9795622d6646ae6c88f.zip |
Implement some machine execution speed control for gui
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/MainWindow.ui | 69 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.cpp | 28 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.h | 4 |
3 files changed, 64 insertions, 37 deletions
diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui index 56f5319..0ab35d1 100644 --- a/qtmips_gui/MainWindow.ui +++ b/qtmips_gui/MainWindow.ui @@ -73,22 +73,14 @@ <property name="title"> <string>Machine</string> </property> - <widget class="QMenu" name="menuSimulation_speed"> - <property name="title"> - <string>Simulation speed</string> - </property> - <addaction name="action1_ips"/> - <addaction name="action2_ips"/> - <addaction name="action5_ips"/> - <addaction name="action10_ips"/> - <addaction name="actionOther_ips"/> - <addaction name="separator"/> - <addaction name="actionUnlimited"/> - </widget> <addaction name="actionRun"/> <addaction name="actionPause"/> <addaction name="actionStep"/> - <addaction name="menuSimulation_speed"/> + <addaction name="separator"/> + <addaction name="ips1"/> + <addaction name="ips5"/> + <addaction name="ips10"/> + <addaction name="ipsUnlimited"/> <addaction name="separator"/> <addaction name="actionRestart"/> </widget> @@ -119,6 +111,10 @@ <addaction name="actionRun"/> <addaction name="actionPause"/> <addaction name="actionStep"/> + <addaction name="separator"/> + <addaction name="ips1"/> + <addaction name="ips10"/> + <addaction name="ipsUnlimited"/> </widget> <action name="actionNew"> <property name="icon"> @@ -188,42 +184,48 @@ <string>Ctrl+P</string> </property> </action> - <action name="action1_ips"> + <action name="ips1"> + <property name="checkable"> + <bool>true</bool> + </property> <property name="text"> <string>1 instruction per second</string> </property> - </action> - <action name="action2_ips"> - <property name="text"> - <string>2 instructions per second</string> + <property name="toolTip"> + <string>Run CPU in speed of single instruction per second</string> </property> </action> - <action name="action5_ips"> + <action name="ips5"> + <property name="checkable"> + <bool>true</bool> + </property> <property name="text"> <string>5 instructions per second</string> </property> + <property name="toolTip"> + <string>Run CPU in speed of 5 instructions per second</string> + </property> </action> - <action name="action10_ips"> + <action name="ips10"> + <property name="checkable"> + <bool>true</bool> + </property> <property name="text"> <string>10 instructions per second</string> </property> - </action> - <action name="actionUnlimited"> - <property name="text"> - <string>Unlimited</string> + <property name="toolTip"> + <string>Run CPU in speed of 10 instructions per second</string> </property> </action> - <action name="actionOther_ips"> + <action name="ipsUnlimited"> <property name="checkable"> - <bool>false</bool> + <bool>true</bool> </property> <property name="text"> - <string>Custom...</string> + <string>Unlimited</string> </property> - </action> - <action name="actionMachine_control"> - <property name="text"> - <string>Machine control</string> + <property name="toolTip"> + <string>Run CPU without any clock constrains</string> </property> </action> <action name="actionMemory"> @@ -251,11 +253,6 @@ <string>Registers</string> </property> </action> - <action name="actionAssembler"> - <property name="text"> - <string>Assembler</string> - </property> - </action> <action name="actionReload"> <property name="icon"> <iconset resource="icons.qrc"> diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 9384890..d1a9770 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -21,12 +21,24 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { registers = new RegistersDock(this); registers->hide(); + // Execution speed actions + speed_group = new QActionGroup(this); + speed_group->addAction(ui->ips1); + speed_group->addAction(ui->ips5); + speed_group->addAction(ui->ips10); + speed_group->addAction(ui->ipsUnlimited); + ui->ips1->setChecked(true); + // Connect signals from menu connect(ui->actionExit, SIGNAL(triggered(bool)), this, SLOT(close())); connect(ui->actionNew, SIGNAL(triggered(bool)), this, SLOT(new_machine())); connect(ui->actionCache, SIGNAL(triggered(bool)), this, SLOT(show_cache_content())); connect(ui->actionCache_statistics, SIGNAL(triggered(bool)), this, SLOT(show_cache_statictics())); connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers())); + connect(ui->ips1, SIGNAL(toggled(bool)), this, SLOT(set_speed())); + connect(ui->ips5, SIGNAL(toggled(bool)), this, SLOT(set_speed())); + connect(ui->ips10, SIGNAL(toggled(bool)), this, SLOT(set_speed())); + connect(ui->ipsUnlimited, SIGNAL(toggled(bool)), this, SLOT(set_speed())); // Restore application state from settings restoreState(settings->value("windowState").toByteArray()); @@ -63,7 +75,7 @@ void MainWindow::create_core(machine::MachineConfig *config) { // Create machine view corescene = new CoreViewScene(coreview, machine); - machine->set_speed(1000); // Set default speed to 1 sec + set_speed(); // Update machine speed to current settings // Connect machine signals and slots connect(ui->actionRun, SIGNAL(triggered(bool)), machine, SLOT(play())); @@ -100,6 +112,20 @@ void MainWindow::show_registers() { show_dockwidget(registers); } +void MainWindow::set_speed() { + if (machine == nullptr) + return; // just ignore + + if (ui->ips1->isChecked()) + machine->set_speed(1000); + else if (ui->ips5->isChecked()) + machine->set_speed(500); + else if (ui->ips10->isChecked()) + machine->set_speed(100); + else + machine->set_speed(0); +} + void MainWindow::closeEvent(QCloseEvent *event) { settings->setValue("windowGeometry", saveGeometry()); settings->setValue("windowState", saveState()); diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index 6f588ac..d2ab9bb 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -31,6 +31,8 @@ public slots: void show_cache_content(); void show_cache_statictics(); void show_registers(); + // Actions - execution speed + void set_speed(); // Machine signals void machine_status(enum machine::QtMipsMachine::Status st); void machine_exit(); @@ -51,6 +53,8 @@ private: CacheStatisticsDock *cache_statictics; RegistersDock *registers; + QActionGroup *speed_group; + QSettings *settings; machine::QtMipsMachine *machine; // Current simulated machine |