Sim_t - Gink3/riscv-isa-sim GitHub Wiki

Data structures

The files contain the following data structures (with descriptions):

  • class sim_t - "Driver" of the program that launches all the necessary things, and handles coordinating multiple processors
  • vector<processor_t*> procs - vector of pointers to all instantiated processors
  • bool histogram_enabled - Enables the PC histogram to be logged and printed by spike
  • bool debug - enables debug mode
  • bool log - enables saving to a log file
  • const size_t INTERLEAVE - Size of memory block
  • const size_t INSNS_PER_RTC_TICK - Instructions per Real Time Clock tick
  • const size_t CPU_HZ - CPU clock speed

Functions

Functions are all member functions of the sim_t class, which inherits publicly from htif_t and simif_t

sim_t()

Argument list:

  • const char* isa - string specifying the Instruction Set Architecture
  • const char* priv - string specifying the privileges
  • const char* varch - string specifying the Virtual Architecture
  • size_t _nprocs - number of processors
  • bool halted
  • bool real_time_clint
  • reg_t initrd_start
  • reg_t initrd_end
  • const char* bootargs
  • reg_t start_pc
  • std::vector<std::pair<reg_t, mem_t*>> mems
  • std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices
  • const std::vectorstd::string& args
  • const std::vector hartids
  • const debug_module_config_t &dm_config
  • const char *log_path
  • bool dtb_enabled
  • const char *dtb_file
  1. Sets debug outputs to stderr
  2. Adds all necessary devices to the bus
  3. Instantiates procs vector with processor_t objects
  4. Runs make_dtb() - Elaborate later
  5. Adds clint devices to the bus - Elaborate later
  6. Sets per core attributes
  7. Handles pmp -- Elaborate later
  8. Instantiates requested type of memory
  9. Validates number of processors.

~sim_t()

No arguments

Deallocates all processors and debug memory port.

run()

No arguments

step()

Argument list:

  • size_t n
  1. Calculates position to step to
  2. Oscillates through all processors in processor vector, and runs step function for each proc
  3. Iterates and keeps going

handle_signal()

No arguments

Redirects ^C signal to enter debug mode on first press, and exit on second.

main()

No arguments

  1. Loops infinitely until processor is done
  2. Enters interactive mode if ^C is pressed or debug mode enabled
  3. Calls step function defined above

interactive()

No arguments In interactive.cc

  1. Defines a map of function pointers to map interactive commands to necessary functions
  2. Reads in commands and calls functions until interactive is exited with "r" command
⚠️ **GitHub.com Fallback** ⚠️