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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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