aboutsummaryrefslogtreecommitdiff
path: root/riscv/sim.h
blob: c56ad95cda772519b55cc9ef40d5de37c25f0e4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _RISCV_SIM_H
#define _RISCV_SIM_H

#include <vector>
#include <string>
#include "processor.h"

class appserver_link_t;

class sim_t
{
public:
  sim_t(int _nprocs, appserver_link_t* _applink, icsim_t* _default_icache, icsim_t* default_dcache);
  ~sim_t();
  void run(bool debug);

  void set_tohost(reg_t val);
  reg_t get_fromhost();
  void send_ipi(reg_t who);

  size_t num_cores() { return procs.size(); }

private:
  // global architected state
  reg_t tohost;
  reg_t fromhost;

  appserver_link_t* applink;

  size_t memsz;
  char* mem;
  mmu_t* mmu;
  std::vector<processor_t*> procs;

  void step_all(size_t n, size_t interleave, bool noisy);

  void interactive_quit(const std::string& cmd, const std::vector<std::string>& args);

  void interactive_run(const std::string& cmd, const std::vector<std::string>& args, bool noisy);
  void interactive_run_noisy(const std::string& cmd, const std::vector<std::string>& args);
  void interactive_run_silent(const std::string& cmd, const std::vector<std::string>& args);

  void interactive_run_proc(const std::string& cmd, const std::vector<std::string>& args, bool noisy);
  void interactive_run_proc_noisy(const std::string& cmd, const std::vector<std::string>& args);
  void interactive_run_proc_silent(const std::string& cmd, const std::vector<std::string>& args);

  void interactive_reg(const std::string& cmd, const std::vector<std::string>& args);
  void interactive_fregs(const std::string& cmd, const std::vector<std::string>& args);
  void interactive_fregd(const std::string& cmd, const std::vector<std::string>& args);
  void interactive_mem(const std::string& cmd, const std::vector<std::string>& args);
  void interactive_str(const std::string& cmd, const std::vector<std::string>& args);
  void interactive_until(const std::string& cmd, const std::vector<std::string>& args);

  reg_t get_reg(const std::vector<std::string>& args);
  reg_t get_freg(const std::vector<std::string>& args);
  reg_t get_mem(const std::vector<std::string>& args);
  reg_t get_pc(const std::vector<std::string>& args);
  reg_t get_tohost(const std::vector<std::string>& args);

  friend class appserver_link_t;
};

struct quit_sim {};

#endif