summaryrefslogtreecommitdiff
path: root/eater_cpu/cpp
diff options
context:
space:
mode:
authoruvok2026-01-19 20:16:34 +0100
committeruvok2026-01-19 20:16:34 +0100
commitda54b3b6d3db776eb57ca502822558577e6c4c4e (patch)
treef0b9263d3a9b2ee8e74e6c3451fc77c2ab87095a /eater_cpu/cpp
parent1f0fc1edcea04e5c1f04803f0bdda337c2245f09 (diff)
Add halt state and flag
Diffstat (limited to 'eater_cpu/cpp')
-rw-r--r--eater_cpu/cpp/Veater_computer__main.cpp7
-rw-r--r--eater_cpu/cpp/simpc_term.cpp4
2 files changed, 7 insertions, 4 deletions
diff --git a/eater_cpu/cpp/Veater_computer__main.cpp b/eater_cpu/cpp/Veater_computer__main.cpp
index 315d52a..7afa4d0 100644
--- a/eater_cpu/cpp/Veater_computer__main.cpp
+++ b/eater_cpu/cpp/Veater_computer__main.cpp
@@ -20,6 +20,8 @@ void load_program(const std::unique_ptr<Veater_computer> &topp) {
topp->eater_computer->RAM->r_datastore[1] = 0x1f;
// OUT
topp->eater_computer->RAM->r_datastore[2] = 0xe0;
+ // HALT
+ topp->eater_computer->RAM->r_datastore[3] = 0xf0;
// Data @ 14
topp->eater_computer->RAM->r_datastore[14] = 14;
// Data @ 15
@@ -53,7 +55,8 @@ int main(int argc, char **argv, char **) {
// Simulate until $finish
while (VL_LIKELY(!contextp->gotFinish()) &&
- VL_LIKELY(contextp->time() < 100)) {
+ VL_LIKELY(contextp->time() < 100) &&
+ VL_LIKELY(!(topp->eater_computer->flags.__PVT__halt))) {
// Evaluate model
topp->eval();
@@ -65,7 +68,7 @@ int main(int argc, char **argv, char **) {
topp->clk_in = !topp->clk_in;
- if (topp->eater_computer->PC_out == 4 &&
+ if (topp->eater_computer->PC_out == 6 &&
topp->eater_computer->decoder__DOT__internal_state == 0x01)
break;
}
diff --git a/eater_cpu/cpp/simpc_term.cpp b/eater_cpu/cpp/simpc_term.cpp
index 540cc98..a2144b2 100644
--- a/eater_cpu/cpp/simpc_term.cpp
+++ b/eater_cpu/cpp/simpc_term.cpp
@@ -42,7 +42,7 @@ void simpc_ui_write(const std::unique_ptr<Veater_computer> &topp, uint64_t i) {
// uint16_t opcode = topp->eater_computer->;
uint8_t opcode = topp->eater_computer->INS->r_datastore;
// topp->halt
- uint8_t halt = 0;
+ uint8_t halt = topp->eater_computer->flags.__PVT__halt;
PRINT_ME_W(status_top, 0, 0, "Step: %10lu", i);
PRINT_ME_W(status_top, 1, 0, "%-20s", paused ? "Paused" : "Running");
@@ -100,7 +100,7 @@ void simpc_ui_finish_message(const std::unique_ptr<VerilatedContext> &contextp,
PRINT_ME_W(status_top, 0, xpos, "Simulation finished.");
const char *msg;
// topp->halt
- bool halt = false;
+ bool halt = topp->eater_computer->flags.__PVT__halt;
if (halt) {
msg = "Halt encountered.";
} else if (!contextp->gotFinish()) {