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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [mc-vl/] [main.cpp] - Blame information for rev 331

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

Line No. Rev Author Line
1 309 hellwig
/*
2
 * main.cpp -- simulation control
3
 */
4
 
5
 
6 310 hellwig
#if VM_TRACE
7
#define VCD_NAME        "dump.vcd"
8
#endif
9
 
10
#define DURATION_NAME   "duration.dat"  /* simulation duration file name */
11
#define RST_IN_OFF      145             /* trailing edge of rst_in, in ns */
12
#define HALF_PERIOD     10              /* half of clock period, in ns */
13
 
14
 
15
#include <iostream>
16
#include <fstream>
17
using namespace std;
18
 
19 309 hellwig
#include "Veco32test.h"
20
#include "verilated.h"
21
 
22 310 hellwig
#if VM_TRACE
23
#include "verilated_vcd_c.h"
24
#endif
25 309 hellwig
 
26 310 hellwig
 
27 309 hellwig
int main(int argc, char *argv[]) {
28
  Verilated::commandArgs(argc, argv);
29
  Veco32test *top = new Veco32test;
30 310 hellwig
#if VM_TRACE
31
  Verilated::traceEverOn(true);
32
  VerilatedVcdC *tfp = new VerilatedVcdC;
33
  top->trace(tfp, 99);
34
  tfp->open(VCD_NAME);
35
#endif
36
  ifstream durationFile(DURATION_NAME);
37
  if (!durationFile.is_open()) {
38
    cout << "Error: cannot open input file '"
39
         << DURATION_NAME
40
         << "'\n";
41
    abort();
42
  }
43
  vluint64_t maxTime;
44
  durationFile >> maxTime;
45
  maxTime += RST_IN_OFF;
46
  durationFile.close();
47
  vluint64_t curTime = 0;
48
  top->clk_in = 1;
49 309 hellwig
  top->rst_in_n = 0;
50 310 hellwig
  while (curTime <= maxTime) {
51
    if (top->rst_in_n == 0 && curTime >= RST_IN_OFF) {
52 309 hellwig
      top->rst_in_n = 1;
53
    }
54
    top->eval();
55 310 hellwig
#if VM_TRACE
56
    tfp->dump(curTime);
57
#endif
58 309 hellwig
    top->clk_in = !top->clk_in;
59 310 hellwig
    curTime += HALF_PERIOD;
60 309 hellwig
  }
61
  top->final();
62 310 hellwig
#if VM_TRACE
63
  tfp->close();
64
  delete tfp;
65
#endif
66 309 hellwig
  delete top;
67
  return 0;
68
}

powered by: WebSVN 2.1.0

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