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

Subversion Repositories openrisc

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

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
@item superscalar = 0|1
1257
@cindex @code{superscalar} (CPU configuration)
1258 82 jeremybenn
If 1, the processor operates in superscalar mode.  Default value is
1259 19 jeremybenn
0.
1260
 
1261
In the current simulator, the only functional effect of superscalar
1262
mode is to affect the calculation of the number of cycles taken to
1263
execute an instruction.
1264
 
1265
@quotation Caution
1266
The code for this does not appear to be complete or well tested, so
1267
users are advised not to use this option.
1268
@end quotation
1269
 
1270
@item hazards = 0|1
1271
@cindex @code{hazards} (CPU configuration)
1272 82 jeremybenn
If 1, data hazards are tracked in a superscalar CPU.  Default value is
1273 19 jeremybenn
0.
1274
 
1275
In the current simulator, the only functional effect is to cause
1276
logging of hazard waiting information if the CPU is
1277 82 jeremybenn
superscalar.  However nowhere in the simulator is this data actually
1278 19 jeremybenn
computed, so the net result is probably to have no effect.
1279
 
1280
if harzards are tracked, current hazards can be displayed using the
1281
simulator's @command{r} command.
1282
 
1283
@quotation Caution
1284
The code for this does not appear to be complete or well tested, so
1285
users are advised not to use this option.
1286
@end quotation
1287
 
1288
@item dependstats = 0|1
1289
@cindex @code{dependstats} (CPU configuration)
1290 82 jeremybenn
If 1, inter-instruction dependencies are calculated.  Default value 0.
1291 19 jeremybenn
 
1292
If these values are calculated, the depencies can be displayed using
1293
the simulator's @command{stat} command.
1294
 
1295
@quotation Note
1296
This field must be enabled, if execution execution flow tracking
1297
(field @code{history}) has been requested in the simulator
1298
configuration section (@pxref{Simulator Behavior, , Simulator
1299
Behavior}).
1300
@end quotation
1301
 
1302
@item sbuf_len = @var{value}
1303
@cindex @code{sbuf_len} (CPU configuration)
1304
The length of the store buffer is set to @var{value}, which must be no
1305 82 jeremybenn
greater than 256.  Larger values will be truncated to 256 with a
1306
warning.  Negative values will be treated as 0 with a warning.  Use 0 to
1307 19 jeremybenn
disable the store buffer.
1308
 
1309
When the store buffer is active, stores are accumulated and committed
1310
when I/O is idle.
1311
 
1312
@end table
1313
 
1314
@node Memory Configuration
1315
@subsection Memory Configuration
1316
@cindex configuring memory
1317
@cindex memory configuration
1318
@cindex @code{section memory}
1319 82 jeremybenn
Memory configuration is described in @code{section memory}.  This
1320 19 jeremybenn
section may appear multiple times, specifying multiple blocks of
1321 82 jeremybenn
memory.  The following parameters may be specified.
1322 19 jeremybenn
 
1323
@table @code
1324
 
1325
@item type=random|pattern|unknown|zero
1326
@cindex @code{type} (memory configuration)
1327 82 jeremybenn
Specifies the values to which memory should be initialized.  The
1328 19 jeremybenn
default value is @code{unknown}.
1329
 
1330
@table @code
1331
 
1332
@item random
1333
@cindex @code{type=random} (memory configuration)
1334 82 jeremybenn
Set the memory values to be a random value.  A seed for the random
1335 19 jeremybenn
generator may be set using the @code{random_seed} field in this
1336
section (see below), thus ensuring the same ``random'' values are used
1337
each time.
1338
 
1339
@item pattern
1340
@cindex @code{type=pattern} (memory configuration)
1341
Set the memory values to be a pattern value, which is set using the
1342
@code{pattern} field in this section (see below).
1343
 
1344
@item unknown
1345
@cindex @code{type=unknown} (memory configuration)
1346 82 jeremybenn
The memory values are not initialized (i.e.  left ``unknown'').  This
1347 19 jeremybenn
option will yield faster initialization of the simulator.
1348
 
1349
@item zero
1350
@cindex @code{type=zero} (memory configuration)
1351 82 jeremybenn
Set the memory values to be 0.  This is the equivalent of
1352 19 jeremybenn
@code{type=pattern} and a @code{pattern} value of 0, and implemented
1353
as such.
1354
 
1355
@quotation Note
1356
As a consequence, if the @code{pattern} field is @emph{subsequently}
1357
specified in this section, the value in that field will be used
1358
instead of zero to initialize the memory.
1359
@end quotation
1360
 
1361
@end table
1362
 
1363
@item random_seed = @var{value}
1364
@cindex @code{random_seed} (memory configuration)
1365 82 jeremybenn
Set the seed for the random number generator to @var{value}.  This only
1366 19 jeremybenn
has any effect for memory type @code{random}.
1367
 
1368
The default value is -1,
1369
which means the seed will be set from a call to the @code{time}
1370
function, thus ensuring different random values are used on each
1371 82 jeremybenn
run.  The simulator prints out the seed used in this case, allowing
1372 19 jeremybenn
repeat runs to regenerate the same random values used in any
1373
particular run.
1374
 
1375
@item pattern = @var{value}
1376
@cindex @code{pattern} (memory configuration)
1377
Set the pattern to be used when initializing memory to
1378 82 jeremybenn
@var{value}.  The default value is 0.  This only has any effect for
1379
memory type @code{pattern}.  The least significant 8 bits of this value
1380
is used to initialize each byte.  More than 8 bits can be specified,
1381 19 jeremybenn
but will ignored with a warning.
1382
 
1383
@quotation Tip
1384
The default value, is equivalent to setting the memory @code{type} to
1385 82 jeremybenn
be @code{zero}.  If that is what is intended, then using
1386 19 jeremybenn
@code{type=zero} explicitly is better than using @code{type=pattern}
1387
and not specifying a value for @code{pattern}.
1388
@end quotation
1389
 
1390
@item baseaddr = @var{value}
1391
@cindex @code{baseaddr} (memory configuration)
1392 82 jeremybenn
Set the base address of the memory to @var{value}.  It should be
1393 19 jeremybenn
aligned to a multiple of the memory size rounded up to the nearest
1394 82 jeremybenn
@math{2^n}.  The default value is 0.
1395 19 jeremybenn
 
1396
@item size = @var{value}
1397
@cindex @code{size} (memory configuration)
1398 82 jeremybenn
Set the size of the memory block to be @var{value} bytes.  This should be a
1399
multiple of 4 (i.e.  word aligned).  The default value is 1024.
1400 19 jeremybenn
 
1401
@quotation Note
1402
When allocating memory, the simulator will allocate the nearest
1403
@math{2^n} bytes greater than or equal to @var{value}, and will not
1404
notice memory misses in any part of the memory between @var{value} and
1405
the amount allocated.
1406
 
1407
As a consequence users are strongly recommended to specify memory
1408 82 jeremybenn
sizes that are an exact power of 2.  If some other amount of memory is
1409 19 jeremybenn
required, it should be specified as separate, contiguous blocks, each
1410
of which is a power of 2 in size.
1411
@end quotation
1412
 
1413
@item name = "@var{text}"
1414
@cindex @code{name} (memory configuration)
1415 82 jeremybenn
Name the block.  Typically these describe the type of memory being
1416
modeled (thus @code{"SRAM"} or @code{"Flash"}.  The default is
1417 19 jeremybenn
@code{@w{"anonymous memory block"}}.
1418
 
1419
@quotation Note
1420
It is not clear that this information is currently ever used in normal
1421 82 jeremybenn
operation of the simulator.  Even the @command{info} command of the simulator
1422 19 jeremybenn
ignores it.
1423
@end quotation
1424
 
1425
@item ce = @var{value}
1426
@cindex @code{ce} (memory configuration)
1427 82 jeremybenn
Set the chip enable index of the memory instance.  Each memory instance
1428 19 jeremybenn
should have a unique chip enable index, which should be greater
1429 82 jeremybenn
than or equal to zero.  This is used by the memory controller when
1430 19 jeremybenn
identifying different memory instances.
1431
 
1432
The default value is -1 (invalid).
1433
 
1434
@item mc = @var{value}
1435
@cindex @code{mc} (memory configuration)
1436 82 jeremybenn
Specifies the memory controller this memory is connected to.  It should
1437 19 jeremybenn
correspond to the @code{index} field specified in a @code{@w{section
1438
mc}} for a memory controller (@pxref{Memory Controller Configuration,
1439
, Memory Controller Configuration}).
1440
 
1441
Default value is 0, which is also the default value of a memory
1442 82 jeremybenn
controller @code{index} field.  This is suitable therefore for designs
1443 19 jeremybenn
with just one memory controller.
1444
 
1445
@item delayr = @var{value}
1446
@cindex @code{delayr} (memory configuration)
1447 82 jeremybenn
The number of cycles required for a read access.  Set to -1 if the
1448
memory does not support reading.  Default value 1.  The simulator will
1449 19 jeremybenn
add this number of cycles to the total instruction cycle count when
1450
reading from main memory.
1451
 
1452
@item delayw = @var{value}
1453
@cindex @code{delayw} (memory configuration)
1454 82 jeremybenn
The number of cycles required for a write access.  Set to -1 if the
1455
memory does not support writing.  Default value 1.  The simulator will
1456 19 jeremybenn
add this number of cycles to the total instruction cycle count when
1457
writing to main memory.
1458
 
1459
@item log = "@var{file}"
1460
@cindex @code{log} (memory configuration)
1461
If specified, @file{file} names a file for all memory accesses to be
1462 82 jeremybenn
logged.  If not specified, the default value, NULL is used, meaning
1463 19 jeremybenn
that the memory is not logged.
1464
 
1465
@end table
1466
 
1467
@node Memory Management Configuration
1468
@subsection Memory Management Configuration
1469
@cindex configuring data & instruction MMUs
1470
@cindex MMU configuration
1471
@cindex DMMU configuration
1472
@cindex data MMU configuration
1473
@cindex IMMU configuration
1474
@cindex instruction MMU configuration
1475
@cindex @code{section dmmu}
1476
@cindex @code{section immu}
1477
Memory Management Unit (MMU) configuration is described in
1478
@code{section dmmu} (for the data MMU) and @code{section immu} (for
1479 82 jeremybenn
the instruction MMU).  Each section should appear at most once.  The
1480 19 jeremybenn
following parameters may be specified.
1481
 
1482
@table @code
1483
 
1484
@item enabled = 0|1
1485
@cindex @code{enabled} (MMU configuration)
1486
If 1 (true), the data or instruction (as appropriate) MMU is
1487 82 jeremybenn
enabled.  If 0 (the default), it is disabled.
1488 19 jeremybenn
 
1489
@item nsets = @var{value}
1490
@cindex @code{nsets} (MMU configuration)
1491
Sets the number of data or instruction (as appropriate) TLB sets to
1492 82 jeremybenn
@var{value}, which must be a power of two, not exceeding 128.  Values
1493
which do not fit these criteria are ignored with a warning.  The
1494
default value is 1.
1495 19 jeremybenn
 
1496
@item nways = @var{value}
1497
@cindex @code{nways} (MMU configuration)
1498
Sets the number of data or instruction (as appropriate) TLB ways to
1499 82 jeremybenn
@var{value}.  The value must be in the range 1 to 4.  Values outside
1500
this range are ignored with a warning.  The default value is 1.
1501 19 jeremybenn
 
1502
@item pagesize = @var{value}
1503
@cindex @code{pagesize} (MMU configuration)
1504
The data or instruction (as appropriate) MMU page size is set to
1505 82 jeremybenn
@var{value}, which must be a power of 2.  Values which are not a power
1506
of 2 are ignored with a warning.  The default is 8192 (0x2000).
1507 19 jeremybenn
 
1508
@item entrysize = @var{value}
1509
@cindex @code{entrysize} (MMU configuration)
1510
The data or instruction (as appropriate) MMU entry size is set to
1511 82 jeremybenn
@var{value}, which must be a power of 2.  Values which are not a power
1512
of 2 are ignored with a warning.  The default value is 1.
1513 19 jeremybenn
 
1514
@quotation Note
1515
@value{OR1KSIM} does not appear to use the @code{entrysize} parameter
1516 82 jeremybenn
in its simulation of the MMUs.  Thus setting this value does not seem
1517 19 jeremybenn
to matter.
1518
@end quotation
1519
 
1520
@item ustates = @var{value}
1521
@cindex @code{ustates} (MMU configuration)
1522
The number of instruction usage states for the data or instruction (as
1523
appropriate) MMU is set to @var{value}, which must be 2, 3 or
1524 82 jeremybenn
4.  Values outside this range are ignored with a warning.  The default
1525 19 jeremybenn
value is 2.
1526
 
1527
@quotation Note
1528
@value{OR1KSIM} does not appear to use the @code{ustates} parameter in
1529 82 jeremybenn
its simulation of the MMUs.  Thus setting this value does not seem to
1530 19 jeremybenn
matter.
1531
@end quotation
1532
 
1533
@item hitdelay = @var{value}
1534
@cindex @code{hitdelay} (MMU configuration)
1535
Set the number of cycles a data or instruction (as appropriate) MMU
1536 82 jeremybenn
hit costs.  Default value 1.
1537 19 jeremybenn
 
1538
@item missdelay = @var{value}
1539
@cindex @code{missdelay} (MMU configuration)
1540
Set the number of cycles a data or instruction (as appropriate) MMU
1541 82 jeremybenn
miss costs.  Default value 1.
1542 19 jeremybenn
 
1543
@end table
1544
 
1545
@node Cache Configuration
1546
@subsection Cache Configuration
1547
@cindex configuring data & instruction caches
1548
@cindex cache configuration
1549
@cindex data cache configuration
1550
@cindex instruction cache configuration
1551
@cindex @code{section dc}
1552
@cindex @code{section ic}
1553
Cache configuration is described in @code{section dc} (for the data
1554 82 jeremybenn
cache) and @code{seciton ic} (for the instruction cache).  Each section
1555
should appear at most once.  The following parameters may be specified.
1556 19 jeremybenn
 
1557
@table @code
1558
 
1559
@item enabled = 0|1
1560
@cindex @code{enabled} (cache configuration)
1561
If 1 (true), the data or instruction (as appropriate) cache is
1562 82 jeremybenn
enabled.  If 0 (the default), it is disabled.
1563 19 jeremybenn
 
1564
@item nsets = @var{value}
1565
@cindex @code{nsets} (cache configuration)
1566
Sets the number of data or instruction (as appropriate) cache sets to
1567
@var{value}, which must be a power of two, not exceeding
1568
@code{MAX_DC_SETS} (for the data cache) or @code{MAX_IC_SETS} (for the
1569 82 jeremybenn
instruction cache).  At the time of writing, these constants are
1570
both defined in the code to be 1024).  The default value is 1.
1571 19 jeremybenn
 
1572
@item nways = @var{value}
1573
@cindex @code{nways} (cache configuration)
1574
Sets the number of data or instruction (as appropriate) cache ways to
1575
@var{value}, which must be a power of two, not exceeding
1576
@code{MAX_DC_WAYS} (for the data cache) or @code{MAX_IC_WAYS} (for the
1577 82 jeremybenn
instruction cache).  At the time of writing, these constants are both
1578
defined in the code to be 32).  The default value is 1.
1579 19 jeremybenn
 
1580
@item blocksize = @var{value}
1581
@cindex @code{blocksize} (cache configuration)
1582
The data or instruction (as appropriate) cache block size is set to
1583 82 jeremybenn
@var{value} bytes, which must be either 16 or 32.  The default is 16.
1584 19 jeremybenn
 
1585
@item ustates = @var{value}
1586
@cindex @code{ustates} (cache configuration)
1587
The number of instruction usage states for the data or instruction (as
1588 82 jeremybenn
appropriate) cache is set to @var{value}, which must be 2, 3 or 4.  The
1589 19 jeremybenn
default value is 2.
1590
 
1591
@item hitdelay = @var{value}
1592
@cindex @code{hitdelay} (instruction cache configuration)
1593 82 jeremybenn
@emph{Instruction cache only}.  Set the number of cycles an instruction
1594
cache hit costs.  Default value 1.
1595 19 jeremybenn
 
1596
@item missdelay = @var{value}
1597
@cindex @code{missdelay} (instruction cache configuration)
1598 82 jeremybenn
@emph{Instruction cache only}.  Set the number of cycles an instruction
1599
cache miss costs.  Default value 1.
1600 19 jeremybenn
 
1601
@item load_hitdelay = @var{value}
1602
@cindex @code{load_hitdelay} (data cache configuration)
1603 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data load cache hit
1604
costs.  Default value 2.
1605 19 jeremybenn
 
1606
@item load_missdelay = @var{value}
1607
@cindex @code{load_missdelay} (data cache configuration)
1608 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data load cache
1609
miss costs.  Default value 2.
1610 19 jeremybenn
 
1611
@item store_hitdelay = @var{value}
1612
@cindex @code{store_hitdelay} (data cache configuration)
1613 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data store cache hit
1614
costs.  Default value 0.
1615 19 jeremybenn
 
1616
@item store_missdelay = @var{value}
1617
@cindex @code{store_missdelay} (data cache configuration)
1618 82 jeremybenn
@emph{Data cache only}.  Set the number of cycles a data store cache
1619
miss costs.  Default value 0.
1620 19 jeremybenn
 
1621
@end table
1622
 
1623
@node Interrupt Configuration
1624
@subsection Interrupt Configuration
1625
@cindex configuring the interrupt controller
1626
@cindex interrupt controller configuration
1627
@cindex programmable interrupt controller configuration
1628
@cindex PIC configuration
1629
@cindex @code{section pic}
1630
Programmable Interrupt Controller (PIC) configuration is described in
1631 82 jeremybenn
@code{section pic}.  This section may appear at most
1632 19 jeremybenn
once---@value{OR1KSIM} has no mechanism for handling multiple
1633 82 jeremybenn
interrupt controllers.  The following parameters may be specified.
1634 19 jeremybenn
 
1635
@table @code
1636
 
1637
@item enabled = 0|1
1638
@cindex @code{enabled} (interrupt controller)
1639 82 jeremybenn
If 1 (true), the programmable interrupt controller is enabled.  If 0
1640 19 jeremybenn
(the default), it is disabled.
1641
 
1642
@item edge_trigger = 0|1
1643
@cindex @code{edge_trigger} (interrupt controller)
1644
If 1 (true, the default), the programmable interrupt controller is
1645 82 jeremybenn
edge triggered.  If 0 (false), it is level triggered.
1646 19 jeremybenn
 
1647
@end table
1648
 
1649
@node Power Management Configuration
1650
@subsection Power Management Configuration
1651
@cindex configuring power management
1652
@cindex power management configuration
1653
@cindex PMU configuration
1654
@cindex @code{section pmu}
1655 82 jeremybenn
Power management implementation is incomplete.  At present the effect
1656 19 jeremybenn
(which only happens when the power management unit is enabled) of
1657
setting the different bits in the power management Special Purpose
1658
Register (PMR, SPR 0x4000) is
1659
 
1660
@table @code
1661
 
1662
@item SDF (bit mask 0x0000000f)
1663
@cindex SDF (power management register)
1664
@cindex slow down factor (power management register)
1665
@cindex power management register, SDF
1666
@cindex PMR - SDF
1667
No effect - these bits are ignored
1668
 
1669
@item DME (bit mask 0x00000010)
1670
@cindex DME (power management register)
1671
@cindex doze mode (power management register)
1672
@cindex power management register, DME
1673
@cindex PMR - DME
1674
@itemx SME (bit mask 0x00000020)
1675
@cindex SME (power management register)
1676
@cindex sleep mode (power management register)
1677
@cindex power management register, SME
1678
@cindex PMR - SME
1679
Both these bits cause the processor to stop executing
1680 82 jeremybenn
instructions.  However all other functions (debug interaction, CLI,
1681 19 jeremybenn
VAPI etc) carry on as normal.
1682
 
1683
@item DCGE (bit mask 0x00000004)
1684
@cindex DCGE (power management register)
1685
@cindex dynamic clock gating (power management register)
1686
@cindex power management register, DGCE
1687
@cindex PMR - DGCE
1688
No effect - this bit is ignored
1689
 
1690
@item SUME (bit mask 0x00000008)
1691
@cindex SUME (power management register)
1692
@cindex suspend mode (power management register)
1693
@cindex power management register, SUME
1694
@cindex PMR - SUME
1695
Enabling this bit causes a message to be printed, advising that the
1696
processor is suspending and the simulator exits.
1697
 
1698
@end table
1699
 
1700
On reset all bits are cleared.
1701
 
1702 82 jeremybenn
Power management configuration is described in @code{section pm}.  This
1703
section may appear at most once.  The following parameter may be specified.
1704 19 jeremybenn
 
1705
@table @code
1706
 
1707
@item enabled = 0|1
1708
@cindex @code{enabled} (power management configuration)
1709 82 jeremybenn
If 1 (true), power management is enabled.  If 0 (the default), it is
1710 19 jeremybenn
disabled.
1711
 
1712
@end table
1713
 
1714
@node Branch Prediction Configuration
1715
@subsection Branch Prediction Configuration
1716
@cindex configuring branch prediction
1717
@cindex branch prediction configuration
1718
@cindex BPB configuration
1719
@cindex @code{section bpb}
1720
From examining the code base, it seems the branch prediction function
1721 82 jeremybenn
is not fully implemented.  At present the functionality seems
1722 19 jeremybenn
restricted to collection of statistics.
1723
 
1724 82 jeremybenn
Branch prediction configuration is described in @code{section bpb}.  This
1725
section may appear at most once.  The following parameters may be specified.
1726 19 jeremybenn
 
1727
@table @code
1728
 
1729
@item enabled = 0|1
1730
@cindex @code{enabled} (branch prediction configuration)
1731 82 jeremybenn
If 1 (true), branch prediction is enabled.  If 0 (the default), it is
1732 19 jeremybenn
disabled.
1733
 
1734
@item btic = 0|1
1735
@cindex @code{btic} (branch prediction configuration)
1736 82 jeremybenn
If 1 (true), the branch target instruction cache model is enabled.  If
1737 19 jeremybenn
 
1738
 
1739
@item sbp_bf_fwd = 0|1
1740
@cindex @code{sbp_bf_fwd} (branch prediction configuration)
1741 82 jeremybenn
If 1 (true), use forward prediction for the @code{l.bf} instruction.  If
1742 19 jeremybenn
 
1743
 
1744
@item sbp_bnf_fwd = 0|1
1745
@cindex @code{sbp_bnf_fwd} (branch prediction configuration)
1746 82 jeremybenn
If 1 (true), use forward prediction for the @code{l.bnf} instruction.  If
1747 19 jeremybenn
 
1748
 
1749
@item hitdelay = @var{value}
1750
@cindex @code{hitdelay} (branch prediction configuration)
1751 82 jeremybenn
Set the number of cycles a branch prediction hit costs.  Default value
1752 19 jeremybenn
0.
1753
 
1754
@item missdelay = @var{value}
1755
@cindex @code{missdelay} (branch prediction configuration)
1756 82 jeremybenn
Set the number of cycles a branch prediction miss costs.  Default value
1757 19 jeremybenn
0.
1758
 
1759
@end table
1760
 
1761
@node Debug Interface Configuration
1762
@subsection Debug Interface Configuration
1763
@cindex configuring the debug unit and interface to external debuggers
1764
@cindex debug unit configuration
1765
@cindex debug interface configuration
1766
@cindex @code{section debug}
1767
The debug unit and debug interface configuration is described in
1768 82 jeremybenn
@code{@w{section debug}}.  This section may appear at most once.  The
1769 19 jeremybenn
following parameters may be specified.
1770
 
1771
@table @code
1772
 
1773
@item enabled = 0|1
1774
@cindex @code{enabled} (debug interface configuration)
1775 82 jeremybenn
If 1 (true), the debug unit is enabled.  If 0 (the default), it is disabled.
1776 19 jeremybenn
 
1777
@quotation Note
1778
This enables the functionality of the debug unit (its registers etc) within
1779 82 jeremybenn
the mode.  It does not provide any external interface to the debug unit.
1780
For
1781 19 jeremybenn
that, see @code{gdb_enabled} and @code{rsp_enabled} below.
1782
@end quotation
1783
 
1784
@item rsp_enabled = 0|1
1785
@cindex @code{rsp_enabled} (debug interface configuration)
1786
@cindex Remote Serial Protocol
1787
If 1 (true), the GDB @dfn{Remote Serial Protocol} server is started, provding
1788
an interface to an external GNU debugger, using the port specified in the
1789
@code{rsp_port} field (see below), or the @code{or1ksim-rsp} TCP/IP
1790 82 jeremybenn
service.  If 0 (the default), the server is not started, and no external
1791 19 jeremybenn
interface is provided.
1792
 
1793
For more detailed information on the interface to the GNU Debugger see
1794
Embecosm Application Note 2, @cite{Howto: Porting the GNU Debugger Practical
1795
Experience with the OpenRISC 1000 Architecture}, by Jeremy Bennett, published
1796
by Embecosm Limited (@url{www.embecosm.com}).
1797
 
1798
@quotation Note
1799 82 jeremybenn
@code{rsp_enabled} may not be enabled with @code{gdb_enabled} (see
1800
below).  If
1801 19 jeremybenn
both are enabled, a warning is issued and only the @dfn{Remote Serial
1802
Protocol} interface is enabled.
1803
@end quotation
1804
 
1805
@item rsp_port = @var{value}
1806
@cindex @code{rsp_port} (debug interface configuration)
1807
@var{value} specifies the port to be used for the GDB @dfn{Remote Serial
1808 82 jeremybenn
Protocol} interface to the GNU Debugger (GDB).  Default value 51000.  If
1809 19 jeremybenn
the value 0 is specified, @value{OR1KSIM} will instead look for a TCP/IP
1810
service named @code{or1ksim-rsp}.
1811
 
1812
@quotation Tip
1813
@cindex TCP/IP port range for @code{or1ksim-rsp} service
1814
There is no registered port for @value{OR1KSIM} @dfn{Remote Serial Protocol}
1815 82 jeremybenn
service @code{or1ksim-rsp}.  Good practice suggests users should adopt port
1816
values in the @dfn{Dynamic} or @dfn{Private} port range, i.e.  49152-65535.
1817 19 jeremybenn
@end quotation
1818
 
1819
@item gdb_enabled = 0|1
1820
@cindex @code{gdb_enabled} (debug interface configuration)
1821
If 1 (true), the OpenRISC Remote JTAG protocol server is started, provding an
1822
interface to an external GNU debugger, using the port specified in the
1823 82 jeremybenn
@code{server_port} field (see below), or the @code{or1ksim} TCP/IP
1824
service.  If
1825 19 jeremybenn
 
1826
provided.
1827
 
1828
For more detailed information on the interface to the GNU Debugger see
1829
Embecosm Application Note 2, @cite{Howto: Porting the GNU Debugger Practical
1830
Experience with the OpenRISC 1000 Architecture}, by Jeremy Bennett, published
1831
by Embecosm Limited (@url{www.embecosm.com}).
1832
 
1833
@quotation Note
1834
The OpenRISC Remote JTAG protocol is unique to OpenRISC, and remains only for
1835 82 jeremybenn
backward compatibility.  New users should adopt the standard GDB @dfn{Remote
1836 19 jeremybenn
Serial Protocol} interface (see @code{rsp_enabled} above) providing access to
1837
a wider range of GDB functionality.
1838
@end quotation
1839
 
1840
@quotation Note
1841 82 jeremybenn
@code{gdb_enabled} may not be enabled with @code{rsp_enabled}.  If both are
1842 19 jeremybenn
enabled, a warning is issued and only the @dfn{Remote Serial Protocol}
1843
interface is enabled.
1844
@end quotation
1845
 
1846
@item server_port = @var{value}
1847
@cindex @code{server_port} (debug interface configuration)
1848
@var{value} specifies the port to be used for the OpenRISC Rmote JTAG
1849 82 jeremybenn
protocol interface to the GNU Debugger (GDB).  Default value 51000.  If
1850 19 jeremybenn
the value 0 is specified, @value{OR1KSIM} will instead look for a TCP/IP
1851
service named @code{or1ksim}.
1852
 
1853
@quotation Tip
1854
@cindex TCP/IP port range for @code{or1ksim} service
1855
There is no registered port for @value{OR1KSIM} Remote JTAG Interface
1856 82 jeremybenn
or service @code{or1ksim}.  Good practice suggests users should adopt
1857 19 jeremybenn
port values in the @dfn{Dynamic} or @dfn{Private} port range,
1858 82 jeremybenn
i.e.  49152-65535.
1859 19 jeremybenn
@end quotation
1860
 
1861
@item vapi_id = @var{value}
1862
@cindex @code{vapi_id} (debug interface configuration)
1863
@var{value} specifies the value of the Verification API (VAPI) base
1864 82 jeremybenn
address to be used with the debug unit.  @xref{Verification API, ,
1865 19 jeremybenn
Verification API}, for more details.
1866
 
1867
If this is specified and @var{value} is non-zero, all OpenRISC Remote
1868
JTAG protocol transactions will be logged to the VAPI log file, if
1869 82 jeremybenn
enabled.  This is the only functionality associated with VAPI for the
1870
debug unit.  No VAPI commands are sent, nor requests handled.
1871 19 jeremybenn
 
1872
@end table
1873
 
1874
@node Peripheral Configuration
1875
@section Configuring Memory Mapped Peripherals
1876
 
1877 82 jeremybenn
All peripheral components are optional.  If they are specified, then
1878 19 jeremybenn
(unlike other components) by default they are enabled.
1879
 
1880
@menu
1881
* Memory Controller Configuration::
1882
* UART Configuration::
1883
* DMA Configuration::
1884
* Ethernet Configuration::
1885
* GPIO Configuration::
1886
* Display Interface Configuration::
1887
* Frame Buffer Configuration::
1888
* Keyboard Configuration::
1889
* Disc Interface Configuration::
1890
* Generic Peripheral Configuration::
1891
@end menu
1892
 
1893
@node Memory Controller Configuration
1894
@subsection Memory Controller Configuration
1895
@cindex configuring the memory controller
1896
@cindex memory controller configuration
1897
@cindex @code{section mc}
1898
The memory controller used in @value{OR1KSIM} is the component
1899
implemented at OpenCores, and found in the top level CVS directory,
1900 82 jeremybenn
@file{mem_ctrl}.  It is described in the document @cite{Memory
1901 19 jeremybenn
Controller IP Core} by Rudolf Usselmann, which can be found in the
1902 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
1903 19 jeremybenn
resides on the main OpenRISC Wishbone data bus.
1904
 
1905
The memory controller configuration is described in @code{@w{section
1906 82 jeremybenn
mc}}.  This section may appear multiple times, specifying multiple
1907
memory controllers.  The following parameters may be specified.
1908 19 jeremybenn
 
1909
@table @code
1910
 
1911
@item enabled = 0|1
1912
@cindex @code{enabled} (memory controller configuration)
1913 82 jeremybenn
If 1 (true, the default), this memory controller is enabled.  If 0, it is
1914 19 jeremybenn
disabled.
1915
 
1916
@quotation Note
1917
The memory controller can effectively also be disabled by setting an
1918 82 jeremybenn
appropriate power on control register value (see below).  However this
1919 19 jeremybenn
should only be used if it is desired to specifically model this
1920
behavior of the memory controller, not as a way of disabling the
1921
memory controller in general.
1922
@end quotation
1923
 
1924
@item baseaddr = @var{value}
1925
@cindex @code{baseaddr} (memory controller configuration)
1926
Set the base address of the memory controller's memory mapped
1927 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
1928 19 jeremybenn
sensible value.
1929
 
1930
The memory controller has a 7 bit address bus, with a total of 19
1931
32-bit registers, at addresses 0x00 through 0x4c (address 0x0c and
1932
addresses 0x50 through 0x7c are not used).
1933
 
1934
@item poc = @var{value}
1935
@cindex @code{poc} (memory controller configuration)
1936
Specifies the value of the power on control register, The least
1937
signficant two bits specify the bus width (use 0 for an 8-bit bus, 1
1938
for a 16-bit bus and 2 for a 32-bit bus) and the next two bits the
1939
type of memory connected (use 0 for a disabled interface, 1 for SSRAM,
1940
2 for asyncrhonous devices and 3 for synchronous devices).
1941
 
1942
If other bits are specified, they are ignored with a warning.
1943
 
1944
@quotation Caution
1945
The default value, 0, corresponds to a disabled 8-bit bus, and
1946
is likely not the most suitable value
1947
@end quotation
1948
 
1949
@item index = @var{value}
1950
@cindex @code{index} (memory controller configuration)
1951
Specify the index of this memory controller amongst all the memory
1952 82 jeremybenn
controllers.  This value should be unique for each memory controller,
1953 19 jeremybenn
and is used to associate specific memories with the controller,
1954
through the @code{mc} field in the @code{@w{section memory}}
1955
configuration (@pxref{Memory Configuration, , Memory Configuration}).
1956
 
1957
The default value, 0, is suitable when there is only one memory controller.
1958
 
1959
@end table
1960
 
1961
@node UART Configuration
1962
@subsection UART Configuration
1963
@cindex configuring the UART
1964
@cindex UART configuration
1965
@cindex @code{section uart}
1966
The UART implemented in @value{OR1KSIM} follows the specification of the
1967 82 jeremybenn
National Semiconductor 16450 and 16550 parts.  It is a memory mapped
1968 19 jeremybenn
component, which resides on the main OpenRISC Wishbone data bus.
1969
 
1970
The component provides a number of interfaces to emulate the behavior
1971
of an external terminal connected to the UART.
1972
 
1973 82 jeremybenn
UART configuration is described in @code{section uart}.  This section
1974
may appear multiple times, specifying multiple UARTs.  The following
1975 19 jeremybenn
parameters may be specified.
1976
 
1977
@table @code
1978
 
1979
@item enabled = 0|1
1980
@cindex @code{enabled} (UART configuration)
1981 82 jeremybenn
If 1 (true, the default), this UART is enabled.  If 0, it is disabled.
1982 19 jeremybenn
 
1983
@item baseaddr = @var{value}
1984
@cindex @code{baseaddr} (UART configuration)
1985
Set the base address of the UART's memory mapped
1986 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
1987 19 jeremybenn
sensible value.
1988
 
1989
The UART has a 3 bit address bus, with a total of 8 8-bit registers,
1990
at addresses 0x0 through 0x7.
1991
 
1992
@item channel = "@var{type}:@var{args}"
1993
@cindex @code{channel} (UART configuration)
1994
Specify the channel representing the terminal connected to the UART
1995
Rx & Tx pins.
1996
 
1997
@table @code
1998
 
1999
@item channel="file:@file{rxfile},@file{txfile}"
2000
@cindex UART I/O from/to files
2001
Read input characters from the file @file{rxfile} and write output
2002
characters to the file @file{txfile} (which will be created if
2003
required).
2004
 
2005
@item channel="xterm:@var{args}"
2006
@cindex UART I/O from/to an @command{xterm}
2007
Create an xterm on startup, write UART Tx traffic to the xterm and
2008
take Rx traffic from the keyboard when the xterm window is
2009 82 jeremybenn
selected.  Additional arguments to the xterm command (for example
2010 19 jeremybenn
specifying window size may be specified in @var{args}, or this may be
2011
left blank.
2012
 
2013
@item channel="tcp:@var{value}"
2014
@cindex UART I/O from/to TCP/IP
2015
Open the TCP/IP port specified by @var{value} and read and write UART
2016
traffic from and to it.
2017
 
2018
Typically a telnet session is connected to the other end of this port.
2019
 
2020
@quotation Tip
2021
There is no registered port for @value{OR1KSIM} telnet UART
2022 82 jeremybenn
connection.  Priviledged access is required to read traffic on the
2023
registered ``well-known'' telnet port (23).  Instead users should use
2024 19 jeremybenn
port values in the @dfn{Dynamic} or @dfn{Private} port range,
2025 82 jeremybenn
i.e.  49152-65535.
2026 19 jeremybenn
@end quotation
2027
 
2028
@item channel="fd:@code{rxfd},@code{txfd}"
2029
@cindex UART I/O from/to open file descriptors
2030
Read and write characters from and to the existing open numerical file
2031
descriptors, file @code{rxfd} and @code{txfd}.
2032
 
2033
@item channel="tty:device=/dev/ttyS0,baud=9600"
2034
@cindex UART I/O from/to a physical serial port
2035 82 jeremybenn
Read and write characters from and to a physical serial port.  The
2036 19 jeremybenn
precise device (shown here as @code{/dev/ttyS0}) may vary from machine
2037
to machine.
2038
 
2039
@end table
2040
 
2041
The default value for this field is @code{"xterm:"}.
2042
 
2043
@item irq = @var{value}
2044
@cindex @code{irq} (UART configuration)
2045 82 jeremybenn
Use @var{value} as the IRQ number of this UART.  Default value 0.
2046 19 jeremybenn
 
2047
@item 16550 = 0|1
2048
@cindex @code{16550} (UART configuration)
2049 82 jeremybenn
If 1 (true), the UART has the functionality of a 16550.  If 0 (the
2050
default), it has the functionality of a 16450.  The principal
2051 19 jeremybenn
difference is that the 16550 can buffer multiple characters.
2052
 
2053
@item jitter = @var{value}
2054
@cindex @code{jitter} (UART configuration)
2055
Set the jitter, modeled as a time to block, to @var{value}
2056 82 jeremybenn
milliseconds.  Set to -1 to disable jitter modeling.  Default value 0.
2057 19 jeremybenn
 
2058
@quotation Note
2059
This functionality has yet to be implemented, so this parameter has no
2060
effect.
2061
@end quotation
2062
 
2063
@item vapi_id = @var{value}
2064
@cindex @code{vapi_id} (UART configuration)
2065
@var{value} specifies the value of the Verification API (VAPI) base
2066 82 jeremybenn
address to be used with the UART.  @xref{Verification API, ,
2067 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2068
with the UART.
2069
 
2070
@end table
2071
 
2072
@node DMA Configuration
2073
@subsection DMA Configuration
2074
@cindex configuring DMA
2075
@cindex DMA configuration
2076
@cindex @code{section dma}
2077
The DMA controller used in @value{OR1KSIM} is the component
2078
implemented at OpenCores, and found in the top level CVS directory,
2079 82 jeremybenn
@file{wb_dma}.  It is described in the document @cite{Wishbone
2080 19 jeremybenn
DMA/Bridge IP Core} by Rudolf Usselmann, which can be found in the
2081 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
2082
resides on the main OpenRISC Wishbone data bus.  The present
2083 19 jeremybenn
implementation is incomplete, intended only to support the Ethernet
2084
interface (@pxref{Ethernet Configuration}), although the Ethernet
2085
interface is not yet completed.
2086
 
2087 82 jeremybenn
DMA configuration is described in @code{@w{section dma}}.  This section
2088
may appear multiple times, specifying multiple DMA controllers.  The
2089 19 jeremybenn
following parameters may be specified.
2090
 
2091
@table @code
2092
 
2093
@item enabled = 0|1
2094
@cindex @code{enabled} (DMA configuration)
2095 82 jeremybenn
If 1 (true, the default), this DMA controller is enabled.  If 0, it is disabled.
2096 19 jeremybenn
 
2097
@item baseaddr = @var{value}
2098
@cindex @code{baseaddr} (DMA configuration)
2099
Set the base address of the DMA's memory mapped
2100 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2101 19 jeremybenn
sensible value.
2102
 
2103
The DMA controller has a 10 bit address bus, with a total of 253
2104 82 jeremybenn
32-bit registers.  The first 5 registers at addresses 0x000 through
2105
0x010 control the overall behavior of the DMA controller.  There are
2106 19 jeremybenn
then 31 blocks of 8 registers, controlling each of the 31 DMA channels
2107 82 jeremybenn
available.  Addresses 0x014 through 0x01c are not used.
2108 19 jeremybenn
 
2109
@item irq = @var{value}
2110
@cindex @code{irq} (DMA configuration)
2111 82 jeremybenn
Use @var{value} as the IRQ number of this DMA controller.  Default value 0.
2112 19 jeremybenn
 
2113
@item vapi_id = @var{value}
2114
@cindex @code{vapi_id} (DMA configuration)
2115
@var{value} specifies the value of the Verification API (VAPI) base
2116 82 jeremybenn
address to be used with the DMA controller.  @xref{Verification API, ,
2117 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2118
with the DMA controller.
2119
 
2120
@end table
2121
 
2122
@node Ethernet Configuration
2123
@subsection Ethernet Configuration
2124
@cindex configuring the Ethernet interface
2125
@cindex Ethernet configuration
2126
@cindex @code{section ethernet}
2127
The Ethernet MAC used in @value{OR1KSIM} is the component implemented
2128
at OpenCores, and found in the top level CVS directory,
2129 82 jeremybenn
@file{ethernet}.  It also forms part of the OpenRISC SoC, ORPSoC.  It is
2130 19 jeremybenn
described in the document @cite{Ethernet IP Core Specification} by
2131 82 jeremybenn
Igor Mohor, which can be found in the @file{doc} subdirectory.  It is a
2132 19 jeremybenn
memory mapped component, which resides on the main OpenRISC Wishbone
2133
data bus.
2134
 
2135 82 jeremybenn
Ethernet configuration is described in @code{section ethernet}.  This
2136 19 jeremybenn
section may appear multiple times, specifying multiple Ethernet
2137 82 jeremybenn
interfaces.  The following parameters may be specified.
2138 19 jeremybenn
 
2139
@table @code
2140
 
2141
@item enabled = 0|1
2142
@cindex @code{enabled} (Ethernet configuration)
2143 82 jeremybenn
If 1 (true, the default), this Ethernet MAC is enabled.  If 0, it is
2144 19 jeremybenn
disabled.
2145
 
2146
@item baseaddr = @var{value}
2147
@cindex @code{baseaddr} (Ethernet configuration)
2148
Set the base address of the MAC's memory mapped registers to
2149 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
2150 19 jeremybenn
 
2151
The Ethernet MAC has a 7-bit address bus, with a total of 21
2152 82 jeremybenn
32-bit registers.  Addresses 0x54 through 0x7c are not used.
2153 19 jeremybenn
 
2154
@quotation Note
2155
The Ethernet specification describes a Tx control register,
2156 82 jeremybenn
@code{TXCTRL}, at address 0x50.  However this register is not
2157 19 jeremybenn
implemented in the @value{OR1KSIM} model.
2158
@end quotation
2159
 
2160
@item dma = @var{value}
2161
@cindex @code{dma} (Ethernet configuration)
2162
@var{value} specifies the DMA controller with which this Ethernet is
2163 82 jeremybenn
associated.  The default value is 0.
2164 19 jeremybenn
 
2165
@quotation Note
2166
Support for external DMA is not provided in the current
2167 82 jeremybenn
implementation, and this value is ignored.  In any case there is no
2168 19 jeremybenn
equivalent field to which this can be matched in the current DMA
2169
component implementation (@pxref{DMA Configuration, , DMA
2170
Configuration}).
2171
@end quotation
2172
 
2173
@item irq = @var{value}
2174
@cindex @code{dma} (Ethernet configuration)
2175 82 jeremybenn
Use @var{value} as the IRQ number of this Ethernet MAC.  Default value 0.
2176 19 jeremybenn
 
2177
@item rtx_type = 0|1
2178
@cindex @code{rtx_type} (Ethernet configuration)
2179
If 1 (true) use a socket interface to the Ethernet (see parameter
2180 82 jeremybenn
@code{sockif} below).  If 0 (the default), use a file interface,
2181 19 jeremybenn
reading and writing from and to the files specified in the
2182
@code{rxfile} and @code{txfile} parameters (see below).
2183
 
2184
@quotation Note
2185 82 jeremybenn
By default the socket interface is not provided in @value{OR1KSIM}.  If
2186 19 jeremybenn
it is required, this must be requested when configuring, by use of the
2187
@code{--enable-ethphy} option to @command{configure}.
2188
 
2189
@example
2190
configure --target=or32-uclinux --enable-ethphy ...
2191
@end example
2192
@end quotation
2193
 
2194
@item rx_channel = @var{rxvalue}
2195
@cindex @code{rx_channel} (Ethernet configuration)
2196
@itemx tx_channel = @var{txvalue}
2197
@cindex @code{tx_channel} (Ethernet configuration)
2198
@var{rxvalue} specifies the DMA channel to use for receive and
2199 82 jeremybenn
@var{txvalue} the DMA channel to use for transmit.  Both default to 0.
2200 19 jeremybenn
 
2201
@quotation Note
2202
As noted above, support for external DMA is not provided in the
2203
current implementation, and so these values are ignored.
2204
@end quotation
2205
 
2206
@item rxfile = "@var{rxfile}"
2207
@cindex @code{rxfile} (Ethernet configuration)
2208
@itemx txfile = "@var{txfile}"
2209
@cindex @code{txfile} (Ethernet configuration)
2210
When @code{rtx_type} is 0 (see above), @var{rxfile} specifies the file
2211
to use as input and @var{txfile} specifies the fie to use as
2212
output.
2213
 
2214 82 jeremybenn
The file contains a sequence of packets.  Each packet consists of a
2215
packet length (32 bits), followed by that many bytes of data.  Once the
2216 19 jeremybenn
input file is empty, the Ethernet MAC behaves as though there were no
2217 82 jeremybenn
data on the Ethernet.  The default values of these parameters are
2218 19 jeremybenn
@code{"eth_rx"} and @code{"eth_tx"} respectively.
2219
 
2220 82 jeremybenn
The input file must exist and be readable.  The output file must be
2221
writable and will be created if necessary.  If either of these
2222 19 jeremybenn
conditions is not met, a warning will be given.
2223
 
2224
@item sockif = "@var{service}"
2225
@cindex @code{sockif} (Ethernet configuration)
2226
When @code{rtx_type} is 1 (see above), @var{service} specifies the
2227 82 jeremybenn
service to use for communication.  This may be TCP/IP or UDP/IP.  The
2228 19 jeremybenn
default value of this parameter is @code{"or1ksim_eth"}.
2229
 
2230
@item vapi_id = @var{value}
2231
@cindex @code{vapi_id} (DMA configuration)
2232
@var{value} specifies the value of the Verification API (VAPI) base
2233 82 jeremybenn
address to be used with the Ethernet PHY.  @xref{Verification API, ,
2234 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2235
with the DMA controller.
2236
 
2237
@end table
2238
 
2239
@node GPIO Configuration
2240
@subsection GPIO Configuration
2241
@cindex configuring the GPIO
2242
@cindex GPIO configuration
2243
@cindex @code{section cpio}
2244
The GPIO used in @value{OR1KSIM} is the component implemented at
2245 82 jeremybenn
OpenCores, and found in the top level CVS directory, @file{gpio}.  It
2246 19 jeremybenn
is described in the document @cite{GPIO IP Core Specification} by
2247
Damjan Lampret and Goran Djakovic, which can be found in the
2248 82 jeremybenn
@file{doc} subdirectory.  It is a memory mapped component, which
2249 19 jeremybenn
resides on the main OpenRISC Wishbone data bus.
2250
 
2251 82 jeremybenn
GPIO configuration is described in @code{@w{section gpio}}.  This section
2252
may appear multiple times, specifying multiple GPIO devices.  The
2253 19 jeremybenn
following parameters may be specified.
2254
 
2255
@table @code
2256
 
2257
@item enabled = 0|1
2258
@cindex @code{enabled} (GPIO configuration)
2259 82 jeremybenn
If 1 (true, the default), this GPIO is enabled.  If 0, it is disabled.
2260 19 jeremybenn
 
2261
@item baseaddr = @var{value}
2262
@cindex @code{baseaddr} (GPIO configuration)
2263
Set the base address of the GPIO's memory mapped
2264 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2265 19 jeremybenn
sensible value.
2266
 
2267
The GPIO has a 6 bit address bus, with a total of 10 32-bit registers,
2268 82 jeremybenn
although the number of bits that are actively used varies.  Addresses
2269 19 jeremybenn
0x28 through 0x3c are not used.
2270
 
2271
@item irq = @var{value}
2272
@cindex @code{irq} (GPIO configuration)
2273 82 jeremybenn
Use @var{value} as the IRQ number of this GPIO.  Default value 0.
2274 19 jeremybenn
 
2275
@item vapi_id = @var{value}
2276
@cindex @code{vapi_id} (GPIO configuration)
2277
@cindex @code{base_vapi_id} (GPIO configuration - deprecated)
2278
@var{value} specifies the value of the Verification API (VAPI) base
2279 82 jeremybenn
address to be used with the GPIO.  @xref{Verification API, ,
2280 19 jeremybenn
Verification API}, for more details, which details the use of the VAPI
2281 82 jeremybenn
with the GPIO controller.  For backwards compatibility, the
2282 19 jeremybenn
alternative name @code{base_vapi_id} is supported for this parameter,
2283
but deprecated.
2284
 
2285
@end table
2286
 
2287
@node Display Interface Configuration
2288
@subsection Display Interface Configuration
2289
@cindex configuring the VGA interface
2290
@cindex display interface configuration
2291
@cindex VGA configuration
2292
@cindex @code{section vga}
2293
@value{OR1KSIM} models a VGA interface to an external monitor.  The
2294
VGA controller used in @value{OR1KSIM} is the component implemented at
2295
OpenCores, and found in the top level CVS directory, @file{vga_lcd},
2296 82 jeremybenn
with no support for the optional hardware cursors.  It is described in
2297 19 jeremybenn
the document @cite{VGA/LCD Core v2.0 Specifications} by Richard
2298 82 jeremybenn
Herveille, which can be found in the @file{doc} subdirectory.  It is a
2299 19 jeremybenn
memory mapped component, which resides on the main OpenRISC Wishbone
2300
data bus.
2301
 
2302
The current implementation provides only functionality to dump the
2303
screen to a file at intervals.
2304
 
2305
VGA controller configuration is described in @code{@w{section
2306 82 jeremybenn
vga}}.  This section may appear multiple times, specifying multiple
2307
VGA controllers.  The following parameters may be specified.
2308 19 jeremybenn
 
2309
@table @code
2310
 
2311
@item enabled = 0|1
2312
@cindex @code{enabled} (VGA configuration)
2313 82 jeremybenn
If 1 (true, the default), this VGA is enabled.  If 0, it is disabled.
2314 19 jeremybenn
 
2315
@item baseaddr = @var{value}
2316
@cindex @code{baseaddr} (VGA configuration)
2317
Set the base address of the VGA controller's memory mapped
2318 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2319 19 jeremybenn
sensible value.
2320
 
2321
The VGA controller has a 12-bit address bus, with 7 32-bit registers, at
2322
addresses 0x000 through 0x018, and two color lookup tables at
2323 82 jeremybenn
addresses 0x800 through 0xfff.  The hardware cursor registers are not
2324 19 jeremybenn
implemented, so addresses 0x01c through 0x7fc are not used.
2325
 
2326
@item irq = @var{value}
2327
@cindex @code{irq} (VGA configuration)
2328 82 jeremybenn
Use @var{value} as the IRQ number of this VGA controller.  Default
2329 19 jeremybenn
value 0.
2330
 
2331
@item refresh_rate = @var{value}
2332
@cindex @code{refresh_rate} (VGA configuration)
2333 82 jeremybenn
@var{value} specifies number of cycles between screen dumps.  Default
2334 19 jeremybenn
value is derived from the simulation clock cycle time
2335
(@pxref{Simulator Behavior, , Simulator Behavior}), to correspond
2336
to dumping 50 times per simulated second.
2337
 
2338
@item txfile = "@var{file}"
2339
@cindex @code{txfile} (VGA configuration)
2340
@cindex @code{filename} (VGA configuration - deprecated)
2341
@var{file} specifies the base of the filename for screen
2342 82 jeremybenn
dumps.  Successive screen dumps will be in BMP format, in files with
2343 19 jeremybenn
the name @file{@var{file}@var{nnnn}.bmp}, where @var{nnnn} is a
2344 82 jeremybenn
sequential count of the screen dumps starting at zero.  The default
2345
value is @code{"vga_out"}.  For backwards compatibility, the
2346 19 jeremybenn
alternative name @code{filename} is supported for this parameter,
2347
but deprecated.
2348
 
2349
@end table
2350
 
2351
@node Frame Buffer Configuration
2352
@subsection Frame Buffer Configuration
2353
@cindex configuring the frame buffer
2354
@cindex frame buffer configuration
2355
@cindex @code{section fb}
2356
@quotation Caution
2357 82 jeremybenn
The frame buffer is only partially implemented.  Its configuration
2358 19 jeremybenn
fields are described here, but the component should not be used at
2359 82 jeremybenn
this time.  Like the VGA controller, it is designed to make screen
2360 19 jeremybenn
dumps to file.
2361
@end quotation
2362
 
2363 82 jeremybenn
Frame buffer configuration is described in @code{section fb}.  This
2364 19 jeremybenn
section may appear multiple times, specifying multiple frame
2365 82 jeremybenn
buffers.  The following parameters may be specified.
2366 19 jeremybenn
 
2367
@table @code
2368
 
2369
@item enabled = 0|1
2370
@cindex @code{enabled} (frame buffer configuration)
2371 82 jeremybenn
If 1 (true, the default), this frame buffer is enabled.  If 0, it is disabled.
2372 19 jeremybenn
 
2373
@item baseaddr = @var{value}
2374
@cindex @code{baseaddr} (frame buffer configuration)
2375
Set the base address of the frame buffer's memory mapped registers to
2376 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
2377 19 jeremybenn
 
2378
The frame buffer has an 121-bit address bus, with 4 32-bit registers,
2379
at addresses 0x000 through 0x00c, and a PAL lookup table at addresses
2380 82 jeremybenn
0x400 through 0x4ff.  Addresses 0x010 through 0x3fc and addresses 0x500
2381 19 jeremybenn
through 0x7ff are not used.
2382
 
2383
@item refresh_rate = @var{value}
2384
@cindex @code{refresh_rate} (frame buffer configuration)
2385 82 jeremybenn
@var{value} specifies number of cycles between screen dumps.  Default
2386 19 jeremybenn
value is derived from the simulation clock cycle time
2387
(@pxref{Simulator Behavior, , Simulator Behavior}), to correspond to
2388
dumping 50 times per simulated second.
2389
 
2390
@item txfile = "@var{file}"
2391
@cindex @code{txfile} (frame buffer configuration)
2392
@cindex @code{filename} (frame buffer configuration - deprecated)
2393
@var{file} specifies the base of the filename for screen
2394 82 jeremybenn
dumps.  Successive screen dumps will be in BMP format, in files with
2395 19 jeremybenn
the name @file{@var{file}@var{nnnn}.bmp}, where @var{nnnn} is a
2396 82 jeremybenn
sequential count of the screen dumps starting at zero.  The default
2397
value is @code{"fb_out"}.  For backwards compatibility, the
2398 19 jeremybenn
alternative name @code{filename} is supported for this parameter,
2399
but deprecated.
2400
 
2401
@end table
2402
 
2403
@node Keyboard Configuration
2404
@subsection Keyboard Configuration (PS2)
2405
@cindex configuring the keyboard interface
2406
@cindex configuring the PS2 interface
2407
@cindex keyboard configuration
2408
@cindex PS2 configuration
2409
@cindex @code{section kb}
2410 82 jeremybenn
The PS2 interface provided by @value{OR1KSIM} is not documented.  It
2411 19 jeremybenn
may be based on the PS2 project at OpenCores, and found in
2412 82 jeremybenn
the top level CVS directory, @file{ps2}.  However this project lacks
2413
any documentation beyond its project webpage.  Since most PS2
2414 19 jeremybenn
interfaces follow the Intel i8042 standard, this is presumably what is
2415
expected with this device.
2416
 
2417
The implementation only provides for keyboard support, which is
2418 82 jeremybenn
modelled as a file of keystrokes.  There is no mouse support.
2419 19 jeremybenn
 
2420
@quotation Caution
2421
A standard i8042 device has two registers at addresses 0x60 (command)
2422 82 jeremybenn
and 0x64 (status).  Inspection of the code, suggests that the
2423 19 jeremybenn
@value{OR1KSIM} component places these registers at addresses 0x00 and
2424
0x04.
2425
 
2426
The port of Linux for the OpenRISC 1000, which runs on @value{OR1KSIM}
2427
implements the i8042 device driver, anticipating these registers
2428 82 jeremybenn
reside at their conventional address.  It seems unlikel that this code
2429 19 jeremybenn
will work.
2430
 
2431
This component should be used with caution.
2432
@end quotation
2433
 
2434 82 jeremybenn
Keyboard configuration is described in @code{section kbd}.  This
2435 19 jeremybenn
section may appear multiple times, specifying multiple keyboard
2436 82 jeremybenn
interfaces.  The following parameters may be specified.
2437 19 jeremybenn
 
2438
@table @code
2439
 
2440
@item enabled = 0|1
2441
@cindex @code{enabled} (keyboard configuration)
2442 82 jeremybenn
If 1 (true, the default), this keyboard is enabled.  If 0, it is disabled.
2443 19 jeremybenn
 
2444
@item baseaddr = @var{value}
2445
@cindex @code{baseaddr} (keyboard configuration)
2446
Set the base address of the keyboard's memory mapped registers to
2447 82 jeremybenn
@var{value}.  The default is 0, which is probably not a sensible value.
2448 19 jeremybenn
 
2449
The keyboard PS/2 interface has an 3-bit address bus, with 2 8-bit registers,
2450
at addresses 0x000 and 0x004.
2451
 
2452
@quotation Caution
2453
As noted above, a standard Intel 8042 interface would expect to find
2454
these registers at locations 0x60 and 0x64, thus requiring at least a
2455
7-bit bus.
2456
@end quotation
2457
 
2458
@item irq = @var{value}
2459
@cindex @code{irq} (keyboard configuration)
2460 82 jeremybenn
Use @var{value} as the IRQ number of this Keyboard interface.  Default
2461 19 jeremybenn
value 0.
2462
 
2463
@item rxfile = "@var{file}"
2464
@cindex @code{file} (keyboard configuration)
2465
@file{file} specifies a file containing raw key stroke data, which
2466 82 jeremybenn
models the input from a physical keyboard.  The default value is
2467 19 jeremybenn
@code{"kbd_in"}.
2468
 
2469
@end table
2470
 
2471
@node Disc Interface Configuration
2472
@subsection Disc Interface Configuration
2473
@cindex configuring the ATA/ATAPI interfaces
2474
@cindex disc interface configuration
2475
@cindex ATA/ATAPI configuration
2476
@cindex @code{section ata}
2477
The ATA/ATAPI disc controller used in @value{OR1KSIM} is the OCIDEC
2478
(OpenCores IDE Controller) component implemented at OpenCores, and
2479 82 jeremybenn
found in the top level CVS directory, @file{ata}.  It is described in
2480 19 jeremybenn
the document @cite{ATA/ATAPI-5 Core Specification} by Richard
2481 82 jeremybenn
Herveille, which can be found in the @file{doc} subdirectory.  It is a
2482 19 jeremybenn
memory mapped component, which resides on the main OpenRISC Wishbone
2483
data bus.
2484
 
2485 82 jeremybenn
ATA/ATAPI configuration is described in @code{@w{section ata}}.  This section
2486
may appear multiple times, specifying multiple disc controllers.  The
2487 19 jeremybenn
following parameters may be specified.
2488
 
2489
@table @code
2490
 
2491
@item enabled = 0|1
2492
@cindex @code{enabled} (ATA/ATAPI configuration)
2493 82 jeremybenn
If 1 (true, the default), this ATA/ATAPI interface is enabled.  If 0,
2494 19 jeremybenn
it is disabled.
2495
 
2496
@item baseaddr = @var{value}
2497
@cindex @code{baseaddr} (ATA/ATAPI configuration)
2498
Set the base address of the ATA/ATAPI interface's memory mapped
2499 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2500 19 jeremybenn
sensible value.
2501
 
2502
The ATA/ATAPI PS/2 interface has an 5-bit address bus, with 8 32-bit
2503 82 jeremybenn
registers.  Depending on the version of the OCIDEC ATA/ATAPI interface
2504 19 jeremybenn
selected (see @code{dev_id} below), not all registers will be available.
2505
 
2506
@item irq = @var{value}
2507
@cindex @code{irq} (ATA/ATAPI configuration)
2508 82 jeremybenn
Use @var{value} as the IRQ number of this ATA/ATAPI interface.  Default
2509 19 jeremybenn
value 0.
2510
 
2511
@item dev_id = 1|2|3
2512
@cindex @code{dev_id} (ATA/ATAPI configuration)
2513
This parameter specifies which version of the OCIDEC ATA/ATAPI
2514 82 jeremybenn
interface to model.  The default value is 1.
2515 19 jeremybenn
 
2516
Version 1 supports only the @code{CTRL}, @code{STAT} and @code{PCTR}
2517 82 jeremybenn
registers.  Versions 2 & 3 add the @code{FCTR} registers, Version 3
2518 19 jeremybenn
adds the @code{DTR} registers and the @code{RXD}/@code{TXD} registers.
2519
 
2520
@item rev = @var{value}
2521
@cindex @code{rev} (ATA/ATAPI configuration)
2522
Set the @var{value} as the revision of the OCIDEC ATA/ATAPI
2523 82 jeremybenn
interface.  The default value is 1.  The default value is 0.  Its value
2524
should be in the range 0-15.  Larger values are truncated with a
2525
warning.  This only affects the reset value of the @code{STAT}
2526 19 jeremybenn
register, where it forms bits 24-27.
2527
 
2528
@item pio_mode0_t1 = @var{value}
2529
@cindex @code{pio_mode0_t1} (ATA/ATAPI configuration)
2530
@itemx pio_mode0_t2 = @var{value}
2531
@cindex @code{pio_mode0_t2} (ATA/ATAPI configuration)
2532
@itemx pio_mode0_t4 = @var{value}
2533
@cindex @code{pio_mode0_t4} (ATA/ATAPI configuration)
2534
@itemx pio_mode0_teoc = @var{value}
2535
@cindex @code{pio_mode0_teoc} (ATA/ATAPI configuration)
2536
These parameters specify the timings for use with Programmed
2537 82 jeremybenn
Input/Output (PIO) transfers.  They are specified as the number of
2538 19 jeremybenn
clock cycles - 2, rounded up to the next highest integer, or zero if
2539 82 jeremybenn
that would be negative.  The values should not exceed 255.  If they do,
2540 19 jeremybenn
they will be ignored with a warning.
2541
 
2542
See the ATA/ATAPI-5 specification for explanations of each of these
2543 82 jeremybenn
timing parameters.  The default values are:
2544 19 jeremybenn
 
2545
@example
2546
pio_mode0_t1   =  6
2547
pio_mode0_t2   = 28
2548
pio_mode0_t4   =  2
2549
pio_mode0_teoc = 23
2550
@end example
2551
 
2552
@item dma_mode0_tm = @var{value}
2553
@cindex @code{dma_mode0_tm} (ATA/ATAPI configuration)
2554
@itemx dma_mode0_td = @var{value}
2555
@cindex @code{dma_mode0_td} (ATA/ATAPI configuration)
2556
@itemx dma_mode0_teoc = @var{value}
2557
@cindex @code{dma_mode0_teoc} (ATA/ATAPI configuration)
2558 82 jeremybenn
These parameters specify the timings for use with DMA transfers.  They
2559 19 jeremybenn
are specified as the number of clock cycles - 2, rounded up to the
2560 82 jeremybenn
next highest integer, or zero if that would be negative.  The values
2561
should not exceed 255.  If they do, they will be ignored with a
2562 19 jeremybenn
warning.
2563
 
2564
See the ATA/ATAPI-5 specification for explanations of each of these
2565 82 jeremybenn
timing parameters.  The default values are:
2566 19 jeremybenn
 
2567
@example
2568
dma_mode0_tm   =  4
2569
dma_mode0_td   = 21
2570
dma_mode0_teoc = 21
2571
@end example
2572
 
2573
@end table
2574
 
2575
@subsubsection ATA/ATAPI Device Configuration
2576
@cindex disc interface device configuration
2577
@cindex ATA/ATAPI device configuration
2578
Within the @code{@w{section ata}}, each device is specified
2579 82 jeremybenn
separately.  The device subsection is introduced by
2580 19 jeremybenn
 
2581
@example
2582
device @var{value}
2583
@end example
2584
 
2585 82 jeremybenn
@var{value} is the device number, which should be 0 or 1.  The
2586
subsection ends with @code{enddevice}.  Note that if the same device
2587 19 jeremybenn
number is specified more than once, the previous values will be
2588 82 jeremybenn
overwritten.  Within the @code{device} subsection, the following
2589 19 jeremybenn
parameters may appear:
2590
 
2591
@table @code
2592
 
2593
@item type = @var{value}
2594
@cindex @code{type} (ATA/ATAPI device configuration)
2595
@var{value}specifies the type of device: 0 (the default) for ``not
2596
connected'', 1 for hard disk simulated in a file and 2 for local system
2597
hard disk.
2598
 
2599
@item file = "@var{filename}"
2600
@cindex @code{file} (ATA/ATAPI device configuration)
2601
@file{filename} specifies the file to be used for a simulated ATA
2602 82 jeremybenn
device if the file type (see @code{type} above) is 1.  Default value
2603 19 jeremybenn
@code{"ata-File@var{n}"}, where @var{n} is the device number.
2604
 
2605
@item size = @var{value}
2606
@cindex @code{size} (ATA/ATAPI device configuration)
2607
@var{value} specifies the size of a simulated ATA device if the file
2608 82 jeremybenn
type (see @code{type} above) is 1.  The default value is zero.
2609 19 jeremybenn
 
2610
@item packet = 0|1
2611
@cindex @code{packet} (ATA/ATAPI device configuration)
2612 82 jeremybenn
If 1 (true), implement the PACKET command feature set.  If 0 (the
2613 19 jeremybenn
default), do not implement the PACKET command feature set.
2614
 
2615
@item firmware = "@var{str}"
2616
@cindex @code{firmware} (ATA/ATAPI device configuration)
2617
Firmware to report in response to the ``Identify Device''
2618 82 jeremybenn
command.  Default @code{"02207031"}.
2619 19 jeremybenn
 
2620
@item heads = @var{value}
2621
@cindex @code{heads} (ATA/ATAPI device configuration)
2622 82 jeremybenn
Number of heads in the device.  Default 7, use -1 to disable all heads.
2623 19 jeremybenn
 
2624
@item sectors = @var{value}
2625
@cindex @code{sectors} (ATA/ATAPI device configuration)
2626 82 jeremybenn
Number of sectors per track in the device.  Default 32.
2627 19 jeremybenn
 
2628
@item mwdma = 0|1|2|-1
2629
@cindex @code{mwdma} (ATA/ATAPI device configuration)
2630 82 jeremybenn
Highest multi-word DMA mode supported.  Default 2, use -1 to disable.
2631 19 jeremybenn
 
2632
@item pio = 0|1|2|3|4
2633
@cindex @code{pio} (ATA/ATAPI device configuration)
2634 82 jeremybenn
Highest PIO mode supported.  Default 4.
2635 19 jeremybenn
 
2636
@end table
2637
 
2638
@node Generic Peripheral Configuration
2639
@subsection Generic Peripheral Configuration
2640
@cindex generic peripheral configuration
2641
@cindex configuration of generic peripherals
2642
@cindex @code{section generic}
2643
When used as a library (@pxref{Simulator Library, , Simulator
2644
Library}), @value{OR1KSIM} makes provision for any additional peripheral to be
2645 82 jeremybenn
implemented externally.  Any read or write access to this peripheral's
2646
memory map generates @dfn{upcall}s to an external handler.  This
2647 19 jeremybenn
interface can support either C or C++, and was particularly designed
2648
to facilitate support for OSCI SystemC (see @url{http://www.systemc.org}).
2649
 
2650
Generic peripheral configuration is described in @code{@w{section
2651 82 jeremybenn
generic}}.  This section may appear multiple times, specifying multiple
2652
external peripherals.  The following parameters may be specified.
2653 19 jeremybenn
 
2654
@table @code
2655
 
2656
@item enabled = 0|1
2657
@cindex @code{enabled} (generic peripheral configuration)
2658 82 jeremybenn
If 1 (true, the default), this ATA/ATAPI interface is enabled.  If 0,
2659 19 jeremybenn
it is disabled.
2660
 
2661
@item baseaddr = @var{value}
2662
@cindex @code{baseaddr} (generic peripheral configuration)
2663
Set the base address of the generic peripheral's memory mapped
2664 82 jeremybenn
registers to @var{value}.  The default is 0, which is probably not a
2665 19 jeremybenn
sensible value.
2666
 
2667
The size of the memory mapped register space is controlled by the
2668
@code{size} paramter, described below.
2669
 
2670
@item size = @var{value}
2671
@cindex @code{size} (generic peripheral configuration)
2672
Set the size of the generic peripheral's memory mapped register space
2673 82 jeremybenn
to @var{value} bytes.  Any read or write accesses to addresses with
2674 19 jeremybenn
offsets of 0 to @var{value}-1 bytes from the base address specified in
2675
parameter @code{baseaddr} (see above) will be directed to the external
2676
interface.
2677
 
2678 82 jeremybenn
@var{value} will be rounded up the nearest power of 2.  It's default
2679
value is zero.  If @var{value} is not an exact power of two, accesses
2680 19 jeremybenn
to address offsets of @var{value} or above up to the next power of 2
2681
will generate a warning, and have no effect (reads will return zero).
2682
 
2683
@item name = "@var{str}"
2684
@cindex @code{name} (generic peripheral configuration)
2685 82 jeremybenn
This gives the peripheral the name @code{"@var{str}"}.  This is used to
2686 19 jeremybenn
identify the peripheral in error messages and warnings, and when
2687 82 jeremybenn
reporting its status.  The default value is @code{@w{"anonymous
2688 19 jeremybenn
external peripheral"}}.
2689
 
2690
@item byte_enabled = 0|1
2691
@cindex @code{byte_enabled} (generic peripheral configuration)
2692
@itemx hw_enabled = 0|1
2693
@cindex @code{hw_enabled} (generic peripheral configuration)
2694
@itemx word_enabled = 0|1
2695
@cindex @code{word_enabled} (generic peripheral configuration)
2696
If 1 (true, the default), these parameters respectively enable the
2697 82 jeremybenn
device for byte wide, half-word wide and word wide accesses.  If 0,
2698 19 jeremybenn
accesses of that width will fail.
2699
 
2700
@end table
2701
 
2702
@node Interactive Command Line
2703
@chapter Interactive Command Line
2704
 
2705
If started with the @code{-f} flag, or if interrupted with
2706
@kbd{ctrl-C}, @value{OR1KSIM} provides the user with an interactive
2707 82 jeremybenn
command line.  The commands available, which may not be abbreviated, are:
2708 19 jeremybenn
 
2709
@table @code
2710
 
2711
@item q
2712
@cindex @code{q} (Interactive CLI)
2713
@cindex quitting (Interactive CLI)
2714
Exit the simulator
2715
 
2716
@item r
2717
@cindex @code{r} (Interactive CLI)
2718
@cindex displaying registers (Interactive CLI)
2719
@cindex register display (Interactive CLI)
2720 82 jeremybenn
Display all the General Purpose Registers (GPRs).  Also shows the just
2721 19 jeremybenn
executed and next to be executed instructions symbolically and the
2722
state of the flag in the Supervision Register.
2723
 
2724
@item t
2725
@cindex @code{t} (Interactive CLI)
2726
@cindex stepping code (Interactive CLI)
2727
Execute the next instruction and then display register/instruction
2728
information as with the @code{r} command (see above).
2729
 
2730
@item run @var{num} [ hush ]
2731
@cindex @code{run} (Interactive CLI)
2732
@cindex running code (Interactive CLI)
2733
@cindex executing code (Interactive CLI)
2734 82 jeremybenn
Execute @var{num} instructions.  The register/instruction information
2735 19 jeremybenn
is displayed after each instruction, as with the @code{r} command (see
2736
above) @emph{unless} @code{hush} is specified.
2737
 
2738
@item pr @var{reg} @var{value}
2739
@cindex @code{pr} (Interactive CLI)
2740
@cindex patching registers (Interactive CLI)
2741
@cindex register patching (Interactive CLI)
2742
Patch register @var{reg} with @var{value}.
2743
 
2744
@item dm @var{fromaddr} [ @var{toaddr} ]
2745
@cindex @code{dm} (Interactive CLI)
2746
@cindex displaying memory (Interactive CLI)
2747
@cindex memory display (Interactive CLI)
2748 82 jeremybenn
Display memory bytes between @var{fromaddr} and @var{toaddr}.  If
2749 19 jeremybenn
@var{toaddr} is not given, 64 bytes are displayed, starting at
2750
@var{fromaddr}.
2751
 
2752
@quotation Caution
2753 82 jeremybenn
The output from this command is broken (a bug).  @value{OR1KSIM}
2754
attempts to print out 16 bytes per row.  However, instead of printing
2755 19 jeremybenn
out the address at the start of each row, it prints the address (of
2756
the first of the 16 bytes) before @emph{each} byte.
2757
@end quotation
2758
 
2759
@item de @var{fromaddr} [ @var{toaddr} ]
2760
@cindex @code{dm} (Interactive CLI)
2761
@cindex disassemble (Interactive CLI)
2762 82 jeremybenn
Disassemble code between @var{fromaddr} and @var{toaddr}.  If
2763 19 jeremybenn
@var{toaddr} is not given, 16 instructions are disassembled.
2764
 
2765
The disassembly is entirely numerical, and gives no symbolic
2766
information.
2767
 
2768
@item pm @var{addr} @var{value}
2769
@cindex @code{pm} (Interactive CLI)
2770
@cindex patching memory (Interactive CLI)
2771
@cindex memory patching (Interactive CLI)
2772
Patch the 4 bytes in memory starting at @var{addr} with the 32-bit
2773
@var{value}.
2774
 
2775
@item pc @var{value}
2776
@cindex @code{pc} (Interactive CLI)
2777
@cindex patching the program counter (Interactive CLI)
2778
@cindex program counter patching (Interactive CLI)
2779
Patch the program counter with @var{value}.
2780
 
2781
@item cm @var{fromaddr} @var{toaddr} @var{size}
2782
@cindex @code{cm} (Interactive CLI)
2783
@cindex copying memory (Interactive CLI)
2784
@cindex memory copying (Interactive CLI)
2785
Copy @var{size} bytes in memory from @var{fromaddr} to @var{toaddr}.
2786
 
2787
@item break @var{addr}
2788
@cindex @code{break} (Interactive CLI)
2789
@cindex breakpoint set/clear (Interactive CLI)
2790
@cindex set breakpoint (Interactive CLI)
2791
@cindex clear breakpoint (Interactive CLI)
2792
@cindex toggle breakpoint (Interactive CLI)
2793
Toggle the breakpoint set at @var{addr}.
2794
 
2795
@item breaks
2796
@cindex @code{breaks} (Interactive CLI)
2797
@cindex breakpoint list (Interactive CLI)
2798
@cindex list breakpoints (Interactive CLI)
2799
List all set breakpoints
2800
 
2801
@item reset
2802
@cindex @code{reset} (Interactive CLI)
2803
@cindex simulator reset (Interactive CLI)
2804
@cindex reset the simulator (Interactive CLI)
2805 82 jeremybenn
Reset the simulator.  Includes modeling a reset of the processor, so
2806 19 jeremybenn
execution will restart from the reset vector location, 0x100.
2807
 
2808
@item hist
2809
@cindex @code{hist} (Interactive CLI)
2810
@cindex execution history (Interactive CLI)
2811
@cindex history of execution (Interactive CLI)
2812
If saving the execution history has been configured (@pxref{Simulator
2813
Behavior, , Simulator Behavior}), display the execution history.
2814
 
2815
@item stall
2816
@cindex @code{stall} (Interactive CLI)
2817
@cindex processor stall (Interactive CLI)
2818
@cindex stall the processor (Interactive CLI)
2819 82 jeremybenn
Stall the processor, so that control is passed to the debug unit.  When
2820
stalled, the processor can execute no instructions.  This command is
2821 19 jeremybenn
useful when debugging the JTAG interface, used by debuggers such as
2822
GDB.
2823
 
2824
@item unstall
2825
@cindex @code{unstall} (Interactive CLI)
2826
@cindex processor unstall (Interactive CLI)
2827
@cindex unstall the processor (Interactive CLI)
2828 82 jeremybenn
Unstall the processor, so that normal execution can continue.  This command is
2829 19 jeremybenn
useful when debugging the JTAG interface, used by debuggers such as GDB.
2830
 
2831
@item stats @var{category} | clear
2832
@cindex @code{stats} (Interactive CLI)
2833
@cindex simulator statistics (Interactive CLI)
2834
@cindex statistics, simulation (Interactive CLI)
2835
Print the statistics for the given @var{category}, if available, or
2836 82 jeremybenn
clear if @code{clear} is specified.  The categories are:
2837 19 jeremybenn
 
2838
@table @asis
2839
 
2840
@item 1
2841
Miscellaneous statistics: branch predictions (if branch predictions
2842
are enabled), branch target cache model (if enabled), cache (if
2843
enbaled), MMU (if enabled) and number of addtional load & store
2844
cycles.
2845
 
2846
@xref{Core OpenRISC Configuration, , Configuring the OpenRisc
2847
Achitectural Components}, for details of how to enable these various
2848
features.
2849
 
2850
@item 2
2851 82 jeremybenn
Instruction usage statistics.  Requires hazard analysis to be enabled
2852 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
2853
 
2854
@item 3
2855 82 jeremybenn
Instruction dependency statistics.  Requires hazard analysis to be enabled
2856 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
2857
 
2858
@item 4
2859 82 jeremybenn
Functional unit dependency statistics.  Requires hazard analysis to be enabled
2860 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
2861
 
2862
@item 5
2863 82 jeremybenn
Raw register usage over time.  Requires hazard analysis to be enabled
2864 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
2865
 
2866
@item 6
2867 82 jeremybenn
Store buffer statistics.  Requires the store buffer to be enabled
2868 19 jeremybenn
(@pxref{CPU Configuration, ,CPU Configuration}).
2869
 
2870
@end table
2871
 
2872
@item info
2873
@cindex @code{info} (Interactive CLI)
2874
@cindex simulator configuration info (Interactive CLI)
2875
@cindex configuration info (Interactive CLI)
2876 82 jeremybenn
Display detailed information about the simulator configuration.  This
2877 19 jeremybenn
is quite a lengthy about, because all MMU TLB information is displayed.
2878
 
2879
@item dv @var{fromaddr} [ @var{toaddr} ] [ @var{module} ]
2880
@cindex @code{dv} (Interactive CLI)
2881
@cindex Verilog memory dump (Interactive CLI)
2882
@cindex memory dump, Verilog (Interactive CLI)
2883
Dump the area of memory between @var{fromaddr} and @var{toaddr} as
2884
Verilog code for a synchronous, 23-bit wide SRAM module, named
2885 82 jeremybenn
@var{module}.  If @var{toaddr} is not specified, then 64 bytes are
2886
dumped (as 16 32-bit words).  If @var{module} is not specified,
2887 19 jeremybenn
@code{or1k_mem} is used.
2888
 
2889
To save to a file, use the redirection function (described after this
2890
table, below).
2891
 
2892
@item dh @var{fromaddr} [ @var{toaddr} ]
2893
@cindex @code{dv} (Interactive CLI)
2894
@cindex hexadecimal memory dump (Interactive CLI)
2895
@cindex memory dump, hexadecimal (Interactive CLI)
2896
Dump the area of memory between @var{fromaddr} and @var{toaddr} as
2897 82 jeremybenn
32-bit hex numbers (no @code{0x}, or @code{32'h} prefix).  If
2898 19 jeremybenn
@var{toaddr} is not specified, then 64 bytes are dumped (as 16 32-bit
2899
words).
2900
 
2901
To save to a file, use the redirection function (described after this
2902
table, below).
2903
 
2904
@item setdbch
2905
@cindex @code{setdbch} (Interactive CLI)
2906
@cindex debug channel toggle (Interactive CLI)
2907
@cindex toggle debug channels (Interactive CLI)
2908 82 jeremybenn
Toggle debug channels on/off.  @xref{Standalone Simulator, , Standalone
2909 19 jeremybenn
Simulator}, for a description of specifying debug channels on the
2910
command line.
2911
 
2912
@item set @var{section} @var{param} = @var{value}
2913
@cindex @code{set} (Interactive CLI)
2914
@cindex configuration parameter setting (Interactive CLI)
2915
Set the configuration parameter @var{para} in section @var{section} to
2916 82 jeremybenn
@var{value}.  @xref{Configuration, , Configuration}, for details of
2917 19 jeremybenn
configuration parameters and their settings.
2918
 
2919
@item debug
2920
@cindex @code{debug} (Interactive CLI)
2921
@cindex debug mode toggle (Interactive CLI)
2922
@cindex toggle debug mode (Interactive CLI)
2923 82 jeremybenn
Toggle the simulator debug mode.  @xref{Debug Interface Configuration,
2924 19 jeremybenn
, Debug Interface Configuration}, for information on this parameter.
2925
 
2926
@quotation Caution
2927 82 jeremybenn
This is effectively enabling or disabling the debug unit.  It does not
2928
effect the remote GDB debug interface.  However using the remote debug
2929 19 jeremybenn
interface while the debug unit is disabled will lead to undefined
2930
behavior and likely crash @value{OR1KSIM}
2931
@end quotation
2932
 
2933
@item cuc
2934
@cindex @code{debug} (Interactive CLI)
2935
@cindex Custom Unit Compiler (Interactive CLI)
2936
Enter the the Custom Unit Compiler command prompt (@pxref{CUC
2937
Configuration, , CUC Configuration}).
2938
 
2939
@quotation Caution
2940 82 jeremybenn
The CUC must be properly configured, for this to succeed.  In
2941
particular a timing file must be available and readable.  Otherwise
2942 19 jeremybenn
@value{OR1KSIM} will crash.
2943
@end quotation
2944
 
2945
@item help
2946
@cindex @code{help} (Interactive CLI)
2947
@cindex Custom Unit Compiler (Interactive CLI)
2948
Print out brief information about each command available.
2949
 
2950
@item mprofile [-vh] [-m @var{m}] [-g @var{n}] [-f @var{file}] @var{from} @var{to}
2951
@cindex @code{mprofile} (Interactive CLI)
2952
@cindex memory profiling utility (Interactive CLI)
2953 82 jeremybenn
Run the memory profiling utility.  This follows the same usage as the
2954 19 jeremybenn
standalone command (@pxref{Memory Profiling Utility, , Memory
2955
Profiling Utility}).
2956
 
2957
@item profile [-vhcq] [-g @var{file}]
2958
@cindex @code{mprofile} (Interactive CLI)
2959
@cindex profiling utility (Interactive CLI)
2960
@cindex instruction profiling utility (Interactive CLI)
2961 82 jeremybenn
Run the instruction profiling utility.  This follows the same usage as the
2962 19 jeremybenn
standalone command (@pxref{Profiling Utility, , Profiling Utility}).
2963
 
2964
@end table
2965
 
2966
For all commands, it is possible to redirect the output to a file, by
2967
using the redirection operator, @code{>}.
2968
 
2969
@example
2970
@var{command} > @var{filename}
2971
@end example
2972
 
2973
This is particularly useful for commands dumping a large amount of
2974
output, such as @code{dv}.
2975
 
2976
@quotation Caution
2977 82 jeremybenn
Unfortunately there is a serious bug with the redirection operator.  It
2978 19 jeremybenn
does not return output to standard output after the command
2979 82 jeremybenn
completes.  Until this bug is fixed, file redirection should not be
2980 19 jeremybenn
used.
2981
@end quotation
2982
 
2983
@node Verification API
2984
@chapter Verification API (VAPI)
2985
 
2986
The Verification API (VAPI) provides a TCP/IP interface to allow
2987 82 jeremybenn
components of the simulation to be controlled externally.  The
2988 19 jeremybenn
interface is polled for new requests on each simulated clock
2989 82 jeremybenn
cycle.  Components within the simulator may send responses to such
2990 19 jeremybenn
requests.
2991
 
2992 82 jeremybenn
The inteface is an asynchronous duplex protocol.  On the request side
2993 19 jeremybenn
it provides for simple commands, known as VAPI IDs (a 32 bit integer),
2994 82 jeremybenn
with a single piece of data (also a 32 bit integer).  On the send side,
2995
it provides for sending a single VAPI ID and data.  However there is no
2996
explicit command-response structure.  Some components just accept
2997
requests (e.g.  to set values), some just generate sends (to report
2998 19 jeremybenn
values), and some do both.
2999
 
3000
Each component has a base ID (32 bit) and its commands will start from
3001 82 jeremybenn
that base ID.  This provides a simple partitioning of the command space
3002
amongst components.  Request commands will be directed to the component with
3003 19 jeremybenn
the closest base ID lower than the VAPI ID of the command.
3004
 
3005
Thus if there are two components with base IDs of 0x200 and 0x300, and
3006
a request with VAPI ID of 0x203 is received, it will be directed to
3007
the first component as its command #3.
3008
 
3009
The results of VAPI interactions are logged (by default in
3010
@file{vapi.log} unless an alternative is specified in @code{@w{section
3011
vapi}}).
3012
 
3013
Currently the following components support VAPI:
3014
 
3015
@table @asis
3016
 
3017
@item Debug Unit
3018
@cindex Debug Unit verification (VAPI)
3019
@cindex VAPI for Debug Unit
3020
Although the Debug Unit can specify a base VAPI ID, it is not used to
3021
send commands or receive requests.
3022
 
3023
Instead, if the base VAPI ID is set, all remote JTAG protocol exchanges are
3024
logged in the VAPI log file.
3025
 
3026
@item UART
3027
@cindex UART verification (VAPI)
3028
@cindex VAPI for UART
3029
If a base VAPI ID is specified, the UART sends details of any chars or
3030
break characters sent, with dteails of the line control register etc
3031
encoded in the data packet sent.
3032
 
3033
This supports a single VAPI command request, but encodes a sub-command in the
3034
top 8 bits of the associated data.
3035
 
3036
@table @code
3037
 
3038
@item 0x00
3039
@cindex 0x00 UART VAPI sub-command (UART verification)
3040
This stuffs the least significant 8 bits of the data into the serial
3041
register of the UART and the next 8 bits into the line control
3042
register, effectively providing control of the next character to be
3043
sent or received.
3044
 
3045
@item 0x01
3046
@cindex 0x01 UART VAPI sub-command (UART verification)
3047
The divisor latch bytes are set from the least significant 16 bits of
3048
the data.
3049
 
3050
@item 0x02
3051
@cindex 0x02 UART VAPI sub-command (UART verification)
3052
The line control register is set from bits 15-8 of the data.
3053
 
3054
@item 0x03
3055
@cindex 0x03 UART VAPI sub-command (UART verification)
3056
The UART skew is set from the least significant 16 bits of the data
3057
 
3058
@item 0x04
3059
@cindex 0x04 UART VAPI sub-command (UART verification)
3060
If the 16th most significant bit of the data is 1, start sending
3061 82 jeremybenn
breaks, otherwise stop sending breaks.  The breaks are sent or cleared
3062 19 jeremybenn
after the number of UART clock divider ticks specified by the data
3063
(immediately if the data is zero).
3064
 
3065
@end table
3066
 
3067
@item DMA
3068
@cindex DMA verification (VAPI)
3069
@cindex VAPI for DMA
3070
Although the DMA unit supports a base VAPI ID in its configuration
3071
(@code{@w{section dma}}), no VAPI data is sent, nor VAPI requests
3072
currently implemented.
3073
 
3074
@item Ethernet
3075
@cindex Ethernet verification (VAPI)
3076
@cindex VAPI for Ethernet
3077 82 jeremybenn
The following requests are handled by the Ethernet.  Specified
3078 19 jeremybenn
symbolically, these are the increments from the base VAPI ID of the
3079 82 jeremybenn
Ethernet.  At present no implementation is provided behind these VAPI
3080 19 jeremybenn
requests.
3081
 
3082
@table @code
3083
 
3084
@item ETH_VAPI_DATA (0)
3085
@cindex @code{ETH_VAPI_DATA} (Ethernet verification)
3086
 
3087
@item ETH_VAPI_CTRL (0)
3088
@cindex @code{ETH_VAPI_CTRL} (Ethernet verification)
3089
 
3090
@end table
3091
 
3092
@item GPIO
3093
@cindex GPIO verification (VAPI)
3094
@cindex VAPI for GPIO
3095
If a base VAPI ID is specified, the GPIO sends out on its base VAPI ID
3096
(symbolically, GPIO_VAPI_DATA (0) offset from the base VAPI ID) any
3097
changes in outputs.
3098
 
3099 82 jeremybenn
The following requests are handled by the GPIO.  Specified
3100 19 jeremybenn
symbolically, these are the increments from the VAPI base ID of the
3101
GPIO.
3102
 
3103
@table @code
3104
 
3105
@item GPIO_VAPI_DATA (0)
3106
@cindex @code{GPIO_VAPI_DATA} (GPIO verification)
3107
Set the next input to the commands data field
3108
 
3109
@item GPIO_VAPI_AUX (1)
3110
@cindex @code{GPIO_VAPI_AUX} (GPIO verification)
3111
Set the GPIO auxiliary inputs to the data field
3112
 
3113
@item GPIO_VAPI_CLOCK (2)
3114
@cindex @code{GPIO_VAPI_CLOCK} (GPIO verification)
3115
Add an external GPIO clock trigger of period specified in the data field.
3116
 
3117
@item GPIO_VAPI_RGPIO_OE (3)
3118
@cindex @code{GPIO_VAPI_RGPIO} (GPIO verification)
3119
Set the GPIO output enable to the data field
3120
 
3121
@item GPIO_VAPI_RGPIO_INTE (4)
3122
@cindex @code{GPIO_VAPI_INTE} (GPIO verification)
3123
Set the next interrupt to the data field
3124
 
3125
@item GPIO_VAPI_RGPIO_PTRIG (5)
3126
@cindex @code{GPIO_VAPI_PTRIG} (GPIO verification)
3127
Set the next trigger to the data field
3128
 
3129
@item GPIO_VAPI_RGPIO_AUX (6)
3130
@cindex @code{GPIO_VAPI_AUX} (GPIO verification)
3131
Set the next auxiliary input to the data field
3132
 
3133
@item GPIO_VAPI_RGPIO_CTRL (7)
3134
@cindex @code{GPIO_VAPI_CTRL} (GPIO verification)
3135
Set th next control input to the data field
3136
 
3137
@end table
3138
 
3139
@end table
3140
 
3141
@node Code Internals
3142
@chapter A Guide to @value{OR1KSIM} Internals
3143
 
3144 82 jeremybenn
These are notes to help those wanting to extend @value{OR1KSIM}.  This
3145 19 jeremybenn
section assumes the use of a tag file, so file locations of entities'
3146 82 jeremybenn
definitions are not in general provided.  For more on tags, see the
3147
Linux manual page for @command{etags}.  A tag file can be created
3148 19 jeremybenn
with:
3149
 
3150
@example
3151
make tags
3152
@end example
3153
 
3154
@menu
3155
* Coding Conventions::
3156
* Global Data Structures::
3157
* Concepts::
3158
* Internal Debugging::
3159
@end menu
3160
 
3161
@node Coding Conventions
3162
@section Coding Conventions for @value{OR1KSIM}
3163
 
3164
This chapter provides some guidelines for coding, to facilitate
3165
extensions to @value{OR1KSIM}
3166
 
3167
@table @emph
3168
 
3169
@item GNU Coding Standard
3170
Code should follow the GNU coding standard for C
3171 82 jeremybenn
(@url{http://www.gnu.org/prep/standards/}.  If in doubt, put your code
3172 19 jeremybenn
through the @command{indent} program.
3173
 
3174
@item @code{#include} headers
3175
All C source code files should include @file{config.h} before any
3176
other file.
3177
 
3178
This should be followed by inclusion of any system headers (but see
3179
the comments about portability and @file{port.h} below) and then by
3180
any @value{OR1KSIM} package headers.
3181
 
3182
If @file{port.h} is required, it should be the first package header to
3183
be included after the system headers.
3184
 
3185
All C source code and header files should directly include any system
3186 82 jeremybenn
or package header they depend on, i.e.  not rely on any other header
3187
having already included it.  The two exceptions are
3188 19 jeremybenn
 
3189
@enumerate
3190
@item
3191
All header files may assume that @file{config.h} has already been
3192
included.
3193
 
3194
@item
3195
System headers which impose portability problems should be included by
3196
using the package header @file{port.h}, rather than the system headers
3197 82 jeremybenn
themselves.  This is the case for code requiring
3198 19 jeremybenn
 
3199
@itemize @bullet
3200
 
3201
@item
3202
@code{strndup} (from @file{string.h})
3203
 
3204
@item
3205
Integer types (@code{int@var{n}_t}, @code{uint@var{n}_t}) (from
3206
@file{inttypes.h}).
3207
 
3208
@item
3209
@code{isblank} (from @file{ctype.h})
3210
 
3211
@end itemize
3212
 
3213
@end enumerate
3214
 
3215
@item @code{#include} files once only
3216
All include files should be protected by @code{#ifndef} to ensure
3217 82 jeremybenn
their definitions are only included once.  For instance a header file
3218 19 jeremybenn
@file{@var{x-y.h}} should surround its contents with:
3219
 
3220
@example
3221
#ifndef X_Y__H
3222
#define X_Y__H
3223
 
3224
<body of the include file>
3225
 
3226
#endif  /* X_Y__H */
3227
@end example
3228
 
3229
@item Avoid @code{typedef}
3230
The GNU coding style for C does not have a clear way to distinguish
3231 82 jeremybenn
between user type name and user variables.  For this reason
3232 19 jeremybenn
@code{typedef} should be avoided except for the most ubiquitous user
3233 82 jeremybenn
defined types.  This makes the code much easier to read.
3234 19 jeremybenn
 
3235
There are some @code{typedef} declarations in the @command{argtable2}
3236
library and the @acronym{ELF} and @acronym{COFF} headers, because this
3237
code is taken from other places.
3238
 
3239
Within @value{OR1KSIM} legacy uses of @code{typedef} have largely been
3240
purged, except in the Custom Unit Compiler (@pxref{CUC Configuration,
3241
, Custom Unit Compiler (CUC) Configuration}).
3242
 
3243
The remaining uses of @code{typedef} occur in two places:
3244
 
3245
@itemize @bullet
3246
 
3247
@item
3248
@file{port/port.h} defines types to replace those in header files that
3249
are not available (character functions, string duplication, integer
3250
types).
3251
 
3252
@file{cpu/or1k/arch.h} defines types for the key @value{OR1KSIM}
3253
entities: addresses (@code{oraddr_t}), unsigned register values
3254
(@code{uorreg_t}) and signed register (@code{orreg_t}) values.
3255
 
3256
@end itemize
3257
 
3258
Where new types are defined, they should appear in one of these two
3259 82 jeremybenn
files as appropriate.  @value{OR1KSIM} specific types appearing in
3260 19 jeremybenn
@file{arch.h} should always have the suffix @file{_h}.
3261
 
3262
@item Don't begin names with underscore
3263
Names beginning with @code{_} are intended to be part of the C
3264 82 jeremybenn
infrastructure.  They should not be used in the simulator code.
3265 19 jeremybenn
 
3266
@item Keep Non-global top level entities static
3267
All top level entities (functions, variables), which are not
3268 82 jeremybenn
explicitly part of a global interface should be declared static.  This
3269 19 jeremybenn
ensures that unwanted connections are not inadvertently built across
3270
the program.
3271
 
3272
@item Use of @code{inline}
3273 82 jeremybenn
Code should not be declared @code{inline}.  Modern compilers can work
3274 19 jeremybenn
out for themselves what is best in this respect.
3275
 
3276
@item Initialization
3277 82 jeremybenn
All data structures should be explicitly initialized.  In particular
3278 19 jeremybenn
code should not rely on static data structures being initialized to
3279
zero.
3280
 
3281
The rationale is that in future static data structures may become
3282 82 jeremybenn
dynamic.  This has been a particular source of bugs in @value{OR1KSIM}
3283 19 jeremybenn
historically.
3284
 
3285
A specific case is with new peripherals, which should always include a
3286
@code{start} function to pre-initialize all configuration parameters
3287
to sensible defaults
3288
 
3289
@item Configuration Validation
3290
All configuration values should be validated, preferably when
3291
encountered, if not when the @code{section} is closed, or otherwise
3292
at run time when the parameter is first used.
3293
 
3294
@end table
3295
 
3296
@node Global Data Structures
3297
@section Global Data Structures
3298
 
3299
@table @code
3300
 
3301
@item config
3302
@cindex configuration global structure
3303
@vindex config
3304
The global variable @code{config} of type @code{struct config} holds
3305
the configuration data for some of the @value{OR1KSIM} components which
3306 82 jeremybenn
are always present.  At present the components are:
3307 19 jeremybenn
 
3308
@itemize @bullet
3309
 
3310
@item
3311
@vindex config.sim
3312
The simulator defined in @code{@w{section sim}} (@pxref{Simulator
3313
Configuration, , Simulator Configuration}).
3314
 
3315
@item
3316
@vindex config.vapi
3317
The Verification API (VAPI) defined  in @code{@w{section vapi}}
3318
(@pxref{Verification API Configuration, , Verification API (VAPI)
3319
Configuration}).
3320
 
3321
@item
3322
@vindex config.cuc
3323
The Custom Unit Compiler (CUC), defined in @code{@w{section cuc}}
3324
(@pxref{CUC Configuration, , Custom Unit Compiler (CUC)
3325
Configuration}).
3326
 
3327
@item
3328
@vindex config.cpu
3329
The CPU, defined in @code{@w{section cpu}} (@pxref{CPU Configuration,
3330
, CPU Configuration}).
3331
 
3332
@item
3333
@vindex config.dc
3334
The data cache (but not the instruction cache), defined in
3335
@code{@w{section dc}} (@pxref{Cache Configuration, , Cache
3336
Configuration}).
3337
 
3338
@item
3339
@vindex config.pm
3340
The power management unit, defined in @code{@w{section pm}}
3341
(@pxref{Power Management Configuration, , Power Management
3342
Configuration}).
3343
 
3344
@item
3345
@vindex config.pic
3346
The programmable interrupt controller, defined in @code{@w{section pic}}
3347
(@pxref{Interrupt Configuration, , Interrupt Configuration}).
3348
 
3349
@item
3350
@vindex config.bpb
3351
Branch prediciton, defined in @code{@w{section bpb}} (@pxref{Branch
3352
Prediction Configuration, , Branch Prediction Configuration}).
3353
 
3354
@item
3355
@vindex config.debug
3356
The debug unit, defined in @code{@w{section debug}} (@pxref{Debug
3357
Interface Configuration, , Debug Interface Configuration}).
3358
 
3359
@end itemize
3360
 
3361
This struct is made of a collection of structs, one for each
3362 82 jeremybenn
component.  For example the simulator configuration is held in
3363 19 jeremybenn
@code{config.sim}.
3364
 
3365
@item config
3366
@cindex configuration dynamic structure
3367
@vindex sections
3368
This is a linked list of data structures holding configuration data
3369
for all sections which are not held in the main @code{config} data
3370 82 jeremybenn
structure.  In general these are components (such as peripherals and
3371
memory) which may occur multiple times.  However it also handles some
3372 19 jeremybenn
architectural components which may occur only once, such as the memory
3373
management units, the instruction cache, the interrupt controller and
3374
branch prediction.
3375
 
3376
@item runtime
3377
@cindex runtime global structure
3378
@vindex runtime
3379
The global variable @code{runtime} of type @code{struct runtime} holds
3380 82 jeremybenn
all the runtime information about the simulation.  To access this
3381 19 jeremybenn
variable, @file{sim-config.h} must be included.
3382
 
3383
@vindex runtime.cpu
3384
@vindex runtime.vapi
3385
@vindex runtime.cuc
3386
This struct is itself made of 3 other structs, @code{cpu} (for CPU run
3387
time state), @code{vapi} (for Verification API state) and @code{cuc}
3388
(for Custom Unit Compiler state).
3389
 
3390
@end table
3391
 
3392
@node Concepts
3393
@section Concepts
3394
 
3395
@table @emph
3396
 
3397
@anchor{Output Redirection}
3398
@item Output Redirection
3399
@cindex output rediretion
3400
@vindex runtime.cpu.fout
3401 82 jeremybenn
The current output stream is held in @code{runtime.cpu.fout}.  Output
3402 19 jeremybenn
should be explicitly written to this stream, or may use the
3403
@code{PRINTF} macro, which will write its arguments to this output stream.
3404
 
3405
@item Reset Hooks
3406
@cindex reset hooks
3407
@findex reg_sim_reset
3408
Any peripheral may register a routine to be called when the the
3409
processor is reset by calling @code{reg_sim_reset}, providing a
3410 82 jeremybenn
function and pointer to a data structure as arguments.  On reset that
3411 19 jeremybenn
function will be called with the data stucture pointer as argument.
3412
 
3413
@end table
3414
 
3415
@node Internal Debugging
3416
@section Internal Debugging
3417
@cindex internal debugging
3418
 
3419
The function @code{debug} is like @code{printf}, but with an extra
3420 82 jeremybenn
first argument, which is the debug level.  If the debug level specified
3421 19 jeremybenn
in the simulator configuration (@pxref{Simulator Behavior, , Simulator
3422
Behavior}) is greater than or equal to this value, the remaining
3423
arguments are printed to the current output stream (@pxref{Output
3424
Redirection, , Output Redirection}).
3425
 
3426
@node  GNU Free Documentation License
3427
@chapter GNU Free Documentation License
3428
@cindex license for @value{OR1KSIM}
3429
 
3430
@include fdl-1.2.texi
3431
 
3432
@node Index
3433
 
3434
@unnumbered Index
3435
 
3436
@printindex cp
3437
 
3438
@bye

powered by: WebSVN 2.1.0

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