diff options
| author | Evan Lojewski <github@meklort.com> | 2019-02-23 10:45:10 -0700 |
|---|---|---|
| committer | Evan Lojewski <github@meklort.com> | 2019-02-23 10:45:10 -0700 |
| commit | b0b46dff2659126d962654a0e799cc0cdb65f3de (patch) | |
| tree | 23713fd220ddbcb9fb6a811ccfc2a405f96649d6 /simulator/include | |
| parent | 8ff0fd9d2b6ea0f7bdf0f65ac1deb90fec425007 (diff) | |
| download | bcm5719-ortega-b0b46dff2659126d962654a0e799cc0cdb65f3de.tar.gz bcm5719-ortega-b0b46dff2659126d962654a0e799cc0cdb65f3de.zip | |
Add some initial support for pretty-printing registers.
Diffstat (limited to 'simulator/include')
| -rw-r--r-- | simulator/include/CXXRegister.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/simulator/include/CXXRegister.h b/simulator/include/CXXRegister.h index 9428639..aac4937 100644 --- a/simulator/include/CXXRegister.h +++ b/simulator/include/CXXRegister.h @@ -47,6 +47,7 @@ #include <vector> #include <utility> #include <stdio.h> +#include <iostream> class CXXRegisterBase { @@ -72,10 +73,37 @@ public: } + void setName(const char* name) + { + mName = name; + } + + const char* getName(void) + { + return mName; + } + + void print(unsigned int value) + { + unsigned int masked = value & mMask; + std::cout << mName << ": " << std::hex << (masked >> mBitPosition) << std::endl; + } + + void printAll(unsigned int value) + { + std::vector<CXXRegisterBase*>::iterator it; + for(it = mRelatedRegisters.begin(); it != mRelatedRegisters.end(); it++) + { + (*it)->print(value); + } + } + + protected: unsigned int mBitPosition; unsigned int mBitWidth; unsigned int mMask; + const char* mName; std::vector<CXXRegisterBase*> mRelatedRegisters; @@ -163,7 +191,6 @@ protected: doReadCallbacks(); } } - }; template<typename T, unsigned int OFFSET, unsigned int WIDTH> class CXXRegister : public CXXRegisterBase @@ -278,6 +305,13 @@ public: } + void print(void) + { + T value = doRead(); + CXXRegisterBase::print(value); + CXXRegisterBase::printAll(value); + } + T getValue() { return mValue; |

