diff options
Diffstat (limited to 'tb/top/decode_test.cpp')
| -rw-r--r-- | tb/top/decode_test.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tb/top/decode_test.cpp b/tb/top/decode_test.cpp new file mode 100644 index 0000000..3d8589a --- /dev/null +++ b/tb/top/decode_test.cpp @@ -0,0 +1,50 @@ +#include <cstdio> + +#include <verilated.h> +#include <verilated_vcd_c.h> + +#include "Vdecode_test.h" // From Verilating "top.v" + +int main(int argc, char** argv) { + Verilated::commandArgs(argc, argv); // Remember args + Verilated::traceEverOn(true); + + Vdecode_test top; + VerilatedVcdC trace; + + top.trace(&trace, 0); + trace.open("decode_test.vcd"); + + int instructions[4] = {}; + top.n = 0; + top.z = 0; + top.c = 0; + top.v = 0; + + int clk_tick = 0; + int time = 0; + + for(int i = 0; i < sizeof(instructions); ++i) + { + top.insn = instructions[i]; + top.n = 0; + top.z = 0; + top.c = 0; + top.v = 0; + + top.eval(); + trace.dump(time++); + + std::printf(" [%c%c%c%c]\n", + top.n ? 'N' : 'n', + top.z ? 'Z' : 'z', + top.c ? 'C' : 'c', + top.v ? 'V' : 'v'); + + std::printf("insn=%d, ctrl=%d", + instructions[i], top.ctrl); + } + + trace.close(); + top.final(); // Done simulating +} |
