@@ -39,6 +39,14 @@ CacheDock::CacheDock(QWidget *parent, const QString &type)
39
39
}
40
40
41
41
void CacheDock::setup (const machine::Cache *cache, bool cache_after_cache) {
42
+ memory_reads = 0 ;
43
+ memory_writes = 0 ;
44
+ hit = 0 ;
45
+ miss = 0 ;
46
+ stalled = 0 ;
47
+ speed_improv = 0.0 ;
48
+ hit_rate = 0.0 ;
49
+
42
50
l_hit->setText (" 0" );
43
51
l_miss->setText (" 0" );
44
52
l_stalled->setText (" 0" );
@@ -48,19 +56,12 @@ void CacheDock::setup(const machine::Cache *cache, bool cache_after_cache) {
48
56
l_speed->setText (" 100%" );
49
57
l_speed->setHidden (cache_after_cache);
50
58
if (cache != nullptr ) {
59
+ connect (cache, &machine::Cache::hit_update, this , &CacheDock::hit_update);
60
+ connect (cache, &machine::Cache::miss_update, this , &CacheDock::miss_update);
61
+ connect (cache, &machine::Cache::memory_reads_update, this , &CacheDock::memory_reads_update);
51
62
connect (
52
- cache, &machine::Cache::hit_update, this , &CacheDock::hit_update);
53
- connect (
54
- cache, &machine::Cache::miss_update, this , &CacheDock::miss_update);
55
- connect (
56
- cache, &machine::Cache::memory_reads_update, this ,
57
- &CacheDock::memory_reads_update);
58
- connect (
59
- cache, &machine::Cache::memory_writes_update, this ,
60
- &CacheDock::memory_writes_update);
61
- connect (
62
- cache, &machine::Cache::statistics_update, this ,
63
- &CacheDock::statistics_update);
63
+ cache, &machine::Cache::memory_writes_update, this , &CacheDock::memory_writes_update);
64
+ connect (cache, &machine::Cache::statistics_update, this , &CacheDock::statistics_update);
64
65
}
65
66
top_form->setVisible (cache != nullptr );
66
67
no_cache->setVisible (cache == nullptr || !cache->get_config ().enabled ());
@@ -71,27 +72,38 @@ void CacheDock::setup(const machine::Cache *cache, bool cache_after_cache) {
71
72
graphicsview->setVisible (cache != nullptr && cache->get_config ().enabled ());
72
73
}
73
74
75
+ void CacheDock::paintEvent (QPaintEvent *event) {
76
+ l_stalled->setText (QString::number (stalled));
77
+ l_hit_rate->setText (QString::number (hit_rate, ' f' , 3 ) + QString (" %" ));
78
+ l_speed->setText (QString::number (speed_improv, ' f' , 0 ) + QString (" %" ));
79
+ l_hit->setText (QString::number (hit));
80
+ l_miss->setText (QString::number (miss));
81
+ l_m_reads->setText (QString::number (memory_reads));
82
+ l_m_writes->setText (QString::number (memory_writes));
83
+ QDockWidget::paintEvent (event);
84
+ }
85
+
74
86
void CacheDock::hit_update (unsigned val) {
75
- l_hit-> setText ( QString::number ( val)) ;
87
+ hit = val;
76
88
}
77
89
78
90
void CacheDock::miss_update (unsigned val) {
79
- l_miss-> setText ( QString::number ( val)) ;
91
+ miss = val;
80
92
}
81
93
82
94
void CacheDock::memory_reads_update (unsigned val) {
83
- l_m_reads-> setText ( QString::number ( val)) ;
95
+ memory_reads = val;
84
96
}
85
97
86
98
void CacheDock::memory_writes_update (unsigned val) {
87
- l_m_writes-> setText ( QString::number ( val)) ;
99
+ memory_writes = val;
88
100
}
89
101
90
102
void CacheDock::statistics_update (
91
103
unsigned stalled_cycles,
92
104
double speed_improv,
93
105
double hit_rate) {
94
- l_stalled-> setText ( QString::number ( stalled_cycles)) ;
95
- l_hit_rate-> setText ( QString::number (hit_rate, ' f ' , 3 ) + QString ( " % " )) ;
96
- l_speed-> setText ( QString::number ( speed_improv, ' f ' , 0 ) + QString ( " % " )) ;
106
+ this -> stalled = stalled_cycles;
107
+ this -> hit = hit_rate ;
108
+ this -> speed_improv = speed_improv ;
97
109
}
0 commit comments