aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qtmips_gui/cacheview.cpp38
-rw-r--r--qtmips_gui/cacheview.h9
-rw-r--r--qtmips_gui/coreview/instructionview.cpp2
-rw-r--r--qtmips_machine/cache.cpp6
-rw-r--r--qtmips_machine/cache.h3
5 files changed, 44 insertions, 14 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();
}
diff --git a/qtmips_gui/cacheview.h b/qtmips_gui/cacheview.h
index 70e312b..6803e37 100644
--- a/qtmips_gui/cacheview.h
+++ b/qtmips_gui/cacheview.h
@@ -53,7 +53,8 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private slots:
- void cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty, std::uint32_t tag, const std::uint32_t *data);
+ void cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty,
+ std::uint32_t tag, const std::uint32_t *data, bool write);
private:
unsigned tag, row, col;
@@ -72,7 +73,8 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private slots:
- void cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty, std::uint32_t tag, const std::uint32_t *data);
+ void cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty,
+ std::uint32_t tag, const std::uint32_t *data, bool write);
private:
bool islast;
@@ -80,6 +82,9 @@ private:
unsigned rows, columns;
QGraphicsSimpleTextItem **validity, **dirty, **tag, ***data;
unsigned curr_row;
+ bool last_highlighted;
+ unsigned last_set;
+ unsigned last_col;
};
class CacheViewScene : public QGraphicsScene {
diff --git a/qtmips_gui/coreview/instructionview.cpp b/qtmips_gui/coreview/instructionview.cpp
index f169869..6897e76 100644
--- a/qtmips_gui/coreview/instructionview.cpp
+++ b/qtmips_gui/coreview/instructionview.cpp
@@ -65,7 +65,7 @@ QRectF InstructionView::boundingRect() const {
void InstructionView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
painter->setPen(QPen(QColor(240, 240, 240)));
if (excause == machine::EXCAUSE_NONE)
- painter->setBrush(QBrush(QColor(240, 240, 240)));
+ painter->setBrush(QBrush(QColor(240, 240, 240)));
else
painter->setBrush(QBrush(QColor(255, 100, 100)));
painter->drawRoundRect(-WIDTH/2, 0, WIDTH, HEIGHT, ROUND, ROUND);
diff --git a/qtmips_machine/cache.cpp b/qtmips_machine/cache.cpp
index 961ab49..ec6a021 100644
--- a/qtmips_machine/cache.cpp
+++ b/qtmips_machine/cache.cpp
@@ -179,7 +179,7 @@ void Cache::flush() {
for (unsigned st = 0; st < cnf.sets(); st++)
if (dt[as][st].valid) {
kick(as, st);
- emit cache_update(as, st, 0, false, false, 0, 0);
+ emit cache_update(as, st, 0, false, false, 0, 0, false);
}
change_counter++;
update_statistics();
@@ -264,7 +264,7 @@ void Cache::reset() {
if (cnf.enabled()) {
for (unsigned as = 0; as < cnf.associativity(); as++)
for (unsigned st = 0; st < cnf.sets(); st++)
- emit cache_update(as, st, 0, false, false, 0, 0);
+ emit cache_update(as, st, 0, false, false, 0, 0, false);
}
}
@@ -415,7 +415,7 @@ bool Cache::access(std::uint32_t address, std::uint32_t *data, bool write, std::
cd.data[col] = value;
}
- emit cache_update(indx, row, col, cd.valid, cd.dirty, cd.tag, cd.data);
+ emit cache_update(indx, row, col, cd.valid, cd.dirty, cd.tag, cd.data, write);
if (changed)
change_counter++;
return changed;
diff --git a/qtmips_machine/cache.h b/qtmips_machine/cache.h
index 2602f0b..324d55a 100644
--- a/qtmips_machine/cache.h
+++ b/qtmips_machine/cache.h
@@ -76,7 +76,8 @@ signals:
void hit_update(unsigned) const;
void miss_update(unsigned) const;
void statistics_update(unsigned stalled_cycles, double speed_improv, double hit_rate) const;
- void cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty, std::uint32_t tag, const std::uint32_t *data) const;
+ void cache_update(unsigned associat, unsigned set, unsigned col, bool valid, bool dirty,
+ std::uint32_t tag, const std::uint32_t *data, bool write) const;
void memory_writes_update(unsigned) const;
void memory_reads_update(unsigned) const;