OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

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

powered by: WebSVN 2.1.0

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