main.cpp 963 字节
Newer Older
L
LinJiawei 已提交
1
#include "emu.h"
Z
Zihao Yu 已提交
2 3
#include <functional>

L
LinJiawei 已提交
4
static char mybuf[BUFSIZ];
Z
Zihao Yu 已提交
5 6 7 8 9 10

// junk, link for verilator
std::function<double()> get_sc_time_stamp = []() -> double { return 0; };
double sc_time_stamp() { return get_sc_time_stamp(); }

int main(int argc, const char** argv) {
11 12
  printf("Emu compiled at %s, %s\n", __DATE__, __TIME__);

L
LinJiawei 已提交
13 14
  setbuf(stderr, mybuf);

15
  auto emu = new Emulator(argc, argv);
Z
Zihao Yu 已提交
16 17

  get_sc_time_stamp = [&emu]() -> double {
L
LinJiawei 已提交
18
    return emu->get_cycles();
Z
Zihao Yu 已提交
19 20
  };

21
  auto args = emu->get_args();
Y
YikeZhou 已提交
22
  uint64_t cycles = emu->execute(args.max_cycles, args.max_instr);
L
LinJiawei 已提交
23 24
  bool is_good_trap = emu->is_good_trap();
  delete emu;
25 26 27

  extern uint32_t uptime(void);
  uint32_t ms = uptime();
Z
Zihao Yu 已提交
28

Z
Zihao Yu 已提交
29
  eprintf(ANSI_COLOR_BLUE "Seed=%d Guest cycle spent: %" PRIu64
L
LinJiawei 已提交
30
      " (this will be different from cycleCnt if emu loads a snapshot)\n" ANSI_COLOR_RESET, args.seed, cycles);
31
  eprintf(ANSI_COLOR_BLUE "Host time spent: %dms\n" ANSI_COLOR_RESET, ms);
32

L
LinJiawei 已提交
33
  return !is_good_trap;
Z
Zihao Yu 已提交
34
}