Allow retrieving current ISA through processorhandler
Removes some verbosity
MODIFY
src/codeeditor.cpp
src/codeeditor.cpp
@@ -221,7 +221,7 @@ void CodeEditor::breakpointAreaPaintEvent(QPaintEvent* event) {
if (m_breakpointAreaEnabled) {
QTextBlock block = firstVisibleBlock();
- uint32_t address = block.blockNumber() * ProcessorHandler::get()->getProcessor()->implementsISA()->bytes();
+ uint32_t address = block.blockNumber() * ProcessorHandler::get()->currentISA()->bytes();
int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top();
int bottom = top + (int)blockBoundingRect(block).height();
@@ -236,7 +236,7 @@ void CodeEditor::breakpointAreaPaintEvent(QPaintEvent* event) {
block = block.next();
top = bottom;
bottom = top + (int)blockBoundingRect(block).height();
- address += ProcessorHandler::get()->getProcessor()->implementsISA()->bytes();
+ address += ProcessorHandler::get()->currentISA()->bytes();
}
}
}
@@ -278,7 +278,7 @@ void CodeEditor::breakpointClick(QMouseEvent* event, int forceState) {
// Toggle breakpoint
const uint32_t address =
- block.blockNumber() * ProcessorHandler::get()->getProcessor()->implementsISA()->bytes();
+ block.blockNumber() * ProcessorHandler::get()->currentISA()->bytes();
ProcessorHandler::get()->toggleBreakpoint(address);
repaint();
}

MODIFY
src/loaddialog.cpp
src/loaddialog.cpp
@@ -44,6 +44,7 @@ LoadDialog::LoadDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::LoadDial
connect(m_ui->binaryEntryPoint, &QLineEdit::textChanged, [=] { this->validateCurrentFile(); });
// ELF page
+ m_ui->currentISA->setText(ProcessorHandler::get()->currentISA()->name());
// default selection
m_ui->assemblyRadioButton->toggle();
@@ -99,6 +100,7 @@ void LoadDialog::paletteValidate(QWidget* w, bool valid) {
bool LoadDialog::validateAssemblyFile(const QFile& file) {
return true;
}
+
bool LoadDialog::validateBinaryFile(const QFile& file) {
bool loadAtValid, entryPointValid;
m_ui->binaryLoadAt->text().toUInt(&loadAtValid, 16);
@@ -109,6 +111,7 @@ bool LoadDialog::validateBinaryFile(const QFile& file) {
return loadAtValid && entryPointValid;
}
+
bool LoadDialog::validateELFFile(const QFile& file) {
return true;
}

MODIFY
src/mainwindow.cpp
src/mainwindow.cpp
@@ -141,34 +141,15 @@ MainWindow::~MainWindow() {
}
void MainWindow::setupExamplesMenu(QMenu* parent) {
- auto binaryExamples = QDir(":/examples/binary/").entryList(QDir::Files);
- auto assemblyExamples = QDir(":/examples/assembly/").entryList(QDir::Files);
-
- // Load examples
- if (!binaryExamples.isEmpty()) {
- auto* binaryExampleMenu = new QMenu();
- binaryExampleMenu->setTitle("Binary");
- for (const auto& fileName : binaryExamples) {
- binaryExampleMenu->addAction(fileName, [=] {
- this->loadBinaryFile(QString(":/examples/binary/") + fileName);
- m_currentFile = QString();
- });
- }
- // Add binary example menu to example menu
- parent->addMenu(binaryExampleMenu);
- }
+ const auto assemblyExamples = QDir(":/examples/assembly/").entryList(QDir::Files);
if (!assemblyExamples.isEmpty()) {
- auto* assemblyExampleMenu = new QMenu();
- assemblyExampleMenu->setTitle("Assembly");
for (const auto& fileName : assemblyExamples) {
- assemblyExampleMenu->addAction(fileName, [=] {
+ parent->addAction(fileName, [=] {
this->loadAssemblyFile(QString(":/examples/assembly/") + fileName);
m_currentFile = QString();
});
}
- // Add binary example menu to example menu
- parent->addMenu(assemblyExampleMenu);
}
}

MODIFY
src/memorymodel.cpp
src/memorymodel.cpp
@@ -9,7 +9,7 @@ MemoryModel::MemoryModel(QObject* parent) : QAbstractTableModel(parent) {}
int MemoryModel::columnCount(const QModelIndex&) const {
return 1 /* address column */ +
- ProcessorHandler::get()->getProcessor()->implementsISA()->bytes() /* byte columns */;
+ ProcessorHandler::get()->currentISA()->bytes() /* byte columns */;
}
int MemoryModel::rowCount(const QModelIndex&) const {
@@ -23,13 +23,13 @@ void MemoryModel::processorWasClocked() {
}
void MemoryModel::setCentralAddress(uint32_t address) {
- address = address - (address % ProcessorHandler::get()->getProcessor()->implementsISA()->bytes());
+ address = address - (address % ProcessorHandler::get()->currentISA()->bytes());
m_centralAddress = address;
processorWasClocked();
}
void MemoryModel::offsetCentralAddress(int rowOffset) {
- const int byteOffset = rowOffset * ProcessorHandler::get()->getProcessor()->implementsISA()->bytes();
+ const int byteOffset = rowOffset * ProcessorHandler::get()->currentISA()->bytes();
const long long newCenterAddress = static_cast<long long>(m_centralAddress) + byteOffset;
m_centralAddress = newCenterAddress < 0 ? m_centralAddress : newCenterAddress;
processorWasClocked();
@@ -59,7 +59,7 @@ QVariant MemoryModel::data(const QModelIndex& index, int role) const {
if (role == Qt::TextAlignmentRole)
return Qt::AlignCenter;
- const auto bytes = ProcessorHandler::get()->getProcessor()->implementsISA()->bytes();
+ const auto bytes = ProcessorHandler::get()->currentISA()->bytes();
const long long alignedAddress = static_cast<long long>(m_centralAddress) +
((((m_rowsVisible * bytes) / 2) / bytes) * bytes) - (index.row() * bytes);
const unsigned byteOffset = index.column() - 1;

MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -25,6 +25,7 @@ public:
const vsrtl::core::RipesProcessor* getProcessor() { return m_currentProcessor.get(); }
const ProcessorSetup& getSetup() const { return m_currentSetup; }
+ const ISAInfoBase* currentISA() const { return m_currentProcessor->implementsISA(); }
/**
* @brief loadProcessorToWidget

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -240,7 +240,7 @@ void ProcessorTab::reset() {
}
void ProcessorTab::setInstructionViewCenterAddr(uint32_t address) {
- const auto index = address / ProcessorHandler::get()->getProcessor()->implementsISA()->bytes();
+ const auto index = address / ProcessorHandler::get()->currentISA()->bytes();
const auto view = m_ui->instructionView;
const auto rect = view->rect();
int indexTop = view->indexAt(rect.topLeft()).row();

MODIFY
src/registermodel.cpp
src/registermodel.cpp
@@ -23,7 +23,7 @@ int RegisterModel::columnCount(const QModelIndex&) const {
}
int RegisterModel::rowCount(const QModelIndex&) const {
- return ProcessorHandler::get()->getProcessor()->implementsISA()->regCnt();
+ return ProcessorHandler::get()->currentISA()->regCnt();
}
void RegisterModel::processorWasClocked() {
@@ -116,15 +116,15 @@ void RegisterModel::setRadix(Ripes::Radix r) {
}
QVariant RegisterModel::nameData(unsigned idx) const {
- return ProcessorHandler::get()->getProcessor()->implementsISA()->regName(idx);
+ return ProcessorHandler::get()->currentISA()->regName(idx);
}
QVariant RegisterModel::aliasData(unsigned idx) const {
- return ProcessorHandler::get()->getProcessor()->implementsISA()->regAlias(idx);
+ return ProcessorHandler::get()->currentISA()->regAlias(idx);
}
QVariant RegisterModel::tooltipData(unsigned idx) const {
- return ProcessorHandler::get()->getProcessor()->implementsISA()->regInfo(idx);
+ return ProcessorHandler::get()->currentISA()->regInfo(idx);
}
QVariant RegisterModel::valueData(unsigned idx) const {
@@ -132,7 +132,7 @@ QVariant RegisterModel::valueData(unsigned idx) const {
}
Qt::ItemFlags RegisterModel::flags(const QModelIndex& index) const {
- const auto def = ProcessorHandler::get()->getProcessor()->implementsISA()->regIsReadOnly(index.row())
+ const auto def = ProcessorHandler::get()->currentISA()->regIsReadOnly(index.row())
? Qt::NoItemFlags
: Qt::ItemIsEnabled;
if (index.column() == Column::Value)

MODIFY
src/stagetablemodel.cpp
src/stagetablemodel.cpp
@@ -16,13 +16,13 @@ QVariant StageTableModel::headerData(int section, Qt::Orientation orientation, i
return QString::number(section);
} else {
return ProcessorHandler::get()->parseInstrAt(section *
- ProcessorHandler::get()->getProcessor()->implementsISA()->bytes());
+ ProcessorHandler::get()->currentISA()->bytes());
}
}
int StageTableModel::rowCount(const QModelIndex&) const {
return ProcessorHandler::get()->getCurrentProgramSize() /
- ProcessorHandler::get()->getProcessor()->implementsISA()->bytes();
+ ProcessorHandler::get()->currentISA()->bytes();
}
int StageTableModel::columnCount(const QModelIndex&) const {
@@ -63,7 +63,7 @@ QVariant StageTableModel::data(const QModelIndex& index, int role) const {
if (!m_cycleStageInfos.count(index.column()))
return QVariant();
- const uint32_t addr = index.row() * ProcessorHandler::get()->getProcessor()->implementsISA()->bytes();
+ const uint32_t addr = index.row() * ProcessorHandler::get()->currentISA()->bytes();
const auto& stageInfo = m_cycleStageInfos.at(index.column());
for (const auto& si : stageInfo) {
if (si.second.pc == addr && si.second.pc_valid) {

Allow retrieving current ISA through processorhandler

Removes some verbosity