int VTADPISim()

in hardware/dpi/tsim_device.cc [102:179]


int VTADPISim() {
  uint64_t trace_count = 0;
  Verilated::flushCall();
  Verilated::gotFinish(false);

#if VM_TRACE
  uint64_t start = 0;
#endif

  VL_TSIM_NAME* top = new VL_TSIM_NAME;

#if VM_TRACE
  Verilated::traceEverOn(true);
#ifdef VM_TRACE_FST
  VerilatedFstC* tfp = new VerilatedFstC;
#else
  VerilatedVcdC* tfp = new VerilatedVcdC;
#endif // VM_TRACE_FST
  top->trace(tfp, 99);
  tfp->open(STRINGIZE_VALUE_OF(TSIM_TRACE_FILE));
#endif

  // reset
  for (int i = 0; i < 10; i++) {
    top->reset = 1;
    top->clock = 0;
    top->eval();
#if VM_TRACE
    if (trace_count >= start)
      tfp->dump(static_cast<vluint64_t>(trace_count * 2));
#endif
    top->clock = 1;
    top->eval();
#if VM_TRACE
    if (trace_count >= start)
      tfp->dump(static_cast<vluint64_t>(trace_count * 2 + 1));
#endif
    trace_count++;
  }
  top->reset = 0;

  // start simulation
  while (!Verilated::gotFinish()) {
    top->sim_clock = 0;
    top->clock = 0;
    top->eval();
#if VM_TRACE
    if (trace_count >= start)
      tfp->dump(static_cast<vluint64_t>(trace_count * 2));
#endif
    top->sim_clock = 1;
    top->clock = 1;
    top->eval();
#if VM_TRACE
    if (trace_count >= start)
      tfp->dump(static_cast<vluint64_t>(trace_count * 2 + 1));
#endif
    trace_count++;
    if ((trace_count % 1000000) == 1)
      fprintf(stderr, "[traced %luM cycles]\n", trace_count / 1000000);
    while (top->sim_wait) {
      top->clock = 0;
      std::this_thread::sleep_for(std::chrono::milliseconds(100));
      top->sim_clock = 0;
      top->eval();
      top->sim_clock = 1;
      top->eval();
    }
  }

#if VM_TRACE
  tfp->close();
#endif

  delete top;

  return 0;
}