@@ -12,18 +12,25 @@ CacheDock::CacheDock(QWidget *parent, const QString &type)
1212 layout_top_form = new QFormLayout (top_form);
1313
1414 l_hit = new QLabel (" 0" , top_form);
15+ l_hit->setTextFormat (Qt::PlainText);
1516 layout_top_form->addRow (" Hit:" , l_hit);
1617 l_miss = new QLabel (" 0" , top_form);
18+ l_miss->setTextFormat (Qt::PlainText);
1719 layout_top_form->addRow (" Miss:" , l_miss);
1820 l_m_reads = new QLabel (" 0" , top_form);
21+ l_m_reads->setTextFormat (Qt::PlainText);
1922 layout_top_form->addRow (" Memory reads:" , l_m_reads);
2023 l_m_writes = new QLabel (" 0" , top_form);
24+ l_m_writes->setTextFormat (Qt::PlainText);
2125 layout_top_form->addRow (" Memory writes:" , l_m_writes);
2226 l_stalled = new QLabel (" 0" , top_form);
27+ l_stalled->setTextFormat (Qt::PlainText);
2328 layout_top_form->addRow (" Memory stall cycles:" , l_stalled);
2429 l_hit_rate = new QLabel (" 0.000%" , top_form);
30+ l_hit_rate->setTextFormat (Qt::PlainText);
2531 layout_top_form->addRow (" Hit rate:" , l_hit_rate);
2632 l_speed = new QLabel (" 100%" , top_form);
33+ l_speed->setTextFormat (Qt::PlainText);
2734 layout_top_form->addRow (" Improved speed:" , l_speed);
2835
2936 graphicsview = new GraphicsView (top_widget);
@@ -39,6 +46,14 @@ CacheDock::CacheDock(QWidget *parent, const QString &type)
3946}
4047
4148void CacheDock::setup (const machine::Cache *cache, bool cache_after_cache) {
49+ memory_reads = 0 ;
50+ memory_writes = 0 ;
51+ hit = 0 ;
52+ miss = 0 ;
53+ stalled = 0 ;
54+ speed_improv = 0.0 ;
55+ hit_rate = 0.0 ;
56+
4257 l_hit->setText (" 0" );
4358 l_miss->setText (" 0" );
4459 l_stalled->setText (" 0" );
@@ -48,19 +63,12 @@ void CacheDock::setup(const machine::Cache *cache, bool cache_after_cache) {
4863 l_speed->setText (" 100%" );
4964 l_speed->setHidden (cache_after_cache);
5065 if (cache != nullptr ) {
66+ connect (cache, &machine::Cache::hit_update, this , &CacheDock::hit_update);
67+ connect (cache, &machine::Cache::miss_update, this , &CacheDock::miss_update);
68+ connect (cache, &machine::Cache::memory_reads_update, this , &CacheDock::memory_reads_update);
5169 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);
70+ cache, &machine::Cache::memory_writes_update, this , &CacheDock::memory_writes_update);
71+ connect (cache, &machine::Cache::statistics_update, this , &CacheDock::statistics_update);
6472 }
6573 top_form->setVisible (cache != nullptr );
6674 no_cache->setVisible (cache == nullptr || !cache->get_config ().enabled ());
@@ -71,27 +79,38 @@ void CacheDock::setup(const machine::Cache *cache, bool cache_after_cache) {
7179 graphicsview->setVisible (cache != nullptr && cache->get_config ().enabled ());
7280}
7381
82+ void CacheDock::paintEvent (QPaintEvent *event) {
83+ l_stalled->setText (QString::number (stalled));
84+ l_hit_rate->setText (QString::number (hit_rate, ' f' , 3 ) + QString (" %" ));
85+ l_speed->setText (QString::number (speed_improv, ' f' , 0 ) + QString (" %" ));
86+ l_hit->setText (QString::number (hit));
87+ l_miss->setText (QString::number (miss));
88+ l_m_reads->setText (QString::number (memory_reads));
89+ l_m_writes->setText (QString::number (memory_writes));
90+ QDockWidget::paintEvent (event);
91+ }
92+
7493void CacheDock::hit_update (unsigned val) {
75- l_hit-> setText ( QString::number ( val)) ;
94+ hit = val;
7695}
7796
7897void CacheDock::miss_update (unsigned val) {
79- l_miss-> setText ( QString::number ( val)) ;
98+ miss = val;
8099}
81100
82101void CacheDock::memory_reads_update (unsigned val) {
83- l_m_reads-> setText ( QString::number ( val)) ;
102+ memory_reads = val;
84103}
85104
86105void CacheDock::memory_writes_update (unsigned val) {
87- l_m_writes-> setText ( QString::number ( val)) ;
106+ memory_writes = val;
88107}
89108
90109void CacheDock::statistics_update (
91110 unsigned stalled_cycles,
92111 double speed_improv,
93112 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 ( " % " )) ;
113+ this -> stalled = stalled_cycles;
114+ this -> hit = hit_rate ;
115+ this -> speed_improv = speed_improv ;
97116}
0 commit comments