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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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