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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [or1ksim/] [or1ksim-0.4.0/] [doc/] [or1ksim.texi] - Blame information for rev 403

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

powered by: WebSVN 2.1.0

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