Skip to content

Commit 6312493

Browse files
committed
Show corresponding memory word address in the cacheview.
Signed-off-by: Pavel Pisa <[email protected]>
1 parent f44ecd1 commit 6312493

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

qtmips_gui/cacheview.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
using namespace std;
5050

5151
CacheAddressBlock::CacheAddressBlock(const machine::Cache *cache, unsigned width) {
52+
rows = cache->config().sets();
53+
columns = cache->config().blocks();
5254
s_row = cache->config().sets() > 1 ? sqrt(cache->config().sets()) : 0;
5355
this->width = width;
5456
s_col = cache->config().blocks() > 1 ? sqrt(cache->config().blocks()) : 0;
@@ -108,6 +110,8 @@ void CacheAddressBlock::paint(QPainter *painter, const QStyleOptionGraphicsItem
108110

109111
// Pain address label
110112
painter->drawText(QRectF(5, 0, wpos - 5, 14), Qt::AlignCenter, "Address");
113+
std::uint32_t addr = (((tag * rows) + row) * columns + col) * 4;
114+
painter->drawText(QRectF(50, 0, wpos + 40, 14), Qt::AlignCenter, "0x" + QString("%1").arg(addr, 8, 16, QChar('0')));
111115

112116
QPen p;
113117
p.setWidth(2);
@@ -343,6 +347,7 @@ void CacheViewBlock::cache_update(unsigned associat, unsigned set, unsigned col,
343347
if (associat != block) {
344348
if (last_highlighted)
345349
this->data[last_set][last_col]->setBrush(QBrush(QColor(0, 0, 0)));
350+
last_highlighted = false;
346351
return; // Ignore blocks that are not us
347352
}
348353
validity[set]->setText(valid ? "1" : "0");

qtmips_gui/cacheview.h

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ private slots:
5757
std::uint32_t tag, const std::uint32_t *data, bool write);
5858

5959
private:
60+
unsigned rows, columns;
6061
unsigned tag, row, col;
6162
unsigned s_tag, s_row, s_col;
6263
unsigned width;

0 commit comments

Comments
 (0)