1 // C++ multiplier testbench
 2 #include <stdlib.h>
 3 #include <iostream>
 4 #include <ctime>
 5 #include "Vwallace.h"
 6 #include "verilated.h"
 7 using namespace std;
 8 
 9 int main(int argc, char **argv, char **env)
10 {
11     Verilated::commandArgs(argc,argv);
12     Vwallace *top=new Vwallace;
13     const unsigned int mdlul=256;
14     const unsigned int mrlul=256;
15     unsigned int check;
16     unsigned int i,j;
17     unsigned int flag=0;
18     for (i=0;i<mdlul;i++)
19     {
20         top->a=i;
21         for (j=0;j<mrlul;j++)
22         {
23             top->b=j;
24             check=top->a*top->b;
25             top->eval();
26             if (top->product!=check)
27             {
28                 printf("\na=%d, b=%d\n", top->a,top->b);
29                 printf("product=%d, check=%d\n",top->product,check);
30                 flag=1;
31                 break;
32             }
33         }
34     }
35     if (flag==0)
36         {printf("   All 65536 were correct using C++ tb.\n\n");}
37     delete top;
38     exit(0);
39 }