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

Subversion Repositories openrisc

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

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
@end menu
1760
 
1761
@node CPU Configuration
1762
@subsection CPU Configuration
1763
@cindex configuring the CPU
1764
@cindex configuring the processor
1765
@cindex CPU configuration
1766
@cindex processor configuration
1767
@cindex @code{section cpu}
1768 82 jeremybenn
CPU configuration is described in @code{section cpu}.  This section
1769
should appear only once.  At present @value{OR1KSIM} does not model multi-CPU
1770
systems.  The following parameters may be specified.
1771 19 jeremybenn
 
1772
@table @code
1773
 
1774
@item ver = @var{value}
1775
@item cfg = @var{value}
1776
@item rev = @var{value}
1777
@cindex @code{ver} (CPU configuration)
1778
@cindex @code{rev} (CPU configuration)
1779
The values are used to form the corresponding fields in the @code{VR}
1780 82 jeremybenn
Special Purpose Register (SPR 0).  Default values 0.  A warning is given
1781 19 jeremybenn
and the value truncated if it is too large (8 bits for @code{ver} and
1782
@code{cfg}, 6 bits for @code{rev}).
1783
 
1784
@item upr = @var{value}
1785
@cindex @code{upr} (CPU configuration)
1786
Used as the value of the Unit Present Register (UPR) Special Purpose Register
1787 82 jeremybenn
(SPR 1) to @var{value}.  Default value is 0x0000075f, i.e.
1788 19 jeremybenn
@itemize @bullet
1789
@item
1790
UPR present (0x00000001)
1791
@item
1792
Data cache present (0x00000002)
1793
@item
1794
Instruction cache present (0x00000004)
1795
@item
1796
Data MMY present (0x00000008)
1797
@item
1798
Instruction MMU present (0x00000010)
1799
@item
1800
Debug unit present (0x00000040)
1801
@item
1802
Power management unit present (0x00000100)
1803
@item
1804
Programmable interrupt controller present (0x00000200)
1805
@item
1806
Tick timer present (0x00000400)
1807
@end itemize
1808
 
1809
However, with the exection of the UPR present (0x00000001) and tick
1810
timer present, the various
1811
fields will be modified with the values specified in their corresponding
1812
configuration sections.
1813
 
1814
@item cfgr = @var{value}
1815
@cindex @code{cfgr} (CPU configuration)
1816
Sets the CPU configuration register (Special Purpose Register 2) to
1817 82 jeremybenn
@var{value}.  Default value is 0x00000020, i.e.  support for the ORBIS32
1818
instruction set.  Attempts to set any other value are accepted, but
1819 19 jeremybenn
issue a warning that there is no support for the instruction set.
1820
 
1821
@item sr = @var{value}
1822
@cindex @code{sr} (CPU configuration)
1823
Sets the supervision register Special Purpose Register (SPR 0x11) to
1824 82 jeremybenn
@var{value}.  Default value is 0x00008001, i.e.  start in supervision
1825 19 jeremybenn
mode (0x00000001) and set the ``Fixed One'' bit (0x00008000).
1826
 
1827 98 jeremybenn
@quotation Note
1828
This is particularly useful when an image is held in Flash at high
1829
memory (0xf0000000).  The EPH  bit can be set, so that interrupt
1830
vectors are basedf at 0xf0000000, rather than 0x0.
1831
@end quotation
1832
 
1833 19 jeremybenn
@item superscalar = 0|1
1834
@cindex @code{superscalar} (CPU configuration)
1835 82 jeremybenn
If 1, the processor operates in superscalar mode.  Default value is
1836 19 jeremybenn
0.
1837
 
1838
In the current simulator, the only functional effect of superscalar
1839
mode is to affect the calculation of the number of cycles taken to
1840
execute an instruction.
1841
 
1842
@quotation Caution
1843
The code for this does not appear to be complete or well tested, so
1844
users are advised not to use this option.
1845
@end quotation
1846
 
1847
@item hazards = 0|1
1848
@cindex @code{hazards} (CPU configuration)
1849 82 jeremybenn
If 1, data hazards are tracked in a superscalar CPU.  Default value is
1850 19 jeremybenn
0.
1851
 
1852
In the current simulator, the only functional effect is to cause
1853
logging of hazard waiting information if the CPU is
1854 82 jeremybenn
superscalar.  However nowhere in the simulator is this data actually
1855 19 jeremybenn
computed, so the net result is probably to have no effect.
1856
 
1857
if harzards are tracked, current hazards can be displayed using the
1858
simulator's @command{r} command.
1859
 
1860
@quotation Caution
1861
The code for this does not appear to be complete or well tested, so
1862
users are advised not to use this option.
1863
@end quotation
1864
 
1865
@item dependstats = 0|1
1866
@cindex @code{dependstats} (CPU configuration)
1867 82 jeremybenn
If 1, inter-instruction dependencies are calculated.  Default value 0.
1868 19 jeremybenn
 
1869
If these values are calculated, the depencies can be displayed using
1870
the simulator's @command{stat} command.
1871
 
1872
@quotation Note
1873
This field must be enabled, if execution execution flow tracking
1874
(field @code{history}) has been requested in the simulator
1875
configuration section (@pxref{Simulator Behavior, , Simulator
1876
Behavior}).
1877
@end quotation
1878
 
1879
@item sbuf_len = @var{value}
1880
@cindex @code{sbuf_len} (CPU configuration)
1881
The length of the store buffer is set to @var{value}, which must be no
1882 82 jeremybenn
greater than 256.  Larger values will be truncated to 256 with a
1883
warning.  Negative values will be treated as 0 with a warning.  Use 0 to
1884 19 jeremybenn
disable the store buffer.
1885
 
1886
When the store buffer is active, stores are accumulated and committed
1887
when I/O is idle.
1888
 
1889 100 julius
@item hardfloat = 0|1
1890
@cindex @code{hardfloat} (CPU configuration)
1891 346 jeremybenn
If 1, hardfloat instructions are enabled.  Default value 0.
1892 101 jeremybenn
 
1893 19 jeremybenn
@end table
1894
 
1895
@node Memory Configuration
1896
@subsection Memory Configuration
1897
@cindex configuring memory
1898
@cindex memory configuration
1899
@cindex @code{section memory}
1900 82 jeremybenn
Memory configuration is described in @code{section memory}.  This
1901 19 jeremybenn
section may appear multiple times, specifying multiple blocks of
1902 98 jeremybenn
memory.
1903 19 jeremybenn
 
1904 98 jeremybenn
@quotation Caution
1905 346 jeremybenn
The user may choose whether or not to enable a memory controller.  If a
1906 385 jeremybenn
memory controller is enabled, then appropriate initalization code must
1907
be provided.  The section describing memory controller configuration
1908
describes the steps necessary for using smaller or larger memory
1909
sections (@pxref{Memory Controller Configuration, , Memory Controller
1910
Configuration}).
1911 98 jeremybenn
 
1912 385 jeremybenn
The @dfn{uClibc} startup code initalizes a memory controller, assumed to
1913
be mapped at 0x93000000.  If a memory controller is @emph{not} enabled,
1914
then the standard C library code will generate memory access errors.
1915
The solution is to declare an additional writable memory block, mimicing
1916
the memory controller's register bank as follows.
1917 98 jeremybenn
 
1918
@example
1919
section memory
1920
  pattern = 0x00
1921
  type = unknown
1922
  name = "MC shadow"
1923
  baseaddr = 0x93000000
1924
  size     = 0x00000080
1925
  delayr = 2
1926
  delayw = 4
1927
end
1928
@end example
1929
 
1930
@end quotation
1931
 
1932
 
1933
The following parameters may be specified.
1934
 
1935 19 jeremybenn
@table @code
1936
 
1937 418 julius
@item type=random|pattern|unknown|zero|exitnops
1938 19 jeremybenn
@cindex @code{type} (memory configuration)
1939 82 jeremybenn
Specifies the values to which memory should be initialized.  The
1940 19 jeremybenn
default value is @code{unknown}.
1941
 
1942
@table @code
1943
 
1944
@item random
1945
@cindex @code{type=random} (memory configuration)
1946 82 jeremybenn
Set the memory values to be a random value.  A seed for the random
1947 19 jeremybenn
generator may be set using the @code{random_seed} field in this
1948
section (see below), thus ensuring the same ``random'' values are used
1949
each time.
1950
 
1951
@item pattern
1952
@cindex @code{type=pattern} (memory configuration)
1953
Set the memory values to be a pattern value, which is set using the
1954
@code{pattern} field in this section (see below).
1955
 
1956
@item unknown
1957
@cindex @code{type=unknown} (memory configuration)
1958 82 jeremybenn
The memory values are not initialized (i.e.  left ``unknown'').  This
1959 346 jeremybenn
option will yield faster initialization of the simulator.  This is the
1960
default.
1961 19 jeremybenn
 
1962
@item zero
1963
@cindex @code{type=zero} (memory configuration)
1964 82 jeremybenn
Set the memory values to be 0.  This is the equivalent of
1965 19 jeremybenn
@code{type=pattern} and a @code{pattern} value of 0, and implemented
1966
as such.
1967
 
1968
@quotation Note
1969
As a consequence, if the @code{pattern} field is @emph{subsequently}
1970
specified in this section, the value in that field will be used
1971
instead of zero to initialize the memory.
1972
@end quotation
1973
 
1974 418 julius
@item exitnops
1975
@cindex @code{type=exitnops} (memory configuration)
1976
Set the memory values to be an instruction used to signal end of
1977
simulation. This is useful for causing immediate end of simulation
1978
when PC corruption occurs.
1979
 
1980 19 jeremybenn
@end table
1981
 
1982
@item random_seed = @var{value}
1983
@cindex @code{random_seed} (memory configuration)
1984 82 jeremybenn
Set the seed for the random number generator to @var{value}.  This only
1985 19 jeremybenn
has any effect for memory type @code{random}.
1986
 
1987
The default value is -1,
1988
which means the seed will be set from a call to the @code{time}
1989
function, thus ensuring different random values are used on each
1990 82 jeremybenn
run.  The simulator prints out the seed used in this case, allowing
1991 19 jeremybenn
repeat runs to regenerate the same random values used in any
1992
particular run.
1993
 
1994
@item pattern = @var{value}
1995
@cindex @code{pattern} (memory configuration)
1996
Set the pattern to be used when initializing memory to
1997 82 jeremybenn
@var{value}.  The default value is 0.  This only has any effect for
1998
memory type @code{pattern}.  The least significant 8 bits of this value
1999
is used to initialize each byte.  More than 8 bits can be specified,
2000 19 jeremybenn
but will ignored with a warning.
2001
 
2002
@quotation Tip
2003
The default value, is equivalent to setting the memory @code{type} to
2004 82 jeremybenn
be @code{zero}.  If that is what is intended, then using
2005 19 jeremybenn
@code{type=zero} explicitly is better than using @code{type=pattern}
2006
and not specifying a value for @code{pattern}.
2007
@end quotation
2008
 
2009
@item baseaddr = @var{value}
2010
@cindex @code{baseaddr} (memory configuration)
2011 82 jeremybenn
Set the base address of the memory to @var{value}.  It should be
2012 19 jeremybenn
aligned to a multiple of the memory size rounded up to the nearest
2013 82 jeremybenn
@math{2^n}.  The default value is 0.
2014 19 jeremybenn
 
2015
@item size = @var{value}
2016
@cindex @code{size} (memory configuration)
2017 82 jeremybenn
Set the size of the memory block to be @var{value} bytes.  This should be a
2018
multiple of 4 (i.e.  word aligned).  The default value is 1024.
2019 19 jeremybenn
 
2020
@quotation Note
2021
When allocating memory, the simulator will allocate the nearest
2022
@math{2^n} bytes greater than or equal to @var{value}, and will not
2023
notice memory misses in any part of the memory between @var{value} and
2024
the amount allocated.
2025
 
2026
As a consequence users are strongly recommended to specify memory
2027 82 jeremybenn
sizes that are an exact power of 2.  If some other amount of memory is
2028 19 jeremybenn
required, it should be specified as separate, contiguous blocks, each
2029
of which is a power of 2 in size.
2030
@end quotation
2031
 
2032
@item name = "@var{text}"
2033
@cindex @code{name} (memory configuration)
2034 82 jeremybenn
Name the block.  Typically these describe the type of memory being
2035
modeled (thus @code{"SRAM"} or @code{"Flash"}.  The default is
2036 19 jeremybenn
@code{@w{"anonymous memory block"}}.
2037
 
2038
@quotation Note
2039
It is not clear that this information is currently ever used in normal
2040 82 jeremybenn
operation of the simulator.  Even the @command{info} command of the simulator
2041 19 jeremybenn
ignores it.
2042
@end quotation
2043
 
2044
@item ce = @var{value}
2045
@cindex @code{ce} (memory configuration)
2046 82 jeremybenn
Set the chip enable index of the memory instance.  Each memory instance
2047 19 jeremybenn
should have a unique chip enable index, which should be greater
2048 82 jeremybenn
than or equal to zero.  This is used by the memory controller when
2049 19 jeremybenn
identifying different memory instances.
2050
 
2051 346 jeremybenn
There is no requirement to set @code{ce} if a memory controller is not
2052
enabled.  The default value is -1 (invalid).
2053 19 jeremybenn
 
2054
@item mc = @var{value}
2055
@cindex @code{mc} (memory configuration)
2056 82 jeremybenn
Specifies the memory controller this memory is connected to.  It should
2057 19 jeremybenn
correspond to the @code{index} field specified in a @code{@w{section
2058
mc}} for a memory controller (@pxref{Memory Controller Configuration,
2059
, Memory Controller Configuration}).
2060
 
2061 346 jeremybenn
There is no requirement to set @code{mc} if a memory controller is not
2062
enabled.  Default value is 0, which is also the default value of a
2063
memory controller @code{index} field.  This is suitable therefore for
2064
designs with just one memory controller.
2065 19 jeremybenn
 
2066
@item delayr = @var{value}
2067
@cindex @code{delayr} (memory configuration)
2068 82 jeremybenn
The number of cycles required for a read access.  Set to -1 if the
2069
memory does not support reading.  Default value 1.  The simulator will
2070 19 jeremybenn
add this number of cycles to the total instruction cycle count when
2071
reading from main memory.
2072
 
2073
@item delayw = @var{value}
2074
@cindex @code{delayw} (memory configuration)
2075 82 jeremybenn
The number of cycles required for a write access.  Set to -1 if the
2076
memory does not support writing.  Default value 1.  The simulator will
2077 19 jeremybenn
add this number of cycles to the total instruction cycle count when
2078
writing to main memory.
2079
 
2080
@item log = "@var{file}"
2081
@cindex @code{log} (memory configuration)
2082
If specified, @file{file} names a file for all memory accesses to be
2083 82 jeremybenn
logged.  If not specified, the default value, NULL is used, meaning
2084 19 jeremybenn
that the memory is not logged.
2085
 
2086
@end table
2087
 
2088
@node Memory Management Configuration
2089
@subsection Memory Management Configuration
2090
@cindex configuring data & instruction MMUs
2091
@cindex MMU configuration
2092
@cindex DMMU configuration
2093
@cindex data MMU configuration
2094
@cindex IMMU configuration
2095
@cindex instruction MMU configuration
2096
@cindex @code{section dmmu}
2097
@cindex @code{section immu}
2098
Memory Management Unit (MMU) configuration is described in
2099
@code{section dmmu} (for the data MMU) and @code{section immu} (for
2100 82 jeremybenn
the instruction MMU).  Each section should appear at most once.  The
2101 19 jeremybenn
following parameters may be specified.
2102
 
2103
@table @code
2104
 
2105
@item enabled = 0|1
2106
@cindex @code{enabled} (MMU configuration)
2107
If 1 (true), the data or instruction (as appropriate) MMU is
2108 82 jeremybenn
enabled.  If 0 (the default), it is disabled.
2109 19 jeremybenn
 
2110
@item nsets = @var{value}
2111
@cindex @code{nsets} (MMU configuration)
2112
Sets the number of data or instruction (as appropriate) TLB sets to
2113 82 jeremybenn
@var{value}, which must be a power of two, not exceeding 128.  Values
2114
which do not fit these criteria are ignored with a warning.  The
2115
default value is 1.
2116 19 jeremybenn
 
2117
@item nways = @var{value}
2118
@cindex @code{nways} (MMU configuration)
2119
Sets the number of data or instruction (as appropriate) TLB ways to
2120 82 jeremybenn
@var{value}.  The value must be in the range 1 to 4.  Values outside
2121
this range are ignored with a warning.  The default value is 1.
2122 19 jeremybenn
 
2123
@item pagesize = @var{value}
2124
@cindex @code{pagesize} (MMU configuration)
2125
The data or instruction (as appropriate) MMU page size is set to
2126 82 jeremybenn
@var{value}, which must be a power of 2.  Values which are not a power
2127
of 2 are ignored with a warning.  The default is 8192 (0x2000).
2128 19 jeremybenn
 
2129
@item entrysize = @var{value}
2130
@cindex @code{entrysize} (MMU configuration)
2131
The data or instruction (as appropriate) MMU entry size is set to
2132 82 jeremybenn
@var{value}, which must be a power of 2.  Values which are not a power
2133
of 2 are ignored with a warning.  The default value is 1.
2134 19 jeremybenn
 
2135
@quotation Note
2136
@value{OR1KSIM} does not appear to use the @code{entrysize} parameter
2137 82 jeremybenn
in its simulation of the MMUs.  Thus setting this value does not seem
2138 19 jeremybenn
to matter.
2139
@end quotation
2140
 
2141
@item ustates = @var{value}
2142
@cindex @code{ustates} (MMU configuration)
2143
The number of instruction usage states for the data or instruction (as
2144
appropriate) MMU is set to @var{value}, which must be 2, 3 or
2145 82 jeremybenn
4.  Values outside this range are ignored with a warning.  The default
2146 19 jeremybenn
value is 2.
2147
 
2148
@quotation Note
2149
@value{OR1KSIM} does not appear to use the @code{ustates} parameter in
2150 82 jeremybenn
its simulation of the MMUs.  Thus setting this value does not seem to
2151 19 jeremybenn
matter.
2152
@end quotation
2153
 
2154
@item hitdelay = @var{value}
2155
@cindex @code{hitdelay} (MMU configuration)
2156
Set the number of cycles a data or instruction (as appropriate) MMU
2157 82 jeremybenn
hit costs.  Default value 1.
2158 19 jeremybenn
 
2159
@item missdelay = @var{value}
2160
@cindex @code{missdelay} (MMU configuration)
2161
Set the number of cycles a data or instruction (as appropriate) MMU
2162 82 jeremybenn
miss costs.  Default value 1.
2163 19 jeremybenn
 
2164
@end table
2165
 
2166
@node Cache Configuration
2167
@subsection Cache Configuration
2168
@cindex configuring data & instruction caches
2169
@cindex cache configuration
2170
@cindex data cache configuration
2171
@cindex instruction cache configuration
2172
@cindex @code{section dc}
2173
@cindex @code{section ic}
2174
Cache configuration is described in @code{section dc} (for the data
2175 82 jeremybenn
cache) and @code{seciton ic} (for the instruction cache).  Each section
2176
should appear at most once.  The following parameters may be specified.
2177 19 jeremybenn
 
2178
@table @code
2179
 
2180
@item enabled = 0|1
2181
@cindex @code{enabled} (cache configuration)
2182
If 1 (true), the data or instruction (as appropriate) cache is
2183 82 jeremybenn
enabled.  If 0 (the default), it is disabled.
2184 19 jeremybenn
 
2185
@item nsets = @var{value}
2186
@cindex @code{nsets} (cache configuration)
2187
Sets the number of data or instruction (as appropriate) cache sets to
2188
@var{value}, which must be a power of two, not exceeding
2189
@code{MAX_DC_SETS} (for the data cache) or @code{MAX_IC_SETS} (for the
2190 82 jeremybenn
instruction cache).  At the time of writing, these constants are
2191
both defined in the code to be 1024).  The default value is 1.
2192 19 jeremybenn
 
2193
@item nways = @var{value}
2194
@cindex @code{nways} (cache configuration)
2195
Sets the number of data or instruction (as appropriate) cache ways to
2196
@var{value}, which must be a power of two, not exceeding
2197
@code{MAX_DC_WAYS} (for the data cache) or @code{MAX_IC_WAYS} (for the
2198 82 jeremybenn
instruction cache).  At the time of writing, these constants are both
2199
defined in the code to be 32).  The default value is 1.
2200 19 jeremybenn
 
2201
@item blocksize = @var{value}
2202
@cindex @code{blocksize} (cache configuration)
2203
The data or instruction (as appropriate) cache block size is set to
2204 82 jeremybenn
@var{value} bytes, which must be either 16 or 32.  The default is 16.
2205 19 jeremybenn
 
2206
@item ustates = @var{value}
2207
@cindex @code{ustates} (cache configuration)
2208
The number of instruction usage states for the data or instruction (as
2209 82 jeremybenn
appropriate) cache is set to @var{value}, which must be 2, 3 or 4.  The
2210 19 jeremybenn
default value is 2.
2211
 
2212
@item hitdelay = @var{value}
2213
@cindex @code{hitdelay} (instruction cache configuration)
2214 82 jeremybenn
@emph{Instruction cache only}.  Set the number of cycles an instruction
2215
cache hit costs.  Default value 1.
2216 19 jeremybenn
 
2217
@item missdelay = @var{value}
2218
@cindex @code{missdelay} (instruction cache configuration)
2219 82 jeremybenn
@emph{Instruction cache only}.  Set the number of cycles an instruction
2220
cache miss costs.  Default value 1.
2221 19 jeremybenn
 
2222
@item load_hitdelay = @var{value}
2223
@cindex @code{load_hitdelay} (data cache configuration)
2224 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data load cache hit
2225
costs.  Default value 2.
2226 19 jeremybenn
 
2227
@item load_missdelay = @var{value}
2228
@cindex @code{load_missdelay} (data cache configuration)
2229 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data load cache
2230
miss costs.  Default value 2.
2231 19 jeremybenn
 
2232
@item store_hitdelay = @var{value}
2233
@cindex @code{store_hitdelay} (data cache configuration)
2234 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data store cache hit
2235
costs.  Default value 0.
2236 19 jeremybenn
 
2237
@item store_missdelay = @var{value}
2238
@cindex @code{store_missdelay} (data cache configuration)
2239 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data store cache
2240
miss costs.  Default value 0.
2241 19 jeremybenn
 
2242
@end table
2243
 
2244
@node Interrupt Configuration
2245
@subsection Interrupt Configuration
2246
@cindex configuring the interrupt controller
2247
@cindex interrupt controller configuration
2248
@cindex programmable interrupt controller configuration
2249
@cindex PIC configuration
2250
@cindex @code{section pic}
2251
Programmable Interrupt Controller (PIC) configuration is described in
2252 82 jeremybenn
@code{section pic}.  This section may appear at most
2253 19 jeremybenn
once---@value{OR1KSIM} has no mechanism for handling multiple
2254 82 jeremybenn
interrupt controllers.  The following parameters may be specified.
2255 19 jeremybenn
 
2256
@table @code
2257
 
2258
@item enabled = 0|1
2259
@cindex @code{enabled} (interrupt controller)
2260 82 jeremybenn
If 1 (true), the programmable interrupt controller is enabled.  If 0
2261 19 jeremybenn
(the default), it is disabled.
2262
 
2263
@item edge_trigger = 0|1
2264
@cindex @code{edge_trigger} (interrupt controller)
2265
If 1 (true, the default), the programmable interrupt controller is
2266 82 jeremybenn
edge triggered.  If 0 (false), it is level triggered.
2267 19 jeremybenn
 
2268 432 jeremybenn
The library interface (@pxref{Simulator Library, , Simulator Library})
2269
provides different functions for setting the different types of
2270
interrupt, and a function to clear level sensitive interrupts. Edge
2271
sensitive interrupts must be cleared by clearing the corresponding bit
2272
in the PICSR SPR.
2273 430 julius
 
2274 432 jeremybenn
Internal functions to set and clear interrupts are also provided for
2275 440 jeremybenn
peripherals implemented within @value{OR1KSIM}. @xref{Interrupts Internal, ,
2276 432 jeremybenn
Interrupts Internal} for more details.
2277 430 julius
 
2278 432 jeremybenn
@item use_nmi = 0|1
2279
@cindex @code{use_nmi} (interrupt controller)
2280
If 1 (true, the default), interrupt lines 0 and 1 are non-maskable. In
2281
other words the least significant 2 bits of the PICMR SPR are hard-wired
2282
to 1.  If 0 (false), all interrupt lines are treated as equivalent.
2283
 
2284
@quotation Note
2285
These are not non-maskable in the true sense that they will pre-empt
2286
other interrupts.  Rather they can never be masked out using the PICMR
2287
register. It is up the interrupt exception handler to give these
2288
interrupt lines priority, and indeed to decide on the priority order in
2289
general.
2290 430 julius
@end quotation
2291
 
2292 19 jeremybenn
@end table
2293
 
2294
@node Power Management Configuration
2295
@subsection Power Management Configuration
2296
@cindex configuring power management
2297
@cindex power management configuration
2298
@cindex PMU configuration
2299
@cindex @code{section pmu}
2300 82 jeremybenn
Power management implementation is incomplete.  At present the effect
2301 19 jeremybenn
(which only happens when the power management unit is enabled) of
2302
setting the different bits in the power management Special Purpose
2303
Register (PMR, SPR 0x4000) is
2304
 
2305
@table @code
2306
 
2307
@item SDF (bit mask 0x0000000f)
2308
@cindex SDF (power management register)
2309
@cindex slow down factor (power management register)
2310
@cindex power management register, SDF
2311
@cindex PMR - SDF
2312
No effect - these bits are ignored
2313
 
2314
@item DME (bit mask 0x00000010)
2315
@cindex DME (power management register)
2316
@cindex doze mode (power management register)
2317
@cindex power management register, DME
2318
@cindex PMR - DME
2319
@itemx SME (bit mask 0x00000020)
2320
@cindex SME (power management register)
2321
@cindex sleep mode (power management register)
2322
@cindex power management register, SME
2323
@cindex PMR - SME
2324
Both these bits cause the processor to stop executing
2325 82 jeremybenn
instructions.  However all other functions (debug interaction, CLI,
2326 19 jeremybenn
VAPI etc) carry on as normal.
2327
 
2328
@item DCGE (bit mask 0x00000004)
2329
@cindex DCGE (power management register)
2330
@cindex dynamic clock gating (power management register)
2331
@cindex power management register, DGCE
2332
@cindex PMR - DGCE
2333
No effect - this bit is ignored
2334
 
2335
@item SUME (bit mask 0x00000008)
2336
@cindex SUME (power management register)
2337
@cindex suspend mode (power management register)
2338
@cindex power management register, SUME
2339
@cindex PMR - SUME
2340
Enabling this bit causes a message to be printed, advising that the
2341
processor is suspending and the simulator exits.
2342
 
2343
@end table
2344
 
2345
On reset all bits are cleared.
2346
 
2347 82 jeremybenn
Power management configuration is described in @code{section pm}.  This
2348
section may appear at most once.  The following parameter may be specified.
2349 19 jeremybenn
 
2350
@table @code
2351
 
2352
@item enabled = 0|1
2353
@cindex @code{enabled} (power management configuration)
2354 82 jeremybenn
If 1 (true), power management is enabled.  If 0 (the default), it is
2355 19 jeremybenn
disabled.
2356
 
2357
@end table
2358
 
2359
@node Branch Prediction Configuration
2360
@subsection Branch Prediction Configuration
2361
@cindex configuring branch prediction
2362
@cindex branch prediction configuration
2363
@cindex BPB configuration
2364
@cindex @code{section bpb}
2365
From examining the code base, it seems the branch prediction function
2366 82 jeremybenn
is not fully implemented.  At present the functionality seems
2367 19 jeremybenn
restricted to collection of statistics.
2368
 
2369 82 jeremybenn
Branch prediction configuration is described in @code{section bpb}.  This
2370
section may appear at most once.  The following parameters may be specified.
2371 19 jeremybenn
 
2372
@table @code
2373
 
2374
@item enabled = 0|1
2375
@cindex @code{enabled} (branch prediction configuration)
2376 82 jeremybenn
If 1 (true), branch prediction is enabled.  If 0 (the default), it is
2377 19 jeremybenn
disabled.
2378
 
2379
@item btic = 0|1
2380
@cindex @code{btic} (branch prediction configuration)
2381 82 jeremybenn
If 1 (true), the branch target instruction cache model is enabled.  If
2382 19 jeremybenn
 
2383
 
2384
@item sbp_bf_fwd = 0|1
2385
@cindex @code{sbp_bf_fwd} (branch prediction configuration)
2386 82 jeremybenn
If 1 (true), use forward prediction for the @code{l.bf} instruction.  If
2387 19 jeremybenn
 
2388
 
2389
@item sbp_bnf_fwd = 0|1
2390
@cindex @code{sbp_bnf_fwd} (branch prediction configuration)
2391 82 jeremybenn
If 1 (true), use forward prediction for the @code{l.bnf} instruction.  If
2392 19 jeremybenn
 
2393
 
2394
@item hitdelay = @var{value}
2395
@cindex @code{hitdelay} (branch prediction configuration)
2396 82 jeremybenn
Set the number of cycles a branch prediction hit costs.  Default value
2397 19 jeremybenn
0.
2398
 
2399
@item missdelay = @var{value}
2400
@cindex @code{missdelay} (branch prediction configuration)
2401 82 jeremybenn
Set the number of cycles a branch prediction miss costs.  Default value
2402 19 jeremybenn
0.
2403
 
2404
@end table
2405
 
2406
@node Debug Interface Configuration
2407
@subsection Debug Interface Configuration
2408
@cindex configuring the debug unit and interface to external debuggers
2409
@cindex debug unit configuration
2410
@cindex debug interface configuration
2411
@cindex @code{section debug}
2412
The debug unit and debug interface configuration is described in
2413 82 jeremybenn
@code{@w{section debug}}.  This section may appear at most once.  The
2414 19 jeremybenn
following parameters may be specified.
2415
 
2416
@table @code
2417
 
2418
@item enabled = 0|1
2419
@cindex @code{enabled} (debug interface configuration)
2420 82 jeremybenn
If 1 (true), the debug unit is enabled.  If 0 (the default), it is disabled.
2421 19 jeremybenn
 
2422
@quotation Note
2423
This enables the functionality of the debug unit (its registers etc) within
2424 82 jeremybenn
the mode.  It does not provide any external interface to the debug unit.
2425
For
2426 235 jeremybenn
that, see @code{rsp_enabled} below.
2427 19 jeremybenn
@end quotation
2428
 
2429
@item rsp_enabled = 0|1
2430
@cindex @code{rsp_enabled} (debug interface configuration)
2431
@cindex Remote Serial Protocol
2432
If 1 (true), the GDB @dfn{Remote Serial Protocol} server is started, provding
2433
an interface to an external GNU debugger, using the port specified in the
2434
@code{rsp_port} field (see below), or the @code{or1ksim-rsp} TCP/IP
2435 82 jeremybenn
service.  If 0 (the default), the server is not started, and no external
2436 19 jeremybenn
interface is provided.
2437
 
2438
For more detailed information on the interface to the GNU Debugger see
2439
Embecosm Application Note 2, @cite{Howto: Porting the GNU Debugger Practical
2440
Experience with the OpenRISC 1000 Architecture}, by Jeremy Bennett, published
2441
by Embecosm Limited (@url{www.embecosm.com}).
2442
 
2443
@item rsp_port = @var{value}
2444
@cindex @code{rsp_port} (debug interface configuration)
2445
@var{value} specifies the port to be used for the GDB @dfn{Remote Serial
2446 82 jeremybenn
Protocol} interface to the GNU Debugger (GDB).  Default value 51000.  If
2447 19 jeremybenn
the value 0 is specified, @value{OR1KSIM} will instead look for a TCP/IP
2448
service named @code{or1ksim-rsp}.
2449
 
2450
@quotation Tip
2451
@cindex TCP/IP port range for @code{or1ksim-rsp} service
2452
There is no registered port for @value{OR1KSIM} @dfn{Remote Serial Protocol}
2453 82 jeremybenn
service @code{or1ksim-rsp}.  Good practice suggests users should adopt port
2454
values in the @dfn{Dynamic} or @dfn{Private} port range, i.e.  49152-65535.
2455 19 jeremybenn
@end quotation
2456
 
2457
@item vapi_id = @var{value}
2458
@cindex @code{vapi_id} (debug interface configuration)
2459
@var{value} specifies the value of the Verification API (VAPI) base
2460 82 jeremybenn
address to be used with the debug unit.  @xref{Verification API, ,
2461 19 jeremybenn
Verification API}, for more details.
2462
 
2463
If this is specified and @var{value} is non-zero, all OpenRISC Remote
2464
JTAG protocol transactions will be logged to the VAPI log file, if
2465 82 jeremybenn
enabled.  This is the only functionality associated with VAPI for the
2466
debug unit.  No VAPI commands are sent, nor requests handled.
2467 19 jeremybenn
 
2468
@end table
2469
 
2470
@node Peripheral Configuration
2471
@section Configuring Memory Mapped Peripherals
2472
 
2473 82 jeremybenn
All peripheral components are optional.  If they are specified, then
2474 19 jeremybenn
(unlike other components) by default they are enabled.
2475
 
2476
@menu
2477
* Memory Controller Configuration::
2478
* UART Configuration::
2479
* DMA Configuration::
2480
* Ethernet Configuration::
2481
* GPIO Configuration::
2482
* Display Interface Configuration::
2483
* Frame Buffer Configuration::
2484
* Keyboard Configuration::
2485
* Disc Interface Configuration::
2486
* Generic Peripheral Configuration::
2487
@end menu
2488
 
2489
@node Memory Controller Configuration
2490
@subsection Memory Controller Configuration
2491
@cindex configuring the memory controller
2492
@cindex memory controller configuration
2493
@cindex @code{section mc}
2494
The memory controller used in @value{OR1KSIM} is the component
2495 98 jeremybenn
implemented at OpenCores, and found in the top level SVN directory,
2496 82 jeremybenn
@file{mem_ctrl}.  It is described in the document @cite{Memory
2497 19 jeremybenn
Controller IP Core} by Rudolf Usselmann, which can be found in the
2498 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
2499 19 jeremybenn
resides on the main OpenRISC Wishbone data bus.
2500
 
2501
The memory controller configuration is described in @code{@w{section
2502 82 jeremybenn
mc}}.  This section may appear multiple times, specifying multiple
2503 98 jeremybenn
memory controllers.
2504 19 jeremybenn
 
2505 385 jeremybenn
@quotation Warning
2506
There are known to be problems with the current memory controller, which
2507
currently is not included in the regression test suite. Users are
2508
advised not to use the memory controller in the current release.
2509
@end quotation
2510
 
2511 98 jeremybenn
@quotation Caution
2512 385 jeremybenn
There is no initialization code in the standard @dfn{newlib}
2513
library.
2514 98 jeremybenn
 
2515 385 jeremybenn
The standard @dfn{uClibc} library assumes a memory controller
2516
mapped at 0x93000000 and will initialize the memory controller to expect
2517
64MB memory blocks, and any memory declarations @emph{must} reflect
2518
this.
2519
 
2520 98 jeremybenn
If smaller memory blocks are declared with a memory controller, then
2521
sufficient memory will not be allocated by @value{OR1KSIM}, but out of
2522 346 jeremybenn
range memory accesses will not be trapped.  For example declaring a
2523 98 jeremybenn
memory section from 0-4MB with a memory controller enabled would mean
2524
that accesses between 4MB and 64MB would be permitted, but having no
2525
allocated memory would likely cause a segmentation fault.
2526
 
2527
If the user is determined to use smaller memories with the memory
2528
controller, then custom initialization code must be provided, to
2529
ensure the memory controller traps out-of-memory accesses.
2530
@end quotation
2531
 
2532
The following parameters may be specified.
2533
 
2534 19 jeremybenn
@table @code
2535
 
2536
@item enabled = 0|1
2537
@cindex @code{enabled} (memory controller configuration)
2538 82 jeremybenn
If 1 (true, the default), this memory controller is enabled.  If 0, it is
2539 19 jeremybenn
disabled.
2540
 
2541
@quotation Note
2542
The memory controller can effectively also be disabled by setting an
2543 82 jeremybenn
appropriate power on control register value (see below).  However this
2544 19 jeremybenn
should only be used if it is desired to specifically model this
2545
behavior of the memory controller, not as a way of disabling the
2546
memory controller in general.
2547
@end quotation
2548
 
2549
@item baseaddr = @var{value}
2550
@cindex @code{baseaddr} (memory controller configuration)
2551
Set the base address of the memory controller's memory mapped
2552 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2553 19 jeremybenn
sensible value.
2554
 
2555
The memory controller has a 7 bit address bus, with a total of 19
2556
32-bit registers, at addresses 0x00 through 0x4c (address 0x0c and
2557
addresses 0x50 through 0x7c are not used).
2558
 
2559
@item poc = @var{value}
2560
@cindex @code{poc} (memory controller configuration)
2561
Specifies the value of the power on control register, The least
2562
signficant two bits specify the bus width (use 0 for an 8-bit bus, 1
2563
for a 16-bit bus and 2 for a 32-bit bus) and the next two bits the
2564
type of memory connected (use 0 for a disabled interface, 1 for SSRAM,
2565
2 for asyncrhonous devices and 3 for synchronous devices).
2566
 
2567
If other bits are specified, they are ignored with a warning.
2568
 
2569
@quotation Caution
2570
The default value, 0, corresponds to a disabled 8-bit bus, and
2571
is likely not the most suitable value
2572
@end quotation
2573
 
2574
@item index = @var{value}
2575
@cindex @code{index} (memory controller configuration)
2576
Specify the index of this memory controller amongst all the memory
2577 82 jeremybenn
controllers.  This value should be unique for each memory controller,
2578 19 jeremybenn
and is used to associate specific memories with the controller,
2579
through the @code{mc} field in the @code{@w{section memory}}
2580
configuration (@pxref{Memory Configuration, , Memory Configuration}).
2581
 
2582
The default value, 0, is suitable when there is only one memory controller.
2583
 
2584
@end table
2585
 
2586
@node UART Configuration
2587
@subsection UART Configuration
2588
@cindex configuring the UART
2589
@cindex UART configuration
2590
@cindex @code{section uart}
2591
The UART implemented in @value{OR1KSIM} follows the specification of the
2592 82 jeremybenn
National Semiconductor 16450 and 16550 parts.  It is a memory mapped
2593 19 jeremybenn
component, which resides on the main OpenRISC Wishbone data bus.
2594
 
2595
The component provides a number of interfaces to emulate the behavior
2596
of an external terminal connected to the UART.
2597
 
2598 82 jeremybenn
UART configuration is described in @code{section uart}.  This section
2599
may appear multiple times, specifying multiple UARTs.  The following
2600 19 jeremybenn
parameters may be specified.
2601
 
2602
@table @code
2603
 
2604
@item enabled = 0|1
2605
@cindex @code{enabled} (UART configuration)
2606 82 jeremybenn
If 1 (true, the default), this UART is enabled.  If 0, it is disabled.
2607 19 jeremybenn
 
2608
@item baseaddr = @var{value}
2609
@cindex @code{baseaddr} (UART configuration)
2610
Set the base address of the UART's memory mapped
2611 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2612 19 jeremybenn
sensible value.
2613
 
2614
The UART has a 3 bit address bus, with a total of 8 8-bit registers,
2615
at addresses 0x0 through 0x7.
2616
 
2617
@item channel = "@var{type}:@var{args}"
2618
@cindex @code{channel} (UART configuration)
2619
Specify the channel representing the terminal connected to the UART
2620
Rx & Tx pins.
2621
 
2622
@table @code
2623
 
2624
@item channel="file:@file{rxfile},@file{txfile}"
2625
@cindex UART I/O from/to files
2626
Read input characters from the file @file{rxfile} and write output
2627
characters to the file @file{txfile} (which will be created if
2628
required).
2629
 
2630
@item channel="xterm:@var{args}"
2631
@cindex UART I/O from/to an @command{xterm}
2632
Create an xterm on startup, write UART Tx traffic to the xterm and
2633
take Rx traffic from the keyboard when the xterm window is
2634 82 jeremybenn
selected.  Additional arguments to the xterm command (for example
2635 19 jeremybenn
specifying window size may be specified in @var{args}, or this may be
2636
left blank.
2637
 
2638
@item channel="tcp:@var{value}"
2639
@cindex UART I/O from/to TCP/IP
2640
Open the TCP/IP port specified by @var{value} and read and write UART
2641
traffic from and to it.
2642
 
2643
Typically a telnet session is connected to the other end of this port.
2644
 
2645
@quotation Tip
2646
There is no registered port for @value{OR1KSIM} telnet UART
2647 82 jeremybenn
connection.  Priviledged access is required to read traffic on the
2648
registered ``well-known'' telnet port (23).  Instead users should use
2649 19 jeremybenn
port values in the @dfn{Dynamic} or @dfn{Private} port range,
2650 82 jeremybenn
i.e.  49152-65535.
2651 19 jeremybenn
@end quotation
2652
 
2653
@item channel="fd:@code{rxfd},@code{txfd}"
2654
@cindex UART I/O from/to open file descriptors
2655
Read and write characters from and to the existing open numerical file
2656
descriptors, file @code{rxfd} and @code{txfd}.
2657
 
2658
@item channel="tty:device=/dev/ttyS0,baud=9600"
2659
@cindex UART I/O from/to a physical serial port
2660 82 jeremybenn
Read and write characters from and to a physical serial port.  The
2661 19 jeremybenn
precise device (shown here as @code{/dev/ttyS0}) may vary from machine
2662
to machine.
2663
 
2664
@end table
2665
 
2666
The default value for this field is @code{"xterm:"}.
2667
 
2668
@item irq = @var{value}
2669
@cindex @code{irq} (UART configuration)
2670 82 jeremybenn
Use @var{value} as the IRQ number of this UART.  Default value 0.
2671 19 jeremybenn
 
2672
@item 16550 = 0|1
2673
@cindex @code{16550} (UART configuration)
2674 82 jeremybenn
If 1 (true), the UART has the functionality of a 16550.  If 0 (the
2675
default), it has the functionality of a 16450.  The principal
2676 19 jeremybenn
difference is that the 16550 can buffer multiple characters.
2677
 
2678
@item jitter = @var{value}
2679
@cindex @code{jitter} (UART configuration)
2680
Set the jitter, modeled as a time to block, to @var{value}
2681 82 jeremybenn
milliseconds.  Set to -1 to disable jitter modeling.  Default value 0.
2682 19 jeremybenn
 
2683
@quotation Note
2684
This functionality has yet to be implemented, so this parameter has no
2685
effect.
2686
@end quotation
2687
 
2688
@item vapi_id = @var{value}
2689
@cindex @code{vapi_id} (UART configuration)
2690
@var{value} specifies the value of the Verification API (VAPI) base
2691 82 jeremybenn
address to be used with the UART.  @xref{Verification API, ,
2692 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2693
with the UART.
2694
 
2695
@end table
2696
 
2697
@node DMA Configuration
2698
@subsection DMA Configuration
2699
@cindex configuring DMA
2700
@cindex DMA configuration
2701
@cindex @code{section dma}
2702
The DMA controller used in @value{OR1KSIM} is the component
2703 98 jeremybenn
implemented at OpenCores, and found in the top level SVN directory,
2704 82 jeremybenn
@file{wb_dma}.  It is described in the document @cite{Wishbone
2705 19 jeremybenn
DMA/Bridge IP Core} by Rudolf Usselmann, which can be found in the
2706 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
2707
resides on the main OpenRISC Wishbone data bus.  The present
2708 19 jeremybenn
implementation is incomplete, intended only to support the Ethernet
2709
interface (@pxref{Ethernet Configuration}), although the Ethernet
2710
interface is not yet completed.
2711
 
2712 82 jeremybenn
DMA configuration is described in @code{@w{section dma}}.  This section
2713
may appear multiple times, specifying multiple DMA controllers.  The
2714 19 jeremybenn
following parameters may be specified.
2715
 
2716
@table @code
2717
 
2718
@item enabled = 0|1
2719
@cindex @code{enabled} (DMA configuration)
2720 82 jeremybenn
If 1 (true, the default), this DMA controller is enabled.  If 0, it is disabled.
2721 19 jeremybenn
 
2722
@item baseaddr = @var{value}
2723
@cindex @code{baseaddr} (DMA configuration)
2724
Set the base address of the DMA's memory mapped
2725 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2726 19 jeremybenn
sensible value.
2727
 
2728
The DMA controller has a 10 bit address bus, with a total of 253
2729 82 jeremybenn
32-bit registers.  The first 5 registers at addresses 0x000 through
2730
0x010 control the overall behavior of the DMA controller.  There are
2731 19 jeremybenn
then 31 blocks of 8 registers, controlling each of the 31 DMA channels
2732 82 jeremybenn
available.  Addresses 0x014 through 0x01c are not used.
2733 19 jeremybenn
 
2734
@item irq = @var{value}
2735
@cindex @code{irq} (DMA configuration)
2736 82 jeremybenn
Use @var{value} as the IRQ number of this DMA controller.  Default value 0.
2737 19 jeremybenn
 
2738
@item vapi_id = @var{value}
2739
@cindex @code{vapi_id} (DMA configuration)
2740
@var{value} specifies the value of the Verification API (VAPI) base
2741 82 jeremybenn
address to be used with the DMA controller.  @xref{Verification API, ,
2742 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2743
with the DMA controller.
2744
 
2745
@end table
2746
 
2747
@node Ethernet Configuration
2748
@subsection Ethernet Configuration
2749
@cindex configuring the Ethernet interface
2750
@cindex Ethernet configuration
2751
@cindex @code{section ethernet}
2752 82 jeremybenn
Ethernet configuration is described in @code{section ethernet}.  This
2753 19 jeremybenn
section may appear multiple times, specifying multiple Ethernet
2754 82 jeremybenn
interfaces.  The following parameters may be specified.
2755 19 jeremybenn
 
2756 440 jeremybenn
The Ethernet MAC used in @value{OR1KSIM} corresponds to the Verilog
2757
implementation in project @dfn{ethmac}. It's source code can be found in
2758
the top level SVN directory, @file{ethmac}.  It also forms part of the
2759
OpenRISC reference SoC, ORPSoC.  It is described in the document
2760
@cite{Ethernet IP Core Specification} by Igor Mohor, which can be found
2761
in the @file{doc} subdirectory.  It is a memory mapped component, which
2762
resides on the main OpenRISC Wishbone data bus.
2763
 
2764 19 jeremybenn
@table @code
2765
 
2766
@item enabled = 0|1
2767
@cindex @code{enabled} (Ethernet configuration)
2768 82 jeremybenn
If 1 (true, the default), this Ethernet MAC is enabled.  If 0, it is
2769 19 jeremybenn
disabled.
2770
 
2771
@item baseaddr = @var{value}
2772
@cindex @code{baseaddr} (Ethernet configuration)
2773
Set the base address of the MAC's memory mapped registers to
2774 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
2775 19 jeremybenn
 
2776
The Ethernet MAC has a 7-bit address bus, with a total of 21
2777 82 jeremybenn
32-bit registers.  Addresses 0x54 through 0x7c are not used.
2778 19 jeremybenn
 
2779
@quotation Note
2780
The Ethernet specification describes a Tx control register,
2781 82 jeremybenn
@code{TXCTRL}, at address 0x50.  However this register is not
2782 19 jeremybenn
implemented in the @value{OR1KSIM} model.
2783
@end quotation
2784
 
2785
@item dma = @var{value}
2786
@cindex @code{dma} (Ethernet configuration)
2787
@var{value} specifies the DMA controller with which this Ethernet is
2788 82 jeremybenn
associated.  The default value is 0.
2789 19 jeremybenn
 
2790
@quotation Note
2791
Support for external DMA is not provided in the current
2792 82 jeremybenn
implementation, and this value is ignored.  In any case there is no
2793 19 jeremybenn
equivalent field to which this can be matched in the current DMA
2794
component implementation (@pxref{DMA Configuration, , DMA
2795
Configuration}).
2796
@end quotation
2797
 
2798
@item irq = @var{value}
2799
@cindex @code{dma} (Ethernet configuration)
2800 82 jeremybenn
Use @var{value} as the IRQ number of this Ethernet MAC.  Default value 0.
2801 19 jeremybenn
 
2802 440 jeremybenn
@item rtx_type = "file"|"tap"
2803 19 jeremybenn
@cindex @code{rtx_type} (Ethernet configuration)
2804 440 jeremybenn
Specifies whether to use a TUN/TAP interface or file interface (the default)
2805
to model the external connection of the Ethernet.
2806
 
2807
If a TUN/TAP interface is requested, Ethernet packets will be sent and
2808
received through the pesistent TAP interface specified in parameter
2809
@code{tap_dev} (see below).
2810
 
2811
More details on configuring the TUN/TAP interface are given in the Usage
2812
section (@pxref{Ethernet TUN/TAP Interface, , Ethernet TUN/TAP
2813
Interface}).
2814
 
2815
If a file interface (the default), is requested, the Ethernet will be
2816
modelled by reading and writing from and to the files specified in the
2817 19 jeremybenn
@code{rxfile} and @code{txfile} parameters (see below).
2818
 
2819 440 jeremybenn
@quotation Caution
2820
If a file interface is specified, @value{OR1KSIM} will terminate once the
2821
receive file specified by @code{rxfile} is exhausted.
2822 19 jeremybenn
@end quotation
2823
 
2824
@item rx_channel = @var{rxvalue}
2825
@cindex @code{rx_channel} (Ethernet configuration)
2826
@itemx tx_channel = @var{txvalue}
2827
@cindex @code{tx_channel} (Ethernet configuration)
2828
@var{rxvalue} specifies the DMA channel to use for receive and
2829 82 jeremybenn
@var{txvalue} the DMA channel to use for transmit.  Both default to 0.
2830 19 jeremybenn
 
2831
@quotation Note
2832
As noted above, support for external DMA is not provided in the
2833
current implementation, and so these values are ignored.
2834
@end quotation
2835
 
2836
@item rxfile = "@var{rxfile}"
2837
@cindex @code{rxfile} (Ethernet configuration)
2838
@itemx txfile = "@var{txfile}"
2839
@cindex @code{txfile} (Ethernet configuration)
2840
When @code{rtx_type} is 0 (see above), @var{rxfile} specifies the file
2841
to use as input and @var{txfile} specifies the fie to use as
2842
output.
2843
 
2844 82 jeremybenn
The file contains a sequence of packets.  Each packet consists of a
2845
packet length (32 bits), followed by that many bytes of data.  Once the
2846 19 jeremybenn
input file is empty, the Ethernet MAC behaves as though there were no
2847 82 jeremybenn
data on the Ethernet.  The default values of these parameters are
2848 19 jeremybenn
@code{"eth_rx"} and @code{"eth_tx"} respectively.
2849
 
2850 82 jeremybenn
The input file must exist and be readable.  The output file must be
2851
writable and will be created if necessary.  If either of these
2852 19 jeremybenn
conditions is not met, a warning will be given.
2853
 
2854 440 jeremybenn
@quotation Caution
2855
@value{OR1KSIM} will terminate once the @var{rxfile} is exhausted.
2856
@end quotation
2857 19 jeremybenn
 
2858 440 jeremybenn
@item tap_dev = "@var{tap}"
2859
@cindex @code{tap_dev} (Ethernet configuration)
2860
When @code{rtx_type} is @code{"tap"} (see above), @var{tap_dev}
2861
specifies the TAP device to use for communication.  This should be a
2862
persistent TAP device configured for the system (@pxref{Ethernet TUN/TAP
2863
Interface, , Ethernet TUN/TAP Interface})
2864
 
2865 451 jeremybenn
@item phy_addr = @var{value}
2866
@cindex @code{phy_addr}
2867
@var{value} specifies the address for emulated ethernet PHY (default
2868
0). If there are multiple Ethernet peripherals, they should each have a
2869
different PHY value.
2870
 
2871
@item dummy_crc = 0|1
2872
@cindex @code{dummy_crc} (Ethernet configuration)
2873
If 1 (true, the default), the length of the data transferred to the core
2874
will be increased by 4 bytes, as though the CRC were included.
2875
 
2876
@quotation Note
2877
This is for historical consistency with the OpenRISC Ethernet hardware
2878
MAC, which passes on the CRC in the data packet. This is unusual
2879
behavior for a MAC, but the OpenRISC Linux device drivers have been
2880
written to expect it.
2881
@end quotation
2882
 
2883
@item phy_addr = @var{value}
2884
@cindex @code{phy_addr}
2885
@var{value} specifies the address for emulated ethernet PHY (default
2886
0). If there are multiple Ethernet peripherals, they should each have a
2887
different PHY value.
2888
 
2889 19 jeremybenn
@item vapi_id = @var{value}
2890
@cindex @code{vapi_id} (DMA configuration)
2891
@var{value} specifies the value of the Verification API (VAPI) base
2892 82 jeremybenn
address to be used with the Ethernet PHY.  @xref{Verification API, ,
2893 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2894
with the DMA controller.
2895
 
2896
@end table
2897
 
2898
@node GPIO Configuration
2899
@subsection GPIO Configuration
2900
@cindex configuring the GPIO
2901
@cindex GPIO configuration
2902
@cindex @code{section cpio}
2903
The GPIO used in @value{OR1KSIM} is the component implemented at
2904 98 jeremybenn
OpenCores, and found in the top level SVN directory, @file{gpio}.  It
2905 19 jeremybenn
is described in the document @cite{GPIO IP Core Specification} by
2906
Damjan Lampret and Goran Djakovic, which can be found in the
2907 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
2908 19 jeremybenn
resides on the main OpenRISC Wishbone data bus.
2909
 
2910 82 jeremybenn
GPIO configuration is described in @code{@w{section gpio}}.  This section
2911
may appear multiple times, specifying multiple GPIO devices.  The
2912 19 jeremybenn
following parameters may be specified.
2913
 
2914
@table @code
2915
 
2916
@item enabled = 0|1
2917
@cindex @code{enabled} (GPIO configuration)
2918 82 jeremybenn
If 1 (true, the default), this GPIO is enabled.  If 0, it is disabled.
2919 19 jeremybenn
 
2920
@item baseaddr = @var{value}
2921
@cindex @code{baseaddr} (GPIO configuration)
2922
Set the base address of the GPIO's memory mapped
2923 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2924 19 jeremybenn
sensible value.
2925
 
2926
The GPIO has a 6 bit address bus, with a total of 10 32-bit registers,
2927 82 jeremybenn
although the number of bits that are actively used varies.  Addresses
2928 19 jeremybenn
0x28 through 0x3c are not used.
2929
 
2930
@item irq = @var{value}
2931
@cindex @code{irq} (GPIO configuration)
2932 82 jeremybenn
Use @var{value} as the IRQ number of this GPIO.  Default value 0.
2933 19 jeremybenn
 
2934
@item vapi_id = @var{value}
2935
@cindex @code{vapi_id} (GPIO configuration)
2936
@cindex @code{base_vapi_id} (GPIO configuration - deprecated)
2937
@var{value} specifies the value of the Verification API (VAPI) base
2938 82 jeremybenn
address to be used with the GPIO.  @xref{Verification API, ,
2939 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2940 82 jeremybenn
with the GPIO controller.  For backwards compatibility, the
2941 19 jeremybenn
alternative name @code{base_vapi_id} is supported for this parameter,
2942
but deprecated.
2943
 
2944
@end table
2945
 
2946
@node Display Interface Configuration
2947
@subsection Display Interface Configuration
2948
@cindex configuring the VGA interface
2949
@cindex display interface configuration
2950
@cindex VGA configuration
2951
@cindex @code{section vga}
2952
@value{OR1KSIM} models a VGA interface to an external monitor.  The
2953
VGA controller used in @value{OR1KSIM} is the component implemented at
2954 98 jeremybenn
OpenCores, and found in the top level SVN directory, @file{vga_lcd},
2955 82 jeremybenn
with no support for the optional hardware cursors.  It is described in
2956 19 jeremybenn
the document @cite{VGA/LCD Core v2.0 Specifications} by Richard
2957 82 jeremybenn
Herveille, which can be found in the @file{doc} subdirectory.  It is a
2958 19 jeremybenn
memory mapped component, which resides on the main OpenRISC Wishbone
2959
data bus.
2960
 
2961
The current implementation provides only functionality to dump the
2962
screen to a file at intervals.
2963
 
2964
VGA controller configuration is described in @code{@w{section
2965 82 jeremybenn
vga}}.  This section may appear multiple times, specifying multiple
2966
VGA controllers.  The following parameters may be specified.
2967 19 jeremybenn
 
2968
@table @code
2969
 
2970
@item enabled = 0|1
2971
@cindex @code{enabled} (VGA configuration)
2972 82 jeremybenn
If 1 (true, the default), this VGA is enabled.  If 0, it is disabled.
2973 19 jeremybenn
 
2974
@item baseaddr = @var{value}
2975
@cindex @code{baseaddr} (VGA configuration)
2976
Set the base address of the VGA controller's memory mapped
2977 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2978 19 jeremybenn
sensible value.
2979
 
2980
The VGA controller has a 12-bit address bus, with 7 32-bit registers, at
2981
addresses 0x000 through 0x018, and two color lookup tables at
2982 82 jeremybenn
addresses 0x800 through 0xfff.  The hardware cursor registers are not
2983 19 jeremybenn
implemented, so addresses 0x01c through 0x7fc are not used.
2984
 
2985
@item irq = @var{value}
2986
@cindex @code{irq} (VGA configuration)
2987 82 jeremybenn
Use @var{value} as the IRQ number of this VGA controller.  Default
2988 19 jeremybenn
value 0.
2989
 
2990
@item refresh_rate = @var{value}
2991
@cindex @code{refresh_rate} (VGA configuration)
2992 82 jeremybenn
@var{value} specifies number of cycles between screen dumps.  Default
2993 19 jeremybenn
value is derived from the simulation clock cycle time
2994
(@pxref{Simulator Behavior, , Simulator Behavior}), to correspond
2995
to dumping 50 times per simulated second.
2996
 
2997
@item txfile = "@var{file}"
2998
@cindex @code{txfile} (VGA configuration)
2999
@cindex @code{filename} (VGA configuration - deprecated)
3000
@var{file} specifies the base of the filename for screen
3001 82 jeremybenn
dumps.  Successive screen dumps will be in BMP format, in files with
3002 19 jeremybenn
the name @file{@var{file}@var{nnnn}.bmp}, where @var{nnnn} is a
3003 82 jeremybenn
sequential count of the screen dumps starting at zero.  The default
3004
value is @code{"vga_out"}.  For backwards compatibility, the
3005 19 jeremybenn
alternative name @code{filename} is supported for this parameter,
3006
but deprecated.
3007
 
3008
@end table
3009
 
3010
@node Frame Buffer Configuration
3011
@subsection Frame Buffer Configuration
3012
@cindex configuring the frame buffer
3013
@cindex frame buffer configuration
3014
@cindex @code{section fb}
3015
@quotation Caution
3016 82 jeremybenn
The frame buffer is only partially implemented.  Its configuration
3017 19 jeremybenn
fields are described here, but the component should not be used at
3018 82 jeremybenn
this time.  Like the VGA controller, it is designed to make screen
3019 19 jeremybenn
dumps to file.
3020
@end quotation
3021
 
3022 82 jeremybenn
Frame buffer configuration is described in @code{section fb}.  This
3023 19 jeremybenn
section may appear multiple times, specifying multiple frame
3024 82 jeremybenn
buffers.  The following parameters may be specified.
3025 19 jeremybenn
 
3026
@table @code
3027
 
3028
@item enabled = 0|1
3029
@cindex @code{enabled} (frame buffer configuration)
3030 82 jeremybenn
If 1 (true, the default), this frame buffer is enabled.  If 0, it is disabled.
3031 19 jeremybenn
 
3032
@item baseaddr = @var{value}
3033
@cindex @code{baseaddr} (frame buffer configuration)
3034
Set the base address of the frame buffer's memory mapped registers to
3035 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
3036 19 jeremybenn
 
3037
The frame buffer has an 121-bit address bus, with 4 32-bit registers,
3038
at addresses 0x000 through 0x00c, and a PAL lookup table at addresses
3039 82 jeremybenn
0x400 through 0x4ff.  Addresses 0x010 through 0x3fc and addresses 0x500
3040 19 jeremybenn
through 0x7ff are not used.
3041
 
3042
@item refresh_rate = @var{value}
3043
@cindex @code{refresh_rate} (frame buffer configuration)
3044 82 jeremybenn
@var{value} specifies number of cycles between screen dumps.  Default
3045 19 jeremybenn
value is derived from the simulation clock cycle time
3046
(@pxref{Simulator Behavior, , Simulator Behavior}), to correspond to
3047
dumping 50 times per simulated second.
3048
 
3049
@item txfile = "@var{file}"
3050
@cindex @code{txfile} (frame buffer configuration)
3051
@cindex @code{filename} (frame buffer configuration - deprecated)
3052
@var{file} specifies the base of the filename for screen
3053 82 jeremybenn
dumps.  Successive screen dumps will be in BMP format, in files with
3054 19 jeremybenn
the name @file{@var{file}@var{nnnn}.bmp}, where @var{nnnn} is a
3055 82 jeremybenn
sequential count of the screen dumps starting at zero.  The default
3056
value is @code{"fb_out"}.  For backwards compatibility, the
3057 19 jeremybenn
alternative name @code{filename} is supported for this parameter,
3058
but deprecated.
3059
 
3060
@end table
3061
 
3062
@node Keyboard Configuration
3063
@subsection Keyboard Configuration (PS2)
3064
@cindex configuring the keyboard interface
3065
@cindex configuring the PS2 interface
3066
@cindex keyboard configuration
3067
@cindex PS2 configuration
3068
@cindex @code{section kb}
3069 82 jeremybenn
The PS2 interface provided by @value{OR1KSIM} is not documented.  It
3070 19 jeremybenn
may be based on the PS2 project at OpenCores, and found in
3071 98 jeremybenn
the top level SVN directory, @file{ps2}.  However this project lacks
3072 82 jeremybenn
any documentation beyond its project webpage.  Since most PS2
3073 19 jeremybenn
interfaces follow the Intel i8042 standard, this is presumably what is
3074
expected with this device.
3075
 
3076
The implementation only provides for keyboard support, which is
3077 82 jeremybenn
modelled as a file of keystrokes.  There is no mouse support.
3078 19 jeremybenn
 
3079
@quotation Caution
3080
A standard i8042 device has two registers at addresses 0x60 (command)
3081 82 jeremybenn
and 0x64 (status).  Inspection of the code, suggests that the
3082 19 jeremybenn
@value{OR1KSIM} component places these registers at addresses 0x00 and
3083
0x04.
3084
 
3085
The port of Linux for the OpenRISC 1000, which runs on @value{OR1KSIM}
3086
implements the i8042 device driver, anticipating these registers
3087 82 jeremybenn
reside at their conventional address.  It seems unlikel that this code
3088 19 jeremybenn
will work.
3089
 
3090
This component should be used with caution.
3091
@end quotation
3092
 
3093 82 jeremybenn
Keyboard configuration is described in @code{section kbd}.  This
3094 19 jeremybenn
section may appear multiple times, specifying multiple keyboard
3095 82 jeremybenn
interfaces.  The following parameters may be specified.
3096 19 jeremybenn
 
3097
@table @code
3098
 
3099
@item enabled = 0|1
3100
@cindex @code{enabled} (keyboard configuration)
3101 82 jeremybenn
If 1 (true, the default), this keyboard is enabled.  If 0, it is disabled.
3102 19 jeremybenn
 
3103
@item baseaddr = @var{value}
3104
@cindex @code{baseaddr} (keyboard configuration)
3105
Set the base address of the keyboard's memory mapped registers to
3106 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
3107 19 jeremybenn
 
3108
The keyboard PS/2 interface has an 3-bit address bus, with 2 8-bit registers,
3109
at addresses 0x000 and 0x004.
3110
 
3111
@quotation Caution
3112
As noted above, a standard Intel 8042 interface would expect to find
3113
these registers at locations 0x60 and 0x64, thus requiring at least a
3114
7-bit bus.
3115
@end quotation
3116
 
3117
@item irq = @var{value}
3118
@cindex @code{irq} (keyboard configuration)
3119 82 jeremybenn
Use @var{value} as the IRQ number of this Keyboard interface.  Default
3120 19 jeremybenn
value 0.
3121
 
3122
@item rxfile = "@var{file}"
3123
@cindex @code{file} (keyboard configuration)
3124
@file{file} specifies a file containing raw key stroke data, which
3125 82 jeremybenn
models the input from a physical keyboard.  The default value is
3126 19 jeremybenn
@code{"kbd_in"}.
3127
 
3128
@end table
3129
 
3130
@node Disc Interface Configuration
3131
@subsection Disc Interface Configuration
3132
@cindex configuring the ATA/ATAPI interfaces
3133
@cindex disc interface configuration
3134
@cindex ATA/ATAPI configuration
3135
@cindex @code{section ata}
3136
The ATA/ATAPI disc controller used in @value{OR1KSIM} is the OCIDEC
3137
(OpenCores IDE Controller) component implemented at OpenCores, and
3138 98 jeremybenn
found in the top level SVN directory, @file{ata}.  It is described in
3139 19 jeremybenn
the document @cite{ATA/ATAPI-5 Core Specification} by Richard
3140 82 jeremybenn
Herveille, which can be found in the @file{doc} subdirectory.  It is a
3141 19 jeremybenn
memory mapped component, which resides on the main OpenRISC Wishbone
3142
data bus.
3143
 
3144 385 jeremybenn
@quotation Warning
3145 440 jeremybenn
In the current release of @value{OR1KSIM}, parsing of the ATA section is
3146 385 jeremybenn
broken. Users should not configure the disc interface in this release.
3147
@end quotation
3148
 
3149 82 jeremybenn
ATA/ATAPI configuration is described in @code{@w{section ata}}.  This section
3150
may appear multiple times, specifying multiple disc controllers.  The
3151 19 jeremybenn
following parameters may be specified.
3152
 
3153
@table @code
3154
 
3155
@item enabled = 0|1
3156
@cindex @code{enabled} (ATA/ATAPI configuration)
3157 82 jeremybenn
If 1 (true, the default), this ATA/ATAPI interface is enabled.  If 0,
3158 19 jeremybenn
it is disabled.
3159
 
3160
@item baseaddr = @var{value}
3161
@cindex @code{baseaddr} (ATA/ATAPI configuration)
3162
Set the base address of the ATA/ATAPI interface's memory mapped
3163 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
3164 19 jeremybenn
sensible value.
3165
 
3166
The ATA/ATAPI PS/2 interface has an 5-bit address bus, with 8 32-bit
3167 82 jeremybenn
registers.  Depending on the version of the OCIDEC ATA/ATAPI interface
3168 19 jeremybenn
selected (see @code{dev_id} below), not all registers will be available.
3169
 
3170
@item irq = @var{value}
3171
@cindex @code{irq} (ATA/ATAPI configuration)
3172 82 jeremybenn
Use @var{value} as the IRQ number of this ATA/ATAPI interface.  Default
3173 19 jeremybenn
value 0.
3174
 
3175
@item dev_id = 1|2|3
3176
@cindex @code{dev_id} (ATA/ATAPI configuration)
3177
This parameter specifies which version of the OCIDEC ATA/ATAPI
3178 82 jeremybenn
interface to model.  The default value is 1.
3179 19 jeremybenn
 
3180
Version 1 supports only the @code{CTRL}, @code{STAT} and @code{PCTR}
3181 82 jeremybenn
registers.  Versions 2 & 3 add the @code{FCTR} registers, Version 3
3182 19 jeremybenn
adds the @code{DTR} registers and the @code{RXD}/@code{TXD} registers.
3183
 
3184
@item rev = @var{value}
3185
@cindex @code{rev} (ATA/ATAPI configuration)
3186
Set the @var{value} as the revision of the OCIDEC ATA/ATAPI
3187 82 jeremybenn
interface.  The default value is 1.  The default value is 0.  Its value
3188
should be in the range 0-15.  Larger values are truncated with a
3189
warning.  This only affects the reset value of the @code{STAT}
3190 19 jeremybenn
register, where it forms bits 24-27.
3191
 
3192
@item pio_mode0_t1 = @var{value}
3193
@cindex @code{pio_mode0_t1} (ATA/ATAPI configuration)
3194
@itemx pio_mode0_t2 = @var{value}
3195
@cindex @code{pio_mode0_t2} (ATA/ATAPI configuration)
3196
@itemx pio_mode0_t4 = @var{value}
3197
@cindex @code{pio_mode0_t4} (ATA/ATAPI configuration)
3198
@itemx pio_mode0_teoc = @var{value}
3199
@cindex @code{pio_mode0_teoc} (ATA/ATAPI configuration)
3200
These parameters specify the timings for use with Programmed
3201 82 jeremybenn
Input/Output (PIO) transfers.  They are specified as the number of
3202 19 jeremybenn
clock cycles - 2, rounded up to the next highest integer, or zero if
3203 82 jeremybenn
that would be negative.  The values should not exceed 255.  If they do,
3204 19 jeremybenn
they will be ignored with a warning.
3205
 
3206
See the ATA/ATAPI-5 specification for explanations of each of these
3207 82 jeremybenn
timing parameters.  The default values are:
3208 19 jeremybenn
 
3209
@example
3210
pio_mode0_t1   =  6
3211
pio_mode0_t2   = 28
3212
pio_mode0_t4   =  2
3213
pio_mode0_teoc = 23
3214
@end example
3215
 
3216
@item dma_mode0_tm = @var{value}
3217
@cindex @code{dma_mode0_tm} (ATA/ATAPI configuration)
3218
@itemx dma_mode0_td = @var{value}
3219
@cindex @code{dma_mode0_td} (ATA/ATAPI configuration)
3220
@itemx dma_mode0_teoc = @var{value}
3221
@cindex @code{dma_mode0_teoc} (ATA/ATAPI configuration)
3222 82 jeremybenn
These parameters specify the timings for use with DMA transfers.  They
3223 19 jeremybenn
are specified as the number of clock cycles - 2, rounded up to the
3224 82 jeremybenn
next highest integer, or zero if that would be negative.  The values
3225
should not exceed 255.  If they do, they will be ignored with a
3226 19 jeremybenn
warning.
3227
 
3228
See the ATA/ATAPI-5 specification for explanations of each of these
3229 82 jeremybenn
timing parameters.  The default values are:
3230 19 jeremybenn
 
3231
@example
3232
dma_mode0_tm   =  4
3233
dma_mode0_td   = 21
3234
dma_mode0_teoc = 21
3235
@end example
3236
 
3237
@end table
3238
 
3239
@subsubsection ATA/ATAPI Device Configuration
3240
@cindex disc interface device configuration
3241
@cindex ATA/ATAPI device configuration
3242
Within the @code{@w{section ata}}, each device is specified
3243 82 jeremybenn
separately.  The device subsection is introduced by
3244 19 jeremybenn
 
3245
@example
3246
device @var{value}
3247
@end example
3248
 
3249 82 jeremybenn
@var{value} is the device number, which should be 0 or 1.  The
3250
subsection ends with @code{enddevice}.  Note that if the same device
3251 19 jeremybenn
number is specified more than once, the previous values will be
3252 82 jeremybenn
overwritten.  Within the @code{device} subsection, the following
3253 19 jeremybenn
parameters may appear:
3254
 
3255
@table @code
3256
 
3257
@item type = @var{value}
3258
@cindex @code{type} (ATA/ATAPI device configuration)
3259
@var{value}specifies the type of device: 0 (the default) for ``not
3260
connected'', 1 for hard disk simulated in a file and 2 for local system
3261
hard disk.
3262
 
3263
@item file = "@var{filename}"
3264
@cindex @code{file} (ATA/ATAPI device configuration)
3265
@file{filename} specifies the file to be used for a simulated ATA
3266 82 jeremybenn
device if the file type (see @code{type} above) is 1.  Default value
3267 346 jeremybenn
@code{"ata_file@var{n}"}, where @var{n} is the device number.
3268 19 jeremybenn
 
3269
@item size = @var{value}
3270
@cindex @code{size} (ATA/ATAPI device configuration)
3271
@var{value} specifies the size of a simulated ATA device if the file
3272 82 jeremybenn
type (see @code{type} above) is 1.  The default value is zero.
3273 19 jeremybenn
 
3274
@item packet = 0|1
3275
@cindex @code{packet} (ATA/ATAPI device configuration)
3276 82 jeremybenn
If 1 (true), implement the PACKET command feature set.  If 0 (the
3277 19 jeremybenn
default), do not implement the PACKET command feature set.
3278
 
3279
@item firmware = "@var{str}"
3280
@cindex @code{firmware} (ATA/ATAPI device configuration)
3281
Firmware to report in response to the ``Identify Device''
3282 82 jeremybenn
command.  Default @code{"02207031"}.
3283 19 jeremybenn
 
3284
@item heads = @var{value}
3285
@cindex @code{heads} (ATA/ATAPI device configuration)
3286 82 jeremybenn
Number of heads in the device.  Default 7, use -1 to disable all heads.
3287 19 jeremybenn
 
3288
@item sectors = @var{value}
3289
@cindex @code{sectors} (ATA/ATAPI device configuration)
3290 82 jeremybenn
Number of sectors per track in the device.  Default 32.
3291 19 jeremybenn
 
3292
@item mwdma = 0|1|2|-1
3293
@cindex @code{mwdma} (ATA/ATAPI device configuration)
3294 82 jeremybenn
Highest multi-word DMA mode supported.  Default 2, use -1 to disable.
3295 19 jeremybenn
 
3296
@item pio = 0|1|2|3|4
3297
@cindex @code{pio} (ATA/ATAPI device configuration)
3298 82 jeremybenn
Highest PIO mode supported.  Default 4.
3299 19 jeremybenn
 
3300
@end table
3301
 
3302
@node Generic Peripheral Configuration
3303
@subsection Generic Peripheral Configuration
3304
@cindex generic peripheral configuration
3305
@cindex configuration of generic peripherals
3306
@cindex @code{section generic}
3307
When used as a library (@pxref{Simulator Library, , Simulator
3308
Library}), @value{OR1KSIM} makes provision for any additional peripheral to be
3309 82 jeremybenn
implemented externally.  Any read or write access to this peripheral's
3310
memory map generates @dfn{upcall}s to an external handler.  This
3311 19 jeremybenn
interface can support either C or C++, and was particularly designed
3312
to facilitate support for OSCI SystemC (see @url{http://www.systemc.org}).
3313
 
3314
Generic peripheral configuration is described in @code{@w{section
3315 82 jeremybenn
generic}}.  This section may appear multiple times, specifying multiple
3316
external peripherals.  The following parameters may be specified.
3317 19 jeremybenn
 
3318
@table @code
3319
 
3320
@item enabled = 0|1
3321
@cindex @code{enabled} (generic peripheral configuration)
3322 82 jeremybenn
If 1 (true, the default), this ATA/ATAPI interface is enabled.  If 0,
3323 19 jeremybenn
it is disabled.
3324
 
3325
@item baseaddr = @var{value}
3326
@cindex @code{baseaddr} (generic peripheral configuration)
3327
Set the base address of the generic peripheral's memory mapped
3328 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
3329 19 jeremybenn
sensible value.
3330
 
3331
The size of the memory mapped register space is controlled by the
3332
@code{size} paramter, described below.
3333
 
3334
@item size = @var{value}
3335
@cindex @code{size} (generic peripheral configuration)
3336
Set the size of the generic peripheral's memory mapped register space
3337 82 jeremybenn
to @var{value} bytes.  Any read or write accesses to addresses with
3338 19 jeremybenn
offsets of 0 to @var{value}-1 bytes from the base address specified in
3339
parameter @code{baseaddr} (see above) will be directed to the external
3340
interface.
3341
 
3342 82 jeremybenn
@var{value} will be rounded up the nearest power of 2.  It's default
3343
value is zero.  If @var{value} is not an exact power of two, accesses
3344 19 jeremybenn
to address offsets of @var{value} or above up to the next power of 2
3345
will generate a warning, and have no effect (reads will return zero).
3346
 
3347
@item name = "@var{str}"
3348
@cindex @code{name} (generic peripheral configuration)
3349 82 jeremybenn
This gives the peripheral the name @code{"@var{str}"}.  This is used to
3350 19 jeremybenn
identify the peripheral in error messages and warnings, and when
3351 82 jeremybenn
reporting its status.  The default value is @code{@w{"anonymous
3352 19 jeremybenn
external peripheral"}}.
3353
 
3354
@item byte_enabled = 0|1
3355
@cindex @code{byte_enabled} (generic peripheral configuration)
3356
@itemx hw_enabled = 0|1
3357
@cindex @code{hw_enabled} (generic peripheral configuration)
3358
@itemx word_enabled = 0|1
3359
@cindex @code{word_enabled} (generic peripheral configuration)
3360
If 1 (true, the default), these parameters respectively enable the
3361 82 jeremybenn
device for byte wide, half-word wide and word wide accesses.  If 0,
3362 19 jeremybenn
accesses of that width will fail.
3363
 
3364
@end table
3365
 
3366
@node Interactive Command Line
3367
@chapter Interactive Command Line
3368
 
3369
If started with the @code{-f} flag, or if interrupted with
3370
@kbd{ctrl-C}, @value{OR1KSIM} provides the user with an interactive
3371 82 jeremybenn
command line.  The commands available, which may not be abbreviated, are:
3372 19 jeremybenn
 
3373
@table @code
3374
 
3375
@item q
3376
@cindex @code{q} (Interactive CLI)
3377
@cindex quitting (Interactive CLI)
3378
Exit the simulator
3379
 
3380
@item r
3381
@cindex @code{r} (Interactive CLI)
3382
@cindex displaying registers (Interactive CLI)
3383
@cindex register display (Interactive CLI)
3384 82 jeremybenn
Display all the General Purpose Registers (GPRs).  Also shows the just
3385 19 jeremybenn
executed and next to be executed instructions symbolically and the
3386
state of the flag in the Supervision Register.
3387
 
3388
@item t
3389
@cindex @code{t} (Interactive CLI)
3390
@cindex stepping code (Interactive CLI)
3391
Execute the next instruction and then display register/instruction
3392
information as with the @code{r} command (see above).
3393
 
3394
@item run @var{num} [ hush ]
3395
@cindex @code{run} (Interactive CLI)
3396
@cindex running code (Interactive CLI)
3397
@cindex executing code (Interactive CLI)
3398 82 jeremybenn
Execute @var{num} instructions.  The register/instruction information
3399 19 jeremybenn
is displayed after each instruction, as with the @code{r} command (see
3400
above) @emph{unless} @code{hush} is specified.
3401
 
3402
@item pr @var{reg} @var{value}
3403
@cindex @code{pr} (Interactive CLI)
3404
@cindex patching registers (Interactive CLI)
3405
@cindex register patching (Interactive CLI)
3406
Patch register @var{reg} with @var{value}.
3407
 
3408
@item dm @var{fromaddr} [ @var{toaddr} ]
3409
@cindex @code{dm} (Interactive CLI)
3410
@cindex displaying memory (Interactive CLI)
3411
@cindex memory display (Interactive CLI)
3412 82 jeremybenn
Display memory bytes between @var{fromaddr} and @var{toaddr}.  If
3413 19 jeremybenn
@var{toaddr} is not given, 64 bytes are displayed, starting at
3414
@var{fromaddr}.
3415
 
3416
@quotation Caution
3417 82 jeremybenn
The output from this command is broken (a bug).  @value{OR1KSIM}
3418
attempts to print out 16 bytes per row.  However, instead of printing
3419 19 jeremybenn
out the address at the start of each row, it prints the address (of
3420
the first of the 16 bytes) before @emph{each} byte.
3421
@end quotation
3422
 
3423
@item de @var{fromaddr} [ @var{toaddr} ]
3424
@cindex @code{dm} (Interactive CLI)
3425
@cindex disassemble (Interactive CLI)
3426 82 jeremybenn
Disassemble code between @var{fromaddr} and @var{toaddr}.  If
3427 19 jeremybenn
@var{toaddr} is not given, 16 instructions are disassembled.
3428
 
3429
The disassembly is entirely numerical, and gives no symbolic
3430
information.
3431
 
3432
@item pm @var{addr} @var{value}
3433
@cindex @code{pm} (Interactive CLI)
3434
@cindex patching memory (Interactive CLI)
3435
@cindex memory patching (Interactive CLI)
3436
Patch the 4 bytes in memory starting at @var{addr} with the 32-bit
3437
@var{value}.
3438
 
3439
@item pc @var{value}
3440
@cindex @code{pc} (Interactive CLI)
3441
@cindex patching the program counter (Interactive CLI)
3442
@cindex program counter patching (Interactive CLI)
3443
Patch the program counter with @var{value}.
3444
 
3445
@item cm @var{fromaddr} @var{toaddr} @var{size}
3446
@cindex @code{cm} (Interactive CLI)
3447
@cindex copying memory (Interactive CLI)
3448
@cindex memory copying (Interactive CLI)
3449
Copy @var{size} bytes in memory from @var{fromaddr} to @var{toaddr}.
3450
 
3451
@item break @var{addr}
3452
@cindex @code{break} (Interactive CLI)
3453
@cindex breakpoint set/clear (Interactive CLI)
3454
@cindex set breakpoint (Interactive CLI)
3455
@cindex clear breakpoint (Interactive CLI)
3456
@cindex toggle breakpoint (Interactive CLI)
3457
Toggle the breakpoint set at @var{addr}.
3458
 
3459
@item breaks
3460
@cindex @code{breaks} (Interactive CLI)
3461
@cindex breakpoint list (Interactive CLI)
3462
@cindex list breakpoints (Interactive CLI)
3463
List all set breakpoints
3464
 
3465
@item reset
3466
@cindex @code{reset} (Interactive CLI)
3467
@cindex simulator reset (Interactive CLI)
3468
@cindex reset the simulator (Interactive CLI)
3469 82 jeremybenn
Reset the simulator.  Includes modeling a reset of the processor, so
3470 19 jeremybenn
execution will restart from the reset vector location, 0x100.
3471
 
3472
@item hist
3473
@cindex @code{hist} (Interactive CLI)
3474
@cindex execution history (Interactive CLI)
3475
@cindex history of execution (Interactive CLI)
3476
If saving the execution history has been configured (@pxref{Simulator
3477
Behavior, , Simulator Behavior}), display the execution history.
3478
 
3479
@item stall
3480
@cindex @code{stall} (Interactive CLI)
3481
@cindex processor stall (Interactive CLI)
3482
@cindex stall the processor (Interactive CLI)
3483 82 jeremybenn
Stall the processor, so that control is passed to the debug unit.  When
3484
stalled, the processor can execute no instructions.  This command is
3485 19 jeremybenn
useful when debugging the JTAG interface, used by debuggers such as
3486
GDB.
3487
 
3488
@item unstall
3489
@cindex @code{unstall} (Interactive CLI)
3490
@cindex processor unstall (Interactive CLI)
3491
@cindex unstall the processor (Interactive CLI)
3492 82 jeremybenn
Unstall the processor, so that normal execution can continue.  This command is
3493 19 jeremybenn
useful when debugging the JTAG interface, used by debuggers such as GDB.
3494
 
3495
@item stats @var{category} | clear
3496
@cindex @code{stats} (Interactive CLI)
3497
@cindex simulator statistics (Interactive CLI)
3498
@cindex statistics, simulation (Interactive CLI)
3499
Print the statistics for the given @var{category}, if available, or
3500 82 jeremybenn
clear if @code{clear} is specified.  The categories are:
3501 19 jeremybenn
 
3502
@table @asis
3503
 
3504
@item 1
3505
Miscellaneous statistics: branch predictions (if branch predictions
3506
are enabled), branch target cache model (if enabled), cache (if
3507
enbaled), MMU (if enabled) and number of addtional load & store
3508
cycles.
3509
 
3510
@xref{Core OpenRISC Configuration, , Configuring the OpenRisc
3511
Achitectural Components}, for details of how to enable these various
3512
features.
3513
 
3514
@item 2
3515 82 jeremybenn
Instruction usage statistics.  Requires hazard analysis to be enabled
3516 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3517
 
3518
@item 3
3519 82 jeremybenn
Instruction dependency statistics.  Requires hazard analysis to be enabled
3520 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3521
 
3522
@item 4
3523 82 jeremybenn
Functional unit dependency statistics.  Requires hazard analysis to be enabled
3524 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3525
 
3526
@item 5
3527 82 jeremybenn
Raw register usage over time.  Requires hazard analysis to be enabled
3528 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3529
 
3530
@item 6
3531 82 jeremybenn
Store buffer statistics.  Requires the store buffer to be enabled
3532 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
3533
 
3534
@end table
3535
 
3536
@item info
3537
@cindex @code{info} (Interactive CLI)
3538
@cindex simulator configuration info (Interactive CLI)
3539
@cindex configuration info (Interactive CLI)
3540 82 jeremybenn
Display detailed information about the simulator configuration.  This
3541 19 jeremybenn
is quite a lengthy about, because all MMU TLB information is displayed.
3542
 
3543
@item dv @var{fromaddr} [ @var{toaddr} ] [ @var{module} ]
3544
@cindex @code{dv} (Interactive CLI)
3545
@cindex Verilog memory dump (Interactive CLI)
3546
@cindex memory dump, Verilog (Interactive CLI)
3547
Dump the area of memory between @var{fromaddr} and @var{toaddr} as
3548
Verilog code for a synchronous, 23-bit wide SRAM module, named
3549 82 jeremybenn
@var{module}.  If @var{toaddr} is not specified, then 64 bytes are
3550
dumped (as 16 32-bit words).  If @var{module} is not specified,
3551 19 jeremybenn
@code{or1k_mem} is used.
3552
 
3553
To save to a file, use the redirection function (described after this
3554
table, below).
3555
 
3556
@item dh @var{fromaddr} [ @var{toaddr} ]
3557
@cindex @code{dv} (Interactive CLI)
3558
@cindex hexadecimal memory dump (Interactive CLI)
3559
@cindex memory dump, hexadecimal (Interactive CLI)
3560
Dump the area of memory between @var{fromaddr} and @var{toaddr} as
3561 82 jeremybenn
32-bit hex numbers (no @code{0x}, or @code{32'h} prefix).  If
3562 19 jeremybenn
@var{toaddr} is not specified, then 64 bytes are dumped (as 16 32-bit
3563
words).
3564
 
3565
To save to a file, use the redirection function (described after this
3566
table, below).
3567
 
3568
@item setdbch
3569
@cindex @code{setdbch} (Interactive CLI)
3570
@cindex debug channel toggle (Interactive CLI)
3571
@cindex toggle debug channels (Interactive CLI)
3572 82 jeremybenn
Toggle debug channels on/off.  @xref{Standalone Simulator, , Standalone
3573 19 jeremybenn
Simulator}, for a description of specifying debug channels on the
3574
command line.
3575
 
3576
@item set @var{section} @var{param} = @var{value}
3577
@cindex @code{set} (Interactive CLI)
3578
@cindex configuration parameter setting (Interactive CLI)
3579
Set the configuration parameter @var{para} in section @var{section} to
3580 82 jeremybenn
@var{value}.  @xref{Configuration, , Configuration}, for details of
3581 19 jeremybenn
configuration parameters and their settings.
3582
 
3583
@item debug
3584
@cindex @code{debug} (Interactive CLI)
3585
@cindex debug mode toggle (Interactive CLI)
3586
@cindex toggle debug mode (Interactive CLI)
3587 82 jeremybenn
Toggle the simulator debug mode.  @xref{Debug Interface Configuration,
3588 19 jeremybenn
, Debug Interface Configuration}, for information on this parameter.
3589
 
3590
@quotation Caution
3591 82 jeremybenn
This is effectively enabling or disabling the debug unit.  It does not
3592
effect the remote GDB debug interface.  However using the remote debug
3593 19 jeremybenn
interface while the debug unit is disabled will lead to undefined
3594
behavior and likely crash @value{OR1KSIM}
3595
@end quotation
3596
 
3597
@item cuc
3598
@cindex @code{debug} (Interactive CLI)
3599
@cindex Custom Unit Compiler (Interactive CLI)
3600
Enter the the Custom Unit Compiler command prompt (@pxref{CUC
3601
Configuration, , CUC Configuration}).
3602
 
3603
@quotation Caution
3604 82 jeremybenn
The CUC must be properly configured, for this to succeed.  In
3605
particular a timing file must be available and readable.  Otherwise
3606 19 jeremybenn
@value{OR1KSIM} will crash.
3607
@end quotation
3608
 
3609
@item help
3610
@cindex @code{help} (Interactive CLI)
3611
@cindex Custom Unit Compiler (Interactive CLI)
3612
Print out brief information about each command available.
3613
 
3614
@item mprofile [-vh] [-m @var{m}] [-g @var{n}] [-f @var{file}] @var{from} @var{to}
3615
@cindex @code{mprofile} (Interactive CLI)
3616
@cindex memory profiling utility (Interactive CLI)
3617 82 jeremybenn
Run the memory profiling utility.  This follows the same usage as the
3618 19 jeremybenn
standalone command (@pxref{Memory Profiling Utility, , Memory
3619
Profiling Utility}).
3620
 
3621
@item profile [-vhcq] [-g @var{file}]
3622
@cindex @code{mprofile} (Interactive CLI)
3623
@cindex profiling utility (Interactive CLI)
3624
@cindex instruction profiling utility (Interactive CLI)
3625 82 jeremybenn
Run the instruction profiling utility.  This follows the same usage as the
3626 19 jeremybenn
standalone command (@pxref{Profiling Utility, , Profiling Utility}).
3627
 
3628
@end table
3629
 
3630
For all commands, it is possible to redirect the output to a file, by
3631
using the redirection operator, @code{>}.
3632
 
3633
@example
3634
@var{command} > @var{filename}
3635
@end example
3636
 
3637
This is particularly useful for commands dumping a large amount of
3638
output, such as @code{dv}.
3639
 
3640
@quotation Caution
3641 82 jeremybenn
Unfortunately there is a serious bug with the redirection operator.  It
3642 19 jeremybenn
does not return output to standard output after the command
3643 82 jeremybenn
completes.  Until this bug is fixed, file redirection should not be
3644 19 jeremybenn
used.
3645
@end quotation
3646
 
3647
@node Verification API
3648
@chapter Verification API (VAPI)
3649
 
3650
The Verification API (VAPI) provides a TCP/IP interface to allow
3651 82 jeremybenn
components of the simulation to be controlled externally.  The
3652 19 jeremybenn
interface is polled for new requests on each simulated clock
3653 82 jeremybenn
cycle.  Components within the simulator may send responses to such
3654 19 jeremybenn
requests.
3655
 
3656 82 jeremybenn
The inteface is an asynchronous duplex protocol.  On the request side
3657 19 jeremybenn
it provides for simple commands, known as VAPI IDs (a 32 bit integer),
3658 82 jeremybenn
with a single piece of data (also a 32 bit integer).  On the send side,
3659
it provides for sending a single VAPI ID and data.  However there is no
3660
explicit command-response structure.  Some components just accept
3661
requests (e.g.  to set values), some just generate sends (to report
3662 19 jeremybenn
values), and some do both.
3663
 
3664
Each component has a base ID (32 bit) and its commands will start from
3665 82 jeremybenn
that base ID.  This provides a simple partitioning of the command space
3666
amongst components.  Request commands will be directed to the component with
3667 19 jeremybenn
the closest base ID lower than the VAPI ID of the command.
3668
 
3669
Thus if there are two components with base IDs of 0x200 and 0x300, and
3670
a request with VAPI ID of 0x203 is received, it will be directed to
3671
the first component as its command #3.
3672
 
3673
The results of VAPI interactions are logged (by default in
3674
@file{vapi.log} unless an alternative is specified in @code{@w{section
3675
vapi}}).
3676
 
3677
Currently the following components support VAPI:
3678
 
3679
@table @asis
3680
 
3681
@item Debug Unit
3682
@cindex Debug Unit verification (VAPI)
3683
@cindex VAPI for Debug Unit
3684
Although the Debug Unit can specify a base VAPI ID, it is not used to
3685
send commands or receive requests.
3686
 
3687
Instead, if the base VAPI ID is set, all remote JTAG protocol exchanges are
3688
logged in the VAPI log file.
3689
 
3690
@item UART
3691
@cindex UART verification (VAPI)
3692
@cindex VAPI for UART
3693
If a base VAPI ID is specified, the UART sends details of any chars or
3694
break characters sent, with dteails of the line control register etc
3695
encoded in the data packet sent.
3696
 
3697
This supports a single VAPI command request, but encodes a sub-command in the
3698
top 8 bits of the associated data.
3699
 
3700
@table @code
3701
 
3702
@item 0x00
3703
@cindex 0x00 UART VAPI sub-command (UART verification)
3704
This stuffs the least significant 8 bits of the data into the serial
3705
register of the UART and the next 8 bits into the line control
3706
register, effectively providing control of the next character to be
3707
sent or received.
3708
 
3709
@item 0x01
3710
@cindex 0x01 UART VAPI sub-command (UART verification)
3711
The divisor latch bytes are set from the least significant 16 bits of
3712
the data.
3713
 
3714
@item 0x02
3715
@cindex 0x02 UART VAPI sub-command (UART verification)
3716
The line control register is set from bits 15-8 of the data.
3717
 
3718
@item 0x03
3719
@cindex 0x03 UART VAPI sub-command (UART verification)
3720
The UART skew is set from the least significant 16 bits of the data
3721
 
3722
@item 0x04
3723
@cindex 0x04 UART VAPI sub-command (UART verification)
3724
If the 16th most significant bit of the data is 1, start sending
3725 82 jeremybenn
breaks, otherwise stop sending breaks.  The breaks are sent or cleared
3726 19 jeremybenn
after the number of UART clock divider ticks specified by the data
3727
(immediately if the data is zero).
3728
 
3729
@end table
3730
 
3731
@item DMA
3732
@cindex DMA verification (VAPI)
3733
@cindex VAPI for DMA
3734
Although the DMA unit supports a base VAPI ID in its configuration
3735
(@code{@w{section dma}}), no VAPI data is sent, nor VAPI requests
3736
currently implemented.
3737
 
3738
@item Ethernet
3739
@cindex Ethernet verification (VAPI)
3740
@cindex VAPI for Ethernet
3741 82 jeremybenn
The following requests are handled by the Ethernet.  Specified
3742 19 jeremybenn
symbolically, these are the increments from the base VAPI ID of the
3743 82 jeremybenn
Ethernet.  At present no implementation is provided behind these VAPI
3744 19 jeremybenn
requests.
3745
 
3746
@table @code
3747
 
3748
@item ETH_VAPI_DATA (0)
3749
@cindex @code{ETH_VAPI_DATA} (Ethernet verification)
3750
 
3751
@item ETH_VAPI_CTRL (0)
3752
@cindex @code{ETH_VAPI_CTRL} (Ethernet verification)
3753
 
3754
@end table
3755
 
3756
@item GPIO
3757
@cindex GPIO verification (VAPI)
3758
@cindex VAPI for GPIO
3759
If a base VAPI ID is specified, the GPIO sends out on its base VAPI ID
3760
(symbolically, GPIO_VAPI_DATA (0) offset from the base VAPI ID) any
3761
changes in outputs.
3762
 
3763 82 jeremybenn
The following requests are handled by the GPIO.  Specified
3764 19 jeremybenn
symbolically, these are the increments from the VAPI base ID of the
3765
GPIO.
3766
 
3767
@table @code
3768
 
3769
@item GPIO_VAPI_DATA (0)
3770
@cindex @code{GPIO_VAPI_DATA} (GPIO verification)
3771
Set the next input to the commands data field
3772
 
3773
@item GPIO_VAPI_AUX (1)
3774
@cindex @code{GPIO_VAPI_AUX} (GPIO verification)
3775
Set the GPIO auxiliary inputs to the data field
3776
 
3777
@item GPIO_VAPI_CLOCK (2)
3778
@cindex @code{GPIO_VAPI_CLOCK} (GPIO verification)
3779
Add an external GPIO clock trigger of period specified in the data field.
3780
 
3781
@item GPIO_VAPI_RGPIO_OE (3)
3782
@cindex @code{GPIO_VAPI_RGPIO} (GPIO verification)
3783
Set the GPIO output enable to the data field
3784
 
3785
@item GPIO_VAPI_RGPIO_INTE (4)
3786
@cindex @code{GPIO_VAPI_INTE} (GPIO verification)
3787
Set the next interrupt to the data field
3788
 
3789
@item GPIO_VAPI_RGPIO_PTRIG (5)
3790
@cindex @code{GPIO_VAPI_PTRIG} (GPIO verification)
3791
Set the next trigger to the data field
3792
 
3793
@item GPIO_VAPI_RGPIO_AUX (6)
3794
@cindex @code{GPIO_VAPI_AUX} (GPIO verification)
3795
Set the next auxiliary input to the data field
3796
 
3797
@item GPIO_VAPI_RGPIO_CTRL (7)
3798
@cindex @code{GPIO_VAPI_CTRL} (GPIO verification)
3799
Set th next control input to the data field
3800
 
3801
@end table
3802
 
3803
@end table
3804
 
3805
@node Code Internals
3806
@chapter A Guide to @value{OR1KSIM} Internals
3807
 
3808 82 jeremybenn
These are notes to help those wanting to extend @value{OR1KSIM}.  This
3809 19 jeremybenn
section assumes the use of a tag file, so file locations of entities'
3810 82 jeremybenn
definitions are not in general provided.  For more on tags, see the
3811
Linux manual page for @command{etags}.  A tag file can be created
3812 19 jeremybenn
with:
3813
 
3814
@example
3815
make tags
3816
@end example
3817
 
3818
@menu
3819
* Coding Conventions::
3820
* Global Data Structures::
3821
* Concepts::
3822
* Internal Debugging::
3823 104 jeremybenn
* Regression Testing::
3824 19 jeremybenn
@end menu
3825
 
3826
@node Coding Conventions
3827
@section Coding Conventions for @value{OR1KSIM}
3828
 
3829
This chapter provides some guidelines for coding, to facilitate
3830
extensions to @value{OR1KSIM}
3831
 
3832
@table @emph
3833
 
3834
@item GNU Coding Standard
3835
Code should follow the GNU coding standard for C
3836 82 jeremybenn
(@url{http://www.gnu.org/prep/standards/}.  If in doubt, put your code
3837 19 jeremybenn
through the @command{indent} program.
3838
 
3839
@item @code{#include} headers
3840
All C source code files should include @file{config.h} before any
3841
other file.
3842
 
3843
This should be followed by inclusion of any system headers (but see
3844
the comments about portability and @file{port.h} below) and then by
3845
any @value{OR1KSIM} package headers.
3846
 
3847
If @file{port.h} is required, it should be the first package header to
3848
be included after the system headers.
3849
 
3850
All C source code and header files should directly include any system
3851 82 jeremybenn
or package header they depend on, i.e.  not rely on any other header
3852
having already included it.  The two exceptions are
3853 19 jeremybenn
 
3854
@enumerate
3855
@item
3856
All header files may assume that @file{config.h} has already been
3857
included.
3858
 
3859
@item
3860
System headers which impose portability problems should be included by
3861
using the package header @file{port.h}, rather than the system headers
3862 82 jeremybenn
themselves.  This is the case for code requiring
3863 19 jeremybenn
 
3864
@itemize @bullet
3865
 
3866
@item
3867
@code{strndup} (from @file{string.h})
3868
 
3869
@item
3870
Integer types (@code{int@var{n}_t}, @code{uint@var{n}_t}) (from
3871
@file{inttypes.h}).
3872
 
3873
@item
3874
@code{isblank} (from @file{ctype.h})
3875
 
3876
@end itemize
3877
 
3878
@end enumerate
3879
 
3880
@item @code{#include} files once only
3881
All include files should be protected by @code{#ifndef} to ensure
3882 82 jeremybenn
their definitions are only included once.  For instance a header file
3883 19 jeremybenn
@file{@var{x-y.h}} should surround its contents with:
3884
 
3885
@example
3886
#ifndef X_Y__H
3887
#define X_Y__H
3888
 
3889
<body of the include file>
3890
 
3891
#endif  /* X_Y__H */
3892
@end example
3893
 
3894
@item Avoid @code{typedef}
3895
The GNU coding style for C does not have a clear way to distinguish
3896 82 jeremybenn
between user type name and user variables.  For this reason
3897 19 jeremybenn
@code{typedef} should be avoided except for the most ubiquitous user
3898 82 jeremybenn
defined types.  This makes the code much easier to read.
3899 19 jeremybenn
 
3900
There are some @code{typedef} declarations in the @command{argtable2}
3901
library and the @acronym{ELF} and @acronym{COFF} headers, because this
3902
code is taken from other places.
3903
 
3904
Within @value{OR1KSIM} legacy uses of @code{typedef} have largely been
3905
purged, except in the Custom Unit Compiler (@pxref{CUC Configuration,
3906
, Custom Unit Compiler (CUC) Configuration}).
3907
 
3908
The remaining uses of @code{typedef} occur in two places:
3909
 
3910
@itemize @bullet
3911
 
3912
@item
3913
@file{port/port.h} defines types to replace those in header files that
3914
are not available (character functions, string duplication, integer
3915
types).
3916
 
3917
@file{cpu/or1k/arch.h} defines types for the key @value{OR1KSIM}
3918
entities: addresses (@code{oraddr_t}), unsigned register values
3919
(@code{uorreg_t}) and signed register (@code{orreg_t}) values.
3920
 
3921
@end itemize
3922
 
3923
Where new types are defined, they should appear in one of these two
3924 82 jeremybenn
files as appropriate.  @value{OR1KSIM} specific types appearing in
3925 19 jeremybenn
@file{arch.h} should always have the suffix @file{_h}.
3926
 
3927
@item Don't begin names with underscore
3928
Names beginning with @code{_} are intended to be part of the C
3929 82 jeremybenn
infrastructure.  They should not be used in the simulator code.
3930 19 jeremybenn
 
3931
@item Keep Non-global top level entities static
3932
All top level entities (functions, variables), which are not
3933 82 jeremybenn
explicitly part of a global interface should be declared static.  This
3934 19 jeremybenn
ensures that unwanted connections are not inadvertently built across
3935
the program.
3936
 
3937
@item Use of @code{inline}
3938 82 jeremybenn
Code should not be declared @code{inline}.  Modern compilers can work
3939 19 jeremybenn
out for themselves what is best in this respect.
3940
 
3941
@item Initialization
3942 82 jeremybenn
All data structures should be explicitly initialized.  In particular
3943 19 jeremybenn
code should not rely on static data structures being initialized to
3944
zero.
3945
 
3946
The rationale is that in future static data structures may become
3947 82 jeremybenn
dynamic.  This has been a particular source of bugs in @value{OR1KSIM}
3948 19 jeremybenn
historically.
3949
 
3950
A specific case is with new peripherals, which should always include a
3951
@code{start} function to pre-initialize all configuration parameters
3952
to sensible defaults
3953
 
3954
@item Configuration Validation
3955
All configuration values should be validated, preferably when
3956
encountered, if not when the @code{section} is closed, or otherwise
3957
at run time when the parameter is first used.
3958
 
3959
@end table
3960
 
3961
@node Global Data Structures
3962
@section Global Data Structures
3963
 
3964
@table @code
3965
 
3966
@item config
3967
@cindex configuration global structure
3968
@vindex config
3969
The global variable @code{config} of type @code{struct config} holds
3970
the configuration data for some of the @value{OR1KSIM} components which
3971 82 jeremybenn
are always present.  At present the components are:
3972 19 jeremybenn
 
3973
@itemize @bullet
3974
 
3975
@item
3976
@vindex config.sim
3977
The simulator defined in @code{@w{section sim}} (@pxref{Simulator
3978
Configuration, , Simulator Configuration}).
3979
 
3980
@item
3981
@vindex config.vapi
3982
The Verification API (VAPI) defined  in @code{@w{section vapi}}
3983
(@pxref{Verification API Configuration, , Verification API (VAPI)
3984
Configuration}).
3985
 
3986
@item
3987
@vindex config.cuc
3988
The Custom Unit Compiler (CUC), defined in @code{@w{section cuc}}
3989
(@pxref{CUC Configuration, , Custom Unit Compiler (CUC)
3990
Configuration}).
3991
 
3992
@item
3993
@vindex config.cpu
3994
The CPU, defined in @code{@w{section cpu}} (@pxref{CPU Configuration,
3995
, CPU Configuration}).
3996
 
3997
@item
3998
@vindex config.dc
3999
The data cache (but not the instruction cache), defined in
4000
@code{@w{section dc}} (@pxref{Cache Configuration, , Cache
4001
Configuration}).
4002
 
4003
@item
4004
@vindex config.pm
4005
The power management unit, defined in @code{@w{section pm}}
4006
(@pxref{Power Management Configuration, , Power Management
4007
Configuration}).
4008
 
4009
@item
4010
@vindex config.pic
4011
The programmable interrupt controller, defined in @code{@w{section pic}}
4012
(@pxref{Interrupt Configuration, , Interrupt Configuration}).
4013
 
4014
@item
4015
@vindex config.bpb
4016
Branch prediciton, defined in @code{@w{section bpb}} (@pxref{Branch
4017
Prediction Configuration, , Branch Prediction Configuration}).
4018
 
4019
@item
4020
@vindex config.debug
4021
The debug unit, defined in @code{@w{section debug}} (@pxref{Debug
4022
Interface Configuration, , Debug Interface Configuration}).
4023
 
4024
@end itemize
4025
 
4026
This struct is made of a collection of structs, one for each
4027 82 jeremybenn
component.  For example the simulator configuration is held in
4028 19 jeremybenn
@code{config.sim}.
4029
 
4030
@item config
4031
@cindex configuration dynamic structure
4032
@vindex sections
4033
This is a linked list of data structures holding configuration data
4034
for all sections which are not held in the main @code{config} data
4035 82 jeremybenn
structure.  In general these are components (such as peripherals and
4036
memory) which may occur multiple times.  However it also handles some
4037 19 jeremybenn
architectural components which may occur only once, such as the memory
4038
management units, the instruction cache, the interrupt controller and
4039
branch prediction.
4040
 
4041
@item runtime
4042
@cindex runtime global structure
4043
@vindex runtime
4044
The global variable @code{runtime} of type @code{struct runtime} holds
4045 82 jeremybenn
all the runtime information about the simulation.  To access this
4046 19 jeremybenn
variable, @file{sim-config.h} must be included.
4047
 
4048
@vindex runtime.cpu
4049
@vindex runtime.vapi
4050
@vindex runtime.cuc
4051
This struct is itself made of 3 other structs, @code{cpu} (for CPU run
4052
time state), @code{vapi} (for Verification API state) and @code{cuc}
4053
(for Custom Unit Compiler state).
4054
 
4055
@end table
4056
 
4057
@node Concepts
4058
@section Concepts
4059
 
4060
@table @emph
4061
 
4062
@anchor{Output Redirection}
4063
@item Output Redirection
4064
@cindex output rediretion
4065
@vindex runtime.cpu.fout
4066 82 jeremybenn
The current output stream is held in @code{runtime.cpu.fout}.  Output
4067 19 jeremybenn
should be explicitly written to this stream, or may use the
4068
@code{PRINTF} macro, which will write its arguments to this output stream.
4069
 
4070
@item Reset Hooks
4071
@cindex reset hooks
4072
@findex reg_sim_reset
4073
Any peripheral may register a routine to be called when the the
4074
processor is reset by calling @code{reg_sim_reset}, providing a
4075 82 jeremybenn
function and pointer to a data structure as arguments.  On reset that
4076 19 jeremybenn
function will be called with the data stucture pointer as argument.
4077
 
4078 432 jeremybenn
@anchor{Interrupts Internal}
4079
@item Interrupts
4080
@cindex interrupts
4081
@findex report_interrupt
4082
@findex clear_interrupt
4083
@findex mtspr
4084
An internal peripheral can model the effect of an interrupt being
4085
asserted by calling @code{report_interrupt}.  This is used for both edge
4086
and level sensitive interrupts.
4087
 
4088
The effect is to set the corresponding bit in the PICSR SPR and to queue
4089
an interrupt exception to take place after the current instruction
4090
completes execution.
4091
 
4092
Externally, the different interrupts require different mechanisms for
4093
clearing.  Level sensitive interrupts should be cleared by deasserting
4094
the interrupt line, edge sensitive interrupts by clearing the
4095
corresponding bit in the PICSR SPR.
4096
 
4097
Internally this amounts to the same thing (clearing the PICSPR bit), so
4098
a single function is provided, @code{clear_interrupt}.  Note however that
4099
when level sensitive interrupts are configured, PICSR is read only, and
4100
can only be cleared by calling @code{clear_interrupt}.  Using the two
4101
functions provided will ensure the peripheral works correctly whichever
4102
type of interrupt is used.
4103
 
4104
@quotation Note
4105
Until an interrupt is cleared, all subsequent interrupts are ignored
4106
with a warning.
4107
@end quotation
4108
 
4109 19 jeremybenn
@end table
4110
 
4111
@node Internal Debugging
4112
@section Internal Debugging
4113
@cindex internal debugging
4114
 
4115
The function @code{debug} is like @code{printf}, but with an extra
4116 82 jeremybenn
first argument, which is the debug level.  If the debug level specified
4117 19 jeremybenn
in the simulator configuration (@pxref{Simulator Behavior, , Simulator
4118
Behavior}) is greater than or equal to this value, the remaining
4119
arguments are printed to the current output stream (@pxref{Output
4120
Redirection, , Output Redirection}).
4121
 
4122 104 jeremybenn
@node Regression Testing
4123
@section Regression Testing
4124
@cindex regression testing
4125
@cindex testing
4126
@value{OR1KSIM} now includes a regression test suite for both standalone
4127
and library usage as described earlier (@pxref{Build and Install,
4128
, Building and Installing}).  Running the tests requires that the
4129
OpenRISC toolchain and DejaGNU are both installed.
4130
 
4131
Tests are written using @command{expect}, a derivative of TCL.
4132
Documentation of DejaGnu, @command{expect} and TCL are freely available
4133
on the Web.  The Embecosm Application Note 8, @cite{Howto: Using DejaGnu
4134
for Testing: A Simple Introduction}
4135
(@uref{http://www.embecosm.com/download/ean8.html}) provides a concise
4136
introduction.
4137
 
4138
All test code is found in the @file{testsuite} directory.  The key
4139
files and directories used are as follows.
4140
 
4141
@table @code
4142
@item global-conf.exp
4143
@cindex DejaGnu configuration
4144
This is the global DejaGNU configuration file used to set up parameters
4145
common to all tests.  If the user has the environment varialbe
4146
@env{DEJAGNU} defined, it will be used instead, but this is not
4147
recommended.
4148
 
4149
@item Makefile.am
4150
@cindex test make file
4151
@cindex make file for tests
4152
This is the top level @command{automake} file for the testsuite.  The
4153
only changes likely to be needed here is additional local cleanup of
4154
files created by new tests.
4155
 
4156
@item README
4157
@cindex test README
4158
This contains details of all the tests
4159
 
4160
@item config
4161
@cindex DejaGnu board configurations
4162
This contains DejaGnu board configurations.  Since the tests are
4163
generally run on a Unix host, this should just contain @file{Unix.exp}.
4164
 
4165
@item lib
4166
@cindex DejaGnu tool specific configuration
4167
This contains DejaGnu tool specific configurations.  ``Tool'' has a
4168
specific meaning in DejaGNU, referring just to a grouping of tests.  In
4169
this case there are two such ``tools'', ``or1ksim'' and ``libsim''
4170
for tests of the standalone tool and tests of the library.
4171
 
4172
Corresponding to this, there are two tool specific configuration files,
4173
@file{or1ksim.exp} and @file{libsim.exp}.  These contain @command{expect}/TCL
4174
procedures for common use among the tests.
4175
 
4176
@item libsim.tests
4177
@itemx or1ksim.tests
4178
@cindex DejaGNU tests directories
4179 440 jeremybenn
These are the directories of tests of the @value{OR1KSIM} library.  They
4180
also include @value{OR1KSIM} configuration files and each has a
4181
@file{Makefile.am} file.  @file{Makefile.am} should be updated whenever
4182
files are added to this directory, to ensure they are included in the
4183
distribution.
4184 104 jeremybenn
 
4185
@item test-code
4186
@cindex host test code
4187
@cindex test code for host
4188
These are all the test programs to be compiled on the host (each in its
4189
own directory).  In general these are programs to support testing of the
4190
library, and build various programs linking in the library.
4191
 
4192
@item test-code
4193
@cindex target test code
4194
@cindex test code for target
4195
These are all the test programs to be compiled with the OpenRISC tool
4196 346 jeremybenn
chain to run with either standalone @value{OR1KSIM} or the library.
4197
This directory includes its own @file{configure.ac}, since it must set
4198
up a separate tool chain based on the target, not the host.
4199 104 jeremybenn
 
4200
@end table
4201
 
4202
To add a new test needs the following steps.
4203
 
4204
@itemize @bullet
4205
 
4206
@item
4207 346 jeremybenn
Put new host C code in its own directory within @file{test-code}.  Add
4208 104 jeremybenn
the directory to the existing @file{Makefile.am} in the @file{test-code}
4209 346 jeremybenn
directory and create a @file{Makefile.am} in the new directory to drive
4210
building the test program(s).  Don't forget to add the new
4211
@file{Makefile} to the top level @file{configure.ac} so it gets
4212
generated. Not all tests require code here.
4213 104 jeremybenn
 
4214
@item
4215 346 jeremybenn
Put new target C code in its own directory within @file{test-code-or1k}.
4216
Once again modify & create @file{Makefile.am}.  This time modify the
4217
@file{configure.ac} in the @file{test-code-or1k} so the @file{Makefile}
4218
gets generated.  The existing programs provide examples to start from,
4219
including custom linker scripts where needed.
4220 104 jeremybenn
 
4221
@item
4222
Add one or more tests and configuration files to the relevant ``tool''
4223 346 jeremybenn
test directory.  Use the existing tests as templates.  They make heavy
4224
use of the @command{expect}/TCL procedures in the @file{config}
4225
directory to facilitate driving the tests.
4226 104 jeremybenn
 
4227
@end itemize
4228
 
4229 19 jeremybenn
@node  GNU Free Documentation License
4230
@chapter GNU Free Documentation License
4231
@cindex license for @value{OR1KSIM}
4232
 
4233
@include fdl-1.2.texi
4234
 
4235
@node Index
4236
 
4237
@unnumbered Index
4238
 
4239
@printindex cp
4240
 
4241
@bye

powered by: WebSVN 2.1.0

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