application exit error handing

This commit is contained in:
Blaise Tine
2021-06-29 02:04:07 -04:00
parent 3a0a9edaca
commit d684a2e632
43 changed files with 89446 additions and 212932 deletions

View File

@@ -15,7 +15,7 @@ SRCS = util.cpp args.cpp mem.cpp pipeline.cpp warp.cpp core.cpp decode.cpp execu
# Debugigng
ifdef DEBUG
CXXFLAGS += $(DBG_FLAGS)
CXXFLAGS += -DDEBUG_LEVEL=3
else
CXXFLAGS += -DNDEBUG
endif

View File

@@ -91,6 +91,8 @@ void Core::clear() {
inst_in_schedule_.valid = true;
warps_[0]->setTmask(0, true);
ebreak_ = false;
}
void Core::step() {
@@ -377,4 +379,12 @@ void Core::writeToStdOut(Addr addr, Word data) {
std::cout << std::dec << "#" << tid << ": " << ss_buf.str() << std::flush;
ss_buf.str("");
}
}
void Core::trigger_ebreak() {
ebreak_ = true;
}
bool Core::check_ebreak() const {
return ebreak_;
}

View File

@@ -70,7 +70,10 @@ public:
Word dcache_read(Addr, Size);
void dcache_write(Addr, Word, Size);
void dcache_write(Addr, Word, Size);
void trigger_ebreak();
bool check_ebreak() const;
private:
@@ -101,6 +104,8 @@ private:
RAM shared_mem_;
#endif
bool ebreak_;
Pipeline inst_in_schedule_;
Pipeline inst_in_fetch_;
Pipeline inst_in_decode_;

View File

@@ -1,11 +1,13 @@
#pragma once
//#define USE_DEBUG 3
#ifndef DEBUG_LEVEL
#define DEBUG_LEVEL 3
#endif
#define DEBUG_HEADER << "DEBUG "
//#define DEBUG_HEADER << "DEBUG " << __FILE__ << ':' << std::dec << __LINE__ << ": "
#ifdef USE_DEBUG
#ifndef NDEBUG
#include <iostream>
#include <iomanip>
@@ -13,19 +15,19 @@
#define DX(x) x
#define D(lvl, x) do { \
if ((lvl) <= USE_DEBUG) { \
if ((lvl) <= DEBUG_LEVEL) { \
std::cout DEBUG_HEADER << x << std::endl; \
} \
} while(0)
#define DPH(lvl, x) do { \
if ((lvl) <= USE_DEBUG) { \
if ((lvl) <= DEBUG_LEVEL) { \
std::cout DEBUG_HEADER << x; \
} \
} while(0)
#define DPN(lvl, x) do { \
if ((lvl) <= USE_DEBUG) { \
if ((lvl) <= DEBUG_LEVEL) { \
std::cout << x; \
} \
} while(0)

View File

@@ -402,9 +402,7 @@ void Warp::execute(const Instr &instr, Pipeline *pipeline) {
case 0:
if (csr_addr < 2) {
// ECALL/EBREAK
tmask_.reset();
active_ = tmask_.any();
pipeline->stall_warp = true;
core_->trigger_ebreak();
}
break;
case 1:

View File

@@ -67,24 +67,33 @@ int main(int argc, char **argv) {
}
bool running;
int exitcode = 0;
do {
running = false;
for (auto& core : cores) {
core->step();
if (core->running())
if (core->running()) {
running = true;
}
if (core->check_ebreak()) {
exitcode = core->getIRegValue(3);
break;
}
}
} while (running);
if (riscv_test) {
bool status = (1 == cores[0]->getIRegValue(3));
if (status) {
if (1 == exitcode) {
std::cout << "Passed." << std::endl;
exitcode = 0;
} else {
std::cout << "Failed." << std::endl;
return -1;
std::cout << "Failed." << std::endl;
}
} else {
if (exitcode != 0) {
std::cout << "*** error: exitcode=" << exitcode << std::endl;
}
}
return 0;
return exitcode;
}