From 48c0b3ffcaef15aeac7b239e769bcc795b943bec Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Thu, 7 Feb 2019 19:20:52 +0100 Subject: Implemented simple indication of presence of memory location in the cache. Signed-off-by: Pavel Pisa --- qtmips_gui/memorydock.cpp | 15 +++++++++++++-- qtmips_gui/memoryview.cpp | 13 ++++++++++++- qtmips_gui/memoryview.h | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) (limited to 'qtmips_gui') diff --git a/qtmips_gui/memorydock.cpp b/qtmips_gui/memorydock.cpp index 7feae4e..86f8f26 100644 --- a/qtmips_gui/memorydock.cpp +++ b/qtmips_gui/memorydock.cpp @@ -54,8 +54,19 @@ QList DataView::row_widget(std::uint32_t address, QWidget *parent) { l = new QLabel(parent); l->setTextInteractionFlags(Qt::TextSelectableByMouse); l->setFont(f); - if (memory != nullptr) - l->setText(QString("0x") + QString("%1").arg(memory->read_word(address), 8, 16, QChar('0')).toUpper()); + if (memory != nullptr) { + machine::LocationStatus loc_stat = machine::LOCSTAT_NONE; + QString val; + val = QString("0x") + QString("%1").arg(memory->read_word(address), 8, 16, QChar('0')).toUpper(); + if (cache_data != nullptr) { + loc_stat = cache_data->location_status(address); + if (loc_stat & machine::LOCSTAT_DIRTY) + val += " D"; + else if (loc_stat & machine::LOCSTAT_CACHED) + val += " C"; + } + l->setText(val); + } widgs.append(l); return widgs; diff --git a/qtmips_gui/memoryview.cpp b/qtmips_gui/memoryview.cpp index 0457633..c4d022a 100644 --- a/qtmips_gui/memoryview.cpp +++ b/qtmips_gui/memoryview.cpp @@ -48,6 +48,7 @@ MemoryView::MemoryView(QWidget *parent, std::uint32_t addr0) : QWidget(parent) { memory = nullptr; addr_0 = addr0; change_counter = 0; + cache_data_change_counter = 0; layout = new QVBoxLayout(this); @@ -67,6 +68,7 @@ MemoryView::MemoryView(QWidget *parent, std::uint32_t addr0) : QWidget(parent) { void MemoryView::setup(machine::QtMipsMachine *machine) { memory = (machine == nullptr) ? nullptr : machine->memory(); + cache_data = (machine == nullptr) ? nullptr : machine->cache_data(); if (machine != nullptr) connect(machine, SIGNAL(post_tick()), this, SLOT(check_for_updates())); reload_content(); @@ -97,10 +99,17 @@ void MemoryView::edit_load_focus() { } void MemoryView::check_for_updates() { + bool need_update = false; if (memory != nullptr) { if (change_counter != memory->get_change_counter()) - reload_content(); + need_update = true; } + if (cache_data != nullptr) { + if (cache_data_change_counter != cache_data->get_change_counter()) + need_update = true; + } + if (need_update) + reload_content(); } void MemoryView::reload_content() { @@ -108,6 +117,8 @@ void MemoryView::reload_content() { memf->widg->clearRows(); if (memory != nullptr) change_counter = memory->get_change_counter(); + if (cache_data != nullptr) + cache_data_change_counter = cache_data->get_change_counter(); update_content(count, 0); } diff --git a/qtmips_gui/memoryview.h b/qtmips_gui/memoryview.h index 17af34f..f60ac53 100644 --- a/qtmips_gui/memoryview.h +++ b/qtmips_gui/memoryview.h @@ -67,6 +67,7 @@ public slots: protected: const machine::Memory *memory; + const machine::Cache *cache_data; virtual QList row_widget(std::uint32_t address, QWidget *parent) = 0; @@ -82,6 +83,7 @@ private slots: private: std::uint32_t change_counter; + std::uint32_t cache_data_change_counter; unsigned count; std::uint32_t addr_0; // First address in view -- cgit v1.2.3