Start finishing counter when encountering ECALL 10 outside of ECALL handling
this fixes an issue where, when running, ecall 10 would gave recursive behaviour in some cases.
MODIFY
src/pipeline.cpp
src/pipeline.cpp
@@ -767,11 +767,6 @@ void Pipeline::handleEcall() {
if(m_ecallArg == ECALL::exit){
m_finishing = true;
}
-
- // Start finishing counter
- if (m_finishing) {
- m_finishingCnt++;
- }
}
}
@@ -825,6 +820,9 @@ int Pipeline::step() {
// Check for finished execution(either end of file or m_finishingCnt > 4 (if ecall 10 has been called)) and
// breakpoints
+ if (m_finishing) {
+ m_finishingCnt++;
+ }
if ((m_pcs.WB.pc > m_textSize) || (m_finishingCnt > 4)) {
m_finished = true;
return 1;

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -34,9 +34,12 @@ ProcessorTab::ProcessorTab(QWidget* parent) : QWidget(parent), m_ui(new Ui::Proc
connect(this, &ProcessorTab::update, m_ui->pipelineWidget, &PipelineWidget::update);
- // Connect ECALL functionality to application output log
+ // Connect ECALL functionality to application output log and scroll to bottom
connect(this, &ProcessorTab::appendToLog,
- [this](QString string) { m_ui->console->insertPlainText(string); });
+ [this](QString string) { m_ui->console->insertPlainText(string);
+ m_ui->console->verticalScrollBar()->setValue(
+ m_ui->console->verticalScrollBar()->maximum());});
+
// Setup splitter such that consoles are always as small as possible
m_ui->pipelinesplitter->setStretchFactor(0, 2);
@@ -128,16 +131,20 @@ void ProcessorTab::on_run_clicked() {
m_ui->step->setEnabled(false);
m_ui->start->setEnabled(false);
m_ui->run->setEnabled(false);
- } else if (pipeline->checkEcall(true).first != Pipeline::ECALL::none) {
+ } else {
+ const auto ecall_val = pipeline->checkEcall(true);
+ if (ecall_val.first != Pipeline::ECALL::none) {
// An ECALL has been invoked during continuous running. Handle ecall and continue to run
- handleEcall();
+ if(handleEcall(ecall_val)){
on_run_clicked();
+ }
} else {
m_ui->table->setEnabled(true);
emit update();
}
}
}
+}
void ProcessorTab::on_reset_clicked() {
Pipeline::getPipeline()->restart();
@@ -147,6 +154,7 @@ void ProcessorTab::on_reset_clicked() {
m_ui->start->setEnabled(true);
m_ui->run->setEnabled(true);
m_ui->table->setEnabled(true);
+ emit appendToLog("\n");
}
void ProcessorTab::setCurrentInstruction(int row) {
@@ -169,8 +177,10 @@ void ProcessorTab::on_step_clicked() {
auto pipeline = Pipeline::getPipeline();
auto state = pipeline->step();
-
- handleEcall();
+ const auto ecallVal = pipeline->checkEcall(true);
+ if(ecallVal.first != Pipeline::ECALL::none){
+ handleEcall(ecallVal);
+ }
emit update();
@@ -185,10 +195,8 @@ void ProcessorTab::on_step_clicked() {
}
}
-void ProcessorTab::handleEcall() {
+bool ProcessorTab::handleEcall(const std::pair<Pipeline::ECALL, int32_t>& ecall_val) {
// Check if ecall has been invoked
- auto pipeline = Pipeline::getPipeline();
- auto ecall_val = pipeline->checkEcall();
if (ecall_val.first != Pipeline::ECALL::none) {
switch (ecall_val.first) {
case Pipeline::ECALL::print_string: {
@@ -198,12 +206,15 @@ void ProcessorTab::handleEcall() {
emit appendToLog(QString::number(ecall_val.second));
break;
}
- default:
- return;
+ case Pipeline::ECALL::exit: {
+ return true;// The simulator will now take a few cycles to stop
}
}
}
+ return true; // continue
+}
+
void ProcessorTab::on_zoomIn_clicked() {
m_ui->pipelineWidget->zoomIn();
}

MODIFY
src/processortab.h
src/processortab.h
@@ -44,7 +44,7 @@ private slots:
void on_table_clicked();
private:
- void handleEcall();
+ bool handleEcall(const std::pair<Pipeline::ECALL, int32_t>& ecallValue);
Ui::ProcessorTab* m_ui;
InstructionModel* m_instrModel;

Start finishing counter when encountering ECALL 10 outside of ECALL handling

this fixes an issue where, when running, ecall 10 would gave recursive behaviour in some cases.