diff options
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/memorydock.cpp | 14 | ||||
-rw-r--r-- | qtmips_gui/memorymodel.cpp | 18 | ||||
-rw-r--r-- | qtmips_gui/memorymodel.h | 2 |
3 files changed, 27 insertions, 7 deletions
diff --git a/qtmips_gui/memorydock.cpp b/qtmips_gui/memorydock.cpp index ccb3b6a..323f053 100644 --- a/qtmips_gui/memorydock.cpp +++ b/qtmips_gui/memorydock.cpp @@ -44,8 +44,6 @@ #include "memorytableview.h" #include "hexlineedit.h" - - MemoryDock::MemoryDock(QWidget *parent, QSettings *settings) : Super(parent) { setObjectName("Memory"); setWindowTitle("Memory"); @@ -58,6 +56,10 @@ MemoryDock::MemoryDock(QWidget *parent, QSettings *settings) : Super(parent) { cell_size->addItem("Word", MemoryModel::CELLSIZE_WORD); cell_size->setCurrentIndex(MemoryModel::CELLSIZE_WORD); + QComboBox *cached_access = new QComboBox(); + cached_access->addItem("Direct", 0); + cached_access->addItem("Cached", 1); + QTableView *memory_content = new MemoryTableView(0, settings); // memory_content->setSizePolicy(); MemoryModel *memory_model = new MemoryModel(0); @@ -67,8 +69,12 @@ MemoryDock::MemoryDock(QWidget *parent, QSettings *settings) : Super(parent) { QLineEdit *go_edit = new HexLineEdit(0, 8, 16, "0x"); + QHBoxLayout *layout_top = new QHBoxLayout; + layout_top->addWidget(cell_size); + layout_top->addWidget(cached_access); + QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(cell_size); + layout->addLayout(layout_top); layout->addWidget(memory_content); layout->addWidget(go_edit); @@ -79,6 +85,8 @@ MemoryDock::MemoryDock(QWidget *parent, QSettings *settings) : Super(parent) { connect(this, &MemoryDock::machine_setup, memory_model, &MemoryModel::setup); connect(cell_size, SIGNAL(currentIndexChanged(int)), memory_content, SLOT(set_cell_size(int))); + connect(cached_access, SIGNAL(currentIndexChanged(int)), + memory_model, SLOT(cached_access(int))); connect(go_edit, SIGNAL(value_edit_finished(std::uint32_t)), memory_content, SLOT(go_to_address(std::uint32_t))); connect(memory_content, SIGNAL(address_changed(std::uint32_t)), diff --git a/qtmips_gui/memorymodel.cpp b/qtmips_gui/memorymodel.cpp index 66da84c..12b3fcb 100644 --- a/qtmips_gui/memorymodel.cpp +++ b/qtmips_gui/memorymodel.cpp @@ -46,6 +46,7 @@ MemoryModel::MemoryModel(QObject *parent) machine = nullptr; memory_change_counter = 0; cache_data_change_counter = 0; + access_through_cache = 0; } int MemoryModel::rowCount(const QModelIndex & /*parent*/) const { @@ -80,6 +81,7 @@ QVariant MemoryModel::data(const QModelIndex &index, int role) const { QString s, t; std::uint32_t address; std::uint32_t data; + const machine::MemoryAccess *mem; if (!get_row_address(address, index.row())) return QString(""); if (index.column() == 0) { @@ -89,21 +91,24 @@ QVariant MemoryModel::data(const QModelIndex &index, int role) const { } if (machine == nullptr) return QString(""); - if (machine->memory() == nullptr) + mem = machine->memory(); + if (mem == nullptr) return QString(""); + if ((access_through_cache > 0) && (machine->cache_data() != nullptr)) + mem = machine->cache_data(); address += cellSizeBytes() * (index.column() - 1); if (address < index0_offset) return QString(""); switch (cell_size) { case CELLSIZE_BYTE: - data = machine->memory()->read_byte(address); + data = mem->read_byte(address, true); break; case CELLSIZE_HWORD: - data = machine->memory()->read_hword(address); + data = mem->read_hword(address, true); break; default: case CELLSIZE_WORD: - data = machine->memory()->read_word(address); + data = mem->read_word(address, true); break; } @@ -215,3 +220,8 @@ bool MemoryModel::adjustRowAndOffset(int &row, int optimal_row, std::uint32_t ad } return get_row_for_address(row, address); } + +void MemoryModel::cached_access(int cached) { + access_through_cache = cached; + update_all(); +} diff --git a/qtmips_gui/memorymodel.h b/qtmips_gui/memorymodel.h index f093dbb..83bc057 100644 --- a/qtmips_gui/memorymodel.h +++ b/qtmips_gui/memorymodel.h @@ -106,6 +106,7 @@ public slots: void setup(machine::QtMipsMachine *machine); void set_cell_size(int index); void check_for_updates(); + void cached_access(int cached); signals: void cell_size_changed(); @@ -118,6 +119,7 @@ private: machine::QtMipsMachine *machine; std::uint32_t memory_change_counter; std::uint32_t cache_data_change_counter; + int access_through_cache; }; |