added some ARM stats to CDF debug widget

This commit is contained in:
thrust26 2021-02-09 19:47:50 +01:00
parent 7199ab7feb
commit 3c188fbb9a
6 changed files with 79 additions and 18 deletions

View File

@ -17,6 +17,7 @@
#include "DataGridWidget.hxx"
#include "PopUpWidget.hxx"
#include "EditTextWidget.hxx"
#include "CartCDFWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -68,7 +69,7 @@ CartridgeCDFWidget::CartridgeCDFWidget(
// Datastream Pointers
#define DS_X (HBORDER + _font.getStringWidth("xx "))
xpos = DS_X;
ypos += myLineHeight + VGAP * 4;
ypos += myLineHeight + VGAP * 3;
new StaticTextWidget(boss, _font, xpos, ypos, "Datastream Pointers");
myDatastreamPointers = new DataGridWidget(boss, _nfont, DS_X,
@ -135,7 +136,7 @@ CartridgeCDFWidget::CartridgeCDFWidget(
Common::Base::Fmt::_16_2_2);
myJumpStreamIncrements->setTarget(this);
myJumpStreamIncrements->setEditable(false);
xpos = HBORDER; ypos += myLineHeight * 11 + VGAP * 4;
xpos = HBORDER; ypos += myLineHeight * 11 + VGAP * 3;
lwidth = _font.getStringWidth("Waveform Sizes ");
@ -198,6 +199,34 @@ CartridgeCDFWidget::CartridgeCDFWidget(
Common::Base::Fmt::_16_8);
mySamplePointer->setTarget(this);
mySamplePointer->setEditable(false);
xpos = HBORDER; ypos += myLineHeight + VGAP * 2;
new StaticTextWidget(boss, _font, xpos, ypos + 1, "Last ARM run stats:");
xpos = HBORDER + INDENT; ypos += myLineHeight + VGAP;
StaticTextWidget* s = new StaticTextWidget(boss, _font, xpos, ypos + 1, "Mem. cycles ");
myThumbMemCycles = new EditTextWidget(boss, _font, s->getRight(), ypos - 1,
EditTextWidget::calcWidth(_font, 6), myLineHeight, "");
myThumbMemCycles->setEditable(false);
myThumbMemCycles->setToolTip("Number of memory cycles of last ARM run.");
s = new StaticTextWidget(boss, _font, myThumbMemCycles->getRight() + _fontWidth * 2, ypos + 1, "Fetches ");
myThumbFetches = new EditTextWidget(boss, _font, s->getRight(), ypos - 1,
EditTextWidget::calcWidth(_font, 6), myLineHeight, "");
myThumbFetches->setEditable(false);
myThumbFetches->setToolTip("Number of fetches/instructions of last ARM run.");
ypos += myLineHeight + VGAP;
s = new StaticTextWidget(boss, _font, xpos, ypos + 1, "Reads ");
myThumbReads = new EditTextWidget(boss, _font, myThumbMemCycles->getLeft(), ypos - 1,
EditTextWidget::calcWidth(_font, 6), myLineHeight, "");
myThumbReads->setEditable(false);
myThumbReads->setToolTip("Number of reads of last ARM run.");
s = new StaticTextWidget(boss, _font, myThumbReads->getRight() + _fontWidth * 2, ypos + 1, "Writes ");
myThumbWrites = new EditTextWidget(boss, _font, myThumbFetches->getLeft(), ypos - 1,
EditTextWidget::calcWidth(_font, 6), myLineHeight, "");
myThumbWrites->setEditable(false);
myThumbWrites->setToolTip("Number of write of last ARM run.");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -376,6 +405,16 @@ void CartridgeCDFWidget::loadConfig()
mySamplePointer->setCrossed(true);
}
myThumbMemCycles->setText(Common::Base::toString(myCart.stats().fetches
+ myCart.stats().reads + myCart.stats().writes,
Common::Base::Fmt::_10_6));
myThumbFetches->setText(Common::Base::toString(myCart.stats().fetches,
Common::Base::Fmt::_10_6));
myThumbReads->setText(Common::Base::toString(myCart.stats().reads,
Common::Base::Fmt::_10_6));
myThumbWrites->setText(Common::Base::toString(myCart.stats().writes,
Common::Base::Fmt::_10_6));
CartDebugWidget::loadConfig();
}

View File

@ -22,6 +22,7 @@ class PopUpWidget;
class CheckboxWidget;
class DataGridWidget;
class StaticTextWidget;
class EditTextWidget;
#include "CartCDF.hxx"
#include "CartDebugWidget.hxx"
@ -69,6 +70,11 @@ class CartridgeCDFWidget : public CartDebugWidget
CheckboxWidget* myFastFetch{nullptr};
CheckboxWidget* myDigitalSample{nullptr};
EditTextWidget* myThumbMemCycles{nullptr};
EditTextWidget* myThumbFetches{nullptr};
EditTextWidget* myThumbReads{nullptr};
EditTextWidget* myThumbWrites{nullptr};
CartState myOldState;
enum { kBankChanged = 'bkCH' };

View File

@ -827,3 +827,9 @@ uInt32 CartridgeCDF::romSize() const
return new CartridgeCDFInfoWidget(boss, lfont, nfont, x, y, w, h, *this);
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Thumbulator::Stats& CartridgeCDF::stats() const
{
return myThumbEmulator->stats();
}

View File

@ -19,9 +19,9 @@
#define CARTRIDGE_CDF_HXX
class System;
class Thumbulator;
#include "bspf.hxx"
#include "Thumbulator.hxx"
#include "Cart.hxx"
/**
@ -264,6 +264,9 @@ class CartridgeCDF : public Cartridge
uInt32 getSample();
void setupVersion();
// Get number of instructions of last ARM run.
const Thumbulator::Stats& CartridgeCDF::stats() const;
private:
// The ROM image of the cartridge
ByteBuffer myImage{nullptr};

View File

@ -158,11 +158,13 @@ inline int Thumbulator::fatalError(const char* opcode, uInt32 v1, uInt32 v2,
void Thumbulator::dump_counters()
{
cout << endl << endl
<< "instructions " << instructions << endl
<< "fetches " << fetches << endl
<< "reads " << reads << endl
<< "writes " << writes << endl
<< "memcycles " << (fetches+reads+writes) << endl;
<< "instructions " << instructions << endl;
#ifndef NO_THUMB_STATS
cout << "fetches " << _stats.fetches << endl
<< "reads " << _stats.reads << endl
<< "writes " << _stats.writes << endl
<< "memcycles " << (_stats.fetches + _stats.reads + _stats.writes) << endl;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -186,7 +188,7 @@ void Thumbulator::dump_regs()
uInt32 Thumbulator::fetch16(uInt32 addr)
{
#ifndef NO_THUMB_STATS
++fetches;
++_stats.fetches;
#endif
#ifndef UNSAFE_OPTIMIZATIONS
@ -230,7 +232,7 @@ void Thumbulator::write16(uInt32 addr, uInt32 data)
fatalError("write16", addr, "abort - misaligned");
#endif
#ifndef NO_THUMB_STATS
++writes;
++_stats.writes;
#endif
DO_DBUG(statusMsg << "write16(" << Base::HEX8 << addr << "," << Base::HEX8 << data << ")" << endl);
@ -404,7 +406,7 @@ uInt32 Thumbulator::read16(uInt32 addr)
fatalError("read16", addr, "abort - misaligned");
#endif
#ifndef NO_THUMB_STATS
++reads;
++_stats.reads;
#endif
switch(addr & 0xF0000000)
@ -2546,7 +2548,7 @@ int Thumbulator::reset()
statusMsg.str("");
#endif
#ifndef NO_THUMB_STATS
fetches = reads = writes = 0;
_stats.fetches = _stats.reads = _stats.writes = 0;
#endif
return 0;

View File

@ -60,6 +60,12 @@ class Thumbulator
DPCplus // cartridges of type DPC+
};
struct Stats {
#ifndef NO_THUMB_STATS
uInt32 fetches{0}, reads{0}, writes{0};
#endif
};
Thumbulator(const uInt16* rom_ptr, uInt16* ram_ptr, uInt32 rom_size,
const uInt32 c_base, const uInt32 c_start, const uInt32 c_stack,
bool traponfatal, Thumbulator::ConfigureFor configurefor,
@ -75,6 +81,7 @@ class Thumbulator
*/
string run();
string run(uInt32 cycles);
const Stats& stats() const { return _stats; }
#ifndef UNSAFE_OPTIMIZATIONS
/**
@ -198,12 +205,10 @@ class Thumbulator
uInt32 cpsr{0}, mamcr{0};
bool handler_mode{false};
uInt32 systick_ctrl{0}, systick_reload{0}, systick_count{0}, systick_calibrate{0};
#ifndef UNSAFE_OPTIMIZATIONS
uInt64 instructions{0};
#endif
#ifndef NO_THUMB_STATS
uInt64 fetches{0}, reads{0}, writes{0};
#endif
#ifndef UNSAFE_OPTIMIZATIONS
uInt32 instructions{0};
#endif
Stats _stats;
// For emulation of LPC2103's timer 1, used for NTSC/PAL/SECAM detection.
// Register names from documentation: