From 0e422ec41b33216b12d8a98612d1b4b3cd84b3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Stensg=C3=A5rd?= Date: Fri, 2 May 2025 20:09:27 +0200 Subject: verilator_mul: multiply 32 bit integers, 38 MHz on pu --- verilator_mul/sim_main.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 verilator_mul/sim_main.cc (limited to 'verilator_mul/sim_main.cc') diff --git a/verilator_mul/sim_main.cc b/verilator_mul/sim_main.cc new file mode 100644 index 0000000..b525e00 --- /dev/null +++ b/verilator_mul/sim_main.cc @@ -0,0 +1,36 @@ +#include +#include + +#include "Vmul.h" +#include "verilated.h" + +enum { MAX = 10000 }; + +int +main(int argc, char **argv) +{ + VerilatedContext *cp = new VerilatedContext; + cp->commandArgs(argc, argv); + + Vmul *top = new Vmul{cp}; + top->clk = 0; + + int numclks = 0; + for (int x = 0; x < MAX; ++x) { + for (int y = 0; y < MAX; ++y) { + top->x = x; + top->y = y; + top->clk = 1; + top->eval(); + + int p = top->p; + if (p != (uint32_t)(x * y)) + printf("%4d * %4d = %4d\n", x, y, p); + + top->clk = 0; + top->eval(); + ++numclks; + } + } + fprintf(stderr, "%d clock cycles\n", numclks); +} -- cgit v1.2.3