summaryrefslogtreecommitdiff
path: root/nandgame/Vcomputer__main.cpp
diff options
context:
space:
mode:
authoruvok2026-01-09 19:36:55 +0100
committeruvok2026-01-10 09:54:18 +0100
commit4e0ed701b0ff4c5b986fc31310dd582c5e7ee92f (patch)
tree3be8ad94511a87605dad757305d400db0a2f77d0 /nandgame/Vcomputer__main.cpp
parentacbeaa40a1580d85c1c4404f5f668b2b3059636d (diff)
main: Write tracefile
Diffstat (limited to 'nandgame/Vcomputer__main.cpp')
-rw-r--r--nandgame/Vcomputer__main.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/nandgame/Vcomputer__main.cpp b/nandgame/Vcomputer__main.cpp
index 2bf6117..5a1b803 100644
--- a/nandgame/Vcomputer__main.cpp
+++ b/nandgame/Vcomputer__main.cpp
@@ -39,11 +39,17 @@ void draw_ui(const std::unique_ptr<Vcomputer> &topp, int &i) {
uint16_t opcode = topp->computer->PC_content_int;
PRINT_ME(1, 1, "Step: %10d", i);
- PRINT_ME(1 + NCUR_OFFSET, NCUR_X, "CLK1: %4d\tPC: @0x%04X\tINS: 0x%04X",
+ PRINT_ME(1 + NCUR_OFFSET, NCUR_X, "CLK1: %4d\tPC: @0x%04X\tINS: 0x%04X\tHLT: %d",
topp->clk_in,
// wrong
// topp->computer->clk_in,
- topp->computer->PC_addr_int, opcode);
+ topp->computer->PC_addr_int, opcode,
+ topp->halt
+ );
+
+ // keep old state
+ if (topp->halt)
+ return;
auto insline = print_decoded(opcode, true);
PRINT_ME(3 + NCUR_OFFSET, NCUR_X, "%-80s", insline.c_str());
@@ -69,6 +75,7 @@ int main(int argc, char **argv, char **) {
// Setup context, defaults, and parse command line
Verilated::debug(0);
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
+ Verilated::traceEverOn(true);
contextp->threads(1);
contextp->commandArgs(argc, argv);
@@ -115,7 +122,7 @@ int main(int argc, char **argv, char **) {
// both bits 14 and 15 need to be set
uint16_t opcode = topp->computer->PC_content_int;
- if ((opcode & 0xC000) == 0x8000)
+ if (topp->halt)
break;
// Advance time
@@ -129,6 +136,11 @@ int main(int argc, char **argv, char **) {
VL_DEBUG_IF(VL_PRINTF("+ Exiting without $finish; no events left\n"););
}
+ // for tracefile to properly show
+ for (int i = 0; i < 10; i++) {
+ contextp->timeInc(1);
+ topp->eval();
+ }
// Execute 'final' processes
topp->final();