aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/cacheview.cpp
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-03-17 01:07:01 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-03-17 01:07:01 +0100
commitf44ecd1e02c0f4760124a95b5019f67d0e77ecb7 (patch)
tree8fee484f9778fb8509c262c34dd7f2974d7105dd /qtmips_gui/cacheview.cpp
parent8b5298566773275b5c8423dace3396a325f38541 (diff)
downloadqtmips-f44ecd1e02c0f4760124a95b5019f67d0e77ecb7.tar.gz
qtmips-f44ecd1e02c0f4760124a95b5019f67d0e77ecb7.tar.bz2
qtmips-f44ecd1e02c0f4760124a95b5019f67d0e77ecb7.zip
Highlight actual word read or written to the cache.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui/cacheview.cpp')
-rw-r--r--qtmips_gui/cacheview.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/qtmips_gui/cacheview.cpp b/qtmips_gui/cacheview.cpp
index 6eb1bfe..b0fdb9a 100644
--- a/qtmips_gui/cacheview.cpp
+++ b/qtmips_gui/cacheview.cpp
@@ -59,8 +59,8 @@ CacheAddressBlock::CacheAddressBlock(const machine::Cache *cache, unsigned width
row = 0;
col = 0;
- connect(cache, SIGNAL(cache_update(uint,uint,uint,bool,bool,std::uint32_t,const std::uint32_t*)),
- this, SLOT(cache_update(uint,uint,uint,bool,bool,std::uint32_t,const std::uint32_t*)));
+ connect(cache, SIGNAL(cache_update(uint,uint,uint,bool,bool,std::uint32_t,const std::uint32_t*,bool)),
+ this, SLOT(cache_update(uint,uint,uint,bool,bool,std::uint32_t,const std::uint32_t*,bool)));
}
QRectF CacheAddressBlock::boundingRect() const {
@@ -131,7 +131,14 @@ void CacheAddressBlock::paint(QPainter *painter, const QStyleOptionGraphicsItem
}
}
-void CacheAddressBlock::cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty, std::uint32_t tag, const std::uint32_t *data) {
+void CacheAddressBlock::cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty,
+ std::uint32_t tag, const std::uint32_t *data, bool write) {
+ (void)associat;
+ (void)valid;
+ (void)dirty;
+ (void)data;
+ (void)write;
+
this->tag = tag;
this->row = set;
this->col = col;
@@ -145,6 +152,9 @@ CacheViewBlock::CacheViewBlock(const machine::Cache *cache, unsigned block , boo
rows = cache->config().sets();
columns = cache->config().blocks();
curr_row = 0;
+ last_set = 0;
+ last_col = 0;
+ last_highlighted = false;
QFont font;
font.setPixelSize(FontSize::SIZE7);
@@ -208,8 +218,8 @@ CacheViewBlock::CacheViewBlock(const machine::Cache *cache, unsigned block , boo
box = l_data->boundingRect();
l_data->setPos(wd + (columns*DATA_WIDTH - box.width())/2 , -1 - box.height());
- connect(cache, SIGNAL(cache_update(uint,uint,uint,bool,bool,std::uint32_t,const std::uint32_t*)),
- this, SLOT(cache_update(uint,uint,uint,bool,bool,std::uint32_t,const std::uint32_t*)));
+ connect(cache, SIGNAL(cache_update(uint,uint,uint,bool,bool,std::uint32_t,const std::uint32_t*,bool)),
+ this, SLOT(cache_update(uint,uint,uint,bool,bool,std::uint32_t,const std::uint32_t*,bool)));
}
CacheViewBlock::~CacheViewBlock() {
@@ -327,10 +337,14 @@ void CacheViewBlock::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
}
}
-void CacheViewBlock::cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty, std::uint32_t tag, const std::uint32_t *data) {
+void CacheViewBlock::cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty,
+ std::uint32_t tag, const std::uint32_t *data, bool write) {
(void)col;
- if (associat != block)
+ if (associat != block) {
+ if (last_highlighted)
+ this->data[last_set][last_col]->setBrush(QBrush(QColor(0, 0, 0)));
return; // Ignore blocks that are not us
+ }
validity[set]->setText(valid ? "1" : "0");
if (this->dirty)
this->dirty[set]->setText(valid ? (dirty ? "1" : "0") : "");
@@ -339,7 +353,17 @@ void CacheViewBlock::cache_update(unsigned associat, unsigned set, unsigned col,
for (unsigned i = 0; i < columns; i++)
this->data[set][i]->setText(valid ? QString("0x") + QString("%1").arg(data[i], 8, 16, QChar('0')).toUpper() : "");
+ if (last_highlighted)
+ this->data[last_set][last_col]->setBrush(QBrush(QColor(0, 0, 0)));
+ if (write)
+ this->data[set][col]->setBrush(QBrush(QColor(240, 0, 0)));
+ else
+ this->data[set][col]->setBrush(QBrush(QColor(0, 0, 240)));
+ last_highlighted = true;
+
curr_row = set;
+ last_set = set;
+ last_col = col;
update();
}