From fab8cb529772dee9a3e28d471cf82796f0ce257d Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Thu, 18 Jul 2019 00:30:35 +0200 Subject: Add config option to reset machine before internal assembler starts. Signed-off-by: Pavel Pisa --- qtmips_gui/NewDialog.ui | 9 ++++++++- qtmips_gui/mainwindow.cpp | 16 +++++++++++----- qtmips_gui/mainwindow.h | 5 +++-- qtmips_gui/newdialog.cpp | 10 ++++++++-- qtmips_gui/newdialog.h | 1 + 5 files changed, 31 insertions(+), 10 deletions(-) (limited to 'qtmips_gui') diff --git a/qtmips_gui/NewDialog.ui b/qtmips_gui/NewDialog.ui index e3423a4..ee30fc2 100644 --- a/qtmips_gui/NewDialog.ui +++ b/qtmips_gui/NewDialog.ui @@ -7,7 +7,7 @@ 0 0 558 - 316 + 323 @@ -80,6 +80,13 @@ + + + + Reset at compile time (reload after make) + + + diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 210b8de..3af5e47 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -224,11 +224,12 @@ void MainWindow::show_hide_coreview(bool show) { coreview->setScene(corescene); } -void MainWindow::create_core(const machine::MachineConfig &config, bool load_executable) { +void MainWindow::create_core(const machine::MachineConfig &config, bool load_executable, + bool keep_memory) { // Create machine machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config, true, load_executable); - if (!load_executable && (machine != nullptr)) { + if (keep_memory && (machine != nullptr)) { new_machine->memory_rw()->reset(*machine->memory()); } @@ -309,13 +310,13 @@ void MainWindow::new_machine() { ndialog->show(); } -void MainWindow::machine_reload() { +void MainWindow::machine_reload(bool force_memory_reset) { if (machine == nullptr) return new_machine(); 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, load_executable); + create_core(cnf, load_executable, !load_executable && !force_memory_reset); } catch (const machine::QtMipsExceptionInput &e) { QMessageBox msg(this); msg.setText(e.msg(false)); @@ -714,20 +715,25 @@ void MainWindow::message_selected(messagetype::Type type, QString file, int line } void MainWindow::compile_source() { - SymbolTableDb symtab(machine->symbol_table_rw(true)); bool error_occured = false; if (current_srceditor == nullptr) return; + if (machine != nullptr) { + if (machine->config().reset_at_compile()) + machine_reload(true); + } if (machine == nullptr) { QMessageBox::critical(this, "QtMips Error", tr("No machine to store program.")); return; } + SymbolTableDb symtab(machine->symbol_table_rw(true)); machine::MemoryAccess *mem = machine->physical_address_space_rw(); if (mem == nullptr) { QMessageBox::critical(this, "QtMips Error", tr("No physical addresspace to store program.")); return; } QString filename = current_srceditor->filename(); + machine->cache_sync(); SrcEditor *editor = current_srceditor; QTextDocument *doc = editor->document(); diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index 95b3b59..d48ccda 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -64,7 +64,8 @@ public: ~MainWindow(); void start(); - void create_core(const machine::MachineConfig &config, bool load_executable = true); + void create_core(const machine::MachineConfig &config, bool load_executable = true, + bool keep_memory = false); bool configured(); @@ -76,7 +77,7 @@ signals: public slots: // Actions signals void new_machine(); - void machine_reload(); + void machine_reload(bool force_memory_reset = false); void print_action(); void new_source(); void open_source(); diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp index ef9dac3..def95fb 100644 --- a/qtmips_gui/newdialog.cpp +++ b/qtmips_gui/newdialog.cpp @@ -66,6 +66,7 @@ NewDialog::NewDialog(QWidget *parent, QSettings *settings) : QDialog(parent) { connect(ui->preset_no_pipeline_cache, SIGNAL(toggled(bool)), this, SLOT(set_preset())); connect(ui->preset_pipelined_bare, SIGNAL(toggled(bool)), this, SLOT(set_preset())); connect(ui->preset_pipelined, SIGNAL(toggled(bool)), this, SLOT(set_preset())); + connect(ui->reset_at_compile, SIGNAL(clicked(bool)), this, SLOT(reset_at_compile_change(bool))); connect(ui->pipelined, SIGNAL(clicked(bool)), this, SLOT(pipelined_change(bool))); connect(ui->delay_slot, SIGNAL(clicked(bool)), this, SLOT(delay_slot_change(bool))); @@ -126,7 +127,7 @@ void NewDialog::create() { MainWindow *prnt = (MainWindow*)parent(); try { - prnt->create_core(*config); + prnt->create_core(*config, true, false); } catch (const machine::QtMipsExceptionInput &e) { QMessageBox msg(this); msg.setText(e.msg(false)); @@ -144,7 +145,7 @@ void NewDialog::create() { void NewDialog::create_empty() { MainWindow *prnt = (MainWindow*)parent(); - prnt->create_core(*config, false); + prnt->create_core(*config, false, true); store_settings(); // Save to settings this->close(); } @@ -270,9 +271,14 @@ void NewDialog::osemu_fs_root_change(QString val) { config->set_osemu_fs_root(val); } +void NewDialog::reset_at_compile_change(bool v) { + config->set_reset_at_compile(v); +} + void NewDialog::config_gui() { // Basic ui->elf_file->setText(config->elf()); + ui->reset_at_compile->setChecked(config->reset_at_compile()); // Core ui->pipelined->setChecked(config->pipelined()); ui->delay_slot->setChecked(config->delay_slot()); diff --git a/qtmips_gui/newdialog.h b/qtmips_gui/newdialog.h index 077b1ab..532f253 100644 --- a/qtmips_gui/newdialog.h +++ b/qtmips_gui/newdialog.h @@ -79,6 +79,7 @@ private slots: void osemu_exception_stop_change(bool); void browse_osemu_fs_root(); void osemu_fs_root_change(QString val); + void reset_at_compile_change(bool); private: Ui::NewDialog *ui; -- cgit v1.2.3