From 473b28e10956e022b8c809a09283f3581af917a2 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 25 Jun 2019 23:12:22 +0200 Subject: Allow to create simulator without loaded executable. This allows to test simple instruction sequences without need to install compiler. Signed-off-by: Pavel Pisa --- qtmips_gui/NewDialog.ui | 10 ++++++++++ qtmips_gui/mainwindow.cpp | 11 ++++++++--- qtmips_gui/mainwindow.h | 2 +- qtmips_gui/newdialog.cpp | 9 +++++++++ qtmips_gui/newdialog.h | 1 + 5 files changed, 29 insertions(+), 4 deletions(-) (limited to 'qtmips_gui') diff --git a/qtmips_gui/NewDialog.ui b/qtmips_gui/NewDialog.ui index b494ffa..03f364f 100644 --- a/qtmips_gui/NewDialog.ui +++ b/qtmips_gui/NewDialog.ui @@ -419,11 +419,21 @@ + + + + Start empty + + + Load machine + + true + diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 32bdd5b..0dc6bd5 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -139,9 +139,13 @@ void MainWindow::start() { ndialog->show(); } -void MainWindow::create_core(const machine::MachineConfig &config) { +void MainWindow::create_core(const machine::MachineConfig &config, bool load_executable) { // Create machine - machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config, true); + machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config, true, load_executable); + + if (!load_executable && (machine != nullptr)) { + new_machine->memory_rw()->reset(*machine->memory()); + } // Remove old machine if (machine != nullptr) @@ -233,9 +237,10 @@ void MainWindow::new_machine() { } void MainWindow::machine_reload() { + bool load_executable = machine->executable_loaded(); machine::MachineConfig cnf(&machine->config()); // We have to make local copy as create_core will delete current machine try { - create_core(cnf); + create_core(cnf, load_executable); } catch (const machine::QtMipsExceptionInput &e) { QMessageBox msg(this); msg.setText(e.msg(false)); diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index cbbc9ec..8a63bd8 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -60,7 +60,7 @@ public: ~MainWindow(); void start(); - void create_core(const machine::MachineConfig &config); + void create_core(const machine::MachineConfig &config, bool load_executable = true); bool configured(); diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp index 67d3f1d..0e1c5dc 100644 --- a/qtmips_gui/newdialog.cpp +++ b/qtmips_gui/newdialog.cpp @@ -52,6 +52,7 @@ NewDialog::NewDialog(QWidget *parent, QSettings *settings) : QDialog(parent) { ui_cache_d = new Ui::NewDialogCache(); ui_cache_d->setupUi(ui->tab_cache_data); + connect(ui->pushButton_start_empty, SIGNAL(clicked(bool)), this, SLOT(create_empty())); connect(ui->pushButton_load, SIGNAL(clicked(bool)), this, SLOT(create())); connect(ui->pushButton_cancel, SIGNAL(clicked(bool)), this, SLOT(cancel())); connect(ui->pushButton_browse, SIGNAL(clicked(bool)), this, SLOT(browse_elf())); @@ -136,6 +137,14 @@ void NewDialog::create() { this->close(); } +void NewDialog::create_empty() { + MainWindow *prnt = (MainWindow*)parent(); + prnt->create_core(*config, false); + store_settings(); // Save to settings + this->close(); +} + + void NewDialog::browse_elf() { QFileDialog elf_dialog(this); elf_dialog.setFileMode(QFileDialog::ExistingFile); diff --git a/qtmips_gui/newdialog.h b/qtmips_gui/newdialog.h index 6e6ed8a..077b1ab 100644 --- a/qtmips_gui/newdialog.h +++ b/qtmips_gui/newdialog.h @@ -60,6 +60,7 @@ protected: private slots: void cancel(); void create(); + void create_empty(); void browse_elf(); void elf_change(QString val); void set_preset(); -- cgit v1.2.3