OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [doc/] [or1ksim.texi] - Blame information for rev 442

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jeremybenn
\input texinfo   @c -*- texinfo -*-
2
@setfilename or1ksim.info
3
@afourpaper
4
@include version.texi
5
@include config.texi
6
@dircategory Embedded development
7
@direntry
8 442 julius
* Or1ksim: (or32-elf-or1ksim).  The OpenRISC 1000 Architectural
9 19 jeremybenn
                                        Simulator
10
@end direntry
11
 
12
@copying
13
This file documents the OpenRISC Architectural Simulator, @value{OR1KSIM}.
14
 
15
Copyright @copyright{} 2008, 2009 Embecosm Limited.
16
 
17
@quotation
18
Permission is granted to copy, distribute and/or modify this document
19
under the terms of the GNU Free Documentation License, Version 1.2 or
20
any later version published by the Free Software Foundation; with no
21
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
22
Texts.  A copy of the license is included in the section entitled ``GNU
23
Free Documentation License''.
24
@end quotation
25
@end copying
26
 
27
@setchapternewpage on
28
@settitle @value{OR1KSIM} User Guide
29
 
30
@syncodeindex fn cp
31
@syncodeindex vr cp
32
 
33
@titlepage
34
@title @value{OR1KSIM} User Guide
35
@author Jeremy Bennett
36
@author Embecosm Limited
37
@author Issue 1 for @value{OR1KSIM} @value{VERSION}
38
 
39
@page
40
@vskip 0pt plus 1filll
41
@insertcopying
42
 
43
Published by Embecosm Limited
44
@end titlepage
45
 
46
@contents
47
 
48
@node Top
49
@c Perhaps this should be the title of the document (but only for info,
50
@c not for TeX).  Existing GNU manuals seem inconsistent on this point.
51
@top Scope of this Document
52
 
53
This document is the user guide for @value{OR1KSIM}, the OpenRISC 1000
54
Architectural Simulator.
55
 
56
@menu
57
* Installation::
58
* Usage::
59
* Configuration::
60
* Interactive Command Line::
61
* Verification API::
62
 
63
* Code Internals::
64
 
65
* GNU Free Documentation License::  The license for this documentation
66
* Index::
67
@end menu
68
 
69
@node Installation
70
@chapter Installation
71
@cindex installing @value{OR1KSIM}
72
 
73
Installation follows standard GNU protocols.
74
 
75
@menu
76
* Preparation::
77
* Configuring the Build::
78
* Build and Install::
79
* Known Issues::
80
@end menu
81
 
82
@node Preparation
83
@section Preparation
84
 
85
Unpack the software and create a @emph{separate} directory in which to
86
build it:
87
 
88
@example
89 440 jeremybenn
tar jxf or1ksim-@value{VERSION}.tar.bz2
90
mkdir builddir_or1ksim
91
cd builddir_or1ksim
92 19 jeremybenn
@end example
93
 
94
@node Configuring the Build
95
@section Configuring the Build
96
 
97
Configure the software using the @command{configure} script in the
98
main directory.
99
 
100
The most significant argument is @code{--target}, which should specify
101 82 jeremybenn
the OpenRISC 1000 32-bit architecture.  If this argument is omitted, it will
102 19 jeremybenn
default to OpenRISC 1000 32-bit with a warning
103
 
104
@example
105 442 julius
../or1ksim-@value{VERSION}/configure --target=or32-elf ...
106 19 jeremybenn
@end example
107
 
108
There are several other options available, many of which are standard
109 82 jeremybenn
to GNU @command{configure} scripts.  Use @kbd{configure --help} to see
110
all the options.  The most useful is @code{--prefix} to specify a
111 19 jeremybenn
directory for installation of the tools.
112
 
113 104 jeremybenn
For testing (using @command{make check}), the @code{--target} parameter
114 385 jeremybenn
may be specified, to allow the target tool chain to be selected.  If not
115
specified, it will default to @code{or32-elf}, which is the same prefix
116
used with the standard OpenRISC toolchain installation script.
117 19 jeremybenn
 
118 104 jeremybenn
A number of @value{OR1KSIM} specific features in the simulator do
119
require enabling at configuration.  These include
120
 
121 19 jeremybenn
@table @code
122
@item --enable-profiling
123
@cindex @code{--enable-profiling}
124
@itemx --disable-profiling
125
@cindex @code{--disable-profiling}
126
If enabled, @value{OR1KSIM} is compiled for profiling with
127 82 jeremybenn
@command{gprof}.  This is disabled by default.  Only really of value for
128 19 jeremybenn
developers of @value{OR1KSIM}.
129
 
130
@item --enable-execution=simple
131
@itemx --enable-execution=complex
132
@itemx --enable-execution=dynamic
133
@cindex @code{--enable-execution}
134
@cindex simple model
135
@cindex complex model
136
@cindex dynamic model
137
@value{OR1KSIM} has developed to improve functionality and
138 82 jeremybenn
performance.  This feature allows three versions of @value{OR1KSIM} to be built
139 19 jeremybenn
 
140
@table @code
141
 
142
@item --enable-execution=simple
143
Build the original simple interpreting simulator
144
 
145
@item --enable-execution=complex
146 82 jeremybenn
Build a more complex interpreting simulator.  Experiments suggest this
147
is 50% faster than the simple simulator.  This is the default.
148 19 jeremybenn
 
149
@item --enable-execution=dynamic
150 82 jeremybenn
Build a dynamically compiling simulator.  This is the way many modern ISS are
151
built.  This represents a work in progress.  Currently @value{OR1KSIM} will
152 19 jeremybenn
compile, but segfaults if configured with this option.
153
 
154
@end table
155
 
156
The default is @code{--enable-execution=complex}.
157
 
158
@item --enable-ethphy
159
@cindex @code{--enable-ethphy}
160
@itemx --disable-ethphy
161
@cindex @code{--disable-ethphy}
162
@cindex Ethernet via socket, enabling
163
@cindex enabling Ethernet via socket
164
If enabled, this option allows the Ethernet to be simulated by connecting via a
165 82 jeremybenn
socket (the alternative reads and writes, from and to files).  This
166 19 jeremybenn
must then be configured using the relevant fields in the
167 82 jeremybenn
@code{ethernet} section of the configuration file.  @xref{Ethernet
168 19 jeremybenn
Configuration, , Ethernet Configuration}.
169
 
170
The default is for this to be disabled.
171
 
172 127 jeremybenn
@item --enable-unsigned-xori
173
@cindex @code{--enable-unsigned-xori}
174
@itemx --disable-unsigned-xori
175
@cindex @code{--disable-unsigned-xori}
176
@cindex exclusive-OR immediate operand
177 346 jeremybenn
Historically, @code{l.xori}, has sign extended its operand.  This is
178 127 jeremybenn
inconsistent with the other logical opcodes (@code{l.andi},
179
@code{l.ori}), but in the absence of @code{l.not}, it allows a register
180
to be inverted in a single instruction using:
181
 
182
@example
183
@code{l.xori  rD,rA,-1}
184
@end example
185
 
186 440 jeremybenn
This flag causes @value{OR1KSIM} to treat the immediate operand as unsigned (i.e
187 127 jeremybenn
to zero-extend rather than sign-extend).
188
 
189
The default is to sign-extend, so that existing code will continue to
190
work.
191
 
192
@quotation Caution
193
The GNU compiler tool chain makes heavy use of this instruction.  Using
194
unsigned behavior will require the compiler to be modified accordingly.
195
 
196
This option is provided for experimentation.  A future version of
197
OpenRISC may adopt this more consistent behavior and also provide a
198
@code{l.not} opcode.
199
@end quotation
200
 
201 19 jeremybenn
@item --enable-range-stats
202
@cindex @code{--enable-range-stats}
203
@itemx --disable-range-stats
204
@cindex @code{--disable-range-stats}
205
@cindex statistics, register over time
206
@cindex register over time statistics
207
If enabled, this option allows statistics to be collected to analyse
208 82 jeremybenn
register access over time.  The default is for this to be disabled.
209 19 jeremybenn
 
210
@item --enable-debug
211
@cindex @code{--enable-debug}
212
@itemx --disable-debug
213
@cindex @code{--disable-debug}
214
@cindex debugging enabled (Argtable2)
215
@cindex Argtable2 debugging
216 82 jeremybenn
This is a feature of the Argtable2 package used to process arguments.  If
217
enabled, some debugging features are turned on in Argtable2.  It is provided for
218 19 jeremybenn
completeness, but there is no reason why this feature should ever be needed by
219
any @value{OR1KSIM} user.
220
 
221 82 jeremybenn
@item --enable-all-tests
222
@cindex @code{--enable-all-tests}
223
@itemx --disable-all-tests
224
@cindex @code{--disable-all-tests}
225
@cindex all tests enabled
226
@cindex tests, all enabled.
227
Some of the tests (at the time of writing just one) will not compile
228
without error.  If enabled with this flag, all test programs will be
229
compiled with @command{make check}.
230
 
231
This flag is intended for those working on the test package, who wish to
232
get the missing test(s) working.
233
 
234 19 jeremybenn
@end table
235
 
236 112 jeremybenn
A number of configuration flags have been removed since version 0.3.0,
237 440 jeremybenn
because they led to invalid behavior of @value{OR1KSIM}.  Those removed are:
238 112 jeremybenn
 
239
@table @code
240
 
241 124 jeremybenn
@item --enable-arith-flag
242
@cindex @code{--enable-arith-flag}
243
@itemx --disable-arith-flag
244
@cindex @code{--disable-arith-flag}
245
@cindex flag setting by instructions
246
If enabled, this option caused certain instructions to set the flag
247
(@code{F} bit) in the supervision register if the result were zero.
248
The instructions affected by this were @code{l.add}, @code{l.addc},
249
@code{l.addi}, @code{l.and} and @code{l.andi}.
250
 
251 346 jeremybenn
If set, this caused incorrect behavior.  Whether or not flags are set is part
252 124 jeremybenn
of the OpenRISC 1000 architectural specification.  The only flags which
253
should set this are the ``set flag'' instructions: @code{l.sfeq},
254
@code{l.sfeqi}, @code{l.sfges}, @code{l.sfgesi}, @code{l.sfgeu},
255
@code{l.sfgeui}, @code{l.sfgts}, @code{l.sfgtsi}, @code{l.sfgtu},
256
@code{l.sfgtui}, @code{l.sfles}, @code{l.sflesi}, @code{l.sfleu},
257
@code{l.sfleui}, @code{l.sflts}, @code{l.sfltsi}, @code{l.sfltu},
258
@code{l.sfltui}, @code{l.sfne} and @code{l.sfnei}.
259
 
260 112 jeremybenn
@item --enable-ov-flag
261
@cindex @code{--enable-ov-flag}
262
@itemx --disable-ov-flag
263
@cindex @code{--disable-ov-flag}
264
@cindex overflow flag setting by instructions
265 124 jeremybenn
This flag caused certain instructions to set the overflow flag.  If not,
266
those instructions would not set the overflow flat.  The instructions
267
affected by this were @code{l.add}, @code{l.addc}, @code{l.addi},
268
@code{l.and}, @code{l.andi}, @code{l.div}, @code{l.divu}, @code{l.mul},
269
@code{l.muli}, @code{l.or}, @code{l.ori}, @code{l.sll}, @code{l.slli},
270
@code{l.srl}, @code{l.srli}, @code{l.sra}, @code{l.srai}, @code{l.sub},
271
@code{l.xor} and @code{l.xori}.
272 112 jeremybenn
 
273
This guaranteed incorrect behavior.  The OpenRISC 1000 architecture
274
specification defines which flags are set by which instructions.
275
 
276
Within the above list, the arithmetic instructions (@code{l.add},
277
@code{l.addc}, @code{l.addi}, @code{l.div}, @code{l.divu}, @code{l.mul},
278
@code{l.muli} and @code{l.sub}), together with @code{l.addic} which is
279
missed out, set the overflow flag.  All the others (@code{l.and},
280
@code{l.andi}, @code{l.or}, @code{l.ori}, @code{l.sll}, @code{l.slli},
281
@code{l.srl}, @code{l.srli}, @code{l.sra}, @code{l.srai}, @code{l.xor}
282
and @code{l.xori}) do not.
283
 
284
@end table
285
 
286 19 jeremybenn
@node Build and Install
287
@section Building and Installing
288 82 jeremybenn
Build the tool with:
289 19 jeremybenn
 
290
@example
291 440 jeremybenn
make all
292 82 jeremybenn
@end example
293
 
294
If you have the OpenRISC tool chain and DejaGNU installed, you can
295
verify the tool as follows (otherwise omit this step):
296
 
297
@example
298 440 jeremybenn
make check
299 82 jeremybenn
@end example
300
 
301
Install the tool with:
302
 
303
@example
304 440 jeremybenn
make install
305 19 jeremybenn
@end example
306
 
307
This will install the three variations of the @value{OR1KSIM} tool,
308 442 julius
@command{or32-elf-sim}, @command{or32-elf-psim} and
309
@command{or32-elf-mpsim}, the @value{OR1KSIM} library, @file{libsim}, the
310 19 jeremybenn
header file, @file{or1ksim.h} and this documentation in @command{info} format.
311
 
312
The documentation may be created and installed in alternative formats (PDF,
313
Postscript, DVI, HTML) with for example:
314
 
315
@example
316 440 jeremybenn
make pdf
317
make install-pdf
318 19 jeremybenn
@end example
319
 
320
@node Known Issues
321
@section Known Problems and Issues
322
 
323 346 jeremybenn
Full details of outstanding issues may be found in the @file{NEWS} file in
324
the main directory of the distribution.  The OpenRISC tracker may be used
325
to see the current state of these issues and to raise new problems and
326
feature requests.  It may be found at
327
@url{http://opencores.org/project,or1k,bugtracker}.
328 19 jeremybenn
 
329 346 jeremybenn
The following issues are long standing and unlikely to be fixed in
330 440 jeremybenn
@value{OR1KSIM} in the near future.
331 346 jeremybenn
 
332 19 jeremybenn
@itemize @bullet
333
@item
334
The Supervision Register Little Endian Enable (LEE) bit is
335 82 jeremybenn
ignored.  @value{OR1KSIM} can be built for either little endian or big endian
336 19 jeremybenn
use, but that behavior cannot be changed dynamically.
337
 
338
@item
339
@value{OR1KSIM} is not reentrant, so a program cannot instantiate
340 82 jeremybenn
multiple instances using the library.  This is clearly a problem when
341
considering multi-core applications.  However it stems from the original
342
design, and can only be fixed by a complete rewrite.  The entire source
343 19 jeremybenn
code uses static global constants liberally!
344
 
345
@end itemize
346
 
347
@node Usage
348
@chapter Usage
349
@cindex running @value{OR1KSIM}
350
 
351
@menu
352
* Standalone Simulator::
353
* Profiling Utility::
354
* Memory Profiling Utility::
355 442 julius
* Trace Generation::
356 19 jeremybenn
* Simulator Library::
357 440 jeremybenn
* Ethernet TUN/TAP Interface::
358 19 jeremybenn
@end menu
359
 
360
@node Standalone Simulator
361
@section Standalone Simulator
362
@cindex command line for @value{OR1KSIM} standalone use
363
 
364
The general form the standalone command is:
365
 
366
@example
367 442 julius
or32-elf-sim [-vhiqVt] [-f @var{file}] [--nosrv] [--srv=[@var{n}]]
368 346 jeremybenn
                 [-m <n>][-d @var{str}]
369 19 jeremybenn
                 [--enable-profile] [--enable-mprofile] [@var{file}]
370
@end example
371
 
372 82 jeremybenn
Many of the options have both a short and a long form.  For example
373 19 jeremybenn
@code{-h} or @code{--help}.
374
 
375
@table @code
376
 
377
@item -v
378
@itemx --version
379
@cindex @code{-v}
380
@cindex @code{--version}
381
Print out the version and copyright notice for @value{OR1KSIM} and
382
exit.
383
 
384
@item -h
385
@itemx --help
386
@cindex @code{-h}
387
@cindex @code{--help}
388
Print out help about the command line options and what they mean.
389
 
390 346 jeremybenn
@item -i
391
@itemx --interactive
392
@cindex @code{-i}
393
@cindex @code{--interactive}
394
After starting, drop into the @value{OR1KSIM} interactive command
395
shell.
396
 
397
@item -q
398
@itemx --quiet
399
@cindex @code{-q}
400
@cindex @code{--quiet}
401
Do not generate any information messages, only error messages.
402
 
403
@item -V
404
@itemx --verbose
405
@cindex @code{-V}
406
@cindex @code{--verbose}
407
Generate extra output messages (equivalent of specifying the ``verbose''
408
option in the simulator configuration section (see @pxref{Simulator Behavior, , Simulator Behavior}).
409
 
410 385 jeremybenn
@item -t
411
@itemx --trace
412 420 jeremybenn
@cindex @code{-t}
413
@cindex @code{--trace}
414
Dump instruction just executed and any register/memory location chaged
415
after each instruction (one line per instruction).
416 385 jeremybenn
 
417 19 jeremybenn
@item -f @var{file}
418 385 jeremybenn
@itemx --file=@var{file}
419 19 jeremybenn
@cindex @code{-f}
420
@cindex @code{--file}
421
Read configuration commands from the specified file, looking first in
422
the current directory, and otherwise in the @file{$HOME/.or1k}
423 82 jeremybenn
directory.  If this argument is not specified, the file @file{sim.cfg}
424
in those two locations is used.  Failure to find the file is a fatal
425
error.  @xref{Configuration, , Configuration}, for detailed information
426 19 jeremybenn
on configuring @value{OR1KSIM}.
427
 
428
@item --nosrv
429
@cindex @code{--nosrv}
430 235 jeremybenn
@cindex Remote Serial Protocol, @code{--nosrv}
431
Do not start up the @dfn{Remote Serial Protocol} debug server.  This
432
overrides any setting specified in the configuration file.  This
433
option may not be specified with @code{--srv}.  If it is, a rude
434
message is printed and the @code{--nosrv} option is ignored.
435 19 jeremybenn
 
436
@item --srv
437
@item --srv=@var{n}
438
@cindex @code{--srv}
439 235 jeremybenn
@cindex Remote Serial Protocol, @code{--srv}
440
Start up the @dfn{Remote Serial Protocol} debug server.  This
441
overrides any setting specified in the configuration file.  If the
442
parameter, @var{n}, is specified, use that as the TCP/IP port for the
443
server, otherwise a random value from the private port range
444
(41920-65535) will be used.  This option may not be specified with
445
@code{--nosrv}.  If it is, a rude message is printed and the
446
@code{--nosrv} option is ignored.
447 19 jeremybenn
 
448 385 jeremybenn
@item -m @var{size}
449 346 jeremybenn
@itemx --memory=@var{size}
450
@cindex @code{-m}
451
@cindex @code{--memory}
452
Configure a memory block of @var{size} bytes, starting at address
453
zero.  The size may be followed by @samp{k}, @samp{K}, @samp{m},
454
@samp{M}, @samp{g}, @samp{G}, to indicate kilobytes (@math{2^{10}}
455
bytes), megabytes (@math{2^{20}} bytes) and gigabytes (@math{2^{30}}
456
bytes).
457
 
458 440 jeremybenn
This is mainly intended for use when @value{OR1KSIM} is used without a
459 346 jeremybenn
configuration file, to allow just the processor and memory to be set
460
up.  This is the equivalent of specifying a configuration memory section
461
with @code{baseaddr = 0} and @code{size = @var{size}} and all other
462
parameters taking their default value.
463
 
464
If a configuration file is also used, it should be sure not to specify
465
an overlapping memory block.
466
 
467 385 jeremybenn
@item -d @var{config_string}
468 19 jeremybenn
@itemx --debug-config=@var{config_string}
469
@cindex @code{-d}
470
@cindex @code{--debug-config}
471 82 jeremybenn
Enable selected debug messages in @value{OR1KSIM}.  This parameter is
472
for use by developers only, and is not covered further here.  See the
473 19 jeremybenn
source code for more details.
474
 
475 346 jeremybenn
@item --report-memory-errors
476
@cindex @code{--report-memory-errors}
477
By default all exceptions are now handled silently.  If this option is
478
specified, bus exceptions will be reported with a message to standard
479
error indicating the address at which the exception occurred.
480 19 jeremybenn
 
481 440 jeremybenn
This was the default behaviour up to @value{OR1KSIM} 0.4.0.  This flag is
482 346 jeremybenn
provided for those who wish to keep that behavior.
483
 
484 19 jeremybenn
@item --strict-npc
485
@cindex @code{--strict-npc}
486
In real hardware, setting the next program counter (NPC, SPR 16),
487 82 jeremybenn
flushes the processor pipeline.  The consequence of this is that until
488
the pipeline refills, reading the NPC will return zero.  This is typically
489 19 jeremybenn
the case when debugging, since the processor is stalled.
490
 
491
Historically, @value{OR1KSIM} has always returned the value of the NPC,
492 82 jeremybenn
irrespective of when it is changed.  If the @code{--strict-npc} option is
493
used, then @value{OR1KSIM} will mirror real hardware more accurately.  If the NPC
494 19 jeremybenn
is changed while the processor is stalled, subsequent reads of its value
495
will return 0 until the processor is unstalled.
496
 
497
This is not currently the default behavior, since tools such as GDB have
498 346 jeremybenn
been implemented assuming the historic @value{OR1KSIM} behavior.
499
However at some time in the future it will become the default.
500 19 jeremybenn
 
501
@item --enable-profile
502
@cindex @code{--enable-profile}
503
Enable instruction profiling.
504
 
505
@item --enable-mprofile
506
@cindex @code{--enable-mprofile}
507
Enable memory profiling.
508
 
509
@end table
510
 
511
@node Profiling Utility
512
@section Profiling Utility
513
@cindex profiling for @value{OR1KSIM}
514
@cindex instruction profiling for @value{OR1KSIM}
515
 
516
This utility analyses instruction profile data generated by
517 82 jeremybenn
@value{OR1KSIM}.  It may be invoked as a standalone command, or from
518
the @value{OR1KSIM} CLI.  The general form the standalone command is:
519 19 jeremybenn
 
520
@example
521 442 julius
or32-elf-profile [-vhcq] [-g=@var{file}]
522 19 jeremybenn
@end example
523
 
524 82 jeremybenn
Many of the options have both a short and a long form.  For example
525 19 jeremybenn
@code{-h} or @code{--help}.
526
 
527
@table @code
528
 
529
@item -v
530
@itemx --version
531
@cindex @code{-v} (profiling utility)
532
@cindex @code{--version} (profiling utility)
533
Print out the version and copyright notice for the @value{OR1KSIM}
534
profiling utility and exit.
535
 
536
@item -h
537
@itemx --help
538
@cindex @code{-h} (profiling utility)
539
@cindex @code{--help} (profiling utility)
540
Print out help about the command line options and what they mean.
541
 
542
@item -c
543
@itemx --cumulative
544
@cindex @code{-c}
545
@cindex @code{--cumulative}
546
Show cumulative sum of cycles in functions
547
 
548
@item -q
549
@itemx --quiet
550
@cindex @code{-q}
551
@cindex @code{--quiet}
552
Suppress messages
553
 
554
@item -g=@var{file}
555
@itemx --generate=@var{file}
556
@cindex @code{-g}
557
@cindex @code{--generate}
558 82 jeremybenn
The data file to analyse.  If omitted, the default file,
559 19 jeremybenn
@file{sim.profile} is used.
560
 
561
@end table
562
 
563
@node Memory Profiling Utility
564
@section Memory Profiling Utility
565
@cindex memory profiling version of @value{OR1KSIM}
566
 
567
This utility analyses memory profile data generated by
568 82 jeremybenn
@value{OR1KSIM}.  It may be invoked as a standalone command, or from
569
the @value{OR1KSIM} CLI.  The general form the standalone command is:
570 19 jeremybenn
 
571
@example
572 442 julius
or32-elf-mprofile  [-vh] [-m=@var{m}] [-g=@var{n}] [-f=@var{file}] @var{from} @var{to}
573 19 jeremybenn
@end example
574
 
575 82 jeremybenn
Many of the options have both a short and a long form.  For example
576 19 jeremybenn
@code{-h} or @code{--help}.
577
 
578
@table @code
579
 
580
@item -v
581
@itemx --version
582
@cindex @code{-v} (memory profiling utility)
583
@cindex @code{--version} (memory profiling utility)
584
Print out the version and copyright notice for the @value{OR1KSIM}
585
memory profiling utility and exit.
586
 
587
@item -h
588
@itemx --help
589
@cindex @code{-h} (memory profiling utility)
590
@cindex @code{--help} (memory profiling utility)
591
Print out help about the command line options and what they mean.
592
 
593
@item -m=@var{m}
594
@itemx --mode=@var{m}
595
@cindex @code{-m}
596
@cindex @code{--mode}
597 82 jeremybenn
Specify the mode out output.  Permitted options are
598 19 jeremybenn
 
599
@table @code
600
 
601
@item detailed
602
@itemx d
603 82 jeremybenn
Detailed output.  This is the default if no mode is specified.
604 19 jeremybenn
 
605
@item pretty
606
@itemx p
607
Pretty printed output.
608
 
609
@item access
610
@itemx a
611
Memory accesses only.
612
 
613
@item width
614
@itemx w
615
Access width only.
616
 
617
@end table
618
 
619
@item -g=@var{n}
620
@itemx --group=@var{n}
621
@cindex @code{-g}
622
@cindex @code{--group}
623
Group @math{2^n} bits of successive addresses together.
624
 
625
@item -f=@var{file}
626
@itemx --filename=@var{file}
627
@cindex @code{-f}
628
@cindex @code{--filename}
629 82 jeremybenn
The data file to analyse.  If not specified, the default,
630 19 jeremybenn
@file{sim.profile} is used.
631
 
632
@item @var{from}
633
@itemx @var{to}
634
@cindex memory profiling start address
635
@cindex memory profiling end address
636
@var{from} and @var{to} are respectively the start and end address of
637
the region of memory to be analysed.
638
 
639
@end table
640
 
641 442 julius
@node Trace Generation
642
@section Trace Generation
643
@cindex trace generation of @value{OR1KSIM}
644
 
645
An execution trace can be generated at run time with options passed by the command line, or via the operating system's signal passing mechanism.
646
 
647
The following, passed at run time, can be used to create an execution dump.
648
 
649
@table @code
650
 
651
@item -t
652
@itemx --trace
653
@cindex @code{-t}
654
@cindex @code{--trace}
655
Dump instruction just executed and any register/memory location chaged
656
after each instruction (one line per instruction).
657
@end table
658
 
659
Passing a signal @code{SIGUSR1} while the simulator is running toggles trace generation. This can be done with the following command, assuming @value{OR1KSIM}'s executable name is @code{or32-elf-sim}:
660
 
661
@example
662
pkill -SIGUSR1 or32-elf-sim
663
@end example
664
 
665
This is useful in the case where trace output is desired after a significant amount of simulation time, where it would be inconvenient to generate trace up to that point.
666
 
667
If the @code{pkill} utility is not available, the @code{kill} utility can be used if @value{OR1KSIM}'s process number is known. Use the following to determine the process ID of the @code{or32-elf-sim} and then send the @code{SIGUSR1} command to toggle execution trace generation:
668
 
669
@example
670
ps a | grep or32-elf-sim
671
kill -SIGUSR1 @emph{process-number}
672
@end example
673
 
674
 
675 19 jeremybenn
@node Simulator Library
676
@section Simulator Library
677
@cindex library version of @value{OR1KSIM}
678
 
679
@value{OR1KSIM} may be used as a static of dynamic library,
680 82 jeremybenn
@file{libsim.a} or @file{libsim.so}.  When compiling with the static
681 19 jeremybenn
library, the flag, @code{-lsim} should be added to the link command.
682
 
683
The header file @file{or1ksim.h} contains appropriate declarations of
684 82 jeremybenn
the functions exported by the @value{OR1KSIM} library.  These are:
685 19 jeremybenn
 
686 432 jeremybenn
@deftypefn {@file{or1ksim.h}} int or1ksim_init (int @var{argc}, @
687
           char *@var{argv}, void *@var{class_ptr}, @
688
           int (*@var{upr})(void *@var{class_ptr}, @
689
           unsigned long int @var{addr}, unsigned char @var{mask}[], @
690
           unsigned char @var{rdata}[], int @var{data_len}), @
691
           int (*@var{upw})(void *@var{class_ptr}, @
692
           unsigned long int @var{addr}, @
693
           unsigned char @var{mask}[], unsigned char @var{wdata}[], @
694
           int @var{data_len}))
695 19 jeremybenn
 
696 346 jeremybenn
The initialization function is supplied with a vector of arguments,
697
which are interpreted as arguments to the standalone version (see
698
@pxref{Standalone Simulator, , Standalone Simulator}), a pointer to the
699
calling class, @var{class_ptr} (since the library may be used from C++)
700
and two up-call functions, one for reads, @var{upr}, and one for writes,
701 19 jeremybenn
@var{upw}.
702
 
703
@var{upw} is called for any write to an address external to the model
704
(determined by a @code{generic} section in the configuration
705 82 jeremybenn
file).  @var{upr} is called for any reads to an external address.  The
706 19 jeremybenn
@var{class_ptr} is passed back with these upcalls, allowing the
707
function to associate the call with the class which originally
708 93 jeremybenn
initialized the library.  Both @var{upw} and @var{upr} should return
709
zero on success and non-zero otherwise.  At the present time the meaning
710
of non-zero values is not defined but this may change in the future.
711 19 jeremybenn
 
712 93 jeremybenn
@var{mask} indicates which bytes in the data are to be written or
713 82 jeremybenn
read.  Bytes to be read/written should have 0xff set in
714 93 jeremybenn
@var{mask}.  Otherwise the byte should be zero.  The adddress,
715
@var{addr}, is the @emph{full} address, since the upcall function must
716
handle all generic devices, using the full address for decoding.
717 19 jeremybenn
 
718 346 jeremybenn
Endianness is not a concern, since @value{OR1KSIM} is transferring byte
719
vectors, not multi-byte values.
720 19 jeremybenn
 
721 346 jeremybenn
The result indicates whether the initialization was successful.  The
722
integer values are available as an @code{enum or1ksim}, with possible
723
values @code{OR1KSIM_RC_OK} and @code{OR1KSIM_RC_BADINIT}.
724
 
725 93 jeremybenn
@quotation Caution
726 346 jeremybenn
This is a change from versions 0.3.0 and 0.4.0.  It further simplifies
727
the interface, and makes @value{OR1KSIM} more consistent with payload
728
representation in SystemC TLM 2.0.
729 93 jeremybenn
@end quotation
730
 
731
@quotation Note
732 440 jeremybenn
The current implementation of @value{OR1KSIM} always transfers single words (4
733 93 jeremybenn
bytes), using masks if smaller values are required.  In this it mimcs the
734
behavior of the WishBone bus.
735
@end quotation
736
 
737 19 jeremybenn
@end deftypefn
738
 
739
@deftypefn {@file{or1ksim.h}} int or1ksim_run (double  @var{duration})
740
 
741 346 jeremybenn
Run the simulator for the simulated duration specified (in seconds).  A
742
duration of -1 indicates `run forever'
743 19 jeremybenn
 
744 346 jeremybenn
The result indicates how the run terminated.  The integer values are
745
available as an @code{enum or1ksim}, with possible values
746
@code{OR1KSIM_RC_OK} (ran for the full duration),
747
@code{OR1KSIM_RC_BRKPT} (terminated early due to hitting a breakpoint)
748
and @code{OR1KSIM_RC_HALTED} (terminated early due to hitting
749
@code{l.nop 1}).
750
 
751 19 jeremybenn
@end deftypefn
752
 
753
@deftypefn {@file{or1ksim.h}} void or1ksim_reset_duration (double @var{duration})
754
 
755
Change the duration of a run specified in an earlier call to
756 82 jeremybenn
@code{or1ksim_run}.  Typically this is called from an upcall, which
757 19 jeremybenn
realizes it needs to change the duration of the run specified in the
758
call to @code{or1ksim_run} that has been interrupted by the upcall.
759
 
760
The time specified is the amount of time that the run must continue
761
for (i.e the duration from @emph{now}, not the duration from the original
762
call to @code{or1ksim_run}).
763
 
764
@end deftypefn
765
 
766
@deftypefn {@file{or1ksim.h}} void  or1ksim_set_time_point ()
767
 
768 82 jeremybenn
Set a timing point.  For use with @code{or1ksim_get_time_period}.
769 19 jeremybenn
 
770
@end deftypefn
771
 
772
@deftypefn {@file{or1ksim.h}} double  or1ksim_get_time_period ()
773
 
774
Return the simulated time (in seconds) that has elapsed since the last
775
call to @code{or1ksim_set_time_point}.
776
 
777
@end deftypefn
778
 
779
@deftypefn {@file{or1ksim.h}} int  or1ksim_is_le ()
780
 
781
Return 1 (logical true) if the @value{OR1KSIM} simulation is
782
little-endian, 0 otherwise.
783
 
784
@end deftypefn
785
 
786
@deftypefn {@file{or1ksim.h}} unsigned long int  or1ksim_clock_rate ()
787
 
788 82 jeremybenn
Return the @value{OR1KSIM} clock rate (in Hz).  This is the value
789 19 jeremybenn
specified in the configuration file.
790
 
791
@end deftypefn
792
 
793
@deftypefn {@file{or1ksim.h}} void or1ksim_interrupt (int  @var{i})
794
 
795 432 jeremybenn
Generate an edge-triggered interrupt on interrupt line @var{i}.  The
796
interrupt must be cleared separately by clearing the corresponding bit
797
in the PICSR SPR.  Until the interrupt is cleared, any further
798
interrupts on the same line will be ignored with a warning.  A warning
799
will be generated and the interrupt request ignored if level sensitive
800
interrupts have been configured with the programmable interrupt
801
controller (@pxref{Interrupt Configuration, , Interrupt Configuration}).
802 19 jeremybenn
 
803
@end deftypefn
804
 
805
@deftypefn {@file{or1ksim.h}} void or1ksim_interrupt_set (int  @var{i})
806
 
807 432 jeremybenn
Assert a level-triggered interrupt on interrupt line @var{i}.  The
808
interrupt must be cleared separately by an explicit call to
809
@code{or1ksim_interrupt_clear}.  Until the interrupt is cleared, any
810
further setting of interrupts on the same line will be ignored with a
811
warning.  A warning will be generated, and the interrupt request ignored
812
if edge sensitive interrupts have been configured with the programmable
813
interrupt controller (@pxref{Interrupt Configuration, , Interrupt
814 19 jeremybenn
Configuration}).
815
 
816
@end deftypefn
817
 
818
@deftypefn {@file{or1ksim.h}} void or1ksim_interrupt_clear (int  @var{i})
819
 
820
Clear a level-triggered interrupt on interrupt line @var{i}, which was
821 82 jeremybenn
previously asserted by a call to @code{or1ksim_interrupt_set}.  A warning will
822 19 jeremybenn
be generated, and the interrupt request ignored if edge sensitive interrupts
823
have been configured with the programmable interrupt controller
824
(@pxref{Interrupt Configuration, , Interrupt Configuration}).
825
 
826
@end deftypefn
827
 
828 104 jeremybenn
@deftypefn {@file{or1ksim.h}} double or1ksim_jtag_reset ()
829
 
830 346 jeremybenn
Drive a reset sequence through the JTAG interface.  Return the (model)
831 104 jeremybenn
time taken for this action.  Remember that the JTAG has its own clock,
832
which can be an order of magnitude slower than the main clock, so even a
833
reset (5 JTAG cycles) could take 50 processor clock cycles to complete.
834
 
835
@end deftypefn
836
 
837 432 jeremybenn
@deftypefn {@file{or1ksim.h}} double or1ksim_jtag_shift_ir @
838
           (unsigned char *@var{jreg}, int @var{num_bits})
839 104 jeremybenn
 
840 346 jeremybenn
Shift the supplied register through the JTAG instruction register.
841
Return the (model) time taken for this action.  The register is supplied
842
as a byte vector, with the least significant bits in the least
843 104 jeremybenn
significant byte.  If the total number of bits is not an exact number of
844
bytes, then the odd bits are found in the least significant end of the
845
highest numbered byte.
846
 
847
For example a 12-bit register would have bits 0-7 in byte 0 and bits
848
11-8 in the least significant 4 bits of byte 1.
849
 
850
@end deftypefn
851
 
852 432 jeremybenn
@deftypefn {@file{or1ksim.h}} double or1ksim_jtag_shift_dr @
853
           (unsigned char *@var{jreg}, int @var{num_bits})
854 104 jeremybenn
 
855
Shift the supplied register through the JTAG data register.  Return the
856 346 jeremybenn
(model) time taken for this action.  The register is supplied as a byte
857 104 jeremybenn
vector, with the least significant bits in the least significant byte.
858
If the total number of bits is not an exact number of bytes, then the
859
odd bits are found in the least significant end of the highest numbered
860
byte.
861
 
862
For example a 12-bit register would have bits 0-7 in byte 0 and bits
863
11-8 in the least significant 4 bits of byte 1.
864
 
865
@end deftypefn
866
 
867 432 jeremybenn
@deftypefn {@file{or1ksim.h}} int or1ksim_read_mem @
868
           (unsigned long int @var{addr}, unsigned char *@var{buf}, @
869
           int @var{len})
870 346 jeremybenn
 
871
Read @var{len} bytes from @var{addr}, placing the result in @var{buf}.
872
Return @var{len} on success and 0 on failure.
873
 
874
@quotation Note
875 440 jeremybenn
This function was added in @value{OR1KSIM} 0.5.0.
876 346 jeremybenn
@end quotation
877
 
878
@end deftypefn
879
 
880 432 jeremybenn
@deftypefn {@file{or1ksim.h}} int or1ksim_write_mem @
881
           (unsigned long int @var{addr}, const unsigned char *@var{buf}, @
882
           int @var{len})
883 346 jeremybenn
 
884
Write @var{len} bytes to @var{addr}, taking the data from @var{buf}.
885
Return @var{len} on success and 0 on failure.
886
 
887
@quotation Note
888 440 jeremybenn
This function was added in @value{OR1KSIM} 0.5.0.
889 346 jeremybenn
@end quotation
890
 
891
@end deftypefn
892
 
893 432 jeremybenn
@deftypefn {@file{or1ksim.h}} int or1ksim_read_spr (int @var{sprnum}, @
894
           unsigned long int *@var{sprval_ptr})
895 346 jeremybenn
 
896
Read the SPR specified by @var{sprnum}, placing the result in
897
@var{sprval_ptr}.  Return non-zero on success and 0 on failure.
898
 
899
@quotation Note
900 440 jeremybenn
This function was added in @value{OR1KSIM} 0.5.0.
901 346 jeremybenn
@end quotation
902
 
903
@end deftypefn
904
 
905 432 jeremybenn
@deftypefn {@file{or1ksim.h}} int or1ksim_write_spr (int @var{sprnum}, @
906
           unsigned long int @var{sprva})
907 346 jeremybenn
 
908
Write @var{sprval} to the SPR specified by @var{sprnum}.  Return
909
non-zero on success and 0 on failure.
910
 
911
@quotation Note
912 440 jeremybenn
This function was added in @value{OR1KSIM} 0.5.0.
913 346 jeremybenn
@end quotation
914
 
915
@end deftypefn
916
 
917 432 jeremybenn
@deftypefn {@file{or1ksim.h}} int or1ksim_read_reg (int @var{regnum}, @
918
           unsigned long int *@var{regval_ptr})
919 346 jeremybenn
 
920
Read the general purpose register specified by @var{regnum}, placing the
921
result in @var{regval_ptr}.  Return non-zero on success and 0 on
922
failure.
923
 
924
@quotation Note
925 440 jeremybenn
This function was added in @value{OR1KSIM} 0.5.0.
926 346 jeremybenn
@end quotation
927
 
928
@end deftypefn
929
 
930 432 jeremybenn
@deftypefn {@file{or1ksim.h}} int or1ksim_write_reg (int @var{regnum}, @
931
           unsigned long int @var{regva})
932 346 jeremybenn
 
933
Write @var{regval} to the general purpose register specified by
934
@var{regnum}.  Return non-zero on success and 0 on failure.
935
 
936
@quotation Note
937 440 jeremybenn
This function was added in @value{OR1KSIM} 0.5.0.
938 346 jeremybenn
@end quotation
939
 
940
@end deftypefn
941
 
942 432 jeremybenn
@deftypefn {@file{or1ksim.h}} void or1ksim_set_stall_state (int @var{state})
943 346 jeremybenn
 
944
Set the processor's state according to @var{state} (1 = stalled, 0 = not
945
stalled).
946
 
947
@quotation Note
948 440 jeremybenn
This function was added in @value{OR1KSIM} 0.5.0.
949 346 jeremybenn
@end quotation
950
 
951
@end deftypefn
952
 
953 19 jeremybenn
The libraries will be installed in the @file{lib} sub-directory of the
954
main installation directory (as specified with the @option{--prefix}
955
option to the @command{configure} script).
956
 
957
For example if the main installation directory is @file{/opt/or1ksim},
958 82 jeremybenn
the library will be found in the @file{/opt/or1ksim/lib} directory.  It
959 19 jeremybenn
is available as both a static library (@file{libsim.a}) and a shared
960
object (@file{libsim.so}).
961
 
962
To link against the library add the @option{-lsim} flag when linking
963
and do one of the following:
964
 
965
@itemize @bullet
966
 
967
@item
968
Add the library directory to the @code{LD_LIBRARY_PATH} environment
969 82 jeremybenn
variable during execution.  For example:
970 19 jeremybenn
 
971
@example
972
export LD_LIBRARY_PATH=/opt/or1ksim/lib:$LD_LIBRARY_PATH
973
@end example
974
 
975
@item
976
Add the library directory to the @code{LD_RUN_PATH} environment
977 82 jeremybenn
variable during linking.  For example:
978 19 jeremybenn
 
979
@example
980
export LD_RUN_PATH=/opt/or1ksim/lib:$LD_RUN_PATH
981
@end example
982
 
983
@item
984
Use the linker @option{--rpath} option and specify the library
985 82 jeremybenn
directory when linking your program.  For example
986 19 jeremybenn
 
987
@example
988 82 jeremybenn
gcc ...  -Wl,--rpath -Wl,/opt/or1ksim/lib ...
989 19 jeremybenn
@end example
990
 
991
@item
992
Add the library directory to @file{/etc/ld.so.conf}
993
 
994
@end itemize
995
 
996 440 jeremybenn
@node Ethernet TUN/TAP Interface
997
@section Ethernet TUN/TAP Interface
998
@cindex configuring the Ethernet TUN/TAP interface
999
 
1000
When an Ethernet peripheral is configured (@pxref{Ethernet
1001
Configuration, , Ethernet Configuration}), one option is to tunnel
1002
traffic through a TUN/TAP interface.  The low level TAP interface is used
1003
to tunnel raw Ethernet datagrams.
1004
 
1005
The TAP interface can then be connected to a physical Ethernet through a
1006
bridge, allowing the @value{OR1KSIM} model to connect to a physical
1007
network.  This is particularly when @value{OR1KSIM} is running the
1008
OpenRISC Linux kernel image.
1009
 
1010
This section explains how to set up a bridge for use by @value{OR1KSIM}. It does
1011
require superuser access to the host machine (or at least the relevant
1012
network capabilities). A system administrator can modify these
1013
guidelines so they are executed on reboot if appropriate.
1014
 
1015
@menu
1016
* Setting Up a Persistent TAP device::
1017
* Establishing a Bridge::
1018
* Opening the Firewall::
1019
* Disabling Ethernet Filtering::
1020
* Networking from OpenRISC Linux and BusyBox::
1021
* Tearing Down a Bridge::
1022
@end menu
1023
 
1024
@node Setting Up a Persistent TAP device
1025
@subsection Setting Up a Persistent TAP device
1026
@cindex persistent TAP device creation
1027
@cindex TAP device creation
1028
 
1029
TUN/TAP devices can be created dynamically, but this requires superuser
1030
privileges (or at least @code{CAP_NET_ADMIN} capability).  The solution
1031
is to create a persistent TAP device.  This can be done using either
1032
@command{openvpn} or @command{tunctl}.  In either case the package must
1033
be installed on the host system.  Using @command{openvpn}, the following
1034
would set up a TAP interface for a specified user and group.
1035
 
1036
@example
1037
openvpn --mktun --dev tap@emph{n} --user @emph{username} --group @emph{groupname}
1038
@end example
1039
 
1040
@node Establishing a Bridge
1041
@subsection Establishing a Bridge
1042
@cindex bridge setup
1043
@cindex Ethernet bridge setup
1044
 
1045
A bridge is a ``virtual'' local area network interfaces, subsuming two or more
1046
existing network interfaces.  In this case we will bridge the physical
1047
Ethernet interface of the host with the TAP interface that will be used
1048
by @value{OR1KSIM}.
1049
 
1050
The Ethernet and TAP must lose their own individual IP addresses (by
1051
setting them to 0.0.0.0) and are replaced by the IP address of the
1052
bridge interface. To do this we use the @command{bridge-utils} package,
1053
which must be installed on the host system. These commands are require
1054
superuser privileges or @code{CAP_NET_ADMIN} capability. To create a new
1055
interface @code{br@emph{n}} the following commands are appropriate.
1056
 
1057
@example
1058
brctl addbr br@emph{n}
1059
brctl addif br@emph{n} eth@emph{x}
1060
brctl addif br@emph{n} tap@emph{y}
1061
 
1062
ifconfig eth@emph{x} 0.0.0.0 promisc up
1063
ifconfig tap@emph{y} 0.0.0.0 promisc up
1064
 
1065
dhclient br@emph{n}
1066
@end example
1067
 
1068
The last command instructs the bridge to obtain its IP address, netmask,
1069
broadcast address, gateway and nameserver information using DHCP.  In a
1070
network without DHCP it should be replaced by @command{ifconfig} to set
1071
a static IP address, netmask and broadcast address.
1072
 
1073
@quotation Note
1074
This will leave a spare dhclient process running in the background,
1075
which should be killed for tidiness. There is a technique to avoid this
1076
using @command{omshell}, but that is beyond the scope of this guide.
1077
@end quotation
1078
 
1079
@quotation Note
1080
It is not clear to the author why the existing interfaces need to be
1081
brought up in promiscuous mode, but it seems to cure various problems.
1082
@end quotation
1083
 
1084
@node Opening the Firewall
1085
@subsection  Opening the Firewall
1086
@cindex firewall with Ethernet bridge and TAP/TUN
1087
 
1088
Firewall rules should be added to ensure traffic flows freely through
1089
the TAP and bridge interfaces. As superuser the following commands are
1090
appropriate.
1091
 
1092
@example
1093
iptables -A INPUT -i tap@emph{y} -j ACCEPT
1094
iptables -A INPUT -i br@emph{n} -j ACCEPT
1095
iptables -A FORWARD -i br@emph{n} -j ACCEPT
1096
@end example
1097
 
1098
@node Disabling Ethernet Filtering
1099
@subsection Disabling Ethernet Filtering
1100
 
1101
Some systems may have ethernet filtering enabled (@command{ebtables},
1102
@command{bridge-nf}, @command{arptables}) which will stop traffic
1103
flowing through the bridge.
1104
 
1105
The easiest way to disable this is by writing zero to all
1106
@file{bridge-nf-*} entries in @file{/proc/sys/net/bridge}. As superuser
1107
the following commands will achieve this.
1108
 
1109
@example
1110
cd /proc/sys/net/bridge
1111
for f in bridge-nf-*; do echo 0 > $f; done
1112
@end example
1113
 
1114
@node Networking from OpenRISC Linux and BusyBox
1115
@subsection Networking from OpenRISC Linux and BusyBox
1116
@cindex BusyBox and Ethernet
1117
@cindex Linux (OpenRISC) and Ethernet
1118
 
1119
The main use of this style of Ethernet interface to @value{OR1KSIM} is when
1120
running the OpenRISC Linux kernel with BusyBox. The following commands
1121
in the BusyBox console window will configure the Ethernet interface
1122
(assumed to be @code{eth0}) and bring it up with a DHCP assigned
1123
address.
1124
 
1125
@example
1126
ifconfig eth0
1127
ifup eth0
1128
@end example
1129
 
1130
At this stage interface to IP addresses will work correctly.
1131
 
1132
For DNS to work the BusyBox system needs to know where to find a
1133
nameserver.  Under BusyBox, @command{udhcp} does not configure
1134
@file{/etc/resolv.conf} automatically.
1135
 
1136
The solution is to duplicate the nameserver entry from the
1137
@file{/etc/resolv.conf} file of the host on the BusyBox system. A
1138
typical file might be as follows:
1139
 
1140
@example
1141
@code{nameserver 192.168.0.1}
1142
@end example
1143
 
1144
It is convenient to make this permanent within the Linux initramfs. Add
1145
the file as @code{arch/openrisc/support/initramfs/etc/resolv.conf}
1146
within the Linux source tree and rebuild @code{vmlinux}. It will then be
1147
present automatically.
1148
 
1149
One of the most useful functions that is possible is to mount
1150
the host file system through NFS. For example, from the BusyBox console:
1151
 
1152
@example
1153
mount -t nfs -o nolock 192.168.0.60:/home /mnt
1154
@end example
1155
 
1156
Another useful technique is to telnet into the BusyBox system from the
1157
host. This is particularly valuable when a console process locks up,
1158
since the @command{xterm} console will not recognize ctrl-C. Instead the
1159
rogue process can be killed from a telnet connection.
1160
 
1161
@node Tearing Down a Bridge
1162
@subsection Tearing Down a Bridge
1163
 
1164
There is little reason why a bridge should ever need to be torn down,
1165
but if desired, the following commands will achieve the effect.
1166
 
1167
@example
1168
ifconfig br@emph{n} down
1169
brctl delbr br@emph{n}
1170
 
1171
dhclient eth@emph{x}
1172
@end example
1173
 
1174
As before this will leave a spare @command{dhclient} process in the
1175
background which should be killed.
1176
 
1177
If desired the TAP interface can be deleted using
1178
 
1179
@example
1180
openvpn --rmtun -dev tap@emph{y}
1181
@end example
1182
 
1183
@quotation Caution
1184
The TAP interface should not be in use when running this command. For
1185
example any OpenRISC Linux/BusyBox sessions should be closed first.
1186
@end quotation
1187
 
1188 19 jeremybenn
@node Configuration
1189
@chapter Configuration
1190
@cindex configuring @value{OR1KSIM}
1191
 
1192 82 jeremybenn
@value{OR1KSIM} is configured through a configuration file.  This is specified
1193 19 jeremybenn
through the @code{-f} parameter to the @value{OR1KSIM} command, or passed as a
1194 82 jeremybenn
string when initializing the @value{OR1KSIM} library.  If no file is specified,
1195
the default @file{sim.cfg} is used.  The file is looked for first in the
1196 224 jeremybenn
current directory, then in the @file{$HOME/.or1ksim} directory of the user.
1197 19 jeremybenn
 
1198
@menu
1199
* Configuration File Format::
1200
* Simulator Configuration::
1201
* Core OpenRISC Configuration::
1202
* Peripheral Configuration::
1203
@end menu
1204
 
1205
@node Configuration File Format
1206
@section Configuration File Format
1207
@cindex configuration file structure
1208
 
1209 346 jeremybenn
The configuration file is a plain text file.  A reference example,
1210
@file{sim.cfg}, is included in the top level directory of the
1211
distribution.
1212 19 jeremybenn
 
1213
@menu
1214
* Configuration File Preprocessing::
1215
* Configuration File Syntax::
1216
@end menu
1217
 
1218
@node Configuration File Preprocessing
1219
@subsection Configuration File Preprocessing
1220
 
1221 82 jeremybenn
The configuration file may include C style comments (i.e.  delimited by
1222 19 jeremybenn
@code{/*} and @code{*/}).
1223
 
1224
@node Configuration File Syntax
1225
@subsection Configuration File Syntax
1226
 
1227
The configuration file is divided into a series of sections, with the general
1228
form:
1229
 
1230
@example
1231
section @var{section_name}
1232
 
1233
  <contents>...
1234
 
1235
end
1236
@end example
1237
 
1238
Sections may also have sub-sections within them (currently only the
1239
ATA/ATAPI disc interface uses this).
1240
 
1241
Within a section, or sub-section are a series of parameter assignments, one
1242
per line, withe the general form
1243
 
1244
@example
1245
  @var{parameter} = @var{value}
1246
@end example
1247
 
1248
Depending on the parameter, the value may be a named value (an enumeration),
1249
an integer (specified in any format acceptable in C) or a string in doubple
1250 82 jeremybenn
quotes.  For flag parameters, the value 1 is used to mean ``true'' or ``on''
1251
and the value ``0'' to mean ``false'' or ``off''.  An example from a memory
1252 19 jeremybenn
section shows each of these
1253
 
1254
@example
1255
section memory
1256
  type    = random
1257
  pattern = 0x00
1258
  name    = "FLASH"
1259
  ...
1260
end
1261
@end example
1262
 
1263
Many parameters are optional and take reasonable default values if not
1264 82 jeremybenn
specified.  However there are some parameters (for example the
1265 19 jeremybenn
@code{ce} parameter in @code{@w{section memory}}) @emph{must} be
1266
specified.
1267
 
1268
Subsections are introduced by a keyword, with a parameter value (no
1269
@code{=} sign), and end with the same keyword prefixed by
1270 82 jeremybenn
@code{end}.  Thus the ATA/ATAPI inteface (@code{@w{section ata}}) has a
1271 19 jeremybenn
@code{device} subsection, thus:
1272
 
1273
@example
1274
section ata
1275
  ...
1276
  device 0
1277
    type    = 1
1278
    file = "@var{filename}"
1279
    ...
1280
  enddevice
1281
  ...
1282
end
1283
@end example
1284
 
1285
Some sections (for example @code{@w{section sim}}) should appear only
1286 82 jeremybenn
once.  Others (for example @code{@w{section memory}} may appear
1287 19 jeremybenn
multiple times.
1288
 
1289
Sections may be omitted, @emph{unless they contain parameters which
1290 82 jeremybenn
are non-optional}.  If the section describes a part of the simulator
1291 19 jeremybenn
which is optional (for example whether it has a UART), then that
1292 82 jeremybenn
functionality will not be provided.  If the section describes a part of
1293 19 jeremybenn
the simulator which is not optional (for example the CPU), then all the
1294
parameters of that section will take their default values.
1295
 
1296
All optional parts of the functionality are always described by
1297
sections including a @code{enabled} parameter, which can be set to 0
1298
to ensure that functionality is explicitly omitted.
1299
 
1300
Even if a section is disabled, all its parameters will be read and
1301 82 jeremybenn
stored.  This is helpful if the section is subsequently enabled from
1302 19 jeremybenn
the @value{OR1KSIM} command line (@pxref{Interactive Command Line, ,
1303
Interactive Command Line}).
1304
 
1305
@quotation Tip
1306
It generally clearer to have sections describing @emph{all}
1307
components, with omitted functionality explicitly indicated by setting
1308
the @code{enabled} parameter to 0
1309
@end quotation
1310
 
1311
The following sections describe the various configuration sections and the
1312
parameters which may be set in each.
1313
 
1314
@node Simulator Configuration
1315
@section Simulator Configuration
1316
 
1317
@menu
1318
* Simulator Behavior::
1319
* Verification API Configuration::
1320
* CUC Configuration::
1321
@end menu
1322
 
1323
@node Simulator Behavior
1324
@subsection Simulator Behavior
1325
@cindex configuring the behavior of @value{OR1KSIM}
1326
@cindex simulator configuration
1327
@cindex @code{section sim}
1328 82 jeremybenn
Simulator behavior is described in @code{section sim}.  This section
1329
should appear only once.  The following parameters may be specified.
1330 19 jeremybenn
 
1331
@table @code
1332
 
1333
@item verbose = 0|1
1334
@cindex @code{verbose} (simulator configuration)
1335 82 jeremybenn
If 1 (true), print extra messages.  Default 0.
1336 19 jeremybenn
 
1337
@item debug = 0-9
1338
@cindex @code{debug} (simulator configuration)
1339 82 jeremybenn
 
1340
value the greater the number of messages.  Default 0.  Negative values
1341
will be treated as 0 (with a warning).  Values that are too large will
1342 19 jeremybenn
be treated as 9 (with a warning).
1343
 
1344
@item profile = 0|1
1345
@cindex @code{profile} (simulator configuration)
1346
If 1 (true) generate a profiling file using the file specified in the
1347 82 jeremybenn
@code{prof_file} parameter or otherwise @file{sim.profile}.  Default 0.
1348 19 jeremybenn
 
1349
@item prof_file = ``@var{filename}''
1350
@cindex @code{prof_file} (simulator configuration)
1351
@cindex @code{prof_fn} (simulator configuration - deprecated)
1352 82 jeremybenn
Specifies the file to be used with the @code{profile} parameter.  Default
1353
@file{sim.profile}.  For backwards compatibility, the alternative name
1354 346 jeremybenn
@code{prof_fn} is supported for this parameter, but deprecated.  Default
1355
@file{sim.profile}.
1356 19 jeremybenn
 
1357 346 jeremybenn
 
1358 19 jeremybenn
@item mprofile = 0|1
1359
@cindex @code{mprofile} (simulator configuration)
1360
If 1 (true) generate a memory profiling file using the file specified in the
1361 82 jeremybenn
@code{mprof_file} parameter or otherwise @file{sim.mprofile}.  Default 0.
1362 19 jeremybenn
 
1363 346 jeremybenn
@item mprof_file = ``@var{filename}''
1364 19 jeremybenn
@cindex @code{mprof_file} (simulator configuration)
1365
@cindex @code{mprof_fn} (simulator configuration - deprecated)
1366 82 jeremybenn
Specifies the file to be used with the @code{mprofile} parameter.  Default
1367
@file{sim.mprofile}.  For backwards compatibility, the alternative name
1368 19 jeremybenn
@code{mprof_fn} is supported for this parameter, but deprecated.
1369 346 jeremybenn
Default @file{sim.mprofile}.
1370 19 jeremybenn
 
1371
@item history = 0|1
1372
@cindex @code{history} (simulator configuration)
1373 82 jeremybenn
If 1 (true) track execution flow.  Default 0.
1374 19 jeremybenn
 
1375
@quotation Note
1376
Setting this parameter seriously degrades performance.
1377
@end quotation
1378
 
1379
@quotation Note
1380
If this execution flow tracking is enabled, then @code{dependstats}
1381
must be enabled in the CPU configuration section (@pxref{CPU
1382
Configuration, , CPU Configuration}).
1383
@end quotation
1384
 
1385
@item exe_log = 0|1
1386
@cindex @code{exe_log} (simulator configuration)
1387 82 jeremybenn
If 1 (true), generate an execution log.  Log is written to the file specified
1388
in parameter @code{exe_log_file}.  Default 0.
1389 19 jeremybenn
 
1390
@quotation Note
1391
Setting this parameter seriously degrades performance.
1392
@end quotation
1393
 
1394
@item exe_log_type = default|hardware|simple|software
1395
@cindex @code{exe_log_type} (simulator configuration)
1396
Type of execution log to produce.
1397
 
1398
@table @code
1399
 
1400
@item default
1401
@cindex @code{exe_log_type=default} (simulator configuration)
1402 82 jeremybenn
Produce default output for the execution log.  In the current implementation
1403 19 jeremybenn
this is the equivalent of @code{hardware}.
1404
 
1405
@item hardware
1406
@cindex @code{exe_log_type=hardware} (simulator configuration)
1407
After each instruction execution, log the number of instructions executed so
1408
far, the next instruction to execute (in hex), the general purpose registers
1409
(GPRs), status register, exception program counter, exception, effective
1410
address register and exception status register.
1411
 
1412
@item simple
1413
@cindex @code{exe_log_type=simple} (simulator configuration)
1414
After each instruction execution, log the number of instructions executed so
1415
far and the next instruction to execute, symbolically disassembled.
1416
 
1417
@item software
1418
@cindex @code{exe_log_type=software} (simulator configuration)
1419
After each instruction execution, log the number of instructions executed so
1420 82 jeremybenn
far and the next instruction to execute, symbolically disassembled.  Also show
1421 19 jeremybenn
the value of each operand to the instruction.
1422
 
1423
@end table
1424
 
1425 82 jeremybenn
Default value @code{hardware}.  Any unrecognized keyword (case
1426 19 jeremybenn
insensitive) will be treated as the default with a warning.
1427
 
1428
@quotation Note
1429
Execution logs can be @emph{very} big.
1430
@end quotation
1431
 
1432
@item exe_log_start = @var{value}
1433
@cindex @code{exe_log_start} (simulator configuration)
1434 82 jeremybenn
Address of the first instruction to start logging.  Default 0.
1435 19 jeremybenn
 
1436
@item exe_log_end = @var{value}
1437
@cindex @code{exe_log_end} (simulator configuration)
1438 82 jeremybenn
Address of the last instruction to log.  Default no limit (i.e once started
1439 19 jeremybenn
logging will continue until the simulator exits).
1440
 
1441
@item exe_log_marker = @var{value}
1442
@cindex @code{exe_log_marker} (simulator configuration)
1443
Specifies the number of instructions between printing horizontal
1444 82 jeremybenn
markers.  Default is to produce no markers.
1445 19 jeremybenn
 
1446
@item exe_log_file = @var{filename}
1447
@cindex @code{exe_log_file} (simulator configuration)
1448
@cindex @code{exe_log_fn} (simulator configuration - deprecated)
1449 82 jeremybenn
Filename for the execution log filename if @code{exe_log} is enabled.  Default
1450
@file{executed.log}.  For backwards compatibility, the alternative name
1451 19 jeremybenn
@code{exe_log_fn} is supported for this parameter, but deprecated.
1452
 
1453 202 julius
@item exe_bin_insn_log = 0|1
1454
@cindex @code{exe_bin_insn_log} (simulator configuration)
1455 346 jeremybenn
Enable logging of executed instructions to a file in binary format.
1456
This is helpful for off-line dynamic execution analysis.
1457 202 julius
 
1458
@quotation Note
1459 346 jeremybenn
Execution logs can be @emph{very} big.  For example, while booting the
1460
Linux kernel, version 2.6.34, a log file 1.2GB in size was generated.
1461 202 julius
@end quotation
1462
 
1463
@item exe_bin_insn_log_file = @var{filename}
1464
@cindex @code{exe_bin_insn_log_file} (simulator configuration)
1465
Filename for the binary execution log filename if @code{exe_bin_insn_log} is
1466
enabled.  Default @file{exe-insn.bin}.
1467
 
1468
 
1469 19 jeremybenn
@item clkcycle = @var{value}[ps|ns|us|ms]
1470
@cindex @code{clkcycle} (simulator configuration)
1471 82 jeremybenn
Specify the time taken by one clock cycle.  If no units are specified,
1472
@code{ps} is assumed.  Default 4000ps (250MHz).
1473 19 jeremybenn
 
1474
@end table
1475
 
1476
@node Verification API Configuration
1477
@subsection Verification API (VAPI) Configuration
1478
@cindex configuring the Verification API (VAPI)
1479
@cindex Verification API configuration
1480
@cindex VAPI configuration
1481
@cindex @code{section vapi}
1482
The Verification API (VAPI) provides a TCP/IP interface to allow
1483
components of the simulation to be controlled
1484 82 jeremybenn
externally.  @xref{Verification API, , Verification API}, for more
1485 19 jeremybenn
details.
1486
 
1487
Verification API configuration is described in @code{section
1488 82 jeremybenn
vapi}.  This section may appear at most once.  The following parameters
1489 19 jeremybenn
may be specified.
1490
 
1491
@table @code
1492
 
1493
@item enabled = 0|1
1494
@cindex @code{enabled} (verification API configuration)
1495 82 jeremybenn
If 1 (true), verification API is enabled and its server started.  If 0
1496 19 jeremybenn
(the default), it is disabled.
1497
 
1498
@item server_port = @var{value}
1499
@cindex @code{server_port} (verification API configuration)
1500
When VAPI is enabled, communication will be via TCP/IP on the port
1501 82 jeremybenn
specified by @var{value}.  The value must lie in the range 1 to 65535.
1502 19 jeremybenn
The default value is 50000.
1503
 
1504
@quotation Tip
1505
@cindex TCP/IP port range
1506
@cindex port range for TCP/IP
1507
@cindex dynamic ports, use of
1508
@cindex private ports, use of
1509 82 jeremybenn
There is no registered port for @value{OR1KSIM} VAPI.  Good practice
1510 19 jeremybenn
suggests users should adopt port values in the @dfn{Dynamic} or
1511 82 jeremybenn
@dfn{Private} port range, i.e.  49152-65535.
1512 19 jeremybenn
@end quotation
1513
 
1514
@item log_enabled = 0|1
1515
@cindex @code{log_enabled} (verification API configuration)
1516 82 jeremybenn
If 1 (true), all VAPI requests and sent commands will be logged.  If 0
1517
(the default), logging is diabled.  Logs are written to the file
1518 19 jeremybenn
specified by the @code{vapi_log_file} field (see below).
1519
 
1520
@quotation Caution
1521
This can generate a substantial amount of file I/O and seriously
1522
degrade simulator performance.
1523
@end quotation
1524
 
1525
@item hide_device_id = 0|1
1526
@cindex @code{hide_device_id} (verification API configuration)
1527 82 jeremybenn
If 1 (true) don't log the device ID.  If 0 (the default), log the
1528
device ID.  This feature (when set to 1) is provided for backwards
1529 19 jeremybenn
compatibility with an old version of VAPI.
1530
 
1531
@item vapi_log_file = "@var{filename}"
1532
@cindex @code{vapi_log_file} (verification API configuration)
1533
@cindex @code{vapi_log_fn} (verification API configuration - deprecated)
1534
Use @file{filename} as the file for logged data is logging is enabled
1535 82 jeremybenn
(see @code{log_enabled} above).  The default is @code{"vapi.log"}.  For
1536 19 jeremybenn
backwards compatibility, the alternative name @code{vapi_log_fn} is
1537
supported for this parameter, but deprecated.
1538
 
1539
@end table
1540
 
1541
@node CUC Configuration
1542
@subsection Custom Unit Compiler (CUC) Configuration
1543
@cindex configuring the Custom Unit Compiler (CUC)
1544
@cindex Custom Unit Compiler Configuration
1545
@cindex CUC configuration
1546
@cindex @code{section cuc}
1547
The Custom Unit Compiler (CUC) was a project by Marko Mlinar to generate
1548 82 jeremybenn
Verilog from ANSI C functions.  The project seems to not have progressed
1549
beyond the initial prototype phase.  The configuration parameters are
1550 19 jeremybenn
described here for the record.
1551
 
1552 82 jeremybenn
CUC configuration is described in @code{@w{section cuc}}.  This section
1553
may appear at most once.  The following parameters may be specified.
1554 19 jeremybenn
 
1555
@table @code
1556
 
1557
@item memory_order = none|weak|strong|exact
1558
@cindex @code{memory_order} (CUC configuration)
1559
This parameter specifies the memory ordering required:
1560
 
1561
@table @code
1562
 
1563
@item memory_order=none
1564
@cindex @code{memory_order=none} (CUC configuration)
1565 82 jeremybenn
Different memory ordering, even if there are dependencies.  Bursts can
1566 19 jeremybenn
be made, width can change.
1567
 
1568 346 jeremybenn
@item memory_order=weak
1569 19 jeremybenn
@cindex @code{memory_order=weak} (CUC configuration)
1570 82 jeremybenn
Different memory ordering, even if there are dependencies.  If
1571 19 jeremybenn
dependencies cannot occur, then bursts can be made, width can change.
1572
 
1573 346 jeremybenn
@item memory_order=strong
1574 19 jeremybenn
@cindex @code{memory_order=strong} (CUC configuration)
1575 82 jeremybenn
Same memory ordering.  Bursts can be made, width can change.
1576 19 jeremybenn
 
1577 346 jeremybenn
@item memory_order=exact
1578 19 jeremybenn
@cindex @code{memory_order=exact} (CUC configuration)
1579
Exactly the same memory ordering and widths.
1580
 
1581
@end table
1582
 
1583 82 jeremybenn
The default value is @code{memory_order=exact}.  Invalid memory
1584 19 jeremybenn
orderings are ignored with a warning.
1585
 
1586
@item calling_convention = 0|1
1587
@cindex @code{calling_convention} (CUC configuration)
1588 82 jeremybenn
If 1 (true), programs follow OpenRISC calling conventions.  If 0 (the
1589 19 jeremybenn
default), they may use other convenitions.
1590
 
1591
@item enable_bursts = 0 | 1
1592
@cindex @code{enable_bursts} (CUC configuration)
1593 82 jeremybenn
If 1 (true), bursts are detected.  If 0 (the default), bursts are not
1594 19 jeremybenn
detected.
1595
 
1596
@item no_multicycle = 0 | 1
1597
@cindex @code{no_multicycle} (CUC configuration)
1598 82 jeremybenn
If 1 (true), no multicycle logic paths will be generated.  If 0 (the
1599 19 jeremybenn
default), multicycle logic paths will be generated.
1600
 
1601
@item timings_file = "@var{filename}"
1602
@cindex @code{timings_file} (CUC configuration)
1603
@cindex @code{timings_fn} (CUC configuration - deprecated)
1604 82 jeremybenn
@var{filename} specifies a file containing timing information.  The
1605
default value is @code{"virtex.tim"}.  For backwards compatibility, the
1606 19 jeremybenn
alternative name @code{timings_fn} is supported for this parameter,
1607
but deprecated.
1608
 
1609
@end table
1610
 
1611
@node Core OpenRISC Configuration
1612
@section Configuring the OpenRISC Architectural Components
1613
 
1614
@menu
1615
* CPU Configuration::
1616
* Memory Configuration::
1617
* Memory Management Configuration::
1618
* Cache Configuration::
1619
* Interrupt Configuration::
1620
* Power Management Configuration::
1621
* Branch Prediction Configuration::
1622
* Debug Interface Configuration::
1623
@end menu
1624
 
1625
@node CPU Configuration
1626
@subsection CPU Configuration
1627
@cindex configuring the CPU
1628
@cindex configuring the processor
1629
@cindex CPU configuration
1630
@cindex processor configuration
1631
@cindex @code{section cpu}
1632 82 jeremybenn
CPU configuration is described in @code{section cpu}.  This section
1633
should appear only once.  At present @value{OR1KSIM} does not model multi-CPU
1634
systems.  The following parameters may be specified.
1635 19 jeremybenn
 
1636
@table @code
1637
 
1638
@item ver = @var{value}
1639
@item cfg = @var{value}
1640
@item rev = @var{value}
1641
@cindex @code{ver} (CPU configuration)
1642
@cindex @code{rev} (CPU configuration)
1643
The values are used to form the corresponding fields in the @code{VR}
1644 82 jeremybenn
Special Purpose Register (SPR 0).  Default values 0.  A warning is given
1645 19 jeremybenn
and the value truncated if it is too large (8 bits for @code{ver} and
1646
@code{cfg}, 6 bits for @code{rev}).
1647
 
1648
@item upr = @var{value}
1649
@cindex @code{upr} (CPU configuration)
1650
Used as the value of the Unit Present Register (UPR) Special Purpose Register
1651 82 jeremybenn
(SPR 1) to @var{value}.  Default value is 0x0000075f, i.e.
1652 19 jeremybenn
@itemize @bullet
1653
@item
1654
UPR present (0x00000001)
1655
@item
1656
Data cache present (0x00000002)
1657
@item
1658
Instruction cache present (0x00000004)
1659
@item
1660
Data MMY present (0x00000008)
1661
@item
1662
Instruction MMU present (0x00000010)
1663
@item
1664
Debug unit present (0x00000040)
1665
@item
1666
Power management unit present (0x00000100)
1667
@item
1668
Programmable interrupt controller present (0x00000200)
1669
@item
1670
Tick timer present (0x00000400)
1671
@end itemize
1672
 
1673
However, with the exection of the UPR present (0x00000001) and tick
1674
timer present, the various
1675
fields will be modified with the values specified in their corresponding
1676
configuration sections.
1677
 
1678
@item cfgr = @var{value}
1679
@cindex @code{cfgr} (CPU configuration)
1680
Sets the CPU configuration register (Special Purpose Register 2) to
1681 82 jeremybenn
@var{value}.  Default value is 0x00000020, i.e.  support for the ORBIS32
1682
instruction set.  Attempts to set any other value are accepted, but
1683 19 jeremybenn
issue a warning that there is no support for the instruction set.
1684
 
1685
@item sr = @var{value}
1686
@cindex @code{sr} (CPU configuration)
1687
Sets the supervision register Special Purpose Register (SPR 0x11) to
1688 82 jeremybenn
@var{value}.  Default value is 0x00008001, i.e.  start in supervision
1689 19 jeremybenn
mode (0x00000001) and set the ``Fixed One'' bit (0x00008000).
1690
 
1691 98 jeremybenn
@quotation Note
1692
This is particularly useful when an image is held in Flash at high
1693
memory (0xf0000000).  The EPH  bit can be set, so that interrupt
1694
vectors are basedf at 0xf0000000, rather than 0x0.
1695
@end quotation
1696
 
1697 19 jeremybenn
@item superscalar = 0|1
1698
@cindex @code{superscalar} (CPU configuration)
1699 82 jeremybenn
If 1, the processor operates in superscalar mode.  Default value is
1700 19 jeremybenn
0.
1701
 
1702
In the current simulator, the only functional effect of superscalar
1703
mode is to affect the calculation of the number of cycles taken to
1704
execute an instruction.
1705
 
1706
@quotation Caution
1707
The code for this does not appear to be complete or well tested, so
1708
users are advised not to use this option.
1709
@end quotation
1710
 
1711
@item hazards = 0|1
1712
@cindex @code{hazards} (CPU configuration)
1713 82 jeremybenn
If 1, data hazards are tracked in a superscalar CPU.  Default value is
1714 19 jeremybenn
0.
1715
 
1716
In the current simulator, the only functional effect is to cause
1717
logging of hazard waiting information if the CPU is
1718 82 jeremybenn
superscalar.  However nowhere in the simulator is this data actually
1719 19 jeremybenn
computed, so the net result is probably to have no effect.
1720
 
1721
if harzards are tracked, current hazards can be displayed using the
1722
simulator's @command{r} command.
1723
 
1724
@quotation Caution
1725
The code for this does not appear to be complete or well tested, so
1726
users are advised not to use this option.
1727
@end quotation
1728
 
1729
@item dependstats = 0|1
1730
@cindex @code{dependstats} (CPU configuration)
1731 82 jeremybenn
If 1, inter-instruction dependencies are calculated.  Default value 0.
1732 19 jeremybenn
 
1733
If these values are calculated, the depencies can be displayed using
1734
the simulator's @command{stat} command.
1735
 
1736
@quotation Note
1737
This field must be enabled, if execution execution flow tracking
1738
(field @code{history}) has been requested in the simulator
1739
configuration section (@pxref{Simulator Behavior, , Simulator
1740
Behavior}).
1741
@end quotation
1742
 
1743
@item sbuf_len = @var{value}
1744
@cindex @code{sbuf_len} (CPU configuration)
1745
The length of the store buffer is set to @var{value}, which must be no
1746 82 jeremybenn
greater than 256.  Larger values will be truncated to 256 with a
1747
warning.  Negative values will be treated as 0 with a warning.  Use 0 to
1748 19 jeremybenn
disable the store buffer.
1749
 
1750
When the store buffer is active, stores are accumulated and committed
1751
when I/O is idle.
1752
 
1753 100 julius
@item hardfloat = 0|1
1754
@cindex @code{hardfloat} (CPU configuration)
1755 346 jeremybenn
If 1, hardfloat instructions are enabled.  Default value 0.
1756 101 jeremybenn
 
1757 19 jeremybenn
@end table
1758
 
1759
@node Memory Configuration
1760
@subsection Memory Configuration
1761
@cindex configuring memory
1762
@cindex memory configuration
1763
@cindex @code{section memory}
1764 82 jeremybenn
Memory configuration is described in @code{section memory}.  This
1765 19 jeremybenn
section may appear multiple times, specifying multiple blocks of
1766 98 jeremybenn
memory.
1767 19 jeremybenn
 
1768 98 jeremybenn
@quotation Caution
1769 346 jeremybenn
The user may choose whether or not to enable a memory controller.  If a
1770 385 jeremybenn
memory controller is enabled, then appropriate initalization code must
1771
be provided.  The section describing memory controller configuration
1772
describes the steps necessary for using smaller or larger memory
1773
sections (@pxref{Memory Controller Configuration, , Memory Controller
1774
Configuration}).
1775 98 jeremybenn
 
1776 385 jeremybenn
The @dfn{uClibc} startup code initalizes a memory controller, assumed to
1777
be mapped at 0x93000000.  If a memory controller is @emph{not} enabled,
1778
then the standard C library code will generate memory access errors.
1779
The solution is to declare an additional writable memory block, mimicing
1780
the memory controller's register bank as follows.
1781 98 jeremybenn
 
1782
@example
1783
section memory
1784
  pattern = 0x00
1785
  type = unknown
1786
  name = "MC shadow"
1787
  baseaddr = 0x93000000
1788
  size     = 0x00000080
1789
  delayr = 2
1790
  delayw = 4
1791
end
1792
@end example
1793
 
1794
@end quotation
1795
 
1796
 
1797
The following parameters may be specified.
1798
 
1799 19 jeremybenn
@table @code
1800
 
1801 418 julius
@item type=random|pattern|unknown|zero|exitnops
1802 19 jeremybenn
@cindex @code{type} (memory configuration)
1803 82 jeremybenn
Specifies the values to which memory should be initialized.  The
1804 19 jeremybenn
default value is @code{unknown}.
1805
 
1806
@table @code
1807
 
1808
@item random
1809
@cindex @code{type=random} (memory configuration)
1810 82 jeremybenn
Set the memory values to be a random value.  A seed for the random
1811 19 jeremybenn
generator may be set using the @code{random_seed} field in this
1812
section (see below), thus ensuring the same ``random'' values are used
1813
each time.
1814
 
1815
@item pattern
1816
@cindex @code{type=pattern} (memory configuration)
1817
Set the memory values to be a pattern value, which is set using the
1818
@code{pattern} field in this section (see below).
1819
 
1820
@item unknown
1821
@cindex @code{type=unknown} (memory configuration)
1822 82 jeremybenn
The memory values are not initialized (i.e.  left ``unknown'').  This
1823 346 jeremybenn
option will yield faster initialization of the simulator.  This is the
1824
default.
1825 19 jeremybenn
 
1826
@item zero
1827
@cindex @code{type=zero} (memory configuration)
1828 82 jeremybenn
Set the memory values to be 0.  This is the equivalent of
1829 19 jeremybenn
@code{type=pattern} and a @code{pattern} value of 0, and implemented
1830
as such.
1831
 
1832
@quotation Note
1833
As a consequence, if the @code{pattern} field is @emph{subsequently}
1834
specified in this section, the value in that field will be used
1835
instead of zero to initialize the memory.
1836
@end quotation
1837
 
1838 418 julius
@item exitnops
1839
@cindex @code{type=exitnops} (memory configuration)
1840
Set the memory values to be an instruction used to signal end of
1841
simulation. This is useful for causing immediate end of simulation
1842
when PC corruption occurs.
1843
 
1844 19 jeremybenn
@end table
1845
 
1846
@item random_seed = @var{value}
1847
@cindex @code{random_seed} (memory configuration)
1848 82 jeremybenn
Set the seed for the random number generator to @var{value}.  This only
1849 19 jeremybenn
has any effect for memory type @code{random}.
1850
 
1851
The default value is -1,
1852
which means the seed will be set from a call to the @code{time}
1853
function, thus ensuring different random values are used on each
1854 82 jeremybenn
run.  The simulator prints out the seed used in this case, allowing
1855 19 jeremybenn
repeat runs to regenerate the same random values used in any
1856
particular run.
1857
 
1858
@item pattern = @var{value}
1859
@cindex @code{pattern} (memory configuration)
1860
Set the pattern to be used when initializing memory to
1861 82 jeremybenn
@var{value}.  The default value is 0.  This only has any effect for
1862
memory type @code{pattern}.  The least significant 8 bits of this value
1863
is used to initialize each byte.  More than 8 bits can be specified,
1864 19 jeremybenn
but will ignored with a warning.
1865
 
1866
@quotation Tip
1867
The default value, is equivalent to setting the memory @code{type} to
1868 82 jeremybenn
be @code{zero}.  If that is what is intended, then using
1869 19 jeremybenn
@code{type=zero} explicitly is better than using @code{type=pattern}
1870
and not specifying a value for @code{pattern}.
1871
@end quotation
1872
 
1873
@item baseaddr = @var{value}
1874
@cindex @code{baseaddr} (memory configuration)
1875 82 jeremybenn
Set the base address of the memory to @var{value}.  It should be
1876 19 jeremybenn
aligned to a multiple of the memory size rounded up to the nearest
1877 82 jeremybenn
@math{2^n}.  The default value is 0.
1878 19 jeremybenn
 
1879
@item size = @var{value}
1880
@cindex @code{size} (memory configuration)
1881 82 jeremybenn
Set the size of the memory block to be @var{value} bytes.  This should be a
1882
multiple of 4 (i.e.  word aligned).  The default value is 1024.
1883 19 jeremybenn
 
1884
@quotation Note
1885
When allocating memory, the simulator will allocate the nearest
1886
@math{2^n} bytes greater than or equal to @var{value}, and will not
1887
notice memory misses in any part of the memory between @var{value} and
1888
the amount allocated.
1889
 
1890
As a consequence users are strongly recommended to specify memory
1891 82 jeremybenn
sizes that are an exact power of 2.  If some other amount of memory is
1892 19 jeremybenn
required, it should be specified as separate, contiguous blocks, each
1893
of which is a power of 2 in size.
1894
@end quotation
1895
 
1896
@item name = "@var{text}"
1897
@cindex @code{name} (memory configuration)
1898 82 jeremybenn
Name the block.  Typically these describe the type of memory being
1899
modeled (thus @code{"SRAM"} or @code{"Flash"}.  The default is
1900 19 jeremybenn
@code{@w{"anonymous memory block"}}.
1901
 
1902
@quotation Note
1903
It is not clear that this information is currently ever used in normal
1904 82 jeremybenn
operation of the simulator.  Even the @command{info} command of the simulator
1905 19 jeremybenn
ignores it.
1906
@end quotation
1907
 
1908
@item ce = @var{value}
1909
@cindex @code{ce} (memory configuration)
1910 82 jeremybenn
Set the chip enable index of the memory instance.  Each memory instance
1911 19 jeremybenn
should have a unique chip enable index, which should be greater
1912 82 jeremybenn
than or equal to zero.  This is used by the memory controller when
1913 19 jeremybenn
identifying different memory instances.
1914
 
1915 346 jeremybenn
There is no requirement to set @code{ce} if a memory controller is not
1916
enabled.  The default value is -1 (invalid).
1917 19 jeremybenn
 
1918
@item mc = @var{value}
1919
@cindex @code{mc} (memory configuration)
1920 82 jeremybenn
Specifies the memory controller this memory is connected to.  It should
1921 19 jeremybenn
correspond to the @code{index} field specified in a @code{@w{section
1922
mc}} for a memory controller (@pxref{Memory Controller Configuration,
1923
, Memory Controller Configuration}).
1924
 
1925 346 jeremybenn
There is no requirement to set @code{mc} if a memory controller is not
1926
enabled.  Default value is 0, which is also the default value of a
1927
memory controller @code{index} field.  This is suitable therefore for
1928
designs with just one memory controller.
1929 19 jeremybenn
 
1930
@item delayr = @var{value}
1931
@cindex @code{delayr} (memory configuration)
1932 82 jeremybenn
The number of cycles required for a read access.  Set to -1 if the
1933
memory does not support reading.  Default value 1.  The simulator will
1934 19 jeremybenn
add this number of cycles to the total instruction cycle count when
1935
reading from main memory.
1936
 
1937
@item delayw = @var{value}
1938
@cindex @code{delayw} (memory configuration)
1939 82 jeremybenn
The number of cycles required for a write access.  Set to -1 if the
1940
memory does not support writing.  Default value 1.  The simulator will
1941 19 jeremybenn
add this number of cycles to the total instruction cycle count when
1942
writing to main memory.
1943
 
1944
@item log = "@var{file}"
1945
@cindex @code{log} (memory configuration)
1946
If specified, @file{file} names a file for all memory accesses to be
1947 82 jeremybenn
logged.  If not specified, the default value, NULL is used, meaning
1948 19 jeremybenn
that the memory is not logged.
1949
 
1950
@end table
1951
 
1952
@node Memory Management Configuration
1953
@subsection Memory Management Configuration
1954
@cindex configuring data & instruction MMUs
1955
@cindex MMU configuration
1956
@cindex DMMU configuration
1957
@cindex data MMU configuration
1958
@cindex IMMU configuration
1959
@cindex instruction MMU configuration
1960
@cindex @code{section dmmu}
1961
@cindex @code{section immu}
1962
Memory Management Unit (MMU) configuration is described in
1963
@code{section dmmu} (for the data MMU) and @code{section immu} (for
1964 82 jeremybenn
the instruction MMU).  Each section should appear at most once.  The
1965 19 jeremybenn
following parameters may be specified.
1966
 
1967
@table @code
1968
 
1969
@item enabled = 0|1
1970
@cindex @code{enabled} (MMU configuration)
1971
If 1 (true), the data or instruction (as appropriate) MMU is
1972 82 jeremybenn
enabled.  If 0 (the default), it is disabled.
1973 19 jeremybenn
 
1974
@item nsets = @var{value}
1975
@cindex @code{nsets} (MMU configuration)
1976
Sets the number of data or instruction (as appropriate) TLB sets to
1977 82 jeremybenn
@var{value}, which must be a power of two, not exceeding 128.  Values
1978
which do not fit these criteria are ignored with a warning.  The
1979
default value is 1.
1980 19 jeremybenn
 
1981
@item nways = @var{value}
1982
@cindex @code{nways} (MMU configuration)
1983
Sets the number of data or instruction (as appropriate) TLB ways to
1984 82 jeremybenn
@var{value}.  The value must be in the range 1 to 4.  Values outside
1985
this range are ignored with a warning.  The default value is 1.
1986 19 jeremybenn
 
1987
@item pagesize = @var{value}
1988
@cindex @code{pagesize} (MMU configuration)
1989
The data or instruction (as appropriate) MMU page size is set to
1990 82 jeremybenn
@var{value}, which must be a power of 2.  Values which are not a power
1991
of 2 are ignored with a warning.  The default is 8192 (0x2000).
1992 19 jeremybenn
 
1993
@item entrysize = @var{value}
1994
@cindex @code{entrysize} (MMU configuration)
1995
The data or instruction (as appropriate) MMU entry size is set to
1996 82 jeremybenn
@var{value}, which must be a power of 2.  Values which are not a power
1997
of 2 are ignored with a warning.  The default value is 1.
1998 19 jeremybenn
 
1999
@quotation Note
2000
@value{OR1KSIM} does not appear to use the @code{entrysize} parameter
2001 82 jeremybenn
in its simulation of the MMUs.  Thus setting this value does not seem
2002 19 jeremybenn
to matter.
2003
@end quotation
2004
 
2005
@item ustates = @var{value}
2006
@cindex @code{ustates} (MMU configuration)
2007
The number of instruction usage states for the data or instruction (as
2008
appropriate) MMU is set to @var{value}, which must be 2, 3 or
2009 82 jeremybenn
4.  Values outside this range are ignored with a warning.  The default
2010 19 jeremybenn
value is 2.
2011
 
2012
@quotation Note
2013
@value{OR1KSIM} does not appear to use the @code{ustates} parameter in
2014 82 jeremybenn
its simulation of the MMUs.  Thus setting this value does not seem to
2015 19 jeremybenn
matter.
2016
@end quotation
2017
 
2018
@item hitdelay = @var{value}
2019
@cindex @code{hitdelay} (MMU configuration)
2020
Set the number of cycles a data or instruction (as appropriate) MMU
2021 82 jeremybenn
hit costs.  Default value 1.
2022 19 jeremybenn
 
2023
@item missdelay = @var{value}
2024
@cindex @code{missdelay} (MMU configuration)
2025
Set the number of cycles a data or instruction (as appropriate) MMU
2026 82 jeremybenn
miss costs.  Default value 1.
2027 19 jeremybenn
 
2028
@end table
2029
 
2030
@node Cache Configuration
2031
@subsection Cache Configuration
2032
@cindex configuring data & instruction caches
2033
@cindex cache configuration
2034
@cindex data cache configuration
2035
@cindex instruction cache configuration
2036
@cindex @code{section dc}
2037
@cindex @code{section ic}
2038
Cache configuration is described in @code{section dc} (for the data
2039 82 jeremybenn
cache) and @code{seciton ic} (for the instruction cache).  Each section
2040
should appear at most once.  The following parameters may be specified.
2041 19 jeremybenn
 
2042
@table @code
2043
 
2044
@item enabled = 0|1
2045
@cindex @code{enabled} (cache configuration)
2046
If 1 (true), the data or instruction (as appropriate) cache is
2047 82 jeremybenn
enabled.  If 0 (the default), it is disabled.
2048 19 jeremybenn
 
2049
@item nsets = @var{value}
2050
@cindex @code{nsets} (cache configuration)
2051
Sets the number of data or instruction (as appropriate) cache sets to
2052
@var{value}, which must be a power of two, not exceeding
2053
@code{MAX_DC_SETS} (for the data cache) or @code{MAX_IC_SETS} (for the
2054 82 jeremybenn
instruction cache).  At the time of writing, these constants are
2055
both defined in the code to be 1024).  The default value is 1.
2056 19 jeremybenn
 
2057
@item nways = @var{value}
2058
@cindex @code{nways} (cache configuration)
2059
Sets the number of data or instruction (as appropriate) cache ways to
2060
@var{value}, which must be a power of two, not exceeding
2061
@code{MAX_DC_WAYS} (for the data cache) or @code{MAX_IC_WAYS} (for the
2062 82 jeremybenn
instruction cache).  At the time of writing, these constants are both
2063
defined in the code to be 32).  The default value is 1.
2064 19 jeremybenn
 
2065
@item blocksize = @var{value}
2066
@cindex @code{blocksize} (cache configuration)
2067
The data or instruction (as appropriate) cache block size is set to
2068 82 jeremybenn
@var{value} bytes, which must be either 16 or 32.  The default is 16.
2069 19 jeremybenn
 
2070
@item ustates = @var{value}
2071
@cindex @code{ustates} (cache configuration)
2072
The number of instruction usage states for the data or instruction (as
2073 82 jeremybenn
appropriate) cache is set to @var{value}, which must be 2, 3 or 4.  The
2074 19 jeremybenn
default value is 2.
2075
 
2076
@item hitdelay = @var{value}
2077
@cindex @code{hitdelay} (instruction cache configuration)
2078 82 jeremybenn
@emph{Instruction cache only}.  Set the number of cycles an instruction
2079
cache hit costs.  Default value 1.
2080 19 jeremybenn
 
2081
@item missdelay = @var{value}
2082
@cindex @code{missdelay} (instruction cache configuration)
2083 82 jeremybenn
@emph{Instruction cache only}.  Set the number of cycles an instruction
2084
cache miss costs.  Default value 1.
2085 19 jeremybenn
 
2086
@item load_hitdelay = @var{value}
2087
@cindex @code{load_hitdelay} (data cache configuration)
2088 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data load cache hit
2089
costs.  Default value 2.
2090 19 jeremybenn
 
2091
@item load_missdelay = @var{value}
2092
@cindex @code{load_missdelay} (data cache configuration)
2093 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data load cache
2094
miss costs.  Default value 2.
2095 19 jeremybenn
 
2096
@item store_hitdelay = @var{value}
2097
@cindex @code{store_hitdelay} (data cache configuration)
2098 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data store cache hit
2099
costs.  Default value 0.
2100 19 jeremybenn
 
2101
@item store_missdelay = @var{value}
2102
@cindex @code{store_missdelay} (data cache configuration)
2103 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data store cache
2104
miss costs.  Default value 0.
2105 19 jeremybenn
 
2106
@end table
2107
 
2108
@node Interrupt Configuration
2109
@subsection Interrupt Configuration
2110
@cindex configuring the interrupt controller
2111
@cindex interrupt controller configuration
2112
@cindex programmable interrupt controller configuration
2113
@cindex PIC configuration
2114
@cindex @code{section pic}
2115
Programmable Interrupt Controller (PIC) configuration is described in
2116 82 jeremybenn
@code{section pic}.  This section may appear at most
2117 19 jeremybenn
once---@value{OR1KSIM} has no mechanism for handling multiple
2118 82 jeremybenn
interrupt controllers.  The following parameters may be specified.
2119 19 jeremybenn
 
2120
@table @code
2121
 
2122
@item enabled = 0|1
2123
@cindex @code{enabled} (interrupt controller)
2124 82 jeremybenn
If 1 (true), the programmable interrupt controller is enabled.  If 0
2125 19 jeremybenn
(the default), it is disabled.
2126
 
2127
@item edge_trigger = 0|1
2128
@cindex @code{edge_trigger} (interrupt controller)
2129
If 1 (true, the default), the programmable interrupt controller is
2130 82 jeremybenn
edge triggered.  If 0 (false), it is level triggered.
2131 19 jeremybenn
 
2132 432 jeremybenn
The library interface (@pxref{Simulator Library, , Simulator Library})
2133
provides different functions for setting the different types of
2134
interrupt, and a function to clear level sensitive interrupts. Edge
2135
sensitive interrupts must be cleared by clearing the corresponding bit
2136
in the PICSR SPR.
2137 430 julius
 
2138 432 jeremybenn
Internal functions to set and clear interrupts are also provided for
2139 440 jeremybenn
peripherals implemented within @value{OR1KSIM}. @xref{Interrupts Internal, ,
2140 432 jeremybenn
Interrupts Internal} for more details.
2141 430 julius
 
2142 432 jeremybenn
@item use_nmi = 0|1
2143
@cindex @code{use_nmi} (interrupt controller)
2144
If 1 (true, the default), interrupt lines 0 and 1 are non-maskable. In
2145
other words the least significant 2 bits of the PICMR SPR are hard-wired
2146
to 1.  If 0 (false), all interrupt lines are treated as equivalent.
2147
 
2148
@quotation Note
2149
These are not non-maskable in the true sense that they will pre-empt
2150
other interrupts.  Rather they can never be masked out using the PICMR
2151
register. It is up the interrupt exception handler to give these
2152
interrupt lines priority, and indeed to decide on the priority order in
2153
general.
2154 430 julius
@end quotation
2155
 
2156 19 jeremybenn
@end table
2157
 
2158
@node Power Management Configuration
2159
@subsection Power Management Configuration
2160
@cindex configuring power management
2161
@cindex power management configuration
2162
@cindex PMU configuration
2163
@cindex @code{section pmu}
2164 82 jeremybenn
Power management implementation is incomplete.  At present the effect
2165 19 jeremybenn
(which only happens when the power management unit is enabled) of
2166
setting the different bits in the power management Special Purpose
2167
Register (PMR, SPR 0x4000) is
2168
 
2169
@table @code
2170
 
2171
@item SDF (bit mask 0x0000000f)
2172
@cindex SDF (power management register)
2173
@cindex slow down factor (power management register)
2174
@cindex power management register, SDF
2175
@cindex PMR - SDF
2176
No effect - these bits are ignored
2177
 
2178
@item DME (bit mask 0x00000010)
2179
@cindex DME (power management register)
2180
@cindex doze mode (power management register)
2181
@cindex power management register, DME
2182
@cindex PMR - DME
2183
@itemx SME (bit mask 0x00000020)
2184
@cindex SME (power management register)
2185
@cindex sleep mode (power management register)
2186
@cindex power management register, SME
2187
@cindex PMR - SME
2188
Both these bits cause the processor to stop executing
2189 82 jeremybenn
instructions.  However all other functions (debug interaction, CLI,
2190 19 jeremybenn
VAPI etc) carry on as normal.
2191
 
2192
@item DCGE (bit mask 0x00000004)
2193
@cindex DCGE (power management register)
2194
@cindex dynamic clock gating (power management register)
2195
@cindex power management register, DGCE
2196
@cindex PMR - DGCE
2197
No effect - this bit is ignored
2198
 
2199
@item SUME (bit mask 0x00000008)
2200
@cindex SUME (power management register)
2201
@cindex suspend mode (power management register)
2202
@cindex power management register, SUME
2203
@cindex PMR - SUME
2204
Enabling this bit causes a message to be printed, advising that the
2205
processor is suspending and the simulator exits.
2206
 
2207
@end table
2208
 
2209
On reset all bits are cleared.
2210
 
2211 82 jeremybenn
Power management configuration is described in @code{section pm}.  This
2212
section may appear at most once.  The following parameter may be specified.
2213 19 jeremybenn
 
2214
@table @code
2215
 
2216
@item enabled = 0|1
2217
@cindex @code{enabled} (power management configuration)
2218 82 jeremybenn
If 1 (true), power management is enabled.  If 0 (the default), it is
2219 19 jeremybenn
disabled.
2220
 
2221
@end table
2222
 
2223
@node Branch Prediction Configuration
2224
@subsection Branch Prediction Configuration
2225
@cindex configuring branch prediction
2226
@cindex branch prediction configuration
2227
@cindex BPB configuration
2228
@cindex @code{section bpb}
2229
From examining the code base, it seems the branch prediction function
2230 82 jeremybenn
is not fully implemented.  At present the functionality seems
2231 19 jeremybenn
restricted to collection of statistics.
2232
 
2233 82 jeremybenn
Branch prediction configuration is described in @code{section bpb}.  This
2234
section may appear at most once.  The following parameters may be specified.
2235 19 jeremybenn
 
2236
@table @code
2237
 
2238
@item enabled = 0|1
2239
@cindex @code{enabled} (branch prediction configuration)
2240 82 jeremybenn
If 1 (true), branch prediction is enabled.  If 0 (the default), it is
2241 19 jeremybenn
disabled.
2242
 
2243
@item btic = 0|1
2244
@cindex @code{btic} (branch prediction configuration)
2245 82 jeremybenn
If 1 (true), the branch target instruction cache model is enabled.  If
2246 19 jeremybenn
 
2247
 
2248
@item sbp_bf_fwd = 0|1
2249
@cindex @code{sbp_bf_fwd} (branch prediction configuration)
2250 82 jeremybenn
If 1 (true), use forward prediction for the @code{l.bf} instruction.  If
2251 19 jeremybenn
 
2252
 
2253
@item sbp_bnf_fwd = 0|1
2254
@cindex @code{sbp_bnf_fwd} (branch prediction configuration)
2255 82 jeremybenn
If 1 (true), use forward prediction for the @code{l.bnf} instruction.  If
2256 19 jeremybenn
 
2257
 
2258
@item hitdelay = @var{value}
2259
@cindex @code{hitdelay} (branch prediction configuration)
2260 82 jeremybenn
Set the number of cycles a branch prediction hit costs.  Default value
2261 19 jeremybenn
0.
2262
 
2263
@item missdelay = @var{value}
2264
@cindex @code{missdelay} (branch prediction configuration)
2265 82 jeremybenn
Set the number of cycles a branch prediction miss costs.  Default value
2266 19 jeremybenn
0.
2267
 
2268
@end table
2269
 
2270
@node Debug Interface Configuration
2271
@subsection Debug Interface Configuration
2272
@cindex configuring the debug unit and interface to external debuggers
2273
@cindex debug unit configuration
2274
@cindex debug interface configuration
2275
@cindex @code{section debug}
2276
The debug unit and debug interface configuration is described in
2277 82 jeremybenn
@code{@w{section debug}}.  This section may appear at most once.  The
2278 19 jeremybenn
following parameters may be specified.
2279
 
2280
@table @code
2281
 
2282
@item enabled = 0|1
2283
@cindex @code{enabled} (debug interface configuration)
2284 82 jeremybenn
If 1 (true), the debug unit is enabled.  If 0 (the default), it is disabled.
2285 19 jeremybenn
 
2286
@quotation Note
2287
This enables the functionality of the debug unit (its registers etc) within
2288 82 jeremybenn
the mode.  It does not provide any external interface to the debug unit.
2289
For
2290 235 jeremybenn
that, see @code{rsp_enabled} below.
2291 19 jeremybenn
@end quotation
2292
 
2293
@item rsp_enabled = 0|1
2294
@cindex @code{rsp_enabled} (debug interface configuration)
2295
@cindex Remote Serial Protocol
2296
If 1 (true), the GDB @dfn{Remote Serial Protocol} server is started, provding
2297
an interface to an external GNU debugger, using the port specified in the
2298
@code{rsp_port} field (see below), or the @code{or1ksim-rsp} TCP/IP
2299 82 jeremybenn
service.  If 0 (the default), the server is not started, and no external
2300 19 jeremybenn
interface is provided.
2301
 
2302
For more detailed information on the interface to the GNU Debugger see
2303
Embecosm Application Note 2, @cite{Howto: Porting the GNU Debugger Practical
2304
Experience with the OpenRISC 1000 Architecture}, by Jeremy Bennett, published
2305
by Embecosm Limited (@url{www.embecosm.com}).
2306
 
2307
@item rsp_port = @var{value}
2308
@cindex @code{rsp_port} (debug interface configuration)
2309
@var{value} specifies the port to be used for the GDB @dfn{Remote Serial
2310 82 jeremybenn
Protocol} interface to the GNU Debugger (GDB).  Default value 51000.  If
2311 19 jeremybenn
the value 0 is specified, @value{OR1KSIM} will instead look for a TCP/IP
2312
service named @code{or1ksim-rsp}.
2313
 
2314
@quotation Tip
2315
@cindex TCP/IP port range for @code{or1ksim-rsp} service
2316
There is no registered port for @value{OR1KSIM} @dfn{Remote Serial Protocol}
2317 82 jeremybenn
service @code{or1ksim-rsp}.  Good practice suggests users should adopt port
2318
values in the @dfn{Dynamic} or @dfn{Private} port range, i.e.  49152-65535.
2319 19 jeremybenn
@end quotation
2320
 
2321
@item vapi_id = @var{value}
2322
@cindex @code{vapi_id} (debug interface configuration)
2323
@var{value} specifies the value of the Verification API (VAPI) base
2324 82 jeremybenn
address to be used with the debug unit.  @xref{Verification API, ,
2325 19 jeremybenn
Verification API}, for more details.
2326
 
2327
If this is specified and @var{value} is non-zero, all OpenRISC Remote
2328
JTAG protocol transactions will be logged to the VAPI log file, if
2329 82 jeremybenn
enabled.  This is the only functionality associated with VAPI for the
2330
debug unit.  No VAPI commands are sent, nor requests handled.
2331 19 jeremybenn
 
2332
@end table
2333
 
2334
@node Peripheral Configuration
2335
@section Configuring Memory Mapped Peripherals
2336
 
2337 82 jeremybenn
All peripheral components are optional.  If they are specified, then
2338 19 jeremybenn
(unlike other components) by default they are enabled.
2339
 
2340
@menu
2341
* Memory Controller Configuration::
2342
* UART Configuration::
2343
* DMA Configuration::
2344
* Ethernet Configuration::
2345
* GPIO Configuration::
2346
* Display Interface Configuration::
2347
* Frame Buffer Configuration::
2348
* Keyboard Configuration::
2349
* Disc Interface Configuration::
2350
* Generic Peripheral Configuration::
2351
@end menu
2352
 
2353
@node Memory Controller Configuration
2354
@subsection Memory Controller Configuration
2355
@cindex configuring the memory controller
2356
@cindex memory controller configuration
2357
@cindex @code{section mc}
2358
The memory controller used in @value{OR1KSIM} is the component
2359 98 jeremybenn
implemented at OpenCores, and found in the top level SVN directory,
2360 82 jeremybenn
@file{mem_ctrl}.  It is described in the document @cite{Memory
2361 19 jeremybenn
Controller IP Core} by Rudolf Usselmann, which can be found in the
2362 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
2363 19 jeremybenn
resides on the main OpenRISC Wishbone data bus.
2364
 
2365
The memory controller configuration is described in @code{@w{section
2366 82 jeremybenn
mc}}.  This section may appear multiple times, specifying multiple
2367 98 jeremybenn
memory controllers.
2368 19 jeremybenn
 
2369 385 jeremybenn
@quotation Warning
2370
There are known to be problems with the current memory controller, which
2371
currently is not included in the regression test suite. Users are
2372
advised not to use the memory controller in the current release.
2373
@end quotation
2374
 
2375 98 jeremybenn
@quotation Caution
2376 385 jeremybenn
There is no initialization code in the standard @dfn{newlib}
2377
library.
2378 98 jeremybenn
 
2379 385 jeremybenn
The standard @dfn{uClibc} library assumes a memory controller
2380
mapped at 0x93000000 and will initialize the memory controller to expect
2381
64MB memory blocks, and any memory declarations @emph{must} reflect
2382
this.
2383
 
2384 98 jeremybenn
If smaller memory blocks are declared with a memory controller, then
2385
sufficient memory will not be allocated by @value{OR1KSIM}, but out of
2386 346 jeremybenn
range memory accesses will not be trapped.  For example declaring a
2387 98 jeremybenn
memory section from 0-4MB with a memory controller enabled would mean
2388
that accesses between 4MB and 64MB would be permitted, but having no
2389
allocated memory would likely cause a segmentation fault.
2390
 
2391
If the user is determined to use smaller memories with the memory
2392
controller, then custom initialization code must be provided, to
2393
ensure the memory controller traps out-of-memory accesses.
2394
@end quotation
2395
 
2396
The following parameters may be specified.
2397
 
2398 19 jeremybenn
@table @code
2399
 
2400
@item enabled = 0|1
2401
@cindex @code{enabled} (memory controller configuration)
2402 82 jeremybenn
If 1 (true, the default), this memory controller is enabled.  If 0, it is
2403 19 jeremybenn
disabled.
2404
 
2405
@quotation Note
2406
The memory controller can effectively also be disabled by setting an
2407 82 jeremybenn
appropriate power on control register value (see below).  However this
2408 19 jeremybenn
should only be used if it is desired to specifically model this
2409
behavior of the memory controller, not as a way of disabling the
2410
memory controller in general.
2411
@end quotation
2412
 
2413
@item baseaddr = @var{value}
2414
@cindex @code{baseaddr} (memory controller configuration)
2415
Set the base address of the memory controller's memory mapped
2416 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2417 19 jeremybenn
sensible value.
2418
 
2419
The memory controller has a 7 bit address bus, with a total of 19
2420
32-bit registers, at addresses 0x00 through 0x4c (address 0x0c and
2421
addresses 0x50 through 0x7c are not used).
2422
 
2423
@item poc = @var{value}
2424
@cindex @code{poc} (memory controller configuration)
2425
Specifies the value of the power on control register, The least
2426
signficant two bits specify the bus width (use 0 for an 8-bit bus, 1
2427
for a 16-bit bus and 2 for a 32-bit bus) and the next two bits the
2428
type of memory connected (use 0 for a disabled interface, 1 for SSRAM,
2429
2 for asyncrhonous devices and 3 for synchronous devices).
2430
 
2431
If other bits are specified, they are ignored with a warning.
2432
 
2433
@quotation Caution
2434
The default value, 0, corresponds to a disabled 8-bit bus, and
2435
is likely not the most suitable value
2436
@end quotation
2437
 
2438
@item index = @var{value}
2439
@cindex @code{index} (memory controller configuration)
2440
Specify the index of this memory controller amongst all the memory
2441 82 jeremybenn
controllers.  This value should be unique for each memory controller,
2442 19 jeremybenn
and is used to associate specific memories with the controller,
2443
through the @code{mc} field in the @code{@w{section memory}}
2444
configuration (@pxref{Memory Configuration, , Memory Configuration}).
2445
 
2446
The default value, 0, is suitable when there is only one memory controller.
2447
 
2448
@end table
2449
 
2450
@node UART Configuration
2451
@subsection UART Configuration
2452
@cindex configuring the UART
2453
@cindex UART configuration
2454
@cindex @code{section uart}
2455
The UART implemented in @value{OR1KSIM} follows the specification of the
2456 82 jeremybenn
National Semiconductor 16450 and 16550 parts.  It is a memory mapped
2457 19 jeremybenn
component, which resides on the main OpenRISC Wishbone data bus.
2458
 
2459
The component provides a number of interfaces to emulate the behavior
2460
of an external terminal connected to the UART.
2461
 
2462 82 jeremybenn
UART configuration is described in @code{section uart}.  This section
2463
may appear multiple times, specifying multiple UARTs.  The following
2464 19 jeremybenn
parameters may be specified.
2465
 
2466
@table @code
2467
 
2468
@item enabled = 0|1
2469
@cindex @code{enabled} (UART configuration)
2470 82 jeremybenn
If 1 (true, the default), this UART is enabled.  If 0, it is disabled.
2471 19 jeremybenn
 
2472
@item baseaddr = @var{value}
2473
@cindex @code{baseaddr} (UART configuration)
2474
Set the base address of the UART's memory mapped
2475 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2476 19 jeremybenn
sensible value.
2477
 
2478
The UART has a 3 bit address bus, with a total of 8 8-bit registers,
2479
at addresses 0x0 through 0x7.
2480
 
2481
@item channel = "@var{type}:@var{args}"
2482
@cindex @code{channel} (UART configuration)
2483
Specify the channel representing the terminal connected to the UART
2484
Rx & Tx pins.
2485
 
2486
@table @code
2487
 
2488
@item channel="file:@file{rxfile},@file{txfile}"
2489
@cindex UART I/O from/to files
2490
Read input characters from the file @file{rxfile} and write output
2491
characters to the file @file{txfile} (which will be created if
2492
required).
2493
 
2494
@item channel="xterm:@var{args}"
2495
@cindex UART I/O from/to an @command{xterm}
2496
Create an xterm on startup, write UART Tx traffic to the xterm and
2497
take Rx traffic from the keyboard when the xterm window is
2498 82 jeremybenn
selected.  Additional arguments to the xterm command (for example
2499 19 jeremybenn
specifying window size may be specified in @var{args}, or this may be
2500
left blank.
2501
 
2502
@item channel="tcp:@var{value}"
2503
@cindex UART I/O from/to TCP/IP
2504
Open the TCP/IP port specified by @var{value} and read and write UART
2505
traffic from and to it.
2506
 
2507
Typically a telnet session is connected to the other end of this port.
2508
 
2509
@quotation Tip
2510
There is no registered port for @value{OR1KSIM} telnet UART
2511 82 jeremybenn
connection.  Priviledged access is required to read traffic on the
2512
registered ``well-known'' telnet port (23).  Instead users should use
2513 19 jeremybenn
port values in the @dfn{Dynamic} or @dfn{Private} port range,
2514 82 jeremybenn
i.e.  49152-65535.
2515 19 jeremybenn
@end quotation
2516
 
2517
@item channel="fd:@code{rxfd},@code{txfd}"
2518
@cindex UART I/O from/to open file descriptors
2519
Read and write characters from and to the existing open numerical file
2520
descriptors, file @code{rxfd} and @code{txfd}.
2521
 
2522
@item channel="tty:device=/dev/ttyS0,baud=9600"
2523
@cindex UART I/O from/to a physical serial port
2524 82 jeremybenn
Read and write characters from and to a physical serial port.  The
2525 19 jeremybenn
precise device (shown here as @code{/dev/ttyS0}) may vary from machine
2526
to machine.
2527
 
2528
@end table
2529
 
2530
The default value for this field is @code{"xterm:"}.
2531
 
2532
@item irq = @var{value}
2533
@cindex @code{irq} (UART configuration)
2534 82 jeremybenn
Use @var{value} as the IRQ number of this UART.  Default value 0.
2535 19 jeremybenn
 
2536
@item 16550 = 0|1
2537
@cindex @code{16550} (UART configuration)
2538 82 jeremybenn
If 1 (true), the UART has the functionality of a 16550.  If 0 (the
2539
default), it has the functionality of a 16450.  The principal
2540 19 jeremybenn
difference is that the 16550 can buffer multiple characters.
2541
 
2542
@item jitter = @var{value}
2543
@cindex @code{jitter} (UART configuration)
2544
Set the jitter, modeled as a time to block, to @var{value}
2545 82 jeremybenn
milliseconds.  Set to -1 to disable jitter modeling.  Default value 0.
2546 19 jeremybenn
 
2547
@quotation Note
2548
This functionality has yet to be implemented, so this parameter has no
2549
effect.
2550
@end quotation
2551
 
2552
@item vapi_id = @var{value}
2553
@cindex @code{vapi_id} (UART configuration)
2554
@var{value} specifies the value of the Verification API (VAPI) base
2555 82 jeremybenn
address to be used with the UART.  @xref{Verification API, ,
2556 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2557
with the UART.
2558
 
2559
@end table
2560
 
2561
@node DMA Configuration
2562
@subsection DMA Configuration
2563
@cindex configuring DMA
2564
@cindex DMA configuration
2565
@cindex @code{section dma}
2566
The DMA controller used in @value{OR1KSIM} is the component
2567 98 jeremybenn
implemented at OpenCores, and found in the top level SVN directory,
2568 82 jeremybenn
@file{wb_dma}.  It is described in the document @cite{Wishbone
2569 19 jeremybenn
DMA/Bridge IP Core} by Rudolf Usselmann, which can be found in the
2570 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
2571
resides on the main OpenRISC Wishbone data bus.  The present
2572 19 jeremybenn
implementation is incomplete, intended only to support the Ethernet
2573
interface (@pxref{Ethernet Configuration}), although the Ethernet
2574
interface is not yet completed.
2575
 
2576 82 jeremybenn
DMA configuration is described in @code{@w{section dma}}.  This section
2577
may appear multiple times, specifying multiple DMA controllers.  The
2578 19 jeremybenn
following parameters may be specified.
2579
 
2580
@table @code
2581
 
2582
@item enabled = 0|1
2583
@cindex @code{enabled} (DMA configuration)
2584 82 jeremybenn
If 1 (true, the default), this DMA controller is enabled.  If 0, it is disabled.
2585 19 jeremybenn
 
2586
@item baseaddr = @var{value}
2587
@cindex @code{baseaddr} (DMA configuration)
2588
Set the base address of the DMA's memory mapped
2589 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2590 19 jeremybenn
sensible value.
2591
 
2592
The DMA controller has a 10 bit address bus, with a total of 253
2593 82 jeremybenn
32-bit registers.  The first 5 registers at addresses 0x000 through
2594
0x010 control the overall behavior of the DMA controller.  There are
2595 19 jeremybenn
then 31 blocks of 8 registers, controlling each of the 31 DMA channels
2596 82 jeremybenn
available.  Addresses 0x014 through 0x01c are not used.
2597 19 jeremybenn
 
2598
@item irq = @var{value}
2599
@cindex @code{irq} (DMA configuration)
2600 82 jeremybenn
Use @var{value} as the IRQ number of this DMA controller.  Default value 0.
2601 19 jeremybenn
 
2602
@item vapi_id = @var{value}
2603
@cindex @code{vapi_id} (DMA configuration)
2604
@var{value} specifies the value of the Verification API (VAPI) base
2605 82 jeremybenn
address to be used with the DMA controller.  @xref{Verification API, ,
2606 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2607
with the DMA controller.
2608
 
2609
@end table
2610
 
2611
@node Ethernet Configuration
2612
@subsection Ethernet Configuration
2613
@cindex configuring the Ethernet interface
2614
@cindex Ethernet configuration
2615
@cindex @code{section ethernet}
2616 82 jeremybenn
Ethernet configuration is described in @code{section ethernet}.  This
2617 19 jeremybenn
section may appear multiple times, specifying multiple Ethernet
2618 82 jeremybenn
interfaces.  The following parameters may be specified.
2619 19 jeremybenn
 
2620 440 jeremybenn
The Ethernet MAC used in @value{OR1KSIM} corresponds to the Verilog
2621
implementation in project @dfn{ethmac}. It's source code can be found in
2622
the top level SVN directory, @file{ethmac}.  It also forms part of the
2623
OpenRISC reference SoC, ORPSoC.  It is described in the document
2624
@cite{Ethernet IP Core Specification} by Igor Mohor, which can be found
2625
in the @file{doc} subdirectory.  It is a memory mapped component, which
2626
resides on the main OpenRISC Wishbone data bus.
2627
 
2628 19 jeremybenn
@table @code
2629
 
2630
@item enabled = 0|1
2631
@cindex @code{enabled} (Ethernet configuration)
2632 82 jeremybenn
If 1 (true, the default), this Ethernet MAC is enabled.  If 0, it is
2633 19 jeremybenn
disabled.
2634
 
2635
@item baseaddr = @var{value}
2636
@cindex @code{baseaddr} (Ethernet configuration)
2637
Set the base address of the MAC's memory mapped registers to
2638 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
2639 19 jeremybenn
 
2640
The Ethernet MAC has a 7-bit address bus, with a total of 21
2641 82 jeremybenn
32-bit registers.  Addresses 0x54 through 0x7c are not used.
2642 19 jeremybenn
 
2643
@quotation Note
2644
The Ethernet specification describes a Tx control register,
2645 82 jeremybenn
@code{TXCTRL}, at address 0x50.  However this register is not
2646 19 jeremybenn
implemented in the @value{OR1KSIM} model.
2647
@end quotation
2648
 
2649
@item dma = @var{value}
2650
@cindex @code{dma} (Ethernet configuration)
2651
@var{value} specifies the DMA controller with which this Ethernet is
2652 82 jeremybenn
associated.  The default value is 0.
2653 19 jeremybenn
 
2654
@quotation Note
2655
Support for external DMA is not provided in the current
2656 82 jeremybenn
implementation, and this value is ignored.  In any case there is no
2657 19 jeremybenn
equivalent field to which this can be matched in the current DMA
2658
component implementation (@pxref{DMA Configuration, , DMA
2659
Configuration}).
2660
@end quotation
2661
 
2662
@item irq = @var{value}
2663
@cindex @code{dma} (Ethernet configuration)
2664 82 jeremybenn
Use @var{value} as the IRQ number of this Ethernet MAC.  Default value 0.
2665 19 jeremybenn
 
2666 440 jeremybenn
@item rtx_type = "file"|"tap"
2667 19 jeremybenn
@cindex @code{rtx_type} (Ethernet configuration)
2668 440 jeremybenn
Specifies whether to use a TUN/TAP interface or file interface (the default)
2669
to model the external connection of the Ethernet.
2670
 
2671
If a TUN/TAP interface is requested, Ethernet packets will be sent and
2672
received through the pesistent TAP interface specified in parameter
2673
@code{tap_dev} (see below).
2674
 
2675
More details on configuring the TUN/TAP interface are given in the Usage
2676
section (@pxref{Ethernet TUN/TAP Interface, , Ethernet TUN/TAP
2677
Interface}).
2678
 
2679
If a file interface (the default), is requested, the Ethernet will be
2680
modelled by reading and writing from and to the files specified in the
2681 19 jeremybenn
@code{rxfile} and @code{txfile} parameters (see below).
2682
 
2683 440 jeremybenn
@quotation Caution
2684
If a file interface is specified, @value{OR1KSIM} will terminate once the
2685
receive file specified by @code{rxfile} is exhausted.
2686 19 jeremybenn
@end quotation
2687
 
2688
@item rx_channel = @var{rxvalue}
2689
@cindex @code{rx_channel} (Ethernet configuration)
2690
@itemx tx_channel = @var{txvalue}
2691
@cindex @code{tx_channel} (Ethernet configuration)
2692
@var{rxvalue} specifies the DMA channel to use for receive and
2693 82 jeremybenn
@var{txvalue} the DMA channel to use for transmit.  Both default to 0.
2694 19 jeremybenn
 
2695
@quotation Note
2696
As noted above, support for external DMA is not provided in the
2697
current implementation, and so these values are ignored.
2698
@end quotation
2699
 
2700
@item rxfile = "@var{rxfile}"
2701
@cindex @code{rxfile} (Ethernet configuration)
2702
@itemx txfile = "@var{txfile}"
2703
@cindex @code{txfile} (Ethernet configuration)
2704
When @code{rtx_type} is 0 (see above), @var{rxfile} specifies the file
2705
to use as input and @var{txfile} specifies the fie to use as
2706
output.
2707
 
2708 82 jeremybenn
The file contains a sequence of packets.  Each packet consists of a
2709
packet length (32 bits), followed by that many bytes of data.  Once the
2710 19 jeremybenn
input file is empty, the Ethernet MAC behaves as though there were no
2711 82 jeremybenn
data on the Ethernet.  The default values of these parameters are
2712 19 jeremybenn
@code{"eth_rx"} and @code{"eth_tx"} respectively.
2713
 
2714 82 jeremybenn
The input file must exist and be readable.  The output file must be
2715
writable and will be created if necessary.  If either of these
2716 19 jeremybenn
conditions is not met, a warning will be given.
2717
 
2718 440 jeremybenn
@quotation Caution
2719
@value{OR1KSIM} will terminate once the @var{rxfile} is exhausted.
2720
@end quotation
2721 19 jeremybenn
 
2722 440 jeremybenn
@item tap_dev = "@var{tap}"
2723
@cindex @code{tap_dev} (Ethernet configuration)
2724
When @code{rtx_type} is @code{"tap"} (see above), @var{tap_dev}
2725
specifies the TAP device to use for communication.  This should be a
2726
persistent TAP device configured for the system (@pxref{Ethernet TUN/TAP
2727
Interface, , Ethernet TUN/TAP Interface})
2728
 
2729 19 jeremybenn
@item vapi_id = @var{value}
2730
@cindex @code{vapi_id} (DMA configuration)
2731
@var{value} specifies the value of the Verification API (VAPI) base
2732 82 jeremybenn
address to be used with the Ethernet PHY.  @xref{Verification API, ,
2733 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2734
with the DMA controller.
2735
 
2736 428 julius
@item phy_addr = @var{value}
2737
@cindex @code{phy_addr}
2738 440 jeremybenn
@var{value} specifies the address for emulated ethernet PHY (default
2739
0). If there are multiple Ethernet peripherals, they should each have a
2740
different PHY value.
2741 428 julius
 
2742 19 jeremybenn
@end table
2743
 
2744
@node GPIO Configuration
2745
@subsection GPIO Configuration
2746
@cindex configuring the GPIO
2747
@cindex GPIO configuration
2748
@cindex @code{section cpio}
2749
The GPIO used in @value{OR1KSIM} is the component implemented at
2750 98 jeremybenn
OpenCores, and found in the top level SVN directory, @file{gpio}.  It
2751 19 jeremybenn
is described in the document @cite{GPIO IP Core Specification} by
2752
Damjan Lampret and Goran Djakovic, which can be found in the
2753 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
2754 19 jeremybenn
resides on the main OpenRISC Wishbone data bus.
2755
 
2756 82 jeremybenn
GPIO configuration is described in @code{@w{section gpio}}.  This section
2757
may appear multiple times, specifying multiple GPIO devices.  The
2758 19 jeremybenn
following parameters may be specified.
2759
 
2760
@table @code
2761
 
2762
@item enabled = 0|1
2763
@cindex @code{enabled} (GPIO configuration)
2764 82 jeremybenn
If 1 (true, the default), this GPIO is enabled.  If 0, it is disabled.
2765 19 jeremybenn
 
2766
@item baseaddr = @var{value}
2767
@cindex @code{baseaddr} (GPIO configuration)
2768
Set the base address of the GPIO's memory mapped
2769 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2770 19 jeremybenn
sensible value.
2771
 
2772
The GPIO has a 6 bit address bus, with a total of 10 32-bit registers,
2773 82 jeremybenn
although the number of bits that are actively used varies.  Addresses
2774 19 jeremybenn
0x28 through 0x3c are not used.
2775
 
2776
@item irq = @var{value}
2777
@cindex @code{irq} (GPIO configuration)
2778 82 jeremybenn
Use @var{value} as the IRQ number of this GPIO.  Default value 0.
2779 19 jeremybenn
 
2780
@item vapi_id = @var{value}
2781
@cindex @code{vapi_id} (GPIO configuration)
2782
@cindex @code{base_vapi_id} (GPIO configuration - deprecated)
2783
@var{value} specifies the value of the Verification API (VAPI) base
2784 82 jeremybenn
address to be used with the GPIO.  @xref{Verification API, ,
2785 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2786 82 jeremybenn
with the GPIO controller.  For backwards compatibility, the
2787 19 jeremybenn
alternative name @code{base_vapi_id} is supported for this parameter,
2788
but deprecated.
2789
 
2790
@end table
2791
 
2792
@node Display Interface Configuration
2793
@subsection Display Interface Configuration
2794
@cindex configuring the VGA interface
2795
@cindex display interface configuration
2796
@cindex VGA configuration
2797
@cindex @code{section vga}
2798
@value{OR1KSIM} models a VGA interface to an external monitor.  The
2799
VGA controller used in @value{OR1KSIM} is the component implemented at
2800 98 jeremybenn
OpenCores, and found in the top level SVN directory, @file{vga_lcd},
2801 82 jeremybenn
with no support for the optional hardware cursors.  It is described in
2802 19 jeremybenn
the document @cite{VGA/LCD Core v2.0 Specifications} by Richard
2803 82 jeremybenn
Herveille, which can be found in the @file{doc} subdirectory.  It is a
2804 19 jeremybenn
memory mapped component, which resides on the main OpenRISC Wishbone
2805
data bus.
2806
 
2807
The current implementation provides only functionality to dump the
2808
screen to a file at intervals.
2809
 
2810
VGA controller configuration is described in @code{@w{section
2811 82 jeremybenn
vga}}.  This section may appear multiple times, specifying multiple
2812
VGA controllers.  The following parameters may be specified.
2813 19 jeremybenn
 
2814
@table @code
2815
 
2816
@item enabled = 0|1
2817
@cindex @code{enabled} (VGA configuration)
2818 82 jeremybenn
If 1 (true, the default), this VGA is enabled.  If 0, it is disabled.
2819 19 jeremybenn
 
2820
@item baseaddr = @var{value}
2821
@cindex @code{baseaddr} (VGA configuration)
2822
Set the base address of the VGA controller's memory mapped
2823 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2824 19 jeremybenn
sensible value.
2825
 
2826
The VGA controller has a 12-bit address bus, with 7 32-bit registers, at
2827
addresses 0x000 through 0x018, and two color lookup tables at
2828 82 jeremybenn
addresses 0x800 through 0xfff.  The hardware cursor registers are not
2829 19 jeremybenn
implemented, so addresses 0x01c through 0x7fc are not used.
2830
 
2831
@item irq = @var{value}
2832
@cindex @code{irq} (VGA configuration)
2833 82 jeremybenn
Use @var{value} as the IRQ number of this VGA controller.  Default
2834 19 jeremybenn
value 0.
2835
 
2836
@item refresh_rate = @var{value}
2837
@cindex @code{refresh_rate} (VGA configuration)
2838 82 jeremybenn
@var{value} specifies number of cycles between screen dumps.  Default
2839 19 jeremybenn
value is derived from the simulation clock cycle time
2840
(@pxref{Simulator Behavior, , Simulator Behavior}), to correspond
2841
to dumping 50 times per simulated second.
2842
 
2843
@item txfile = "@var{file}"
2844
@cindex @code{txfile} (VGA configuration)
2845
@cindex @code{filename} (VGA configuration - deprecated)
2846
@var{file} specifies the base of the filename for screen
2847 82 jeremybenn
dumps.  Successive screen dumps will be in BMP format, in files with
2848 19 jeremybenn
the name @file{@var{file}@var{nnnn}.bmp}, where @var{nnnn} is a
2849 82 jeremybenn
sequential count of the screen dumps starting at zero.  The default
2850
value is @code{"vga_out"}.  For backwards compatibility, the
2851 19 jeremybenn
alternative name @code{filename} is supported for this parameter,
2852
but deprecated.
2853
 
2854
@end table
2855
 
2856
@node Frame Buffer Configuration
2857
@subsection Frame Buffer Configuration
2858
@cindex configuring the frame buffer
2859
@cindex frame buffer configuration
2860
@cindex @code{section fb}
2861
@quotation Caution
2862 82 jeremybenn
The frame buffer is only partially implemented.  Its configuration
2863 19 jeremybenn
fields are described here, but the component should not be used at
2864 82 jeremybenn
this time.  Like the VGA controller, it is designed to make screen
2865 19 jeremybenn
dumps to file.
2866
@end quotation
2867
 
2868 82 jeremybenn
Frame buffer configuration is described in @code{section fb}.  This
2869 19 jeremybenn
section may appear multiple times, specifying multiple frame
2870 82 jeremybenn
buffers.  The following parameters may be specified.
2871 19 jeremybenn
 
2872
@table @code
2873
 
2874
@item enabled = 0|1
2875
@cindex @code{enabled} (frame buffer configuration)
2876 82 jeremybenn
If 1 (true, the default), this frame buffer is enabled.  If 0, it is disabled.
2877 19 jeremybenn
 
2878
@item baseaddr = @var{value}
2879
@cindex @code{baseaddr} (frame buffer configuration)
2880
Set the base address of the frame buffer's memory mapped registers to
2881 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
2882 19 jeremybenn
 
2883
The frame buffer has an 121-bit address bus, with 4 32-bit registers,
2884
at addresses 0x000 through 0x00c, and a PAL lookup table at addresses
2885 82 jeremybenn
0x400 through 0x4ff.  Addresses 0x010 through 0x3fc and addresses 0x500
2886 19 jeremybenn
through 0x7ff are not used.
2887
 
2888
@item refresh_rate = @var{value}
2889
@cindex @code{refresh_rate} (frame buffer configuration)
2890 82 jeremybenn
@var{value} specifies number of cycles between screen dumps.  Default
2891 19 jeremybenn
value is derived from the simulation clock cycle time
2892
(@pxref{Simulator Behavior, , Simulator Behavior}), to correspond to
2893
dumping 50 times per simulated second.
2894
 
2895
@item txfile = "@var{file}"
2896
@cindex @code{txfile} (frame buffer configuration)
2897
@cindex @code{filename} (frame buffer configuration - deprecated)
2898
@var{file} specifies the base of the filename for screen
2899 82 jeremybenn
dumps.  Successive screen dumps will be in BMP format, in files with
2900 19 jeremybenn
the name @file{@var{file}@var{nnnn}.bmp}, where @var{nnnn} is a
2901 82 jeremybenn
sequential count of the screen dumps starting at zero.  The default
2902
value is @code{"fb_out"}.  For backwards compatibility, the
2903 19 jeremybenn
alternative name @code{filename} is supported for this parameter,
2904
but deprecated.
2905
 
2906
@end table
2907
 
2908
@node Keyboard Configuration
2909
@subsection Keyboard Configuration (PS2)
2910
@cindex configuring the keyboard interface
2911
@cindex configuring the PS2 interface
2912
@cindex keyboard configuration
2913
@cindex PS2 configuration
2914
@cindex @code{section kb}
2915 82 jeremybenn
The PS2 interface provided by @value{OR1KSIM} is not documented.  It
2916 19 jeremybenn
may be based on the PS2 project at OpenCores, and found in
2917 98 jeremybenn
the top level SVN directory, @file{ps2}.  However this project lacks
2918 82 jeremybenn
any documentation beyond its project webpage.  Since most PS2
2919 19 jeremybenn
interfaces follow the Intel i8042 standard, this is presumably what is
2920
expected with this device.
2921
 
2922
The implementation only provides for keyboard support, which is
2923 82 jeremybenn
modelled as a file of keystrokes.  There is no mouse support.
2924 19 jeremybenn
 
2925
@quotation Caution
2926
A standard i8042 device has two registers at addresses 0x60 (command)
2927 82 jeremybenn
and 0x64 (status).  Inspection of the code, suggests that the
2928 19 jeremybenn
@value{OR1KSIM} component places these registers at addresses 0x00 and
2929
0x04.
2930
 
2931
The port of Linux for the OpenRISC 1000, which runs on @value{OR1KSIM}
2932
implements the i8042 device driver, anticipating these registers
2933 82 jeremybenn
reside at their conventional address.  It seems unlikel that this code
2934 19 jeremybenn
will work.
2935
 
2936
This component should be used with caution.
2937
@end quotation
2938
 
2939 82 jeremybenn
Keyboard configuration is described in @code{section kbd}.  This
2940 19 jeremybenn
section may appear multiple times, specifying multiple keyboard
2941 82 jeremybenn
interfaces.  The following parameters may be specified.
2942 19 jeremybenn
 
2943
@table @code
2944
 
2945
@item enabled = 0|1
2946
@cindex @code{enabled} (keyboard configuration)
2947 82 jeremybenn
If 1 (true, the default), this keyboard is enabled.  If 0, it is disabled.
2948 19 jeremybenn
 
2949
@item baseaddr = @var{value}
2950
@cindex @code{baseaddr} (keyboard configuration)
2951
Set the base address of the keyboard's memory mapped registers to
2952 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
2953 19 jeremybenn
 
2954
The keyboard PS/2 interface has an 3-bit address bus, with 2 8-bit registers,
2955
at addresses 0x000 and 0x004.
2956
 
2957
@quotation Caution
2958
As noted above, a standard Intel 8042 interface would expect to find
2959
these registers at locations 0x60 and 0x64, thus requiring at least a
2960
7-bit bus.
2961
@end quotation
2962
 
2963
@item irq = @var{value}
2964
@cindex @code{irq} (keyboard configuration)
2965 82 jeremybenn
Use @var{value} as the IRQ number of this Keyboard interface.  Default
2966 19 jeremybenn
value 0.
2967
 
2968
@item rxfile = "@var{file}"
2969
@cindex @code{file} (keyboard configuration)
2970
@file{file} specifies a file containing raw key stroke data, which
2971 82 jeremybenn
models the input from a physical keyboard.  The default value is
2972 19 jeremybenn
@code{"kbd_in"}.
2973
 
2974
@end table
2975
 
2976
@node Disc Interface Configuration
2977
@subsection Disc Interface Configuration
2978
@cindex configuring the ATA/ATAPI interfaces
2979
@cindex disc interface configuration
2980
@cindex ATA/ATAPI configuration
2981
@cindex @code{section ata}
2982
The ATA/ATAPI disc controller used in @value{OR1KSIM} is the OCIDEC
2983
(OpenCores IDE Controller) component implemented at OpenCores, and
2984 98 jeremybenn
found in the top level SVN directory, @file{ata}.  It is described in
2985 19 jeremybenn
the document @cite{ATA/ATAPI-5 Core Specification} by Richard
2986 82 jeremybenn
Herveille, which can be found in the @file{doc} subdirectory.  It is a
2987 19 jeremybenn
memory mapped component, which resides on the main OpenRISC Wishbone
2988
data bus.
2989
 
2990 385 jeremybenn
@quotation Warning
2991 440 jeremybenn
In the current release of @value{OR1KSIM}, parsing of the ATA section is
2992 385 jeremybenn
broken. Users should not configure the disc interface in this release.
2993
@end quotation
2994
 
2995 82 jeremybenn
ATA/ATAPI configuration is described in @code{@w{section ata}}.  This section
2996
may appear multiple times, specifying multiple disc controllers.  The
2997 19 jeremybenn
following parameters may be specified.
2998
 
2999
@table @code
3000
 
3001
@item enabled = 0|1
3002
@cindex @code{enabled} (ATA/ATAPI configuration)
3003 82 jeremybenn
If 1 (true, the default), this ATA/ATAPI interface is enabled.  If 0,
3004 19 jeremybenn
it is disabled.
3005
 
3006
@item baseaddr = @var{value}
3007
@cindex @code{baseaddr} (ATA/ATAPI configuration)
3008
Set the base address of the ATA/ATAPI interface's memory mapped
3009 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
3010 19 jeremybenn
sensible value.
3011
 
3012
The ATA/ATAPI PS/2 interface has an 5-bit address bus, with 8 32-bit
3013 82 jeremybenn
registers.  Depending on the version of the OCIDEC ATA/ATAPI interface
3014 19 jeremybenn
selected (see @code{dev_id} below), not all registers will be available.
3015
 
3016
@item irq = @var{value}
3017
@cindex @code{irq} (ATA/ATAPI configuration)
3018 82 jeremybenn
Use @var{value} as the IRQ number of this ATA/ATAPI interface.  Default
3019 19 jeremybenn
value 0.
3020
 
3021
@item dev_id = 1|2|3
3022
@cindex @code{dev_id} (ATA/ATAPI configuration)
3023
This parameter specifies which version of the OCIDEC ATA/ATAPI
3024 82 jeremybenn
interface to model.  The default value is 1.
3025 19 jeremybenn
 
3026
Version 1 supports only the @code{CTRL}, @code{STAT} and @code{PCTR}
3027 82 jeremybenn
registers.  Versions 2 & 3 add the @code{FCTR} registers, Version 3
3028 19 jeremybenn
adds the @code{DTR} registers and the @code{RXD}/@code{TXD} registers.
3029
 
3030
@item rev = @var{value}
3031
@cindex @code{rev} (ATA/ATAPI configuration)
3032
Set the @var{value} as the revision of the OCIDEC ATA/ATAPI
3033 82 jeremybenn
interface.  The default value is 1.  The default value is 0.  Its value
3034
should be in the range 0-15.  Larger values are truncated with a
3035
warning.  This only affects the reset value of the @code{STAT}
3036 19 jeremybenn
register, where it forms bits 24-27.
3037
 
3038
@item pio_mode0_t1 = @var{value}
3039
@cindex @code{pio_mode0_t1} (ATA/ATAPI configuration)
3040
@itemx pio_mode0_t2 = @var{value}
3041
@cindex @code{pio_mode0_t2} (ATA/ATAPI configuration)
3042
@itemx pio_mode0_t4 = @var{value}
3043
@cindex @code{pio_mode0_t4} (ATA/ATAPI configuration)
3044
@itemx pio_mode0_teoc = @var{value}
3045
@cindex @code{pio_mode0_teoc} (ATA/ATAPI configuration)
3046
These parameters specify the timings for use with Programmed
3047 82 jeremybenn
Input/Output (PIO) transfers.  They are specified as the number of
3048 19 jeremybenn
clock cycles - 2, rounded up to the next highest integer, or zero if
3049 82 jeremybenn
that would be negative.  The values should not exceed 255.  If they do,
3050 19 jeremybenn
they will be ignored with a warning.
3051
 
3052
See the ATA/ATAPI-5 specification for explanations of each of these
3053 82 jeremybenn
timing parameters.  The default values are:
3054 19 jeremybenn
 
3055
@example
3056
pio_mode0_t1   =  6
3057
pio_mode0_t2   = 28
3058
pio_mode0_t4   =  2
3059
pio_mode0_teoc = 23
3060
@end example
3061
 
3062
@item dma_mode0_tm = @var{value}
3063
@cindex @code{dma_mode0_tm} (ATA/ATAPI configuration)
3064
@itemx dma_mode0_td = @var{value}
3065
@cindex @code{dma_mode0_td} (ATA/ATAPI configuration)
3066
@itemx dma_mode0_teoc = @var{value}
3067
@cindex @code{dma_mode0_teoc} (ATA/ATAPI configuration)
3068 82 jeremybenn
These parameters specify the timings for use with DMA transfers.  They
3069 19 jeremybenn
are specified as the number of clock cycles - 2, rounded up to the
3070 82 jeremybenn
next highest integer, or zero if that would be negative.  The values
3071
should not exceed 255.  If they do, they will be ignored with a
3072 19 jeremybenn
warning.
3073
 
3074
See the ATA/ATAPI-5 specification for explanations of each of these
3075 82 jeremybenn
timing parameters.  The default values are:
3076 19 jeremybenn
 
3077
@example
3078
dma_mode0_tm   =  4
3079
dma_mode0_td   = 21
3080
dma_mode0_teoc = 21
3081
@end example
3082
 
3083
@end table
3084
 
3085
@subsubsection ATA/ATAPI Device Configuration
3086
@cindex disc interface device configuration
3087
@cindex ATA/ATAPI device configuration
3088
Within the @code{@w{section ata}}, each device is specified
3089 82 jeremybenn
separately.  The device subsection is introduced by
3090 19 jeremybenn
 
3091
@example
3092
device @var{value}
3093
@end example
3094
 
3095 82 jeremybenn
@var{value} is the device number, which should be 0 or 1.  The
3096
subsection ends with @code{enddevice}.  Note that if the same device
3097 19 jeremybenn
number is specified more than once, the previous values will be
3098 82 jeremybenn
overwritten.  Within the @code{device} subsection, the following
3099 19 jeremybenn
parameters may appear:
3100
 
3101
@table @code
3102
 
3103
@item type = @var{value}
3104
@cindex @code{type} (ATA/ATAPI device configuration)
3105
@var{value}specifies the type of device: 0 (the default) for ``not
3106
connected'', 1 for hard disk simulated in a file and 2 for local system
3107
hard disk.
3108
 
3109
@item file = "@var{filename}"
3110
@cindex @code{file} (ATA/ATAPI device configuration)
3111
@file{filename} specifies the file to be used for a simulated ATA
3112 82 jeremybenn
device if the file type (see @code{type} above) is 1.  Default value
3113 346 jeremybenn
@code{"ata_file@var{n}"}, where @var{n} is the device number.
3114 19 jeremybenn
 
3115
@item size = @var{value}
3116
@cindex @code{size} (ATA/ATAPI device configuration)
3117
@var{value} specifies the size of a simulated ATA device if the file
3118 82 jeremybenn
type (see @code{type} above) is 1.  The default value is zero.
3119 19 jeremybenn
 
3120
@item packet = 0|1
3121
@cindex @code{packet} (ATA/ATAPI device configuration)
3122 82 jeremybenn
If 1 (true), implement the PACKET command feature set.  If 0 (the
3123 19 jeremybenn
default), do not implement the PACKET command feature set.
3124
 
3125
@item firmware = "@var{str}"
3126
@cindex @code{firmware} (ATA/ATAPI device configuration)
3127
Firmware to report in response to the ``Identify Device''
3128 82 jeremybenn
command.  Default @code{"02207031"}.
3129 19 jeremybenn
 
3130
@item heads = @var{value}
3131
@cindex @code{heads} (ATA/ATAPI device configuration)
3132 82 jeremybenn
Number of heads in the device.  Default 7, use -1 to disable all heads.
3133 19 jeremybenn
 
3134
@item sectors = @var{value}
3135
@cindex @code{sectors} (ATA/ATAPI device configuration)
3136 82 jeremybenn
Number of sectors per track in the device.  Default 32.
3137 19 jeremybenn
 
3138
@item mwdma = 0|1|2|-1
3139
@cindex @code{mwdma} (ATA/ATAPI device configuration)
3140 82 jeremybenn
Highest multi-word DMA mode supported.  Default 2, use -1 to disable.
3141 19 jeremybenn
 
3142
@item pio = 0|1|2|3|4
3143
@cindex @code{pio} (ATA/ATAPI device configuration)
3144 82 jeremybenn
Highest PIO mode supported.  Default 4.
3145 19 jeremybenn
 
3146
@end table
3147
 
3148
@node Generic Peripheral Configuration
3149
@subsection Generic Peripheral Configuration
3150
@cindex generic peripheral configuration
3151
@cindex configuration of generic peripherals
3152
@cindex @code{section generic}
3153
When used as a library (@pxref{Simulator Library, , Simulator
3154
Library}), @value{OR1KSIM} makes provision for any additional peripheral to be
3155 82 jeremybenn
implemented externally.  Any read or write access to this peripheral's
3156
memory map generates @dfn{upcall}s to an external handler.  This
3157 19 jeremybenn
interface can support either C or C++, and was particularly designed
3158
to facilitate support for OSCI SystemC (see @url{http://www.systemc.org}).
3159
 
3160
Generic peripheral configuration is described in @code{@w{section
3161 82 jeremybenn
generic}}.  This section may appear multiple times, specifying multiple
3162
external peripherals.  The following parameters may be specified.
3163 19 jeremybenn
 
3164
@table @code
3165
 
3166
@item enabled = 0|1
3167
@cindex @code{enabled} (generic peripheral configuration)
3168 82 jeremybenn
If 1 (true, the default), this ATA/ATAPI interface is enabled.  If 0,
3169 19 jeremybenn
it is disabled.
3170
 
3171
@item baseaddr = @var{value}
3172
@cindex @code{baseaddr} (generic peripheral configuration)
3173
Set the base address of the generic peripheral's memory mapped
3174 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
3175 19 jeremybenn
sensible value.
3176
 
3177
The size of the memory mapped register space is controlled by the
3178
@code{size} paramter, described below.
3179
 
3180
@item size = @var{value}
3181
@cindex @code{size} (generic peripheral configuration)
3182
Set the size of the generic peripheral's memory mapped register space
3183 82 jeremybenn
to @var{value} bytes.  Any read or write accesses to addresses with
3184 19 jeremybenn
offsets of 0 to @var{value}-1 bytes from the base address specified in
3185
parameter @code{baseaddr} (see above) will be directed to the external
3186
interface.
3187
 
3188 82 jeremybenn
@var{value} will be rounded up the nearest power of 2.  It's default
3189
value is zero.  If @var{value} is not an exact power of two, accesses
3190 19 jeremybenn
to address offsets of @var{value} or above up to the next power of 2
3191
will generate a warning, and have no effect (reads will return zero).
3192
 
3193
@item name = "@var{str}"
3194
@cindex @code{name} (generic peripheral configuration)
3195 82 jeremybenn
This gives the peripheral the name @code{"@var{str}"}.  This is used to
3196 19 jeremybenn
identify the peripheral in error messages and warnings, and when
3197 82 jeremybenn
reporting its status.  The default value is @code{@w{"anonymous
3198 19 jeremybenn
external peripheral"}}.
3199
 
3200
@item byte_enabled = 0|1
3201
@cindex @code{byte_enabled} (generic peripheral configuration)
3202
@itemx hw_enabled = 0|1
3203
@cindex @code{hw_enabled} (generic peripheral configuration)
3204
@itemx word_enabled = 0|1
3205
@cindex @code{word_enabled} (generic peripheral configuration)
3206
If 1 (true, the default), these parameters respectively enable the
3207 82 jeremybenn
device for byte wide, half-word wide and word wide accesses.  If 0,
3208 19 jeremybenn
accesses of that width will fail.
3209
 
3210
@end table
3211
 
3212
@node Interactive Command Line
3213
@chapter Interactive Command Line
3214
 
3215
If started with the @code{-f} flag, or if interrupted with
3216
@kbd{ctrl-C}, @value{OR1KSIM} provides the user with an interactive
3217 82 jeremybenn
command line.  The commands available, which may not be abbreviated, are:
3218 19 jeremybenn
 
3219
@table @code
3220
 
3221
@item q
3222
@cindex @code{q} (Interactive CLI)
3223
@cindex quitting (Interactive CLI)
3224
Exit the simulator
3225
 
3226
@item r
3227
@cindex @code{r} (Interactive CLI)
3228
@cindex displaying registers (Interactive CLI)
3229
@cindex register display (Interactive CLI)
3230 82 jeremybenn
Display all the General Purpose Registers (GPRs).  Also shows the just
3231 19 jeremybenn
executed and next to be executed instructions symbolically and the
3232
state of the flag in the Supervision Register.
3233
 
3234
@item t
3235
@cindex @code{t} (Interactive CLI)
3236
@cindex stepping code (Interactive CLI)
3237
Execute the next instruction and then display register/instruction
3238
information as with the @code{r} command (see above).
3239
 
3240
@item run @var{num} [ hush ]
3241
@cindex @code{run} (Interactive CLI)
3242
@cindex running code (Interactive CLI)
3243
@cindex executing code (Interactive CLI)
3244 82 jeremybenn
Execute @var{num} instructions.  The register/instruction information
3245 19 jeremybenn
is displayed after each instruction, as with the @code{r} command (see
3246
above) @emph{unless} @code{hush} is specified.
3247
 
3248
@item pr @var{reg} @var{value}
3249
@cindex @code{pr} (Interactive CLI)
3250
@cindex patching registers (Interactive CLI)
3251
@cindex register patching (Interactive CLI)
3252
Patch register @var{reg} with @var{value}.
3253
 
3254
@item dm @var{fromaddr} [ @var{toaddr} ]
3255
@cindex @code{dm} (Interactive CLI)
3256
@cindex displaying memory (Interactive CLI)
3257
@cindex memory display (Interactive CLI)
3258 82 jeremybenn
Display memory bytes between @var{fromaddr} and @var{toaddr}.  If
3259 19 jeremybenn
@var{toaddr} is not given, 64 bytes are displayed, starting at
3260
@var{fromaddr}.
3261
 
3262
@quotation Caution
3263 82 jeremybenn
The output from this command is broken (a bug).  @value{OR1KSIM}
3264
attempts to print out 16 bytes per row.  However, instead of printing
3265 19 jeremybenn
out the address at the start of each row, it prints the address (of
3266
the first of the 16 bytes) before @emph{each} byte.
3267
@end quotation
3268
 
3269
@item de @var{fromaddr} [ @var{toaddr} ]
3270
@cindex @code{dm} (Interactive CLI)
3271
@cindex disassemble (Interactive CLI)
3272 82 jeremybenn
Disassemble code between @var{fromaddr} and @var{toaddr}.  If
3273 19 jeremybenn
@var{toaddr} is not given, 16 instructions are disassembled.
3274
 
3275
The disassembly is entirely numerical, and gives no symbolic
3276
information.
3277
 
3278
@item pm @var{addr} @var{value}
3279
@cindex @code{pm} (Interactive CLI)
3280
@cindex patching memory (Interactive CLI)
3281
@cindex memory patching (Interactive CLI)
3282
Patch the 4 bytes in memory starting at @var{addr} with the 32-bit
3283
@var{value}.
3284
 
3285
@item pc @var{value}
3286
@cindex @code{pc} (Interactive CLI)
3287
@cindex patching the program counter (Interactive CLI)
3288
@cindex program counter patching (Interactive CLI)
3289
Patch the program counter with @var{value}.
3290
 
3291
@item cm @var{fromaddr} @var{toaddr} @var{size}
3292
@cindex @code{cm} (Interactive CLI)
3293
@cindex copying memory (Interactive CLI)
3294
@cindex memory copying (Interactive CLI)
3295
Copy @var{size} bytes in memory from @var{fromaddr} to @var{toaddr}.
3296
 
3297
@item break @var{addr}
3298
@cindex @code{break} (Interactive CLI)
3299
@cindex breakpoint set/clear (Interactive CLI)
3300
@cindex set breakpoint (Interactive CLI)
3301
@cindex clear breakpoint (Interactive CLI)
3302
@cindex toggle breakpoint (Interactive CLI)
3303
Toggle the breakpoint set at @var{addr}.
3304
 
3305
@item breaks
3306
@cindex @code{breaks} (Interactive CLI)
3307
@cindex breakpoint list (Interactive CLI)
3308
@cindex list breakpoints (Interactive CLI)
3309
List all set breakpoints
3310
 
3311
@item reset
3312
@cindex @code{reset} (Interactive CLI)
3313
@cindex simulator reset (Interactive CLI)
3314
@cindex reset the simulator (Interactive CLI)
3315 82 jeremybenn
Reset the simulator.  Includes modeling a reset of the processor, so
3316 19 jeremybenn
execution will restart from the reset vector location, 0x100.
3317
 
3318
@item hist
3319
@cindex @code{hist} (Interactive CLI)
3320
@cindex execution history (Interactive CLI)
3321
@cindex history of execution (Interactive CLI)
3322
If saving the execution history has been configured (@pxref{Simulator
3323
Behavior, , Simulator Behavior}), display the execution history.
3324
 
3325
@item stall
3326
@cindex @code{stall} (Interactive CLI)
3327
@cindex processor stall (Interactive CLI)
3328
@cindex stall the processor (Interactive CLI)
3329 82 jeremybenn
Stall the processor, so that control is passed to the debug unit.  When
3330
stalled, the processor can execute no instructions.  This command is
3331 19 jeremybenn
useful when debugging the JTAG interface, used by debuggers such as
3332
GDB.
3333
 
3334
@item unstall
3335
@cindex @code{unstall} (Interactive CLI)
3336
@cindex processor unstall (Interactive CLI)
3337
@cindex unstall the processor (Interactive CLI)
3338 82 jeremybenn
Unstall the processor, so that normal execution can continue.  This command is
3339 19 jeremybenn
useful when debugging the JTAG interface, used by debuggers such as GDB.
3340
 
3341
@item stats @var{category} | clear
3342
@cindex @code{stats} (Interactive CLI)
3343
@cindex simulator statistics (Interactive CLI)
3344
@cindex statistics, simulation (Interactive CLI)
3345
Print the statistics for the given @var{category}, if available, or
3346 82 jeremybenn
clear if @code{clear} is specified.  The categories are:
3347 19 jeremybenn
 
3348
@table @asis
3349
 
3350
@item 1
3351
Miscellaneous statistics: branch predictions (if branch predictions
3352
are enabled), branch target cache model (if enabled), cache (if
3353
enbaled), MMU (if enabled) and number of addtional load & store
3354
cycles.
3355
 
3356
@xref{Core OpenRISC Configuration, , Configuring the OpenRisc
3357
Achitectural Components}, for details of how to enable these various
3358
features.
3359
 
3360
@item 2
3361 82 jeremybenn
Instruction usage statistics.  Requires hazard analysis to be enabled
3362 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3363
 
3364
@item 3
3365 82 jeremybenn
Instruction dependency statistics.  Requires hazard analysis to be enabled
3366 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3367
 
3368
@item 4
3369 82 jeremybenn
Functional unit dependency statistics.  Requires hazard analysis to be enabled
3370 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3371
 
3372
@item 5
3373 82 jeremybenn
Raw register usage over time.  Requires hazard analysis to be enabled
3374 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3375
 
3376
@item 6
3377 82 jeremybenn
Store buffer statistics.  Requires the store buffer to be enabled
3378 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3379
 
3380
@end table
3381
 
3382
@item info
3383
@cindex @code{info} (Interactive CLI)
3384
@cindex simulator configuration info (Interactive CLI)
3385
@cindex configuration info (Interactive CLI)
3386 82 jeremybenn
Display detailed information about the simulator configuration.  This
3387 19 jeremybenn
is quite a lengthy about, because all MMU TLB information is displayed.
3388
 
3389
@item dv @var{fromaddr} [ @var{toaddr} ] [ @var{module} ]
3390
@cindex @code{dv} (Interactive CLI)
3391
@cindex Verilog memory dump (Interactive CLI)
3392
@cindex memory dump, Verilog (Interactive CLI)
3393
Dump the area of memory between @var{fromaddr} and @var{toaddr} as
3394
Verilog code for a synchronous, 23-bit wide SRAM module, named
3395 82 jeremybenn
@var{module}.  If @var{toaddr} is not specified, then 64 bytes are
3396
dumped (as 16 32-bit words).  If @var{module} is not specified,
3397 19 jeremybenn
@code{or1k_mem} is used.
3398
 
3399
To save to a file, use the redirection function (described after this
3400
table, below).
3401
 
3402
@item dh @var{fromaddr} [ @var{toaddr} ]
3403
@cindex @code{dv} (Interactive CLI)
3404
@cindex hexadecimal memory dump (Interactive CLI)
3405
@cindex memory dump, hexadecimal (Interactive CLI)
3406
Dump the area of memory between @var{fromaddr} and @var{toaddr} as
3407 82 jeremybenn
32-bit hex numbers (no @code{0x}, or @code{32'h} prefix).  If
3408 19 jeremybenn
@var{toaddr} is not specified, then 64 bytes are dumped (as 16 32-bit
3409
words).
3410
 
3411
To save to a file, use the redirection function (described after this
3412
table, below).
3413
 
3414
@item setdbch
3415
@cindex @code{setdbch} (Interactive CLI)
3416
@cindex debug channel toggle (Interactive CLI)
3417
@cindex toggle debug channels (Interactive CLI)
3418 82 jeremybenn
Toggle debug channels on/off.  @xref{Standalone Simulator, , Standalone
3419 19 jeremybenn
Simulator}, for a description of specifying debug channels on the
3420
command line.
3421
 
3422
@item set @var{section} @var{param} = @var{value}
3423
@cindex @code{set} (Interactive CLI)
3424
@cindex configuration parameter setting (Interactive CLI)
3425
Set the configuration parameter @var{para} in section @var{section} to
3426 82 jeremybenn
@var{value}.  @xref{Configuration, , Configuration}, for details of
3427 19 jeremybenn
configuration parameters and their settings.
3428
 
3429
@item debug
3430
@cindex @code{debug} (Interactive CLI)
3431
@cindex debug mode toggle (Interactive CLI)
3432
@cindex toggle debug mode (Interactive CLI)
3433 82 jeremybenn
Toggle the simulator debug mode.  @xref{Debug Interface Configuration,
3434 19 jeremybenn
, Debug Interface Configuration}, for information on this parameter.
3435
 
3436
@quotation Caution
3437 82 jeremybenn
This is effectively enabling or disabling the debug unit.  It does not
3438
effect the remote GDB debug interface.  However using the remote debug
3439 19 jeremybenn
interface while the debug unit is disabled will lead to undefined
3440
behavior and likely crash @value{OR1KSIM}
3441
@end quotation
3442
 
3443
@item cuc
3444
@cindex @code{debug} (Interactive CLI)
3445
@cindex Custom Unit Compiler (Interactive CLI)
3446
Enter the the Custom Unit Compiler command prompt (@pxref{CUC
3447
Configuration, , CUC Configuration}).
3448
 
3449
@quotation Caution
3450 82 jeremybenn
The CUC must be properly configured, for this to succeed.  In
3451
particular a timing file must be available and readable.  Otherwise
3452 19 jeremybenn
@value{OR1KSIM} will crash.
3453
@end quotation
3454
 
3455
@item help
3456
@cindex @code{help} (Interactive CLI)
3457
@cindex Custom Unit Compiler (Interactive CLI)
3458
Print out brief information about each command available.
3459
 
3460
@item mprofile [-vh] [-m @var{m}] [-g @var{n}] [-f @var{file}] @var{from} @var{to}
3461
@cindex @code{mprofile} (Interactive CLI)
3462
@cindex memory profiling utility (Interactive CLI)
3463 82 jeremybenn
Run the memory profiling utility.  This follows the same usage as the
3464 19 jeremybenn
standalone command (@pxref{Memory Profiling Utility, , Memory
3465
Profiling Utility}).
3466
 
3467
@item profile [-vhcq] [-g @var{file}]
3468
@cindex @code{mprofile} (Interactive CLI)
3469
@cindex profiling utility (Interactive CLI)
3470
@cindex instruction profiling utility (Interactive CLI)
3471 82 jeremybenn
Run the instruction profiling utility.  This follows the same usage as the
3472 19 jeremybenn
standalone command (@pxref{Profiling Utility, , Profiling Utility}).
3473
 
3474
@end table
3475
 
3476
For all commands, it is possible to redirect the output to a file, by
3477
using the redirection operator, @code{>}.
3478
 
3479
@example
3480
@var{command} > @var{filename}
3481
@end example
3482
 
3483
This is particularly useful for commands dumping a large amount of
3484
output, such as @code{dv}.
3485
 
3486
@quotation Caution
3487 82 jeremybenn
Unfortunately there is a serious bug with the redirection operator.  It
3488 19 jeremybenn
does not return output to standard output after the command
3489 82 jeremybenn
completes.  Until this bug is fixed, file redirection should not be
3490 19 jeremybenn
used.
3491
@end quotation
3492
 
3493
@node Verification API
3494
@chapter Verification API (VAPI)
3495
 
3496
The Verification API (VAPI) provides a TCP/IP interface to allow
3497 82 jeremybenn
components of the simulation to be controlled externally.  The
3498 19 jeremybenn
interface is polled for new requests on each simulated clock
3499 82 jeremybenn
cycle.  Components within the simulator may send responses to such
3500 19 jeremybenn
requests.
3501
 
3502 82 jeremybenn
The inteface is an asynchronous duplex protocol.  On the request side
3503 19 jeremybenn
it provides for simple commands, known as VAPI IDs (a 32 bit integer),
3504 82 jeremybenn
with a single piece of data (also a 32 bit integer).  On the send side,
3505
it provides for sending a single VAPI ID and data.  However there is no
3506
explicit command-response structure.  Some components just accept
3507
requests (e.g.  to set values), some just generate sends (to report
3508 19 jeremybenn
values), and some do both.
3509
 
3510
Each component has a base ID (32 bit) and its commands will start from
3511 82 jeremybenn
that base ID.  This provides a simple partitioning of the command space
3512
amongst components.  Request commands will be directed to the component with
3513 19 jeremybenn
the closest base ID lower than the VAPI ID of the command.
3514
 
3515
Thus if there are two components with base IDs of 0x200 and 0x300, and
3516
a request with VAPI ID of 0x203 is received, it will be directed to
3517
the first component as its command #3.
3518
 
3519
The results of VAPI interactions are logged (by default in
3520
@file{vapi.log} unless an alternative is specified in @code{@w{section
3521
vapi}}).
3522
 
3523
Currently the following components support VAPI:
3524
 
3525
@table @asis
3526
 
3527
@item Debug Unit
3528
@cindex Debug Unit verification (VAPI)
3529
@cindex VAPI for Debug Unit
3530
Although the Debug Unit can specify a base VAPI ID, it is not used to
3531
send commands or receive requests.
3532
 
3533
Instead, if the base VAPI ID is set, all remote JTAG protocol exchanges are
3534
logged in the VAPI log file.
3535
 
3536
@item UART
3537
@cindex UART verification (VAPI)
3538
@cindex VAPI for UART
3539
If a base VAPI ID is specified, the UART sends details of any chars or
3540
break characters sent, with dteails of the line control register etc
3541
encoded in the data packet sent.
3542
 
3543
This supports a single VAPI command request, but encodes a sub-command in the
3544
top 8 bits of the associated data.
3545
 
3546
@table @code
3547
 
3548
@item 0x00
3549
@cindex 0x00 UART VAPI sub-command (UART verification)
3550
This stuffs the least significant 8 bits of the data into the serial
3551
register of the UART and the next 8 bits into the line control
3552
register, effectively providing control of the next character to be
3553
sent or received.
3554
 
3555
@item 0x01
3556
@cindex 0x01 UART VAPI sub-command (UART verification)
3557
The divisor latch bytes are set from the least significant 16 bits of
3558
the data.
3559
 
3560
@item 0x02
3561
@cindex 0x02 UART VAPI sub-command (UART verification)
3562
The line control register is set from bits 15-8 of the data.
3563
 
3564
@item 0x03
3565
@cindex 0x03 UART VAPI sub-command (UART verification)
3566
The UART skew is set from the least significant 16 bits of the data
3567
 
3568
@item 0x04
3569
@cindex 0x04 UART VAPI sub-command (UART verification)
3570
If the 16th most significant bit of the data is 1, start sending
3571 82 jeremybenn
breaks, otherwise stop sending breaks.  The breaks are sent or cleared
3572 19 jeremybenn
after the number of UART clock divider ticks specified by the data
3573
(immediately if the data is zero).
3574
 
3575
@end table
3576
 
3577
@item DMA
3578
@cindex DMA verification (VAPI)
3579
@cindex VAPI for DMA
3580
Although the DMA unit supports a base VAPI ID in its configuration
3581
(@code{@w{section dma}}), no VAPI data is sent, nor VAPI requests
3582
currently implemented.
3583
 
3584
@item Ethernet
3585
@cindex Ethernet verification (VAPI)
3586
@cindex VAPI for Ethernet
3587 82 jeremybenn
The following requests are handled by the Ethernet.  Specified
3588 19 jeremybenn
symbolically, these are the increments from the base VAPI ID of the
3589 82 jeremybenn
Ethernet.  At present no implementation is provided behind these VAPI
3590 19 jeremybenn
requests.
3591
 
3592
@table @code
3593
 
3594
@item ETH_VAPI_DATA (0)
3595
@cindex @code{ETH_VAPI_DATA} (Ethernet verification)
3596
 
3597
@item ETH_VAPI_CTRL (0)
3598
@cindex @code{ETH_VAPI_CTRL} (Ethernet verification)
3599
 
3600
@end table
3601
 
3602
@item GPIO
3603
@cindex GPIO verification (VAPI)
3604
@cindex VAPI for GPIO
3605
If a base VAPI ID is specified, the GPIO sends out on its base VAPI ID
3606
(symbolically, GPIO_VAPI_DATA (0) offset from the base VAPI ID) any
3607
changes in outputs.
3608
 
3609 82 jeremybenn
The following requests are handled by the GPIO.  Specified
3610 19 jeremybenn
symbolically, these are the increments from the VAPI base ID of the
3611
GPIO.
3612
 
3613
@table @code
3614
 
3615
@item GPIO_VAPI_DATA (0)
3616
@cindex @code{GPIO_VAPI_DATA} (GPIO verification)
3617
Set the next input to the commands data field
3618
 
3619
@item GPIO_VAPI_AUX (1)
3620
@cindex @code{GPIO_VAPI_AUX} (GPIO verification)
3621
Set the GPIO auxiliary inputs to the data field
3622
 
3623
@item GPIO_VAPI_CLOCK (2)
3624
@cindex @code{GPIO_VAPI_CLOCK} (GPIO verification)
3625
Add an external GPIO clock trigger of period specified in the data field.
3626
 
3627
@item GPIO_VAPI_RGPIO_OE (3)
3628
@cindex @code{GPIO_VAPI_RGPIO} (GPIO verification)
3629
Set the GPIO output enable to the data field
3630
 
3631
@item GPIO_VAPI_RGPIO_INTE (4)
3632
@cindex @code{GPIO_VAPI_INTE} (GPIO verification)
3633
Set the next interrupt to the data field
3634
 
3635
@item GPIO_VAPI_RGPIO_PTRIG (5)
3636
@cindex @code{GPIO_VAPI_PTRIG} (GPIO verification)
3637
Set the next trigger to the data field
3638
 
3639
@item GPIO_VAPI_RGPIO_AUX (6)
3640
@cindex @code{GPIO_VAPI_AUX} (GPIO verification)
3641
Set the next auxiliary input to the data field
3642
 
3643
@item GPIO_VAPI_RGPIO_CTRL (7)
3644
@cindex @code{GPIO_VAPI_CTRL} (GPIO verification)
3645
Set th next control input to the data field
3646
 
3647
@end table
3648
 
3649
@end table
3650
 
3651
@node Code Internals
3652
@chapter A Guide to @value{OR1KSIM} Internals
3653
 
3654 82 jeremybenn
These are notes to help those wanting to extend @value{OR1KSIM}.  This
3655 19 jeremybenn
section assumes the use of a tag file, so file locations of entities'
3656 82 jeremybenn
definitions are not in general provided.  For more on tags, see the
3657
Linux manual page for @command{etags}.  A tag file can be created
3658 19 jeremybenn
with:
3659
 
3660
@example
3661
make tags
3662
@end example
3663
 
3664
@menu
3665
* Coding Conventions::
3666
* Global Data Structures::
3667
* Concepts::
3668
* Internal Debugging::
3669 104 jeremybenn
* Regression Testing::
3670 19 jeremybenn
@end menu
3671
 
3672
@node Coding Conventions
3673
@section Coding Conventions for @value{OR1KSIM}
3674
 
3675
This chapter provides some guidelines for coding, to facilitate
3676
extensions to @value{OR1KSIM}
3677
 
3678
@table @emph
3679
 
3680
@item GNU Coding Standard
3681
Code should follow the GNU coding standard for C
3682 82 jeremybenn
(@url{http://www.gnu.org/prep/standards/}.  If in doubt, put your code
3683 19 jeremybenn
through the @command{indent} program.
3684
 
3685
@item @code{#include} headers
3686
All C source code files should include @file{config.h} before any
3687
other file.
3688
 
3689
This should be followed by inclusion of any system headers (but see
3690
the comments about portability and @file{port.h} below) and then by
3691
any @value{OR1KSIM} package headers.
3692
 
3693
If @file{port.h} is required, it should be the first package header to
3694
be included after the system headers.
3695
 
3696
All C source code and header files should directly include any system
3697 82 jeremybenn
or package header they depend on, i.e.  not rely on any other header
3698
having already included it.  The two exceptions are
3699 19 jeremybenn
 
3700
@enumerate
3701
@item
3702
All header files may assume that @file{config.h} has already been
3703
included.
3704
 
3705
@item
3706
System headers which impose portability problems should be included by
3707
using the package header @file{port.h}, rather than the system headers
3708 82 jeremybenn
themselves.  This is the case for code requiring
3709 19 jeremybenn
 
3710
@itemize @bullet
3711
 
3712
@item
3713
@code{strndup} (from @file{string.h})
3714
 
3715
@item
3716
Integer types (@code{int@var{n}_t}, @code{uint@var{n}_t}) (from
3717
@file{inttypes.h}).
3718
 
3719
@item
3720
@code{isblank} (from @file{ctype.h})
3721
 
3722
@end itemize
3723
 
3724
@end enumerate
3725
 
3726
@item @code{#include} files once only
3727
All include files should be protected by @code{#ifndef} to ensure
3728 82 jeremybenn
their definitions are only included once.  For instance a header file
3729 19 jeremybenn
@file{@var{x-y.h}} should surround its contents with:
3730
 
3731
@example
3732
#ifndef X_Y__H
3733
#define X_Y__H
3734
 
3735
<body of the include file>
3736
 
3737
#endif  /* X_Y__H */
3738
@end example
3739
 
3740
@item Avoid @code{typedef}
3741
The GNU coding style for C does not have a clear way to distinguish
3742 82 jeremybenn
between user type name and user variables.  For this reason
3743 19 jeremybenn
@code{typedef} should be avoided except for the most ubiquitous user
3744 82 jeremybenn
defined types.  This makes the code much easier to read.
3745 19 jeremybenn
 
3746
There are some @code{typedef} declarations in the @command{argtable2}
3747
library and the @acronym{ELF} and @acronym{COFF} headers, because this
3748
code is taken from other places.
3749
 
3750
Within @value{OR1KSIM} legacy uses of @code{typedef} have largely been
3751
purged, except in the Custom Unit Compiler (@pxref{CUC Configuration,
3752
, Custom Unit Compiler (CUC) Configuration}).
3753
 
3754
The remaining uses of @code{typedef} occur in two places:
3755
 
3756
@itemize @bullet
3757
 
3758
@item
3759
@file{port/port.h} defines types to replace those in header files that
3760
are not available (character functions, string duplication, integer
3761
types).
3762
 
3763
@file{cpu/or1k/arch.h} defines types for the key @value{OR1KSIM}
3764
entities: addresses (@code{oraddr_t}), unsigned register values
3765
(@code{uorreg_t}) and signed register (@code{orreg_t}) values.
3766
 
3767
@end itemize
3768
 
3769
Where new types are defined, they should appear in one of these two
3770 82 jeremybenn
files as appropriate.  @value{OR1KSIM} specific types appearing in
3771 19 jeremybenn
@file{arch.h} should always have the suffix @file{_h}.
3772
 
3773
@item Don't begin names with underscore
3774
Names beginning with @code{_} are intended to be part of the C
3775 82 jeremybenn
infrastructure.  They should not be used in the simulator code.
3776 19 jeremybenn
 
3777
@item Keep Non-global top level entities static
3778
All top level entities (functions, variables), which are not
3779 82 jeremybenn
explicitly part of a global interface should be declared static.  This
3780 19 jeremybenn
ensures that unwanted connections are not inadvertently built across
3781
the program.
3782
 
3783
@item Use of @code{inline}
3784 82 jeremybenn
Code should not be declared @code{inline}.  Modern compilers can work
3785 19 jeremybenn
out for themselves what is best in this respect.
3786
 
3787
@item Initialization
3788 82 jeremybenn
All data structures should be explicitly initialized.  In particular
3789 19 jeremybenn
code should not rely on static data structures being initialized to
3790
zero.
3791
 
3792
The rationale is that in future static data structures may become
3793 82 jeremybenn
dynamic.  This has been a particular source of bugs in @value{OR1KSIM}
3794 19 jeremybenn
historically.
3795
 
3796
A specific case is with new peripherals, which should always include a
3797
@code{start} function to pre-initialize all configuration parameters
3798
to sensible defaults
3799
 
3800
@item Configuration Validation
3801
All configuration values should be validated, preferably when
3802
encountered, if not when the @code{section} is closed, or otherwise
3803
at run time when the parameter is first used.
3804
 
3805
@end table
3806
 
3807
@node Global Data Structures
3808
@section Global Data Structures
3809
 
3810
@table @code
3811
 
3812
@item config
3813
@cindex configuration global structure
3814
@vindex config
3815
The global variable @code{config} of type @code{struct config} holds
3816
the configuration data for some of the @value{OR1KSIM} components which
3817 82 jeremybenn
are always present.  At present the components are:
3818 19 jeremybenn
 
3819
@itemize @bullet
3820
 
3821
@item
3822
@vindex config.sim
3823
The simulator defined in @code{@w{section sim}} (@pxref{Simulator
3824
Configuration, , Simulator Configuration}).
3825
 
3826
@item
3827
@vindex config.vapi
3828
The Verification API (VAPI) defined  in @code{@w{section vapi}}
3829
(@pxref{Verification API Configuration, , Verification API (VAPI)
3830
Configuration}).
3831
 
3832
@item
3833
@vindex config.cuc
3834
The Custom Unit Compiler (CUC), defined in @code{@w{section cuc}}
3835
(@pxref{CUC Configuration, , Custom Unit Compiler (CUC)
3836
Configuration}).
3837
 
3838
@item
3839
@vindex config.cpu
3840
The CPU, defined in @code{@w{section cpu}} (@pxref{CPU Configuration,
3841
, CPU Configuration}).
3842
 
3843
@item
3844
@vindex config.dc
3845
The data cache (but not the instruction cache), defined in
3846
@code{@w{section dc}} (@pxref{Cache Configuration, , Cache
3847
Configuration}).
3848
 
3849
@item
3850
@vindex config.pm
3851
The power management unit, defined in @code{@w{section pm}}
3852
(@pxref{Power Management Configuration, , Power Management
3853
Configuration}).
3854
 
3855
@item
3856
@vindex config.pic
3857
The programmable interrupt controller, defined in @code{@w{section pic}}
3858
(@pxref{Interrupt Configuration, , Interrupt Configuration}).
3859
 
3860
@item
3861
@vindex config.bpb
3862
Branch prediciton, defined in @code{@w{section bpb}} (@pxref{Branch
3863
Prediction Configuration, , Branch Prediction Configuration}).
3864
 
3865
@item
3866
@vindex config.debug
3867
The debug unit, defined in @code{@w{section debug}} (@pxref{Debug
3868
Interface Configuration, , Debug Interface Configuration}).
3869
 
3870
@end itemize
3871
 
3872
This struct is made of a collection of structs, one for each
3873 82 jeremybenn
component.  For example the simulator configuration is held in
3874 19 jeremybenn
@code{config.sim}.
3875
 
3876
@item config
3877
@cindex configuration dynamic structure
3878
@vindex sections
3879
This is a linked list of data structures holding configuration data
3880
for all sections which are not held in the main @code{config} data
3881 82 jeremybenn
structure.  In general these are components (such as peripherals and
3882
memory) which may occur multiple times.  However it also handles some
3883 19 jeremybenn
architectural components which may occur only once, such as the memory
3884
management units, the instruction cache, the interrupt controller and
3885
branch prediction.
3886
 
3887
@item runtime
3888
@cindex runtime global structure
3889
@vindex runtime
3890
The global variable @code{runtime} of type @code{struct runtime} holds
3891 82 jeremybenn
all the runtime information about the simulation.  To access this
3892 19 jeremybenn
variable, @file{sim-config.h} must be included.
3893
 
3894
@vindex runtime.cpu
3895
@vindex runtime.vapi
3896
@vindex runtime.cuc
3897
This struct is itself made of 3 other structs, @code{cpu} (for CPU run
3898
time state), @code{vapi} (for Verification API state) and @code{cuc}
3899
(for Custom Unit Compiler state).
3900
 
3901
@end table
3902
 
3903
@node Concepts
3904
@section Concepts
3905
 
3906
@table @emph
3907
 
3908
@anchor{Output Redirection}
3909
@item Output Redirection
3910
@cindex output rediretion
3911
@vindex runtime.cpu.fout
3912 82 jeremybenn
The current output stream is held in @code{runtime.cpu.fout}.  Output
3913 19 jeremybenn
should be explicitly written to this stream, or may use the
3914
@code{PRINTF} macro, which will write its arguments to this output stream.
3915
 
3916
@item Reset Hooks
3917
@cindex reset hooks
3918
@findex reg_sim_reset
3919
Any peripheral may register a routine to be called when the the
3920
processor is reset by calling @code{reg_sim_reset}, providing a
3921 82 jeremybenn
function and pointer to a data structure as arguments.  On reset that
3922 19 jeremybenn
function will be called with the data stucture pointer as argument.
3923
 
3924 432 jeremybenn
@anchor{Interrupts Internal}
3925
@item Interrupts
3926
@cindex interrupts
3927
@findex report_interrupt
3928
@findex clear_interrupt
3929
@findex mtspr
3930
An internal peripheral can model the effect of an interrupt being
3931
asserted by calling @code{report_interrupt}.  This is used for both edge
3932
and level sensitive interrupts.
3933
 
3934
The effect is to set the corresponding bit in the PICSR SPR and to queue
3935
an interrupt exception to take place after the current instruction
3936
completes execution.
3937
 
3938
Externally, the different interrupts require different mechanisms for
3939
clearing.  Level sensitive interrupts should be cleared by deasserting
3940
the interrupt line, edge sensitive interrupts by clearing the
3941
corresponding bit in the PICSR SPR.
3942
 
3943
Internally this amounts to the same thing (clearing the PICSPR bit), so
3944
a single function is provided, @code{clear_interrupt}.  Note however that
3945
when level sensitive interrupts are configured, PICSR is read only, and
3946
can only be cleared by calling @code{clear_interrupt}.  Using the two
3947
functions provided will ensure the peripheral works correctly whichever
3948
type of interrupt is used.
3949
 
3950
@quotation Note
3951
Until an interrupt is cleared, all subsequent interrupts are ignored
3952
with a warning.
3953
@end quotation
3954
 
3955 19 jeremybenn
@end table
3956
 
3957
@node Internal Debugging
3958
@section Internal Debugging
3959
@cindex internal debugging
3960
 
3961
The function @code{debug} is like @code{printf}, but with an extra
3962 82 jeremybenn
first argument, which is the debug level.  If the debug level specified
3963 19 jeremybenn
in the simulator configuration (@pxref{Simulator Behavior, , Simulator
3964
Behavior}) is greater than or equal to this value, the remaining
3965
arguments are printed to the current output stream (@pxref{Output
3966
Redirection, , Output Redirection}).
3967
 
3968 104 jeremybenn
@node Regression Testing
3969
@section Regression Testing
3970
@cindex regression testing
3971
@cindex testing
3972
@value{OR1KSIM} now includes a regression test suite for both standalone
3973
and library usage as described earlier (@pxref{Build and Install,
3974
, Building and Installing}).  Running the tests requires that the
3975
OpenRISC toolchain and DejaGNU are both installed.
3976
 
3977
Tests are written using @command{expect}, a derivative of TCL.
3978
Documentation of DejaGnu, @command{expect} and TCL are freely available
3979
on the Web.  The Embecosm Application Note 8, @cite{Howto: Using DejaGnu
3980
for Testing: A Simple Introduction}
3981
(@uref{http://www.embecosm.com/download/ean8.html}) provides a concise
3982
introduction.
3983
 
3984
All test code is found in the @file{testsuite} directory.  The key
3985
files and directories used are as follows.
3986
 
3987
@table @code
3988
@item global-conf.exp
3989
@cindex DejaGnu configuration
3990
This is the global DejaGNU configuration file used to set up parameters
3991
common to all tests.  If the user has the environment varialbe
3992
@env{DEJAGNU} defined, it will be used instead, but this is not
3993
recommended.
3994
 
3995
@item Makefile.am
3996
@cindex test make file
3997
@cindex make file for tests
3998
This is the top level @command{automake} file for the testsuite.  The
3999
only changes likely to be needed here is additional local cleanup of
4000
files created by new tests.
4001
 
4002
@item README
4003
@cindex test README
4004
This contains details of all the tests
4005
 
4006
@item config
4007
@cindex DejaGnu board configurations
4008
This contains DejaGnu board configurations.  Since the tests are
4009
generally run on a Unix host, this should just contain @file{Unix.exp}.
4010
 
4011
@item lib
4012
@cindex DejaGnu tool specific configuration
4013
This contains DejaGnu tool specific configurations.  ``Tool'' has a
4014
specific meaning in DejaGNU, referring just to a grouping of tests.  In
4015
this case there are two such ``tools'', ``or1ksim'' and ``libsim''
4016
for tests of the standalone tool and tests of the library.
4017
 
4018
Corresponding to this, there are two tool specific configuration files,
4019
@file{or1ksim.exp} and @file{libsim.exp}.  These contain @command{expect}/TCL
4020
procedures for common use among the tests.
4021
 
4022
@item libsim.tests
4023
@itemx or1ksim.tests
4024
@cindex DejaGNU tests directories
4025 440 jeremybenn
These are the directories of tests of the @value{OR1KSIM} library.  They
4026
also include @value{OR1KSIM} configuration files and each has a
4027
@file{Makefile.am} file.  @file{Makefile.am} should be updated whenever
4028
files are added to this directory, to ensure they are included in the
4029
distribution.
4030 104 jeremybenn
 
4031
@item test-code
4032
@cindex host test code
4033
@cindex test code for host
4034
These are all the test programs to be compiled on the host (each in its
4035
own directory).  In general these are programs to support testing of the
4036
library, and build various programs linking in the library.
4037
 
4038
@item test-code
4039
@cindex target test code
4040
@cindex test code for target
4041
These are all the test programs to be compiled with the OpenRISC tool
4042 346 jeremybenn
chain to run with either standalone @value{OR1KSIM} or the library.
4043
This directory includes its own @file{configure.ac}, since it must set
4044
up a separate tool chain based on the target, not the host.
4045 104 jeremybenn
 
4046
@end table
4047
 
4048
To add a new test needs the following steps.
4049
 
4050
@itemize @bullet
4051
 
4052
@item
4053 346 jeremybenn
Put new host C code in its own directory within @file{test-code}.  Add
4054 104 jeremybenn
the directory to the existing @file{Makefile.am} in the @file{test-code}
4055 346 jeremybenn
directory and create a @file{Makefile.am} in the new directory to drive
4056
building the test program(s).  Don't forget to add the new
4057
@file{Makefile} to the top level @file{configure.ac} so it gets
4058
generated. Not all tests require code here.
4059 104 jeremybenn
 
4060
@item
4061 346 jeremybenn
Put new target C code in its own directory within @file{test-code-or1k}.
4062
Once again modify & create @file{Makefile.am}.  This time modify the
4063
@file{configure.ac} in the @file{test-code-or1k} so the @file{Makefile}
4064
gets generated.  The existing programs provide examples to start from,
4065
including custom linker scripts where needed.
4066 104 jeremybenn
 
4067
@item
4068
Add one or more tests and configuration files to the relevant ``tool''
4069 346 jeremybenn
test directory.  Use the existing tests as templates.  They make heavy
4070
use of the @command{expect}/TCL procedures in the @file{config}
4071
directory to facilitate driving the tests.
4072 104 jeremybenn
 
4073
@end itemize
4074
 
4075 19 jeremybenn
@node  GNU Free Documentation License
4076
@chapter GNU Free Documentation License
4077
@cindex license for @value{OR1KSIM}
4078
 
4079
@include fdl-1.2.texi
4080
 
4081
@node Index
4082
 
4083
@unnumbered Index
4084
 
4085
@printindex cp
4086
 
4087
@bye

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.