From 70ea50e60dbb9dc13835f0c7c34b0015e0513196 Mon Sep 17 00:00:00 2001 From: Olof Kindgren Date: Sun, 4 Mar 2018 21:20:29 +0100 Subject: [PATCH] Add verilator testbench --- testbench.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 testbench.cc diff --git a/testbench.cc b/testbench.cc new file mode 100644 index 0000000..81c6273 --- /dev/null +++ b/testbench.cc @@ -0,0 +1,27 @@ +#include "Vpicorv32_wrapper.h" +#include "verilated_vcd_c.h" + +int main(int argc, char **argv, char **env) +{ + Verilated::commandArgs(argc, argv); + Verilated::traceEverOn(true); + Vpicorv32_wrapper* top = new Vpicorv32_wrapper; + + VerilatedVcdC* tfp = new VerilatedVcdC; + top->trace (tfp, 99); + tfp->open ("testbench.vcd"); + top->clk = 0; + int t = 0; + while (!Verilated::gotFinish()) { + if (t > 200) + top->resetn = 1; + top->clk = !top->clk; + top->eval(); + tfp->dump (t); + t += 5; + } + tfp->close(); + delete top; + exit(0); +} +