README.erc32
1
2 1. MEC and ERC32 emulation
3
4 The file 'erc32.c' contains a model of the MEC, 512 K rom and 4 M ram.
5
6 The following paragraphs outline the implemented MEC functions.
7
8 1.1 UARTs
9
10 The UARTs are connected to two pseudo-devices, /dev/ttypc and /dev/ttypd.
11 The following registers are implemeted:
12
13 - UART A RX and TX register (0x01f800e0)
14 - UART B RX and TX register (0x01f800e4)
15 - UART status register (0x01f800e8)
16
17 To speed up simulation, the UARTs operate at approximately 115200 baud.
18 The UARTs generate interrupt 4 and 5 after each received or transmitted
19 character. The error interrupt is generated if overflow occurs - other
20 errors cannot occure.
21
22 1.2 Real-time clock and general pupose timer A
23
24 The following registers are implemeted:
25
26 - Real-time clock timer (0x01f80080, read-only)
27 - Real-time clock scaler program register (0x01f80084, write-only)
28 - Real-time clock counter program register (0x01f80080, write-only)
29
30 - Genearl pupose timer (0x01f80088, read-only)
31 - Real-time clock scaler program register (0x01f8008c, write-only)
32 - General purpose timer counter prog. register (0x01f80088, write-only)
33
34 - Timer control register (0x01f80098, write-only)
35
36 1.3 Interrupt controller
37
38 The interrupt controller is implemented as in the MEC specification with
39 the exception of the interrupt shape register. Since external interrupts
40 are not possible, the interrupt shape register is not implemented. The
41 only internal interrupts that are generated are the real-time clock,
42 the general purpose timer and UARTs. However, all 15 interrupts
43 can be tested via the interrupt force register.
44
45 The following registers are implemeted:
46
47 - Interrupt pending register (0x01f80048, read-only)
48 - Interrupt mask register (0x01f8004c, read-write)
49 - Interrupt clear register (0x01f80050, write-only)
50 - Interrupt force register (0x01f80054, read-write)
51
52 1.4 Breakpoint and watchpoint register
53
54 The breakpoint and watchpoint functions are implemented as in the MEC
55 specification. Traps are correctly generated, and the system fault status
56 register is updated accordingly. Implemeted registers are:
57
58 - Debug control register (0x01f800c0, read-write)
59 - Breakpoint register (0x01f800c4, write-only)
60 - Watchpoint register (0x01f800c8, write-only)
61 - System fault status register (0x01f800a0, read-write)
62 - First failing address register (0x01f800a4, read-write)
63
64
65 1.5 Memory interface
66
67 The following memory areas are valid for the ERC32 simulator:
68
69 0x00000000 - 0x00080000 ROM (512 Kbyte, loaded at start-up)
70 0x02000000 - 0x02400000 RAM (4 Mbyte, initialised to 0x0)
71 0x01f80000 - 0x01f800ff MEC registers
72
73 Access to unimplemented MEC registers or non-existing memory will result
74 in a memory exception trap. However, access to unimplemented MEC registers
75 in the area 0x01f80000 - 0x01f80100 will not cause a memory exception trap.
76 The written value will be stored in a register and can be read back. It
77 does however not affect the function in any way.
78
79 The memory configuartion register is used to define available memory
80 in the system. The fields RSIZ and PSIZ are used to set RAM and ROM
81 size, the remaining fields are not used. NOTE: after reset, the MEC
82 is set to decode 4 Kbyte of ROM and 256 Kbyte of RAM. The memory
83 configuration register has to be updated to reflect the available memory.
84
85 The waitstate configuration register is used to generate waitstates.
86 This register must also be updated with the correct configuration after
87 reset.
88
89 The memory protection scheme is implemented - it is enabled through bit 3
90 in the MEC control register.
91
92 The following registers are implemeted:
93
94 - MEC control register (bit 3 only) (0x01f80000, read-write)
95 - Memory control register (0x01f80010, read-write)
96 - Waitstate configuration register (0x01f80018, read-write)
97 - Memory access register 0 (0x01f80020, read-write)
98 - Memory access register 1 (0x01f80024, read-write)
99
100 1.6 Watchdog
101
102 The watchdog is implemented as in the specification. The input clock is
103 always the system clock regardsless of WDCS bit in mec configuration
104 register.
105
106 The following registers are implemeted:
107
108 - Watchdog program and acknowledge register (0x01f80060, write-only)
109 - Watchdog trap door set register (0x01f80064, write-only)
110
111 1.7 Software reset register
112
113 Implemented as in the specification (0x01f800004, write-only).
114
115 1.8 Power-down mode
116
117 The power-down register (0x01f800008) is implemented as in the specification.
118 However, if the simulator event queue is empty, power-down mode is not
119 entered since no interrupt would be generated to exit from the mode. A
120 Ctrl-C in the simulator window will exit the power-down mode.
121
122 1.9 MEC control register
123
124 The following bits are implemented in the MEC control register:
125
126 Bit Name Function
127 0 PRD Power-down mode enable
128 1 SWR Soft reset enable
129 3 APR Access protection enable
130
131
README.gdb
1 How to use SIS with GDB
2 -----------------------
3
4 1. Building GDB with SIS
5
6 To build GDB with the SIS/ERC32 simulator, configure with option
7 '--target sparc-erc32-aout' and build as usual.
8
9 2. Attaching the simulator
10
11 To attach GDB to the simulator, use:
12
13 target sim [options] [files]
14
15 The following options are supported:
16
17 -nfp Disable FPU. FPops will cause an FPU disabled trap.
18
19 -freq <f> Set the simulated "system clock" to <f> MHz.
20
21 -v Verbose mode.
22
23 -nogdb Disable GDB breakpoint handling (see below)
24
25 The listed [files] are expected to be in aout format and will be
26 loaded in the simulator memory prior. This could be used to load
27 a boot block at address 0x0 if the application is linked to run
28 from RAM (0x2000000).
29
30 To start debugging a program type 'load <program>' and debug as
31 usual.
32
33 The native simulator commands can be reached using the GDB 'sim'
34 command:
35
36 sim <sis_command>
37
38 Direct simulator commands during a GDB session must be issued
39 with care not to disturb GDB's operation ...
40
41 For info on supported ERC32 functionality, see README.sis.
42
43
44 3. Loading aout files
45
46 The GDB load command loads an aout file into the simulator
47 memory with the data section starting directly after the text
48 section regardless of which start address was specified for the data
49 at link time! This means that your applications either has to include
50 a routine that initialise the data segment at the proper address or
51 link with the data placed directly after the text section.
52
53 A copying routine is fairly simple, just copy all data between
54 _etext and _data to a memory loaction starting at _environ. This
55 should be done at the same time as the bss is cleared (in srt0.s).
56
57
58 4. GDB breakpoint handling
59
60 GDB inserts breakpoint in the form of the 'ta 1' instruction. The
61 GDB-integrated simulator will therefore recognize the breakpoint
62 instruction and return control to GDB. If the application uses
63 'ta 1', the breakpoint detection can be disabled with the -nogdb
64 switch. In this case however, GDB breakpoints will not work.
65
66
67 Report problems to Jiri Gaisler ESA/ESTEC (jgais (a] wd.estec.esa.nl)
68
README.sis
1
2 SIS - Sparc Instruction Simulator README file (v2.0, 05-02-1996)
3 -------------------------------------------------------------------
4
5 1. Introduction
6
7 The SIS is a SPARC V7 architecture simulator. It consist of two parts,
8 the simulator core and a user defined memory module. The simulator
9 core executes the instructions while the memory module emulates memory
10 and peripherals.
11
12 2. Usage
13
14 The simulator is started as follows:
15
16 sis [-uart1 uart_device1] [-uart2 uart_device2]
17 [-nfp] [-freq frequency] [-c batch_file] [files]
18
19 The default uart devices for SIS are /dev/ptypc and /dev/ptypd. The
20 -uart[1,2] switch can be used to connect the uarts to other devices.
21 Use 'tip /dev/ttypc' to connect a terminal emulator to the uarts.
22 The '-nfp' will disable the simulated FPU, so each FPU instruction will
23 generate a FPU disabled trap. The '-freq' switch can be used to define
24 which "frequency" the simulator runs at. This is used by the 'perf'
25 command to calculated the MIPS figure for a particular configuration.
26 The give frequency must be an integer indicating the frequency in MHz.
27
28 The -c option indicates that sis commands should be read from 'batch_file'
29 at startup.
30
31 Files to be loaded must be in one of the supported formats (see INSTALLATION),
32 and will be loaded into the simulated memory. The file formats are
33 automatically recognised.
34
35 The script 'startsim' will start the simulator in one xterm window and
36 open a terminal emulator (tip) connected to the UART A in a second
37 xterm window. Below is description of commands that are recognized by
38 the simulator. The command-line is parsed using GNU readline. A command
39 history of 64 commands is maintained. Use the up/down arrows to recall
40 previous commands. For more details, see the readline documentation.
41
42 batch <file>
43
44 Execute a batch file of SIS commands.
45
46 +bp <address>
47
48 Adds an breakpoint at address <address>.
49
50 bp
51
52 Prints all breakpoints
53
54 -bp <num>
55
56 Deletes breakpoint <num>. Use 'bp' to see which number is assigned to the
57 breakpoints.
58
59 cont [inst_count]
60
61 Continue execution at present position, optionally for [inst_count]
62 instructions.
63
64 dis [addr] [count]
65
66 Disassemble [count] instructions at address [addr]. Default values for
67 count is 16 and addr is the present address.
68
69 echo <string>
70
71 Print <string> to the simulator window.
72
73 float
74
75 Prints the FPU registers
76
77 go <address> [inst_count]
78
79 The go command will set pc to <address> and npc to <address> + 4, and start
80 execution. No other initialisation will be done. If inst_count is given,
81 execution will stop after the specified number of instructions.
82
83 help
84
85 Print a small help menu for the SIS commands.
86
87 hist [trace_length]
88
89 Enable the instruction trace buffer. The 'trace_length' last executed
90 instructions will be placed in the trace buffer. A 'hist' command without
91 a trace_length will display the trace buffer. Specifying a zero trace
92 length will disable the trace buffer.
93
94 load <file_name>
95
96 Loads a file into simulator memory.
97
98 mem [addr] [count]
99
100 Display memory at [addr] for [count] bytes. Same default values as above.
101
102 quit
103
104 Exits the simulator.
105
106 perf [reset]
107
108 The 'perf' command will display various execution statistics. A 'perf reset'
109 command will reset the statistics. This can be used if statistics shall
110 be calculated only over a part of the program. The 'run' and 'reset'
111 command also resets the statistic information.
112
113 reg [reg_name] [value]
114
115 Prints and sets the IU regiters. 'reg' without parameters prints the IU
116 registers. 'reg [reg_name] [value]' sets the corresponding register to
117 [value]. Valid register names are psr, tbr, wim, y, g1-g7, o0-o7 and
118 l0-l7.
119
120 reset
121
122 Performs a power-on reset. This command is equal to 'run 0'.
123
124 run [inst_count]
125
126 Resets the simulator and starts execution from address 0. If an instruction
127 count is given (inst_count), the simulator will stop after the specified
128 number of instructions. The event queue is emptied but any set breakpoints
129 remain.
130
131 step
132
133 Equal to 'trace 1'
134
135 tra [inst_count]
136
137 Starts the simulator at the present position and prints each instruction
138 it executes. If an instruction count is given (inst_count), the simulator
139 will stop after the specified number of instructions.
140
141 Typing a 'Ctrl-C' will interrupt a running simulator.
142
143 Short forms of the commands are allowed, e.g 'c' 'co' or 'con' are all
144 interpreted as 'cont'.
145
146
147 3. Simulator core
148
149 The SIS emulates the behavior of the 90C601E and 90C602E sparc IU and
150 FPU from Matra MHS. These are roughly equivalent to the Cypress C601
151 and C602. The simulator is cycle true, i.e a simulator time is
152 maintained and inremented according the IU and FPU instruction timing.
153 The parallel execution between the IU and FPU is modelled, as well as
154 stalls due to operand dependencies (FPU). The core interacts with the
155 user-defined memory modules through a number of functions. The memory
156 module must provide the following functions:
157
158 int memory_read(asi,addr,data,ws)
159 int asi;
160 unsigned int addr;
161 unsigned int *data;
162 int *ws;
163
164 int memory_write(asi,addr,data,sz,ws)
165 int asi;
166 unsigned int addr;
167 unsigned int *data;
168 int sz;
169 int *ws;
170
171 int sis_memory_read(addr, data, length)
172 unsigned int addr;
173 char *data;
174 unsigned int length;
175
176 int sis_memory_write(addr, data, length)
177 unsigned int addr;
178 char *data;
179 unsigned int length;
180
181 int init_sim()
182
183 int reset()
184
185 int error_mode(pc)
186 unsigned int pc;
187
188 memory_read() is used by the simulator to fetch instructions and
189 operands. The address space identifier (asi) and address is passed as
190 parameters. The read data should be assigned to the data pointer
191 (*data) and the number of waitstate to *ws. 'memory_read' should return
192 0 on success and 1 on failure. A failure will cause a data or
193 instruction fetch trap. memory_read() always reads one 32-bit word.
194
195 sis_memory_read() is used by the simulator to display and disassemble
196 memory contants. The function should copy 'length' bytes of the simulated
197 memory starting at 'addr' to '*data'.
198 The sis_memory_read() should return 1 on success and 0 on failure.
199 Failure should only be indicated if access to unimplemented memory is attempted.
200
201 memory_write() is used to write to memory. In addition to the asi
202 and address parameters, the size of the written data is given by 'sz'.
203 The pointer *data points to the data to be written. The 'sz' is coded
204 as follows:
205
206 sz access type
207 0 byte
208 1 halfword
209 2 word
210 3 double-word
211
212 If a double word is written, the most significant word is in data[0] and
213 the least significant in data[1].
214
215 sis_memory_write() is used by the simulator during loading of programs.
216 The function should copy 'length' bytes from *data to the simulated
217 memory starting at 'addr'. sis_memory_write() should return 1 on
218 success and 0 on failure. Failure should only be indicated if access
219 to unimplemented memory is attempted. See erc32.c for more details
220 on how to define the memory emulation functions.
221
222 The 'init_sim' is called once when the simulator is started. This function
223 should be used to perform initialisations of user defined memory or
224 peripherals that only have to be done once, such as opening files etc.
225
226 The 'reset' is called every time the simulator is reset, i.e. when a
227 'run' command is given. This function should be used to simulate a power
228 on reset of memory and peripherals.
229
230 error_mode() is called by the simulator when the IU goes into error mode,
231 typically if a trap is caused when traps are disabled. The memory module
232 can then take actions, such as issue a reset.
233
234 sys_reset() can be called by the memory module to reset the simulator. A
235 reset will empty the event queue and perform a power-on reset.
236
237 4. Events and interrupts
238
239 The simulator supports an event queue and the generation of processor
240 interrupts. The following functions are available to the user-defined
241 memory module:
242
243 event(cfunc,arg,delta)
244 void (*cfunc)(int32_t);
245 int32_t arg;
246 unsigned int delta;
247
248 set_int(level,callback,arg)
249 int32_t level;
250 void (*callback)(int32_t);
251 int32_t arg;
252
253 clear_int(level)
254 int level;
255
256 sim_stop()
257
258 The 'event' functions will schedule the execution of the function 'cfunc'
259 at time 'now + delta' clock cycles. The parameter 'arg' is passed as a
260 parameter to 'cfunc'.
261
262 The 'set_int' function set the processor interrupt 'level'. When the interrupt
263 is taken, the function 'callback' is called with the argument 'arg'. This
264 will also clear the interrupt. An interrupt can be cleared before it is
265 taken by calling 'clear_int' with the appropriate interrupt level.
266
267 The sim_stop function is called each time the simulator stops execution.
268 It can be used to flush buffered devices to get a clean state during
269 single stepping etc.
270
271 See 'erc32.c' for examples on how to use events and interrupts.
272
273 5. Memory module
274
275 The supplied memory module (erc32.c) emulates the functions of memory and
276 the MEC asic developed for the 90C601/2. It includes the following functions:
277
278 * UART A & B
279 * Real-time clock
280 * General purpose timer
281 * Interrupt controller
282 * Breakpoint register
283 * Watchpoint register
284 * 512 Kbyte ROM
285 * 4 Mbyte RAM
286
287 See README.erc32 on how the MEC functions are emulated. For a detailed MEC
288 specification, look at the ERC32 home page at URL:
289
290 http://www.estec.esa.nl/wsmwww/erc32
291
292 6. Compile and linking programs
293
294 The directory 'examples' contain some code fragments for SIS.
295 The script gccx indicates how the native sunos gcc and linker can be used
296 to produce executables for the simulator. To compile and link the provided
297 'hello.c', type 'gccx hello.c'. This will build the executable 'hello'.
298 Start the simulator by running 'startsim hello', and issue the command 'run.
299 After the program is terminated, the IU will be force to error mode through
300 a software trap and halt.
301
302 The programs are linked with a start-up file, srt0.S. This file includes
303 the traptable and window underflow/overflow trap routines.
304
305 7. IU and FPU instruction timing.
306
307 The simulator provides cycle true simulation. The following table shows
308 the emulated instruction timing for 90C601E & 90C602E:
309
310 Instructions Cycles
311
312 jmpl, rett 2
313 load 2
314 store 3
315 load double 3
316 store double 4
317 other integer ops 1
318 fabs 2
319 fadds 4
320 faddd 4
321 fcmps 4
322 fcmpd 4
323 fdivs 20
324 fdivd 35
325 fmovs 2
326 fmuls 5
327 fmuld 9
328 fnegs 2
329 fsqrts 37
330 fsqrtd 65
331 fsubs 4
332 fsubd 4
333 fdtoi 7
334 fdots 3
335 fitos 6
336 fitod 6
337 fstoi 6
338 fstod 2
339
340 The parallel operation between the IU and FPU is modelled. This means
341 that a FPU instruction will execute in parallel with other instructions as
342 long as no data or resource dependency is detected. See the 90C602E data
343 sheet for the various types of dependencies. Tracing using the 'trace'
344 command will display the current simulator time in the left column. This
345 time indicates when the instruction is fetched. If a dependency is detetected,
346 the following fetch will be delayed until the conflict is resolved.
347
348 The load dependency in the 90C601E is also modelled - if the destination
349 register of a load instruction is used by the following instruction, an
350 idle cycle is inserted.
351
352 8. FPU implementation
353
354 The simulator maps floating-point operations on the hosts floating point
355 capabilities. This means that accuracy and generation of IEEE exceptions is
356 host dependent.
357