README.sis 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. SIS - Sparc Instruction Simulator README file (v2.0, 05-02-1996)
  2. -------------------------------------------------------------------
  3. 1. Introduction
  4. The SIS is a SPARC V7 architecture simulator. It consist of two parts,
  5. the simulator core and a user defined memory module. The simulator
  6. core executes the instructions while the memory module emulates memory
  7. and peripherals.
  8. 2. Usage
  9. The simulator is started as follows:
  10. sis [-uart1 uart_device1] [-uart2 uart_device2]
  11. [-nfp] [-freq frequency] [-c batch_file] [files]
  12. The default uart devices for SIS are /dev/ptypc and /dev/ptypd. The
  13. -uart[1,2] switch can be used to connect the uarts to other devices.
  14. Use 'tip /dev/ttypc' to connect a terminal emulator to the uarts.
  15. The '-nfp' will disable the simulated FPU, so each FPU instruction will
  16. generate a FPU disabled trap. The '-freq' switch can be used to define
  17. which "frequency" the simulator runs at. This is used by the 'perf'
  18. command to calculated the MIPS figure for a particular configuration.
  19. The give frequency must be an integer indicating the frequency in MHz.
  20. The -c option indicates that sis commands should be read from 'batch_file'
  21. at startup.
  22. Files to be loaded must be in one of the supported formats (see INSTALLATION),
  23. and will be loaded into the simulated memory. The file formats are
  24. automatically recognised.
  25. The script 'startsim' will start the simulator in one xterm window and
  26. open a terminal emulator (tip) connected to the UART A in a second
  27. xterm window. Below is description of commands that are recognized by
  28. the simulator. The command-line is parsed using GNU readline. A command
  29. history of 64 commands is maintained. Use the up/down arrows to recall
  30. previous commands. For more details, see the readline documentation.
  31. batch <file>
  32. Execute a batch file of SIS commands.
  33. +bp <address>
  34. Adds an breakpoint at address <address>.
  35. bp
  36. Prints all breakpoints
  37. -bp <num>
  38. Deletes breakpoint <num>. Use 'bp' to see which number is assigned to the
  39. breakpoints.
  40. cont [inst_count]
  41. Continue execution at present position, optionally for [inst_count]
  42. instructions.
  43. dis [addr] [count]
  44. Disassemble [count] instructions at address [addr]. Default values for
  45. count is 16 and addr is the present address.
  46. echo <string>
  47. Print <string> to the simulator window.
  48. float
  49. Prints the FPU registers
  50. go <address> [inst_count]
  51. The go command will set pc to <address> and npc to <address> + 4, and start
  52. execution. No other initialisation will be done. If inst_count is given,
  53. execution will stop after the specified number of instructions.
  54. help
  55. Print a small help menu for the SIS commands.
  56. hist [trace_length]
  57. Enable the instruction trace buffer. The 'trace_length' last executed
  58. instructions will be placed in the trace buffer. A 'hist' command without
  59. a trace_length will display the trace buffer. Specifying a zero trace
  60. length will disable the trace buffer.
  61. load <file_name>
  62. Loads a file into simulator memory.
  63. mem [addr] [count]
  64. Display memory at [addr] for [count] bytes. Same default values as above.
  65. quit
  66. Exits the simulator.
  67. perf [reset]
  68. The 'perf' command will display various execution statistics. A 'perf reset'
  69. command will reset the statistics. This can be used if statistics shall
  70. be calculated only over a part of the program. The 'run' and 'reset'
  71. command also resets the statistic information.
  72. reg [reg_name] [value]
  73. Prints and sets the IU regiters. 'reg' without parameters prints the IU
  74. registers. 'reg [reg_name] [value]' sets the corresponding register to
  75. [value]. Valid register names are psr, tbr, wim, y, g1-g7, o0-o7 and
  76. l0-l7.
  77. reset
  78. Performs a power-on reset. This command is equal to 'run 0'.
  79. run [inst_count]
  80. Resets the simulator and starts execution from address 0. If an instruction
  81. count is given (inst_count), the simulator will stop after the specified
  82. number of instructions. The event queue is emptied but any set breakpoints
  83. remain.
  84. step
  85. Equal to 'trace 1'
  86. tra [inst_count]
  87. Starts the simulator at the present position and prints each instruction
  88. it executes. If an instruction count is given (inst_count), the simulator
  89. will stop after the specified number of instructions.
  90. Typing a 'Ctrl-C' will interrupt a running simulator.
  91. Short forms of the commands are allowed, e.g 'c' 'co' or 'con' are all
  92. interpreted as 'cont'.
  93. 3. Simulator core
  94. The SIS emulates the behavior of the 90C601E and 90C602E sparc IU and
  95. FPU from Matra MHS. These are roughly equivalent to the Cypress C601
  96. and C602. The simulator is cycle true, i.e a simulator time is
  97. maintained and inremented according the IU and FPU instruction timing.
  98. The parallel execution between the IU and FPU is modelled, as well as
  99. stalls due to operand dependencies (FPU). The core interacts with the
  100. user-defined memory modules through a number of functions. The memory
  101. module must provide the following functions:
  102. int memory_read(asi,addr,data,ws)
  103. int asi;
  104. unsigned int addr;
  105. unsigned int *data;
  106. int *ws;
  107. int memory_write(asi,addr,data,sz,ws)
  108. int asi;
  109. unsigned int addr;
  110. unsigned int *data;
  111. int sz;
  112. int *ws;
  113. int sis_memory_read(addr, data, length)
  114. unsigned int addr;
  115. char *data;
  116. unsigned int length;
  117. int sis_memory_write(addr, data, length)
  118. unsigned int addr;
  119. char *data;
  120. unsigned int length;
  121. int init_sim()
  122. int reset()
  123. int error_mode(pc)
  124. unsigned int pc;
  125. memory_read() is used by the simulator to fetch instructions and
  126. operands. The address space identifier (asi) and address is passed as
  127. parameters. The read data should be assigned to the data pointer
  128. (*data) and the number of waitstate to *ws. 'memory_read' should return
  129. 0 on success and 1 on failure. A failure will cause a data or
  130. instruction fetch trap. memory_read() always reads one 32-bit word.
  131. sis_memory_read() is used by the simulator to display and disassemble
  132. memory contants. The function should copy 'length' bytes of the simulated
  133. memory starting at 'addr' to '*data'.
  134. The sis_memory_read() should return 1 on success and 0 on failure.
  135. Failure should only be indicated if access to unimplemented memory is attempted.
  136. memory_write() is used to write to memory. In addition to the asi
  137. and address parameters, the size of the written data is given by 'sz'.
  138. The pointer *data points to the data to be written. The 'sz' is coded
  139. as follows:
  140. sz access type
  141. 0 byte
  142. 1 halfword
  143. 2 word
  144. 3 double-word
  145. If a double word is written, the most significant word is in data[0] and
  146. the least significant in data[1].
  147. sis_memory_write() is used by the simulator during loading of programs.
  148. The function should copy 'length' bytes from *data to the simulated
  149. memory starting at 'addr'. sis_memory_write() should return 1 on
  150. success and 0 on failure. Failure should only be indicated if access
  151. to unimplemented memory is attempted. See erc32.c for more details
  152. on how to define the memory emulation functions.
  153. The 'init_sim' is called once when the simulator is started. This function
  154. should be used to perform initialisations of user defined memory or
  155. peripherals that only have to be done once, such as opening files etc.
  156. The 'reset' is called every time the simulator is reset, i.e. when a
  157. 'run' command is given. This function should be used to simulate a power
  158. on reset of memory and peripherals.
  159. error_mode() is called by the simulator when the IU goes into error mode,
  160. typically if a trap is caused when traps are disabled. The memory module
  161. can then take actions, such as issue a reset.
  162. sys_reset() can be called by the memory module to reset the simulator. A
  163. reset will empty the event queue and perform a power-on reset.
  164. 4. Events and interrupts
  165. The simulator supports an event queue and the generation of processor
  166. interrupts. The following functions are available to the user-defined
  167. memory module:
  168. event(cfunc,arg,delta)
  169. void (*cfunc)();
  170. int arg;
  171. unsigned int delta;
  172. set_int(level,callback,arg)
  173. int level;
  174. void (*callback)();
  175. int arg;
  176. clear_int(level)
  177. int level;
  178. sim_stop()
  179. The 'event' functions will schedule the execution of the function 'cfunc'
  180. at time 'now + delta' clock cycles. The parameter 'arg' is passed as a
  181. parameter to 'cfunc'.
  182. The 'set_int' function set the processor interrupt 'level'. When the interrupt
  183. is taken, the function 'callback' is called with the argument 'arg'. This
  184. will also clear the interrupt. An interrupt can be cleared before it is
  185. taken by calling 'clear_int' with the appropriate interrupt level.
  186. The sim_stop function is called each time the simulator stops execution.
  187. It can be used to flush buffered devices to get a clean state during
  188. single stepping etc.
  189. See 'erc32.c' for examples on how to use events and interrupts.
  190. 5. Memory module
  191. The supplied memory module (erc32.c) emulates the functions of memory and
  192. the MEC asic developed for the 90C601/2. It includes the following functions:
  193. * UART A & B
  194. * Real-time clock
  195. * General purpose timer
  196. * Interrupt controller
  197. * Breakpoint register
  198. * Watchpoint register
  199. * 512 Kbyte ROM
  200. * 4 Mbyte RAM
  201. See README.erc32 on how the MEC functions are emulated. For a detailed MEC
  202. specification, look at the ERC32 home page at URL:
  203. http://www.estec.esa.nl/wsmwww/erc32
  204. 6. Compile and linking programs
  205. The directory 'examples' contain some code fragments for SIS.
  206. The script gccx indicates how the native sunos gcc and linker can be used
  207. to produce executables for the simulator. To compile and link the provided
  208. 'hello.c', type 'gccx hello.c'. This will build the executable 'hello'.
  209. Start the simulator by running 'startsim hello', and issue the command 'run.
  210. After the program is terminated, the IU will be force to error mode through
  211. a software trap and halt.
  212. The programs are linked with a start-up file, srt0.S. This file includes
  213. the traptable and window underflow/overflow trap routines.
  214. 7. IU and FPU instruction timing.
  215. The simulator provides cycle true simulation. The following table shows
  216. the emulated instruction timing for 90C601E & 90C602E:
  217. Instructions Cycles
  218. jmpl, rett 2
  219. load 2
  220. store 3
  221. load double 3
  222. store double 4
  223. other integer ops 1
  224. fabs 2
  225. fadds 4
  226. faddd 4
  227. fcmps 4
  228. fcmpd 4
  229. fdivs 20
  230. fdivd 35
  231. fmovs 2
  232. fmuls 5
  233. fmuld 9
  234. fnegs 2
  235. fsqrts 37
  236. fsqrtd 65
  237. fsubs 4
  238. fsubd 4
  239. fdtoi 7
  240. fdots 3
  241. fitos 6
  242. fitod 6
  243. fstoi 6
  244. fstod 2
  245. The parallel operation between the IU and FPU is modelled. This means
  246. that a FPU instruction will execute in parallel with other instructions as
  247. long as no data or resource dependency is detected. See the 90C602E data
  248. sheet for the various types of dependencies. Tracing using the 'trace'
  249. command will display the current simulator time in the left column. This
  250. time indicates when the instruction is fetched. If a dependency is detetected,
  251. the following fetch will be delayed until the conflict is resolved.
  252. The load dependency in the 90C601E is also modelled - if the destination
  253. register of a load instruction is used by the following instruction, an
  254. idle cycle is inserted.
  255. 8. FPU implementation
  256. The simulator maps floating-point operations on the hosts floating point
  257. capabilities. This means that accuracy and generation of IEEE exceptions is
  258. host dependent.