OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

powered by: WebSVN 2.1.0

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