Add relative stage label positions to Layout struct
MODIFY
external/VSRTL
external/VSRTL
-Subproject commit 59e3a1455647013ff053bb96d087a288176b5f9a
+Subproject commit f24478d8123f65bc90a5b97a14ac81a7e8a722a7

MODIFY
src/processorregistry.h
src/processorregistry.h
@@ -22,6 +22,14 @@ struct Layout {
QString name;
QString file;
bool showPortWidth;
+ /**
+ * @brief stageLabelPositions
+ * Stage labels are not a part of the VSRTL processor model, and as such are not serialized within the models
+ * layout. stageLabelPositions determines the position of stage labels as a relative distance based on the processor
+ * models' width in the VSRTL view. Should be in the range [0;1].
+ * Must contain an entry for each stage in the processor model.
+ */
+ std::vector<double> stageLabelPositions;
};
struct ProcessorDescription {
@@ -60,8 +68,8 @@ private:
desc.isa = ISAInfo<ISA::RV32IM>::instance();
desc.name = "RISC-V Single Cycle Processor";
desc.description = "A single cycle RISC-V processor";
- desc.layouts = {{"Standard", ":/layouts/RISC-V/rvss/rv_ss_standard_layout.json", false},
- {"Extended", ":/layouts/RISC-V/rvss/rv_ss_extended_layout.json", true}};
+ desc.layouts = {{"Standard", ":/layouts/RISC-V/rvss/rv_ss_standard_layout.json", false, {0.5}},
+ {"Extended", ":/layouts/RISC-V/rvss/rv_ss_extended_layout.json", true, {0.5}}};
desc.defaultRegisterVals = {{2, 0x7ffffff0}, {3, 0x10000000}};
m_descriptions[desc.id] = desc;

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -72,6 +72,11 @@ void ProcessorTab::printToLog(const QString& text) {
void ProcessorTab::loadLayout(const Layout& layout) {
if (layout.name.isEmpty() || layout.file.isEmpty())
return; // Not a valid layout
+
+ if (layout.stageLabelPositions.size() != ProcessorHandler::get()->getProcessor()->stageCount()) {
+ Q_ASSERT(false && "A stage label position must be specified for each stage");
+ }
+
// cereal expects the archive file to be present standalone on disk, and available through an ifstream. Copy the
// resource layout file temporarily, while loading the layout.
const auto& layoutResourceFilename = layout.file;
@@ -81,6 +86,14 @@ void ProcessorTab::loadLayout(const Layout& layout) {
m_vsrtlWidget->getTopLevelComponent()->loadLayoutFile(tmpLayoutFilename);
QFile::remove(tmpLayoutFilename);
m_vsrtlWidget->setShowPortWidth(layout.showPortWidth);
+
+ // Adjust stage label positions
+ const auto& parent = m_stageInstructionLabels.at(0)->parentItem();
+ for (unsigned i = 0; i < m_stageInstructionLabels.size(); i++) {
+ auto& label = m_stageInstructionLabels.at(i);
+ label->setPos(parent->boundingRect().width() * layout.stageLabelPositions.at(i),
+ label->boundingRect().height());
+ }
}
void ProcessorTab::setupSimulatorActions() {
@@ -183,19 +196,17 @@ void ProcessorTab::pause() {
void ProcessorTab::loadProcessorToWidget(const Layout& layout) {
ProcessorHandler::get()->loadProcessorToWidget(m_vsrtlWidget);
- loadLayout(layout);
// Construct stage instruction labels
auto* topLevelComponent = m_vsrtlWidget->getTopLevelComponent();
m_stageInstructionLabels.clear();
const auto& proc = ProcessorHandler::get()->getProcessor();
- for (int i = 0; i < proc->stageCount(); i++) {
+ for (unsigned i = 0; i < proc->stageCount(); i++) {
auto* stagelabel = new vsrtl::Label("-", topLevelComponent);
- stagelabel->setPos((i + 1) * (topLevelComponent->boundingRect().width() / (proc->stageCount() + 1)),
- stagelabel->boundingRect().height());
m_stageInstructionLabels[i] = stagelabel;
}
+ loadLayout(layout);
updateInstructionLabels();
}

Add relative stage label positions to Layout struct