diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-02-13 11:50:28 +0100 |
---|---|---|
committer | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-02-13 11:50:28 +0100 |
commit | 04ab3211f8a052e7f0a05b36206403197e526284 (patch) | |
tree | 53de0b401f289823a196649e14364987353abda4 /qtmips_machine | |
parent | 86a70c781c7b9a62782b785cec14fb483bdaa761 (diff) | |
download | qtmips-04ab3211f8a052e7f0a05b36206403197e526284.tar.gz qtmips-04ab3211f8a052e7f0a05b36206403197e526284.tar.bz2 qtmips-04ab3211f8a052e7f0a05b36206403197e526284.zip |
Add speed option to run core for time chunks without visualization.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_machine')
-rw-r--r-- | qtmips_machine/qtmipsmachine.cpp | 12 | ||||
-rw-r--r-- | qtmips_machine/qtmipsmachine.h | 3 |
2 files changed, 11 insertions, 4 deletions
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; |