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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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