/**************************************************************************************************
 * Apache License, Version 2.0
 * Copyright (c) 2024 chciken/Niko
 * Compile with: g++ -O3 -I${SYSTEMC_PATH}/include/ -L${SYSTEMC_PATH}/lib-linux64 \
                 -DSC_DISABLE_API_VERSION_CHECK -lsystemc simple_bm.cpp -o simple_bm.exe
 **************************************************************************************************/

#include <chrono>
#include <iostream>

#include "systemc.h"

struct Cpu : public sc_module {
  SC_HAS_PROCESS(Cpu);

  void thread() {
    while (true) {
      // Do stuff...
      wait(1, SC_NS);
    }
  }

  Cpu(sc_module_name name) : sc_module(name) {
    SC_THREAD(thread);
  }
};


struct Soc : public sc_module {
  SC_HAS_PROCESS(Soc);
  Cpu cpu0, cpu1;

  Soc(sc_module_name name) : sc_module(name), cpu0("cpu0"), cpu1("cpu1") {
  }
};

constexpr double kSimulationTime = 10000000;

int sc_main(int argc, char* argv[]) {
  Soc soc("soc");
  auto begin = std::chrono::steady_clock::now();
  sc_start(kSimulationTime, SC_NS);
  auto end = std::chrono::steady_clock::now();
  auto time_us = std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count();
    std::cout << "Time (sec) = " << time_us / 1000000.0 << std::endl
              << "MIPS = " << (kSimulationTime * 2) / time_us << std::endl;
  return 0;
}
