Finish state widget.

This commit is contained in:
Christian Speckner 2024-08-27 22:07:00 +02:00
parent 74adffdd3a
commit 4026ca4c80
6 changed files with 81 additions and 1 deletions

View File

@ -20,8 +20,10 @@
#include <sstream> #include <sstream>
#include "CartELF.hxx" #include "CartELF.hxx"
#include "BusTransactionQueue.hxx"
#include "DataGridWidget.hxx" #include "DataGridWidget.hxx"
#include "ToggleBitWidget.hxx" #include "ToggleBitWidget.hxx"
#include "EditTextWidget.hxx"
namespace { namespace {
string registerName(uInt8 reg) { string registerName(uInt8 reg) {
@ -49,6 +51,18 @@ namespace {
} }
} }
} }
string describeTransaction(uInt16 address, uInt16 mask, uInt64 timestamp) {
ostringstream s;
s
<< std::hex << std::setfill('0')
<< "waiting for 0x" << std::setw(4) << address
<< " mask 0x" << std::setw(4) << mask
<< " time " << std::dec << timestamp;
return s.str();
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -69,9 +83,10 @@ void CartridgeELFStateWidget::initialize()
int y = lineHeight / 2; int y = lineHeight / 2;
new StaticTextWidget(_boss, _font, x0, y, "ARM registers:"); new StaticTextWidget(_boss, _font, x0, y, "ARM registers:");
const int indent = _font.getMaxCharWidth() * 15; const int indent = _font.getMaxCharWidth() * 17;
myArmRegisters = new DataGridWidget(_boss, _font, x0 + indent, y, 4, 4, 8, 8, Common::Base::Fmt::_16_8); myArmRegisters = new DataGridWidget(_boss, _font, x0 + indent, y, 4, 4, 8, 8, Common::Base::Fmt::_16_8);
y += myArmRegisters->getHeight() + lineHeight / 2; y += myArmRegisters->getHeight() + lineHeight / 2;
myArmRegisters->setEditable(false); myArmRegisters->setEditable(false);
@ -85,6 +100,28 @@ void CartridgeELFStateWidget::initialize()
new StaticTextWidget(_boss, _font, x0 + indent + 3 + myFlags->colWidth(), y, "Z"); new StaticTextWidget(_boss, _font, x0 + indent + 3 + myFlags->colWidth(), y, "Z");
new StaticTextWidget(_boss, _font, x0 + indent + 3 + 2 * myFlags->colWidth(), y, "C"); new StaticTextWidget(_boss, _font, x0 + indent + 3 + 2 * myFlags->colWidth(), y, "C");
new StaticTextWidget(_boss, _font, x0 + indent + 3 + 3 * myFlags->colWidth(), y, "V"); new StaticTextWidget(_boss, _font, x0 + indent + 3 + 3 * myFlags->colWidth(), y, "V");
y += (5 * lineHeight) / 2;
new StaticTextWidget(_boss, _font, x0, y + 4, "Time VCS:");
myCurrentCyclesVcs = new EditTextWidget(_boss, _font, x0 + indent, y, 16 * _font.getMaxCharWidth(), lineHeight);
myCurrentCyclesVcs->setEditable(false, true);
y += myCurrentCyclesVcs->getHeight() + lineHeight / 2;
new StaticTextWidget(_boss, _font, x0, y + 4, "Time ARM:");
myCurrentCyclesArm = new EditTextWidget(_boss, _font, x0 + indent, y, 16 * _font.getMaxCharWidth(), lineHeight);
myCurrentCyclesArm->setEditable(false, true);
y += myCurrentCyclesArm->getHeight() + lineHeight / 2;
new StaticTextWidget(_boss, _font, x0, y + 4, "Bus queue size:");
myQueueSize = new EditTextWidget(_boss, _font, x0 + indent, y, 4 * _font.getMaxCharWidth(), lineHeight);
myQueueSize->setEditable(false, true);
y += myQueueSize->getHeight() + lineHeight / 2;
myNextTransaction = new StaticTextWidget(_boss, _font, x0, y, describeTransaction(0xffff, 0xffff, ~0ll));
} }
void CartridgeELFStateWidget::loadConfig() void CartridgeELFStateWidget::loadConfig()
@ -103,4 +140,26 @@ void CartridgeELFStateWidget::loadConfig()
myFlagValues = flags; myFlagValues = flags;
myFlags->setState(flags, flagsChanged); myFlags->setState(flags, flagsChanged);
ostringstream s;
s << myCart.getVcsCyclesArm();
myCurrentCyclesVcs->setText(s.str());
s.str("");
s << myCart.getArmCycles();
myCurrentCyclesArm->setText(s.str());
s.str("");
s << myCart.myTransactionQueue.size();
myQueueSize->setText(s.str());
BusTransactionQueue::Transaction* nextTransaction = myCart.myTransactionQueue.peekNextTransaction();
myNextTransaction->setLabel(nextTransaction
? describeTransaction(
nextTransaction->address,
nextTransaction->mask,
nextTransaction->timestamp + myCart.myArmCyclesOffset
)
: ""
);
} }

View File

@ -23,6 +23,8 @@
class CartridgeELF; class CartridgeELF;
class DataGridWidget; class DataGridWidget;
class ToggleBitWidget; class ToggleBitWidget;
class EditTextWidget;
class StaticTextWidget;
class CartridgeELFStateWidget : public CartDebugWidget { class CartridgeELFStateWidget : public CartDebugWidget {
public: public:
@ -44,6 +46,11 @@ class CartridgeELFStateWidget : public CartDebugWidget {
DataGridWidget* myArmRegisters{nullptr}; DataGridWidget* myArmRegisters{nullptr};
ToggleBitWidget* myFlags{nullptr}; ToggleBitWidget* myFlags{nullptr};
EditTextWidget* myCurrentCyclesVcs{nullptr};
EditTextWidget* myCurrentCyclesArm{nullptr};
EditTextWidget* myQueueSize{nullptr};
StaticTextWidget* myNextTransaction{nullptr};
}; };
#endif // CART_ELF_INFO_WIDGET_HXX #endif // CART_ELF_INFO_WIDGET_HXX

View File

@ -434,6 +434,12 @@ inline uInt64 CartridgeELF::getArmCycles() const
return myCortexEmu.getCycles() + myArmCyclesOffset; return myCortexEmu.getCycles() + myArmCyclesOffset;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt64 CartridgeELF::getVcsCyclesArm() const
{
return mySystem->cycles() * myArmCyclesPer6502Cycle;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline uInt8 CartridgeELF::driveBus(uInt16 address, uInt8 value) inline uInt8 CartridgeELF::driveBus(uInt16 address, uInt8 value)
{ {

View File

@ -128,6 +128,7 @@ class CartridgeELF: public Cartridge {
void resetWithConfig(); void resetWithConfig();
uInt64 getArmCycles() const; uInt64 getArmCycles() const;
uInt64 getVcsCyclesArm() const;
uInt8 driveBus(uInt16 address, uInt8 value); uInt8 driveBus(uInt16 address, uInt8 value);
void syncArmTime(uInt64 armCycles); void syncArmTime(uInt64 armCycles);

View File

@ -205,6 +205,12 @@ BusTransactionQueue::Transaction* BusTransactionQueue::getNextTransaction(uInt16
return nextTransaction; return nextTransaction;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BusTransactionQueue::Transaction* BusTransactionQueue::peekNextTransaction()
{
return myQueueSize > 0 ? &myQueue[myQueueNext] : nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BusTransactionQueue::push(const Transaction& transaction) void BusTransactionQueue::push(const Transaction& transaction)
{ {

View File

@ -62,6 +62,7 @@ class BusTransactionQueue: public Serializable {
bool hasPendingTransaction() const; bool hasPendingTransaction() const;
Transaction* getNextTransaction(uInt16 address, uInt64 timestamp); Transaction* getNextTransaction(uInt16 address, uInt64 timestamp);
Transaction* peekNextTransaction();
size_t size() const { size_t size() const {
return myQueueSize; return myQueueSize;