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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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