OpenCores
URL https://opencores.org/ocsvn/socgen/socgen/trunk

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [lint/] [sim_main2.cpp] - Blame information for rev 125

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 125 jt_eaton
#include "VTB.h"
2
#include "verilated.h"
3
#include "verilated_vcd_c.h"
4
 
5
 
6
int main(int argc, char **argv, char **env) {
7
  int i;
8
  int clk;
9
 
10
  int  timeout = 10000;
11
  int  period  = 50;
12
 
13
  int  timepassed = 0;
14
  char result[] ="PASSED          ";
15
  char fail[]   ="FAILED - TIMEOUT";
16
 
17
  Verilated::commandArgs(argc, argv);
18
  // init top verilog instance
19
  VTB* top = new VTB;
20
  // init trace dump
21
    Verilated::traceEverOn(true);
22
    VerilatedVcdC* tfp = new VerilatedVcdC;
23
    top->trace (tfp, 99);
24
    tfp->open ("TestBench.vcd");
25
  // initialize simulation inputs
26
    //    printf("Hello,World %i   \n",argc);
27
 
28
    if(argc == 2)
29
      {
30
        timeout = atoi(argv[1]);
31
      }
32
 
33
    if(argc == 3)
34
      {
35
        timeout = atoi(argv[1]);
36
        period  = atoi(argv[2]);
37
      }
38
 
39
 
40
 
41
 
42
    printf("Simulating timeout    %i   period  %i    \n",timeout ,period);
43
 
44
 
45
  top->clk = 0;
46
  top->START = 0;
47
  // run simulation till the end
48
  i=0;
49
  while ( !top->FINISH   )
50
      {
51
      top->START = (i > 12);
52
      // dump variables into VCD file and toggle clock
53
 
54
 
55
          {
56
          clk = 0;
57
          tfp->dump (40*i+clk);
58
          top->clk = !top->clk;
59
          top->eval ();
60
 
61
          clk = 20;
62
          tfp->dump (40*i+clk);
63
          top->clk = !top->clk;
64
          top->eval ();
65
 
66
 
67
          }
68
    if (Verilated::gotFinish())  exit(0);
69
    timepassed++;
70
    i = i++;
71
    if(timepassed > timeout)
72
      {
73
        strcpy(result,fail);
74
        break;
75
      }
76
 
77
      }
78
 
79
 
80
  printf("Finished   %i  -  %s   \n", timepassed , result);
81
   tfp->close();
82
  exit(0);
83
}
84
 
85
 
86
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.