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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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