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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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