main.cpp 1023 字节
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
  bool is_good_trap = emu->is_good_trap();
S
SKTT1Ryze 已提交
24
  int trapcode = emu->get_trapcode();
L
LinJiawei 已提交
25
  delete emu;
26 27 28

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

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

S
SKTT1Ryze 已提交
34 35
  // return !is_good_trap;
  return trapcode;
Z
Zihao Yu 已提交
36
}