diff options
| author | JulianCamacho <jjulian.341@gmail.com> | 2022-11-07 17:18:40 -0600 |
|---|---|---|
| committer | JulianCamacho <jjulian.341@gmail.com> | 2022-11-07 21:52:04 -0600 |
| commit | 511a6dad9538f20f5bbdd2c87b752b4690c648ff (patch) | |
| tree | cc49cc2b9ff63014e930c633e578e3860f6d8e15 /tb/top/decode_test.cpp | |
| parent | 19c860221fb2fc129e6d2c1a41a77a8e8010f6c3 (diff) | |
Adding decode test
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 +} |
