aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qtmips_gui/MainWindow.ui15
-rw-r--r--qtmips_gui/mainwindow.cpp4
-rw-r--r--qtmips_machine/qtmipsmachine.cpp12
-rw-r--r--qtmips_machine/qtmipsmachine.h3
4 files changed, 30 insertions, 4 deletions
diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui
index b42b3c5..bdaba23 100644
--- a/qtmips_gui/MainWindow.ui
+++ b/qtmips_gui/MainWindow.ui
@@ -117,6 +117,7 @@
<addaction name="ips2"/>
<addaction name="ips5"/>
<addaction name="ips10"/>
+ <addaction name="ipsMax"/>
</widget>
<action name="actionNew">
<property name="icon">
@@ -326,6 +327,20 @@
<string>Ctrl+2</string>
</property>
</action>
+ <action name="ipsMax">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Max</string>
+ </property>
+ <property name="toolTip">
+ <string>Run at maximal speed, skip visualization for 100 msec</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+M</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index c4f57f5..6c752f0 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -67,6 +67,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
speed_group->addAction(ui->ips5);
speed_group->addAction(ui->ips10);
speed_group->addAction(ui->ipsUnlimited);
+ speed_group->addAction(ui->ipsMax);
ui->ips1->setChecked(true);
// Connect signals from menu
@@ -83,6 +84,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
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()));
+ connect(ui->ipsMax, SIGNAL(toggled(bool)), this, SLOT(set_speed()));
// Restore application state from settings
restoreState(settings->value("windowState").toByteArray());
@@ -220,6 +222,8 @@ void MainWindow::set_speed() {
machine->set_speed(200);
else if (ui->ips10->isChecked())
machine->set_speed(100);
+ else if (ui->ipsMax->isChecked())
+ machine->set_speed(0, 100);
else
machine->set_speed(0);
}
diff --git a/qtmips_machine/qtmipsmachine.cpp b/qtmips_machine/qtmipsmachine.cpp
index 69deeb1..81f733b 100644
--- a/qtmips_machine/qtmipsmachine.cpp
+++ b/qtmips_machine/qtmipsmachine.cpp
@@ -33,6 +33,7 @@
*
******************************************************************************/
+#include <QTime>
#include "qtmipsmachine.h"
#include "programloader.h"
@@ -102,8 +103,9 @@ const MachineConfig &QtMipsMachine::config() {
return mcnf;
}
-void QtMipsMachine::set_speed(unsigned val) {
- run_t->setInterval(val);
+void QtMipsMachine::set_speed(unsigned int ips, unsigned int time_chunk) {
+ this->time_chunk = time_chunk;
+ run_t->setInterval(ips);
}
const Registers *QtMipsMachine::registers() {
@@ -174,7 +176,11 @@ void QtMipsMachine::step_internal(bool skip_break) {
set_status(ST_BUSY);
emit tick();
try {
- cr->step(skip_break);
+ QTime start_time = QTime::currentTime();
+ do {
+ cr->step(skip_break);
+ } while(time_chunk != 0 && stat == ST_BUSY &&
+ start_time.msecsTo(QTime::currentTime()) < time_chunk);
} catch (QtMipsException &e) {
run_t->stop();
set_status(ST_TRAPPED);
diff --git a/qtmips_machine/qtmipsmachine.h b/qtmips_machine/qtmipsmachine.h
index 4ad39c5..2a191f0 100644
--- a/qtmips_machine/qtmipsmachine.h
+++ b/qtmips_machine/qtmipsmachine.h
@@ -57,7 +57,7 @@ public:
~QtMipsMachine();
const MachineConfig &config();
- void set_speed(unsigned);
+ void set_speed(unsigned int ips, unsigned int time_chunk = 0);
const Registers *registers();
const Memory *memory();
@@ -111,6 +111,7 @@ private:
Core *cr;
QTimer *run_t;
+ unsigned int time_chunk;
std::uint32_t program_end;
enum Status stat;