URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [or1ksim/] [doc/] [or1ksim.info] - Rev 478
Go to most recent revision | Compare with Previous | Blame | View Log
This is ../../doc/or1ksim.info, produced by makeinfo version 4.13 from../../doc/or1ksim.texi.INFO-DIR-SECTION Embedded developmentSTART-INFO-DIR-ENTRY* Or1ksim: (or32-elf-or1ksim). The OpenRISC 1000 ArchitecturalSimulatorEND-INFO-DIR-ENTRYThis file documents the OpenRISC Architectural Simulator, Or1ksim.Copyright (C) 2008, 2009 Embecosm Limited.Permission is granted to copy, distribute and/or modify thisdocument under the terms of the GNU Free Documentation License,Version 1.2 or any later version published by the Free SoftwareFoundation; with no Invariant Sections, with no Front-Cover Texts,and with no Back-Cover Texts. A copy of the license is includedin the section entitled "GNU Free Documentation License".File: or1ksim.info, Node: Top, Next: Installation, Up: (dir)Scope of this Document**********************This document is the user guide for Or1ksim, the OpenRISC 1000Architectural Simulator.* Menu:* Installation::* Usage::* Configuration::* Interactive Command Line::* Verification API::* Code Internals::* GNU Free Documentation License:: The license for this documentation* Index::File: or1ksim.info, Node: Installation, Next: Usage, Prev: Top, Up: Top1 Installation**************Installation follows standard GNU protocols.* Menu:* Preparation::* Configuring the Build::* Build and Install::* Known Issues::File: or1ksim.info, Node: Preparation, Next: Configuring the Build, Up: Installation1.1 Preparation===============Unpack the software and create a _separate_ directory in which to buildit:tar jxf or1ksim-2011-01-05.tar.bz2mkdir builddir_or1ksimcd builddir_or1ksimFile: or1ksim.info, Node: Configuring the Build, Next: Build and Install, Prev: Preparation, Up: Installation1.2 Configuring the Build=========================Configure the software using the `configure' script in the maindirectory.The most significant argument is `--target', which should specify theOpenRISC 1000 32-bit architecture. If this argument is omitted, it willdefault to OpenRISC 1000 32-bit with a warning../or1ksim-2011-01-05/configure --target=or32-elf ...There are several other options available, many of which are standardto GNU `configure' scripts. Use `configure --help' to see all theoptions. The most useful is `--prefix' to specify a directory forinstallation of the tools.For testing (using `make check'), the `--target' parameter may bespecified, to allow the target tool chain to be selected. If notspecified, it will default to `or32-elf', which is the same prefix usedwith the standard OpenRISC toolchain installation script.A number of Or1ksim specific features in the simulator do requireenabling at configuration. These include`--enable-profiling'`--disable-profiling'If enabled, Or1ksim is compiled for profiling with `gprof'. Thisis disabled by default. Only really of value for developers ofOr1ksim.`--enable-execution=simple'`--enable-execution=complex'`--enable-execution=dynamic'Or1ksim has developed to improve functionality and performance.This feature allows three versions of Or1ksim to be built`--enable-execution=simple'Build the original simple interpreting simulator`--enable-execution=complex'Build a more complex interpreting simulator. Experimentssuggest this is 50% faster than the simple simulator. Thisis the default.`--enable-execution=dynamic'Build a dynamically compiling simulator. This is the waymany modern ISS are built. This represents a work inprogress. Currently Or1ksim will compile, but segfaults ifconfigured with this option.The default is `--enable-execution=complex'.`--enable-ethphy'`--disable-ethphy'If enabled, this option allows the Ethernet to be simulated byconnecting via a socket (the alternative reads and writes, fromand to files). This must then be configured using the relevantfields in the `ethernet' section of the configuration file. *NoteEthernet Configuration: Ethernet Configuration.The default is for this to be disabled.`--enable-unsigned-xori'`--disable-unsigned-xori'Historically, `l.xori', has sign extended its operand. This isinconsistent with the other logical opcodes (`l.andi', `l.ori'),but in the absence of `l.not', it allows a register to be invertedin a single instruction using:`l.xori rD,rA,-1'This flag causes Or1ksim to treat the immediate operand asunsigned (i.e to zero-extend rather than sign-extend).The default is to sign-extend, so that existing code will continueto work.Caution: The GNU compiler tool chain makes heavy use of thisinstruction. Using unsigned behavior will require thecompiler to be modified accordingly.This option is provided for experimentation. A futureversion of OpenRISC may adopt this more consistent behaviorand also provide a `l.not' opcode.`--enable-range-stats'`--disable-range-stats'If enabled, this option allows statistics to be collected toanalyse register access over time. The default is for this to bedisabled.`--enable-debug'`--disable-debug'This is a feature of the Argtable2 package used to processarguments. If enabled, some debugging features are turned on inArgtable2. It is provided for completeness, but there is noreason why this feature should ever be needed by any Or1ksim user.`--enable-all-tests'`--disable-all-tests'Some of the tests (at the time of writing just one) will notcompile without error. If enabled with this flag, all testprograms will be compiled with `make check'.This flag is intended for those working on the test package, whowish to get the missing test(s) working.A number of configuration flags have been removed since version 0.3.0,because they led to invalid behavior of Or1ksim. Those removed are:`--enable-arith-flag'`--disable-arith-flag'If enabled, this option caused certain instructions to set the flag(`F' bit) in the supervision register if the result were zero.The instructions affected by this were `l.add', `l.addc',`l.addi', `l.and' and `l.andi'.If set, this caused incorrect behavior. Whether or not flags areset is part of the OpenRISC 1000 architectural specification. Theonly flags which should set this are the "set flag" instructions:`l.sfeq', `l.sfeqi', `l.sfges', `l.sfgesi', `l.sfgeu', `l.sfgeui',`l.sfgts', `l.sfgtsi', `l.sfgtu', `l.sfgtui', `l.sfles',`l.sflesi', `l.sfleu', `l.sfleui', `l.sflts', `l.sfltsi',`l.sfltu', `l.sfltui', `l.sfne' and `l.sfnei'.`--enable-ov-flag'`--disable-ov-flag'This flag caused certain instructions to set the overflow flag.If not, those instructions would not set the overflow flat. Theinstructions affected by this were `l.add', `l.addc', `l.addi',`l.and', `l.andi', `l.div', `l.divu', `l.mul', `l.muli', `l.or',`l.ori', `l.sll', `l.slli', `l.srl', `l.srli', `l.sra', `l.srai',`l.sub', `l.xor' and `l.xori'.This guaranteed incorrect behavior. The OpenRISC 1000 architecturespecification defines which flags are set by which instructions.Within the above list, the arithmetic instructions (`l.add',`l.addc', `l.addi', `l.div', `l.divu', `l.mul', `l.muli' and`l.sub'), together with `l.addic' which is missed out, set theoverflow flag. All the others (`l.and', `l.andi', `l.or',`l.ori', `l.sll', `l.slli', `l.srl', `l.srli', `l.sra', `l.srai',`l.xor' and `l.xori') do not.File: or1ksim.info, Node: Build and Install, Next: Known Issues, Prev: Configuring the Build, Up: Installation1.3 Building and Installing===========================Build the tool with:make allIf you have the OpenRISC tool chain and DejaGNU installed, you canverify the tool as follows (otherwise omit this step):make checkInstall the tool with:make installThis will install the three variations of the Or1ksim tool,`or32-elf-sim', `or32-elf-psim' and `or32-elf-mpsim', the Or1ksimlibrary, `libsim', the header file, `or1ksim.h' and this documentationin `info' format.The documentation may be created and installed in alternative formats(PDF, Postscript, DVI, HTML) with for example:make pdfmake install-pdfFile: or1ksim.info, Node: Known Issues, Prev: Build and Install, Up: Installation1.4 Known Problems and Issues=============================Full details of outstanding issues may be found in the `NEWS' file inthe main directory of the distribution. The OpenRISC tracker may beused to see the current state of these issues and to raise new problemsand feature requests. It may be found at bugtracker.The following issues are long standing and unlikely to be fixed inOr1ksim in the near future.* The Supervision Register Little Endian Enable (LEE) bit isignored. Or1ksim can be built for either little endian or bigendian use, but that behavior cannot be changed dynamically.* Or1ksim is not reentrant, so a program cannot instantiate multipleinstances using the library. This is clearly a problem whenconsidering multi-core applications. However it stems from theoriginal design, and can only be fixed by a complete rewrite. Theentire source code uses static global constants liberally!File: or1ksim.info, Node: Usage, Next: Configuration, Prev: Installation, Up: Top2 Usage******** Menu:* Standalone Simulator::* Profiling Utility::* Memory Profiling Utility::* Trace Generation::* Simulator Library::* Ethernet TUN/TAP Interface::* l.nop Support::File: or1ksim.info, Node: Standalone Simulator, Next: Profiling Utility, Up: Usage2.1 Standalone Simulator========================The general form the standalone command is:or32-elf-sim [-vhiqVt] [-f FILE] [--nosrv] [--srv=[N]][-m <n>][-d STR][--enable-profile] [--enable-mprofile] [FILE]Many of the options have both a short and a long form. For example`-h' or `--help'.`-v'`--version'Print out the version and copyright notice for Or1ksim and exit.`-h'`--help'Print out help about the command line options and what they mean.`-i'`--interactive'After starting, drop into the Or1ksim interactive command shell.`-q'`--quiet'Do not generate any information messages, only error messages.`-V'`--verbose'Generate extra output messages (equivalent of specifying the"verbose" option in the simulator configuration section (see *noteSimulator Behavior: Simulator Behavior.).`-t'`--trace'Dump instruction just executed and any register/memory locationchaged after each instruction (one line per instruction).`--trace-physical'`--trace-virtual'When tracing instructions, show the physical address(`--trace-physical') and/or the virtual address(`--trace-virtual') of the instruction being executed. Both flagsmay be specified, in which case both physical and virtualaddresses are shown, physical first.Note: Either or both flags may be specified without`--trace', to indicate how addresses should be shown ifsubsequently enabled by a `SIGUSER1' signal or `l.nop 8'opcode (*note Trace Generation: Trace Generation.).`-f FILE'`--file=FILE'Read configuration commands from the specified file, looking firstin the current directory, and otherwise in the `$HOME/.or1k'directory. If this argument is not specified, the file `sim.cfg'in those two locations is used. Failure to find the file is afatal error. *Note Configuration: Configuration, for detailedinformation on configuring Or1ksim.`--nosrv'Do not start up the "Remote Serial Protocol" debug server. Thisoverrides any setting specified in the configuration file. Thisoption may not be specified with `--srv'. If it is, a rudemessage is printed and the `--nosrv' option is ignored.`--srv'`--srv=N'Start up the "Remote Serial Protocol" debug server. Thisoverrides any setting specified in the configuration file. If theparameter, N, is specified, use that as the TCP/IP port for theserver, otherwise a random value from the private port range(41920-65535) will be used. This option may not be specified with`--nosrv'. If it is, a rude message is printed and the `--nosrv'option is ignored.`-m SIZE'`--memory=SIZE'Configure a memory block of SIZE bytes, starting at address zero.The size may be followed by `k', `K', `m', `M', `g', `G', toindicate kilobytes (2^10 bytes), megabytes (2^20 bytes) andgigabytes (2^30 bytes).This is mainly intended for use when Or1ksim is used without aconfiguration file, to allow just the processor and memory to beset up. This is the equivalent of specifying a configurationmemory section with `baseaddr = 0' and `size = SIZE' and all otherparameters taking their default value.If a configuration file is also used, it should be sure not tospecify an overlapping memory block.`-d CONFIG_STRING'`--debug-config=CONFIG_STRING'Enable selected debug messages in Or1ksim. This parameter is foruse by developers only, and is not covered further here. See thesource code for more details.`--report-memory-errors'By default all exceptions are now handled silently. If thisoption is specified, bus exceptions will be reported with amessage to standard error indicating the address at which theexception occurred.This was the default behaviour up to Or1ksim 0.4.0. This flag isprovided for those who wish to keep that behavior.`--strict-npc'In real hardware, setting the next program counter (NPC, SPR 16),flushes the processor pipeline. The consequence of this is thatuntil the pipeline refills, reading the NPC will return zero.This is typically the case when debugging, since the processor isstalled.Historically, Or1ksim has always returned the value of the NPC,irrespective of when it is changed. If the `--strict-npc' optionis used, then Or1ksim will mirror real hardware more accurately.If the NPC is changed while the processor is stalled, subsequentreads of its value will return 0 until the processor is unstalled.This is not currently the default behavior, since tools such asGDB have been implemented assuming the historic Or1ksim behavior.However at some time in the future it will become the default.`--enable-profile'Enable instruction profiling.`--enable-mprofile'Enable memory profiling.File: or1ksim.info, Node: Profiling Utility, Next: Memory Profiling Utility, Prev: Standalone Simulator, Up: Usage2.2 Profiling Utility=====================This utility analyses instruction profile data generated by Or1ksim.It may be invoked as a standalone command, or from the Or1ksim CLI.The general form the standalone command is:or32-elf-profile [-vhcq] [-g=FILE]Many of the options have both a short and a long form. For example`-h' or `--help'.`-v'`--version'Print out the version and copyright notice for the Or1ksimprofiling utility and exit.`-h'`--help'Print out help about the command line options and what they mean.`-c'`--cumulative'Show cumulative sum of cycles in functions`-q'`--quiet'Suppress messages`-g=FILE'`--generate=FILE'The data file to analyse. If omitted, the default file,`sim.profile' is used.File: or1ksim.info, Node: Memory Profiling Utility, Next: Trace Generation, Prev: Profiling Utility, Up: Usage2.3 Memory Profiling Utility============================This utility analyses memory profile data generated by Or1ksim. It maybe invoked as a standalone command, or from the Or1ksim CLI. Thegeneral form the standalone command is:or32-elf-mprofile [-vh] [-m=M] [-g=N] [-f=FILE] FROM TOMany of the options have both a short and a long form. For example`-h' or `--help'.`-v'`--version'Print out the version and copyright notice for the Or1ksim memoryprofiling utility and exit.`-h'`--help'Print out help about the command line options and what they mean.`-m=M'`--mode=M'Specify the mode out output. Permitted options are`detailed'`d'Detailed output. This is the default if no mode is specified.`pretty'`p'Pretty printed output.`access'`a'Memory accesses only.`width'`w'Access width only.`-g=N'`--group=N'Group 2^n bits of successive addresses together.`-f=FILE'`--filename=FILE'The data file to analyse. If not specified, the default,`sim.profile' is used.`FROM'`TO'FROM and TO are respectively the start and end address of theregion of memory to be analysed.File: or1ksim.info, Node: Trace Generation, Next: Simulator Library, Prev: Memory Profiling Utility, Up: Usage2.4 Trace Generation====================An execution trace can be generated at run time with options passed bythe command line, or via the operating system's signal passingmechanism, or by `l.nop' opcodes in an application program.The following flag can be used to create an execution dump.`-t'`--trace'Dump instruction just executed and any register/memory locationchanged after each instruction (one line per instruction). Eachline starts with either "S" or "U" to indicate whether theprocessor was in supervisor or user mode _when the instructioncompleted_. It is worth bearing in mind that tracing happens atcompletion of instruction execution and shows the state at thattime.Passing a signal `SIGUSR1' while the simulator is running toggles tracegeneration. This can be done with the following command, assumingOr1ksim's executable name is `or32-elf-sim':pkill -SIGUSR1 or32-elf-simThis is useful in the case where trace output is desired after asignificant amount of simulation time, where it would be inconvenient togenerate trace up to that point.If the `pkill' utility is not available, the `kill' utility can be usedif Or1ksim's process number is known. Use the following to determinethe process ID of the `or32-elf-sim' and then send the `SIGUSR1'command to toggle execution trace generation:ps a | grep or32-elf-simkill -SIGUSR1 _process-number_Tracing can also be enabled and disabled from within a target programusing the `l.nop 8' and `l.nop 9' opcodes to enable and disable tracingrespectively.By default tracing will show the virtual address of each instructiontraced. This may be controlled by two options, `--trace-physical' toshow the physical address and/or `--trace-virtual' to show the virtualaddress. If neither is specified, the virtual address is shown.Note: Either or both flags may be specified without `--trace', toindicate how addresses should be shown if subsequently enabled by a`SIGUSER1' signal or `l.nop 8' opcode.File: or1ksim.info, Node: Simulator Library, Next: Ethernet TUN/TAP Interface, Prev: Trace Generation, Up: Usage2.5 Simulator Library=====================Or1ksim may be used as a static of dynamic library, `libsim.a' or`libsim.so'. When compiling with the static library, the flag, `-lsim'should be added to the link command.The header file `or1ksim.h' contains appropriate declarations of thefunctions exported by the Or1ksim library. These are:-- `or1ksim.h': int or1ksim_init (int ARGC, char *ARGV, void*CLASS_PTR, int (*UPR)(void *CLASS_PTR, unsigned long intADDR, unsigned char MASK[], unsigned char RDATA[], intDATA_LEN), int (*UPW)(void *CLASS_PTR, unsigned long intADDR, unsigned char MASK[], unsigned char WDATA[], intDATA_LEN))The initialization function is supplied with a vector of arguments,which are interpreted as arguments to the standalone version (see*note Standalone Simulator: Standalone Simulator.), a pointer tothe calling class, CLASS_PTR (since the library may be used fromC++) and two up-call functions, one for reads, UPR, and one forwrites, UPW.UPW is called for any write to an address external to the model(determined by a `generic' section in the configuration file).UPR is called for any reads to an external address. The CLASS_PTRis passed back with these upcalls, allowing the function toassociate the call with the class which originally initialized thelibrary. Both UPW and UPR should return zero on success andnon-zero otherwise. At the present time the meaning of non-zerovalues is not defined but this may change in the future.MASK indicates which bytes in the data are to be written or read.Bytes to be read/written should have 0xff set in MASK. Otherwisethe byte should be zero. The adddress, ADDR, is the _full_address, since the upcall function must handle all genericdevices, using the full address for decoding.Endianness is not a concern, since Or1ksim is transferring bytevectors, not multi-byte values.The result indicates whether the initialization was successful.The integer values are available as an `enum or1ksim', withpossible values `OR1KSIM_RC_OK' and `OR1KSIM_RC_BADINIT'.Caution: This is a change from versions 0.3.0 and 0.4.0. Itfurther simplifies the interface, and makes Or1ksim moreconsistent with payload representation in SystemC TLM 2.0.Note: The current implementation of Or1ksim always transferssingle words (4 bytes), using masks if smaller values arerequired. In this it mimcs the behavior of the WishBone bus.-- `or1ksim.h': int or1ksim_run (double DURATION)Run the simulator for the simulated duration specified (inseconds). A duration of -1 indicates `run forever'The result indicates how the run terminated. The integer valuesare available as an `enum or1ksim', with possible values`OR1KSIM_RC_OK' (ran for the full duration), `OR1KSIM_RC_BRKPT'(terminated early due to hitting a breakpoint) and`OR1KSIM_RC_HALTED' (terminated early due to hitting `l.nop 1').-- `or1ksim.h': void or1ksim_reset_duration (double DURATION)Change the duration of a run specified in an earlier call to`or1ksim_run'. Typically this is called from an upcall, whichrealizes it needs to change the duration of the run specified inthe call to `or1ksim_run' that has been interrupted by the upcall.The time specified is the amount of time that the run must continuefor (i.e the duration from _now_, not the duration from theoriginal call to `or1ksim_run').-- `or1ksim.h': void or1ksim_set_time_point ()Set a timing point. For use with `or1ksim_get_time_period'.-- `or1ksim.h': double or1ksim_get_time_period ()Return the simulated time (in seconds) that has elapsed since thelast call to `or1ksim_set_time_point'.-- `or1ksim.h': int or1ksim_is_le ()Return 1 (logical true) if the Or1ksim simulation islittle-endian, 0 otherwise.-- `or1ksim.h': unsigned long int or1ksim_clock_rate ()Return the Or1ksim clock rate (in Hz). This is the valuespecified in the configuration file.-- `or1ksim.h': void or1ksim_interrupt (int I)Generate an edge-triggered interrupt on interrupt line I. Theinterrupt must be cleared separately by clearing the correspondingbit in the PICSR SPR. Until the interrupt is cleared, any furtherinterrupts on the same line will be ignored with a warning. Awarning will be generated and the interrupt request ignored iflevel sensitive interrupts have been configured with theprogrammable interrupt controller (*note Interrupt Configuration:Interrupt Configuration.).-- `or1ksim.h': void or1ksim_interrupt_set (int I)Assert a level-triggered interrupt on interrupt line I. Theinterrupt must be cleared separately by an explicit call to`or1ksim_interrupt_clear'. Until the interrupt is cleared, anyfurther setting of interrupts on the same line will be ignoredwith a warning. A warning will be generated, and the interruptrequest ignored if edge sensitive interrupts have been configuredwith the programmable interrupt controller (*note InterruptConfiguration: Interrupt Configuration.).-- `or1ksim.h': void or1ksim_interrupt_clear (int I)Clear a level-triggered interrupt on interrupt line I, which waspreviously asserted by a call to `or1ksim_interrupt_set'. Awarning will be generated, and the interrupt request ignored ifedge sensitive interrupts have been configured with theprogrammable interrupt controller (*note Interrupt Configuration:Interrupt Configuration.).-- `or1ksim.h': double or1ksim_jtag_reset ()Drive a reset sequence through the JTAG interface. Return the(model) time taken for this action. Remember that the JTAG hasits own clock, which can be an order of magnitude slower than themain clock, so even a reset (5 JTAG cycles) could take 50processor clock cycles to complete.-- `or1ksim.h': double or1ksim_jtag_shift_ir (unsigned char *JREG, intNUM_BITS)Shift the supplied register through the JTAG instruction register.Return the (model) time taken for this action. The register issupplied as a byte vector, with the least significant bits in theleast significant byte. If the total number of bits is not anexact number of bytes, then the odd bits are found in the leastsignificant end of the highest numbered byte.For example a 12-bit register would have bits 0-7 in byte 0 andbits 11-8 in the least significant 4 bits of byte 1.-- `or1ksim.h': double or1ksim_jtag_shift_dr (unsigned char *JREG, intNUM_BITS)Shift the supplied register through the JTAG data register.Return the (model) time taken for this action. The register issupplied as a byte vector, with the least significant bits in theleast significant byte. If the total number of bits is not anexact number of bytes, then the odd bits are found in the leastsignificant end of the highest numbered byte.For example a 12-bit register would have bits 0-7 in byte 0 andbits 11-8 in the least significant 4 bits of byte 1.-- `or1ksim.h': int or1ksim_read_mem (unsigned long int ADDR, unsignedchar *BUF, int LEN)Read LEN bytes from ADDR, placing the result in BUF. Return LENon success and 0 on failure.Note: This function was added in Or1ksim 0.5.0.-- `or1ksim.h': int or1ksim_write_mem (unsigned long int ADDR, constunsigned char *BUF, int LEN)Write LEN bytes to ADDR, taking the data from BUF. Return LEN onsuccess and 0 on failure.Note: This function was added in Or1ksim 0.5.0.-- `or1ksim.h': int or1ksim_read_spr (int SPRNUM, unsigned long int*SPRVAL_PTR)Read the SPR specified by SPRNUM, placing the result inSPRVAL_PTR. Return non-zero on success and 0 on failure.Note: This function was added in Or1ksim 0.5.0.-- `or1ksim.h': int or1ksim_write_spr (int SPRNUM, unsigned long intSPRVA)Write SPRVAL to the SPR specified by SPRNUM. Return non-zero onsuccess and 0 on failure.Note: This function was added in Or1ksim 0.5.0.-- `or1ksim.h': int or1ksim_read_reg (int REGNUM, unsigned long int*REGVAL_PTR)Read the general purpose register specified by REGNUM, placing theresult in REGVAL_PTR. Return non-zero on success and 0 on failure.Note: This function was added in Or1ksim 0.5.0.-- `or1ksim.h': int or1ksim_write_reg (int REGNUM, unsigned long intREGVA)Write REGVAL to the general purpose register specified by REGNUM.Return non-zero on success and 0 on failure.Note: This function was added in Or1ksim 0.5.0.-- `or1ksim.h': void or1ksim_set_stall_state (int STATE)Set the processor's state according to STATE (1 = stalled, 0 = notstalled).Note: This function was added in Or1ksim 0.5.0.The libraries will be installed in the `lib' sub-directory of the maininstallation directory (as specified with the `--prefix' option to the`configure' script).For example if the main installation directory is `/opt/or1ksim', thelibrary will be found in the `/opt/or1ksim/lib' directory. It isavailable as both a static library (`libsim.a') and a shared object(`libsim.so').To link against the library add the `-lsim' flag when linking and doone of the following:* Add the library directory to the `LD_LIBRARY_PATH' environmentvariable during execution. For example:export LD_LIBRARY_PATH=/opt/or1ksim/lib:$LD_LIBRARY_PATH* Add the library directory to the `LD_RUN_PATH' environmentvariable during linking. For example:export LD_RUN_PATH=/opt/or1ksim/lib:$LD_RUN_PATH* Use the linker `--rpath' option and specify the library directorywhen linking your program. For examplegcc ... -Wl,--rpath -Wl,/opt/or1ksim/lib ...* Add the library directory to `/etc/ld.so.conf'File: or1ksim.info, Node: Ethernet TUN/TAP Interface, Next: l.nop Support, Prev: Simulator Library, Up: Usage2.6 Ethernet TUN/TAP Interface==============================When an Ethernet peripheral is configured (*note EthernetConfiguration: Ethernet Configuration.), one option is to tunneltraffic through a TUN/TAP interface. The low level TAP interface isused to tunnel raw Ethernet datagrams.The TAP interface can then be connected to a physical Ethernet through abridge, allowing the Or1ksim model to connect to a physical network.This is particularly when Or1ksim is running the OpenRISC Linux kernelimage.This section explains how to set up a bridge for use by Or1ksim. It doesrequire superuser access to the host machine (or at least the relevantnetwork capabilities). A system administrator can modify theseguidelines so they are executed on reboot if appropriate.* Menu:* Setting Up a Persistent TAP device::* Establishing a Bridge::* Opening the Firewall::* Disabling Ethernet Filtering::* Networking from OpenRISC Linux and BusyBox::* Tearing Down a Bridge::File: or1ksim.info, Node: Setting Up a Persistent TAP device, Next: Establishing a Bridge, Up: Ethernet TUN/TAP Interface2.6.1 Setting Up a Persistent TAP device----------------------------------------TUN/TAP devices can be created dynamically, but this requires superuserprivileges (or at least `CAP_NET_ADMIN' capability). The solution isto create a persistent TAP device. This can be done using either`openvpn' or `tunctl'. In either case the package must be installed onthe host system. Using `openvpn', the following would set up a TAPinterface for a specified user and group.openvpn --mktun --dev tap_n_ --user _username_ --group _groupname_File: or1ksim.info, Node: Establishing a Bridge, Next: Opening the Firewall, Prev: Setting Up a Persistent TAP device, Up: Ethernet TUN/TAP Interface2.6.2 Establishing a Bridge---------------------------A bridge is a "virtual" local area network interfaces, subsuming two ormore existing network interfaces. In this case we will bridge thephysical Ethernet interface of the host with the TAP interface thatwill be used by Or1ksim.The Ethernet and TAP must lose their own individual IP addresses (bysetting them to 0.0.0.0) and are replaced by the IP address of thebridge interface. To do this we use the `bridge-utils' package, whichmust be installed on the host system. These commands are requiresuperuser privileges or `CAP_NET_ADMIN' capability. To create a newinterface `br_n_' the following commands are appropriate.brctl addbr br_n_brctl addif br_n_ eth_x_brctl addif br_n_ tap_y_ifconfig eth_x_ 0.0.0.0 promisc upifconfig tap_y_ 0.0.0.0 promisc updhclient br_n_The last command instructs the bridge to obtain its IP address, netmask,broadcast address, gateway and nameserver information using DHCP. In anetwork without DHCP it should be replaced by `ifconfig' to set astatic IP address, netmask and broadcast address.Note: This will leave a spare dhclient process running in thebackground, which should be killed for tidiness. There is atechnique to avoid this using `omshell', but that is beyond thescope of this guide.Note: It is not clear to the author why the existing interfacesneed to be brought up in promiscuous mode, but it seems to curevarious problems.File: or1ksim.info, Node: Opening the Firewall, Next: Disabling Ethernet Filtering, Prev: Establishing a Bridge, Up: Ethernet TUN/TAP Interface2.6.3 Opening the Firewall--------------------------Firewall rules should be added to ensure traffic flows freely throughthe TAP and bridge interfaces. As superuser the following commands areappropriate.iptables -A INPUT -i tap_y_ -j ACCEPTiptables -A INPUT -i br_n_ -j ACCEPTiptables -A FORWARD -i br_n_ -j ACCEPTFile: or1ksim.info, Node: Disabling Ethernet Filtering, Next: Networking from OpenRISC Linux and BusyBox, Prev: Opening the Firewall, Up: Ethernet TUN/TAP Interface2.6.4 Disabling Ethernet Filtering----------------------------------Some systems may have ethernet filtering enabled (`ebtables',`bridge-nf', `arptables') which will stop traffic flowing through thebridge.The easiest way to disable this is by writing zero to all `bridge-nf-*'entries in `/proc/sys/net/bridge'. As superuser the following commandswill achieve this.cd /proc/sys/net/bridgefor f in bridge-nf-*; do echo 0 > $f; doneFile: or1ksim.info, Node: Networking from OpenRISC Linux and BusyBox, Next: Tearing Down a Bridge, Prev: Disabling Ethernet Filtering, Up: Ethernet TUN/TAP Interface2.6.5 Networking from OpenRISC Linux and BusyBox------------------------------------------------The main use of this style of Ethernet interface to Or1ksim is whenrunning the OpenRISC Linux kernel with BusyBox. The following commandsin the BusyBox console window will configure the Ethernet interface(assumed to be `eth0') and bring it up with a DHCP assigned address.ifconfig eth0ifup eth0At this stage interface to IP addresses will work correctly.For DNS to work the BusyBox system needs to know where to find anameserver. Under BusyBox, `udhcp' does not configure`/etc/resolv.conf' automatically.The solution is to duplicate the nameserver entry from the`/etc/resolv.conf' file of the host on the BusyBox system. A typicalfile might be as follows:`nameserver 192.168.0.1'It is convenient to make this permanent within the Linux initramfs. Addthe file as `arch/openrisc/support/initramfs/etc/resolv.conf' withinthe Linux source tree and rebuild `vmlinux'. It will then be presentautomatically.One of the most useful functions that is possible is to mount the hostfile system through NFS. For example, from the BusyBox console:mount -t nfs -o nolock 192.168.0.60:/home /mntAnother useful technique is to telnet into the BusyBox system from thehost. This is particularly valuable when a console process locks up,since the `xterm' console will not recognize ctrl-C. Instead the rogueprocess can be killed from a telnet connection.File: or1ksim.info, Node: Tearing Down a Bridge, Prev: Networking from OpenRISC Linux and BusyBox, Up: Ethernet TUN/TAP Interface2.6.6 Tearing Down a Bridge---------------------------There is little reason why a bridge should ever need to be torn down,but if desired, the following commands will achieve the effect.ifconfig br_n_ downbrctl delbr br_n_dhclient eth_x_As before this will leave a spare `dhclient' process in the backgroundwhich should be killed.If desired the TAP interface can be deleted usingopenvpn --rmtun -dev tap_y_Caution: The TAP interface should not be in use when running thiscommand. For example any OpenRISC Linux/BusyBox sessions should beclosed first.File: or1ksim.info, Node: l.nop Support, Prev: Ethernet TUN/TAP Interface, Up: Usage2.7 l.nop Opcode Support========================The OpenRISC `l.nop' opcode can take a parameter. This has no effecton the semantics of the opcode, but can be used to trigger side effectbehavior in a simulator. Within Or1ksim, the following parameters aresupported.`l.nop 0'The equivalent to `l.nop' with no parameter. Has no side effects.`l.nop 1'Execution of Or1ksim is terminated. This is used to implement thelibrary `exit' functions.`l.nop 2'Report the value in `r3' on the console as a 32-bit hex value.`l.nop 3'In earlier versions of Or1ksim this treated `r3' as a pointer to a`printf' style format string, and regsiters `r4' through `r8' asparameters for that format string.This opcode is no longer supported, and has no effect if used.`l.nop 4'The value in `r3' is printed to standard output as an ASCIIcharacter. All library output routines are implemented using thisopcode.`l.nop 5'The statistics counters are reset.`l.nop 6'The number of clock ticks since start of execution (a 64-bitvalue) is returned in `r11' (low 32 bits) and `r12' (high 32 bits).`l.nop 7'The number of picoseconds per clock cycle is returned in `r11'.This is used with `l.nop 6' to implement timing functions.`l.nop 8'Instruction tracing is turned on.`l.nop 9'Instruction tracing is turned off.File: or1ksim.info, Node: Configuration, Next: Interactive Command Line, Prev: Usage, Up: Top3 Configuration***************Or1ksim is configured through a configuration file. This is specifiedthrough the `-f' parameter to the Or1ksim command, or passed as astring when initializing the Or1ksim library. If no file is specified,the default `sim.cfg' is used. The file is looked for first in thecurrent directory, then in the `$HOME/.or1ksim' directory of the user.* Menu:* Configuration File Format::* Simulator Configuration::* Core OpenRISC Configuration::* Peripheral Configuration::File: or1ksim.info, Node: Configuration File Format, Next: Simulator Configuration, Up: Configuration3.1 Configuration File Format=============================The configuration file is a plain text file. A reference example,`sim.cfg', is included in the top level directory of the distribution.* Menu:* Configuration File Preprocessing::* Configuration File Syntax::File: or1ksim.info, Node: Configuration File Preprocessing, Next: Configuration File Syntax, Up: Configuration File Format3.1.1 Configuration File Preprocessing--------------------------------------The configuration file may include C style comments (i.e. delimited by`/*' and `*/').File: or1ksim.info, Node: Configuration File Syntax, Prev: Configuration File Preprocessing, Up: Configuration File Format3.1.2 Configuration File Syntax-------------------------------The configuration file is divided into a series of sections, with thegeneral form:section SECTION_NAME<contents>...endSections may also have sub-sections within them (currently only theATA/ATAPI disc interface uses this).Within a section, or sub-section are a series of parameter assignments,one per line, withe the general formPARAMETER = VALUEDepending on the parameter, the value may be a named value (anenumeration), an integer (specified in any format acceptable in C) or astring in doubple quotes. For flag parameters, the value 1 is used tomean "true" or "on" and the value "0" to mean "false" or "off". Anexample from a memory section shows each of thesesection memorytype = randompattern = 0x00name = "FLASH"...endMany parameters are optional and take reasonable default values if notspecified. However there are some parameters (for example the `ce'parameter in `section memory') _must_ be specified.Subsections are introduced by a keyword, with a parameter value (no `='sign), and end with the same keyword prefixed by `end'. Thus theATA/ATAPI inteface (`section ata') has a `device' subsection, thus:section ata...device 0type = 1file = "FILENAME"...enddevice...endSome sections (for example `section sim') should appear only once.Others (for example `section memory' may appear multiple times.Sections may be omitted, _unless they contain parameters which arenon-optional_. If the section describes a part of the simulator whichis optional (for example whether it has a UART), then thatfunctionality will not be provided. If the section describes a part ofthe simulator which is not optional (for example the CPU), then all theparameters of that section will take their default values.All optional parts of the functionality are always described bysections including a `enabled' parameter, which can be set to 0 toensure that functionality is explicitly omitted.Even if a section is disabled, all its parameters will be read andstored. This is helpful if the section is subsequently enabled fromthe Or1ksim command line (*note Interactive Command Line: InteractiveCommand Line.).Tip: It generally clearer to have sections describing _all_components, with omitted functionality explicitly indicated bysetting the `enabled' parameter to 0The following sections describe the various configuration sections andthe parameters which may be set in each.File: or1ksim.info, Node: Simulator Configuration, Next: Core OpenRISC Configuration, Prev: Configuration File Format, Up: Configuration3.2 Simulator Configuration===========================* Menu:* Simulator Behavior::* Verification API Configuration::* CUC Configuration::File: or1ksim.info, Node: Simulator Behavior, Next: Verification API Configuration, Up: Simulator Configuration3.2.1 Simulator Behavior------------------------Simulator behavior is described in `section sim'. This section shouldappear only once. The following parameters may be specified.`verbose = 0|1'If 1 (true), print extra messages. Default 0.`debug = 0-9'0 means no debug messages. 1-9 means produce debug messages. Thehigher the value the greater the number of messages. Default 0.Negative values will be treated as 0 (with a warning). Valuesthat are too large will be treated as 9 (with a warning).`profile = 0|1'If 1 (true) generate a profiling file using the file specified inthe `prof_file' parameter or otherwise `sim.profile'. Default 0.`prof_file = ``FILENAME'''Specifies the file to be used with the `profile' parameter.Default `sim.profile'. For backwards compatibility, thealternative name `prof_fn' is supported for this parameter, butdeprecated. Default `sim.profile'.`mprofile = 0|1'If 1 (true) generate a memory profiling file using the filespecified in the `mprof_file' parameter or otherwise`sim.mprofile'. Default 0.`mprof_file = ``FILENAME'''Specifies the file to be used with the `mprofile' parameter.Default `sim.mprofile'. For backwards compatibility, thealternative name `mprof_fn' is supported for this parameter, butdeprecated. Default `sim.mprofile'.`history = 0|1'If 1 (true) track execution flow. Default 0.Note: Setting this parameter seriously degrades performance.Note: If this execution flow tracking is enabled, then`dependstats' must be enabled in the CPU configurationsection (*note CPU Configuration: CPU Configuration.).`exe_log = 0|1'If 1 (true), generate an execution log. Log is written to thefile specified in parameter `exe_log_file'. Default 0.Note: Setting this parameter seriously degrades performance.`exe_log_type = default|hardware|simple|software'Type of execution log to produce.`default'Produce default output for the execution log. In the currentimplementation this is the equivalent of `hardware'.`hardware'After each instruction execution, log the number ofinstructions executed so far, the next instruction to execute(in hex), the general purpose registers (GPRs), statusregister, exception program counter, exception, effectiveaddress register and exception status register.`simple'After each instruction execution, log the number ofinstructions executed so far and the next instruction toexecute, symbolically disassembled.`software'After each instruction execution, log the number ofinstructions executed so far and the next instruction toexecute, symbolically disassembled. Also show the value ofeach operand to the instruction.Default value `hardware'. Any unrecognized keyword (caseinsensitive) will be treated as the default with a warning.Note: Execution logs can be _very_ big.`exe_log_start = VALUE'Address of the first instruction to start logging. Default 0.`exe_log_end = VALUE'Address of the last instruction to log. Default no limit (i.eonce started logging will continue until the simulator exits).`exe_log_marker = VALUE'Specifies the number of instructions between printing horizontalmarkers. Default is to produce no markers.`exe_log_file = FILENAME'Filename for the execution log filename if `exe_log' is enabled.Default `executed.log'. For backwards compatibility, thealternative name `exe_log_fn' is supported for this parameter, butdeprecated.`exe_bin_insn_log = 0|1'Enable logging of executed instructions to a file in binary format.This is helpful for off-line dynamic execution analysis.Note: Execution logs can be _very_ big. For example, whilebooting the Linux kernel, version 2.6.34, a log file 1.2GB insize was generated.`exe_bin_insn_log_file = FILENAME'Filename for the binary execution log filename if`exe_bin_insn_log' is enabled. Default `exe-insn.bin'.`clkcycle = VALUE[ps|ns|us|ms]'Specify the time taken by one clock cycle. If no units arespecified, `ps' is assumed. Default 4000ps (250MHz).File: or1ksim.info, Node: Verification API Configuration, Next: CUC Configuration, Prev: Simulator Behavior, Up: Simulator Configuration3.2.2 Verification API (VAPI) Configuration-------------------------------------------The Verification API (VAPI) provides a TCP/IP interface to allowcomponents of the simulation to be controlled externally. *NoteVerification API: Verification API, for more details.Verification API configuration is described in `section vapi'. Thissection may appear at most once. The following parameters may bespecified.`enabled = 0|1'If 1 (true), verification API is enabled and its server started.If 0 (the default), it is disabled.`server_port = VALUE'When VAPI is enabled, communication will be via TCP/IP on the portspecified by VALUE. The value must lie in the range 1 to 65535.The default value is 50000.Tip: There is no registered port for Or1ksim VAPI. Goodpractice suggests users should adopt port values in the"Dynamic" or "Private" port range, i.e. 49152-65535.`log_enabled = 0|1'If 1 (true), all VAPI requests and sent commands will be logged.If 0 (the default), logging is diabled. Logs are written to thefile specified by the `vapi_log_file' field (see below).Caution: This can generate a substantial amount of file I/Oand seriously degrade simulator performance.`hide_device_id = 0|1'If 1 (true) don't log the device ID. If 0 (the default), log thedevice ID. This feature (when set to 1) is provided for backwardscompatibility with an old version of VAPI.`vapi_log_file = "FILENAME"'Use `filename' as the file for logged data is logging is enabled(see `log_enabled' above). The default is `"vapi.log"'. Forbackwards compatibility, the alternative name `vapi_log_fn' issupported for this parameter, but deprecated.File: or1ksim.info, Node: CUC Configuration, Prev: Verification API Configuration, Up: Simulator Configuration3.2.3 Custom Unit Compiler (CUC) Configuration----------------------------------------------The Custom Unit Compiler (CUC) was a project by Marko Mlinar to generateVerilog from ANSI C functions. The project seems to not have progressedbeyond the initial prototype phase. The configuration parameters aredescribed here for the record.CUC configuration is described in `section cuc'. This section mayappear at most once. The following parameters may be specified.`memory_order = none|weak|strong|exact'This parameter specifies the memory ordering required:`memory_order=none'Different memory ordering, even if there are dependencies.Bursts can be made, width can change.`memory_order=weak'Different memory ordering, even if there are dependencies. Ifdependencies cannot occur, then bursts can be made, width canchange.`memory_order=strong'Same memory ordering. Bursts can be made, width can change.`memory_order=exact'Exactly the same memory ordering and widths.The default value is `memory_order=exact'. Invalid memoryorderings are ignored with a warning.`calling_convention = 0|1'If 1 (true), programs follow OpenRISC calling conventions. If 0(the default), they may use other convenitions.`enable_bursts = 0 | 1'If 1 (true), bursts are detected. If 0 (the default), bursts arenot detected.`no_multicycle = 0 | 1'If 1 (true), no multicycle logic paths will be generated. If 0(the default), multicycle logic paths will be generated.`timings_file = "FILENAME"'FILENAME specifies a file containing timing information. Thedefault value is `"virtex.tim"'. For backwards compatibility, thealternative name `timings_fn' is supported for this parameter, butdeprecated.File: or1ksim.info, Node: Core OpenRISC Configuration, Next: Peripheral Configuration, Prev: Simulator Configuration, Up: Configuration3.3 Configuring the OpenRISC Architectural Components=====================================================* Menu:* CPU Configuration::* Memory Configuration::* Memory Management Configuration::* Cache Configuration::* Interrupt Configuration::* Power Management Configuration::* Branch Prediction Configuration::* Debug Interface Configuration::File: or1ksim.info, Node: CPU Configuration, Next: Memory Configuration, Up: Core OpenRISC Configuration3.3.1 CPU Configuration-----------------------CPU configuration is described in `section cpu'. This section shouldappear only once. At present Or1ksim does not model multi-CPU systems.The following parameters may be specified.`ver = VALUE'`cfg = VALUE'`rev = VALUE'The values are used to form the corresponding fields in the `VR'Special Purpose Register (SPR 0). Default values 0. A warning isgiven and the value truncated if it is too large (8 bits for `ver'and `cfg', 6 bits for `rev').`upr = VALUE'Used as the value of the Unit Present Register (UPR) SpecialPurpose Register (SPR 1) to VALUE. Default value is 0x0000075f,i.e.* UPR present (0x00000001)* Data cache present (0x00000002)* Instruction cache present (0x00000004)* Data MMY present (0x00000008)* Instruction MMU present (0x00000010)* Debug unit present (0x00000040)* Power management unit present (0x00000100)* Programmable interrupt controller present (0x00000200)* Tick timer present (0x00000400)However, with the exection of the UPR present (0x00000001) and ticktimer present, the various fields will be modified with the valuesspecified in their corresponding configuration sections.`cfgr = VALUE'Sets the CPU configuration register (Special Purpose Register 2) toVALUE. Default value is 0x00000020, i.e. support for the ORBIS32instruction set. Attempts to set any other value are accepted, butissue a warning that there is no support for the instruction set.`sr = VALUE'Sets the supervision register Special Purpose Register (SPR 0x11)to VALUE. Default value is 0x00008001, i.e. start in supervisionmode (0x00000001) and set the "Fixed One" bit (0x00008000).Note: This is particularly useful when an image is held inFlash at high memory (0xf0000000). The EPH bit can be set,so that interrupt vectors are basedf at 0xf0000000, ratherthan 0x0.`superscalar = 0|1'If 1, the processor operates in superscalar mode. Default value is0.In the current simulator, the only functional effect of superscalarmode is to affect the calculation of the number of cycles taken toexecute an instruction.Caution: The code for this does not appear to be complete orwell tested, so users are advised not to use this option.`hazards = 0|1'If 1, data hazards are tracked in a superscalar CPU. Defaultvalue is 0.In the current simulator, the only functional effect is to causelogging of hazard waiting information if the CPU is superscalar.However nowhere in the simulator is this data actually computed,so the net result is probably to have no effect.if harzards are tracked, current hazards can be displayed using thesimulator's `r' command.Caution: The code for this does not appear to be complete orwell tested, so users are advised not to use this option.`dependstats = 0|1'If 1, inter-instruction dependencies are calculated. Defaultvalue 0.If these values are calculated, the depencies can be displayedusing the simulator's `stat' command.Note: This field must be enabled, if execution execution flowtracking (field `history') has been requested in the simulatorconfiguration section (*note Simulator Behavior: SimulatorBehavior.).`sbuf_len = VALUE'The length of the store buffer is set to VALUE, which must be nogreater than 256. Larger values will be truncated to 256 with awarning. Negative values will be treated as 0 with a warning.Use 0 to disable the store buffer.When the store buffer is active, stores are accumulated andcommitted when I/O is idle.`hardfloat = 0|1'If 1, hardfloat instructions are enabled. Default value 0.File: or1ksim.info, Node: Memory Configuration, Next: Memory Management Configuration, Prev: CPU Configuration, Up: Core OpenRISC Configuration3.3.2 Memory Configuration--------------------------Memory configuration is described in `section memory'. This sectionmay appear multiple times, specifying multiple blocks of memory.Caution: The user may choose whether or not to enable a memorycontroller. If a memory controller is enabled, then appropriateinitalization code must be provided. The section describingmemory controller configuration describes the steps necessary forusing smaller or larger memory sections (*note Memory ControllerConfiguration: Memory Controller Configuration.).The "uClibc" startup code initalizes a memory controller, assumedto be mapped at 0x93000000. If a memory controller is _not_enabled, then the standard C library code will generate memoryaccess errors. The solution is to declare an additional writablememory block, mimicing the memory controller's register bank asfollows.section memorypattern = 0x00type = unknownname = "MC shadow"baseaddr = 0x93000000size = 0x00000080delayr = 2delayw = 4endThe following parameters may be specified.`type=random|pattern|unknown|zero|exitnops'Specifies the values to which memory should be initialized. Thedefault value is `unknown'.`random'Set the memory values to be a random value. A seed for therandom generator may be set using the `random_seed' field inthis section (see below), thus ensuring the same "random"values are used each time.`pattern'Set the memory values to be a pattern value, which is setusing the `pattern' field in this section (see below).`unknown'The memory values are not initialized (i.e. left "unknown").This option will yield faster initialization of thesimulator. This is the default.`zero'Set the memory values to be 0. This is the equivalent of`type=pattern' and a `pattern' value of 0, and implemented assuch.Note: As a consequence, if the `pattern' field is_subsequently_ specified in this section, the value inthat field will be used instead of zero to initializethe memory.`exitnops'Set the memory values to be an instruction used to signal endof simulation. This is useful for causing immediate end ofsimulation when PC corruption occurs.`random_seed = VALUE'Set the seed for the random number generator to VALUE. This onlyhas any effect for memory type `random'.The default value is -1, which means the seed will be set from acall to the `time' function, thus ensuring different random valuesare used on each run. The simulator prints out the seed used inthis case, allowing repeat runs to regenerate the same randomvalues used in any particular run.`pattern = VALUE'Set the pattern to be used when initializing memory to VALUE. Thedefault value is 0. This only has any effect for memory type`pattern'. The least significant 8 bits of this value is used toinitialize each byte. More than 8 bits can be specified, but willignored with a warning.Tip: The default value, is equivalent to setting the memory`type' to be `zero'. If that is what is intended, then using`type=zero' explicitly is better than using `type=pattern'and not specifying a value for `pattern'.`baseaddr = VALUE'Set the base address of the memory to VALUE. It should be alignedto a multiple of the memory size rounded up to the nearest 2^n.The default value is 0.`size = VALUE'Set the size of the memory block to be VALUE bytes. This shouldbe a multiple of 4 (i.e. word aligned). The default value is1024.Note: When allocating memory, the simulator will allocate thenearest 2^n bytes greater than or equal to VALUE, and will notnotice memory misses in any part of the memory between VALUEand the amount allocated.As a consequence users are strongly recommended to specifymemory sizes that are an exact power of 2. If some otheramount of memory is required, it should be specified asseparate, contiguous blocks, each of which is a power of 2 insize.`name = "TEXT"'Name the block. Typically these describe the type of memory beingmodeled (thus `"SRAM"' or `"Flash"'. The default is`"anonymous memory block"'.Note: It is not clear that this information is currently everused in normal operation of the simulator. Even the `info'command of the simulator ignores it.`ce = VALUE'Set the chip enable index of the memory instance. Each memoryinstance should have a unique chip enable index, which should begreater than or equal to zero. This is used by the memorycontroller when identifying different memory instances.There is no requirement to set `ce' if a memory controller is notenabled. The default value is -1 (invalid).`mc = VALUE'Specifies the memory controller this memory is connected to. Itshould correspond to the `index' field specified in a `section mc'for a memory controller (*note Memory Controller Configuration:Memory Controller Configuration.).There is no requirement to set `mc' if a memory controller is notenabled. Default value is 0, which is also the default value of amemory controller `index' field. This is suitable therefore fordesigns with just one memory controller.`delayr = VALUE'The number of cycles required for a read access. Set to -1 if thememory does not support reading. Default value 1. The simulatorwill add this number of cycles to the total instruction cyclecount when reading from main memory.`delayw = VALUE'The number of cycles required for a write access. Set to -1 if thememory does not support writing. Default value 1. The simulatorwill add this number of cycles to the total instruction cyclecount when writing to main memory.`log = "FILE"'If specified, `file' names a file for all memory accesses to belogged. If not specified, the default value, NULL is used, meaningthat the memory is not logged.File: or1ksim.info, Node: Memory Management Configuration, Next: Cache Configuration, Prev: Memory Configuration, Up: Core OpenRISC Configuration3.3.3 Memory Management Configuration-------------------------------------Memory Management Unit (MMU) configuration is described in `sectiondmmu' (for the data MMU) and `section immu' (for the instruction MMU).Each section should appear at most once. The following parameters maybe specified.`enabled = 0|1'If 1 (true), the data or instruction (as appropriate) MMU isenabled. If 0 (the default), it is disabled.`nsets = VALUE'Sets the number of data or instruction (as appropriate) TLB sets toVALUE, which must be a power of two, not exceeding 128. Valueswhich do not fit these criteria are ignored with a warning. Thedefault value is 1.`nways = VALUE'Sets the number of data or instruction (as appropriate) TLB ways toVALUE. The value must be in the range 1 to 4. Values outsidethis range are ignored with a warning. The default value is 1.`pagesize = VALUE'The data or instruction (as appropriate) MMU page size is set toVALUE, which must be a power of 2. Values which are not a powerof 2 are ignored with a warning. The default is 8192 (0x2000).`entrysize = VALUE'The data or instruction (as appropriate) MMU entry size is set toVALUE, which must be a power of 2. Values which are not a powerof 2 are ignored with a warning. The default value is 1.Note: Or1ksim does not appear to use the `entrysize' parameterin its simulation of the MMUs. Thus setting this value doesnot seem to matter.`ustates = VALUE'The number of instruction usage states for the data or instruction(as appropriate) MMU is set to VALUE, which must be 2, 3 or 4.Values outside this range are ignored with a warning. The defaultvalue is 2.Note: Or1ksim does not appear to use the `ustates' parameterin its simulation of the MMUs. Thus setting this value doesnot seem to matter.`hitdelay = VALUE'Set the number of cycles a data or instruction (as appropriate) MMUhit costs. Default value 1.`missdelay = VALUE'Set the number of cycles a data or instruction (as appropriate) MMUmiss costs. Default value 1.File: or1ksim.info, Node: Cache Configuration, Next: Interrupt Configuration, Prev: Memory Management Configuration, Up: Core OpenRISC Configuration3.3.4 Cache Configuration-------------------------Cache configuration is described in `section dc' (for the data cache)and `seciton ic' (for the instruction cache). Each section shouldappear at most once. The following parameters may be specified.`enabled = 0|1'If 1 (true), the data or instruction (as appropriate) cache isenabled. If 0 (the default), it is disabled.`nsets = VALUE'Sets the number of data or instruction (as appropriate) cache setsto VALUE, which must be a power of two, not exceeding`MAX_DC_SETS' (for the data cache) or `MAX_IC_SETS' (for theinstruction cache). At the time of writing, these constants areboth defined in the code to be 1024). The default value is 1.`nways = VALUE'Sets the number of data or instruction (as appropriate) cache waysto VALUE, which must be a power of two, not exceeding`MAX_DC_WAYS' (for the data cache) or `MAX_IC_WAYS' (for theinstruction cache). At the time of writing, these constants areboth defined in the code to be 32). The default value is 1.`blocksize = VALUE'The data or instruction (as appropriate) cache block size is set toVALUE bytes, which must be either 16 or 32. The default is 16.`ustates = VALUE'The number of instruction usage states for the data or instruction(as appropriate) cache is set to VALUE, which must be 2, 3 or 4.The default value is 2.`hitdelay = VALUE'_Instruction cache only_. Set the number of cycles an instructioncache hit costs. Default value 1.`missdelay = VALUE'_Instruction cache only_. Set the number of cycles an instructioncache miss costs. Default value 1.`load_hitdelay = VALUE'_Data cache only_. Set the number of cycles a data load cache hitcosts. Default value 2.`load_missdelay = VALUE'_Data cache only_. Set the number of cycles a data load cachemiss costs. Default value 2.`store_hitdelay = VALUE'_Data cache only_. Set the number of cycles a data store cache hitcosts. Default value 0.`store_missdelay = VALUE'_Data cache only_. Set the number of cycles a data store cachemiss costs. Default value 0.File: or1ksim.info, Node: Interrupt Configuration, Next: Power Management Configuration, Prev: Cache Configuration, Up: Core OpenRISC Configuration3.3.5 Interrupt Configuration-----------------------------Programmable Interrupt Controller (PIC) configuration is described in`section pic'. This section may appear at most once--Or1ksim has nomechanism for handling multiple interrupt controllers. The followingparameters may be specified.`enabled = 0|1'If 1 (true), the programmable interrupt controller is enabled. If0 (the default), it is disabled.`edge_trigger = 0|1'If 1 (true, the default), the programmable interrupt controller isedge triggered. If 0 (false), it is level triggered.The library interface (*note Simulator Library: Simulator Library.)provides different functions for setting the different types ofinterrupt, and a function to clear level sensitive interrupts. Edgesensitive interrupts must be cleared by clearing the correspondingbit in the PICSR SPR.Internal functions to set and clear interrupts are also providedfor peripherals implemented within Or1ksim. *Note InterruptsInternal: Interrupts Internal for more details.`use_nmi = 0|1'If 1 (true, the default), interrupt lines 0 and 1 arenon-maskable. In other words the least significant 2 bits of thePICMR SPR are hard-wired to 1. If 0 (false), all interrupt linesare treated as equivalent.Note: These are not non-maskable in the true sense that theywill pre-empt other interrupts. Rather they can never bemasked out using the PICMR register. It is up the interruptexception handler to give these interrupt lines priority, andindeed to decide on the priority order in general.File: or1ksim.info, Node: Power Management Configuration, Next: Branch Prediction Configuration, Prev: Interrupt Configuration, Up: Core OpenRISC Configuration3.3.6 Power Management Configuration------------------------------------Power management implementation is incomplete. At present the effect(which only happens when the power management unit is enabled) ofsetting the different bits in the power management Special PurposeRegister (PMR, SPR 0x4000) is`SDF (bit mask 0x0000000f)'No effect - these bits are ignored`DME (bit mask 0x00000010)'`SME (bit mask 0x00000020)'Both these bits cause the processor to stop executinginstructions. However all other functions (debug interaction, CLI,VAPI etc) carry on as normal.`DCGE (bit mask 0x00000004)'No effect - this bit is ignored`SUME (bit mask 0x00000008)'Enabling this bit causes a message to be printed, advising that theprocessor is suspending and the simulator exits.On reset all bits are cleared.Power management configuration is described in `section pm'. Thissection may appear at most once. The following parameter may bespecified.`enabled = 0|1'If 1 (true), power management is enabled. If 0 (the default), itis disabled.File: or1ksim.info, Node: Branch Prediction Configuration, Next: Debug Interface Configuration, Prev: Power Management Configuration, Up: Core OpenRISC Configuration3.3.7 Branch Prediction Configuration-------------------------------------From examining the code base, it seems the branch prediction functionis not fully implemented. At present the functionality seemsrestricted to collection of statistics.Branch prediction configuration is described in `section bpb'. Thissection may appear at most once. The following parameters may bespecified.`enabled = 0|1'If 1 (true), branch prediction is enabled. If 0 (the default), itis disabled.`btic = 0|1'If 1 (true), the branch target instruction cache model is enabled.If 0 (the default), it is disabled.`sbp_bf_fwd = 0|1'If 1 (true), use forward prediction for the `l.bf' instruction. If0 (the default), do not use forward prediction for thisinstruction.`sbp_bnf_fwd = 0|1'If 1 (true), use forward prediction for the `l.bnf' instruction.If 0 (the default), do not use forward prediction for thisinstruction.`hitdelay = VALUE'Set the number of cycles a branch prediction hit costs. Defaultvalue 0.`missdelay = VALUE'Set the number of cycles a branch prediction miss costs. Defaultvalue 0.File: or1ksim.info, Node: Debug Interface Configuration, Prev: Branch Prediction Configuration, Up: Core OpenRISC Configuration3.3.8 Debug Interface Configuration-----------------------------------The debug unit and debug interface configuration is described in`section debug'. This section may appear at most once. The followingparameters may be specified.`enabled = 0|1'If 1 (true), the debug unit is enabled. If 0 (the default), it isdisabled.Note: This enables the functionality of the debug unit (itsregisters etc) within the mode. It does not provide anyexternal interface to the debug unit. For that, see`rsp_enabled' below.`rsp_enabled = 0|1'If 1 (true), the GDB "Remote Serial Protocol" server is started,provding an interface to an external GNU debugger, using the portspecified in the `rsp_port' field (see below), or the`or1ksim-rsp' TCP/IP service. If 0 (the default), the server isnot started, and no external interface is provided.For more detailed information on the interface to the GNU Debuggersee Embecosm Application Note 2, `Howto: Porting the GNU DebuggerPractical Experience with the OpenRISC 1000 Architecture', byJeremy Bennett, published by Embecosm Limited (`www.embecosm.com').`rsp_port = VALUE'VALUE specifies the port to be used for the GDB "Remote SerialProtocol" interface to the GNU Debugger (GDB). Default value51000. If the value 0 is specified, Or1ksim will instead look fora TCP/IP service named `or1ksim-rsp'.Tip: There is no registered port for Or1ksim "Remote SerialProtocol" service `or1ksim-rsp'. Good practice suggestsusers should adopt port values in the "Dynamic" or "Private"port range, i.e. 49152-65535.`vapi_id = VALUE'VALUE specifies the value of the Verification API (VAPI) baseaddress to be used with the debug unit. *Note Verification API:Verification API, for more details.If this is specified and VALUE is non-zero, all OpenRISC RemoteJTAG protocol transactions will be logged to the VAPI log file, ifenabled. This is the only functionality associated with VAPI forthe debug unit. No VAPI commands are sent, nor requests handled.File: or1ksim.info, Node: Peripheral Configuration, Prev: Core OpenRISC Configuration, Up: Configuration3.4 Configuring Memory Mapped Peripherals=========================================All peripheral components are optional. If they are specified, then(unlike other components) by default they are enabled.* Menu:* Memory Controller Configuration::* UART Configuration::* DMA Configuration::* Ethernet Configuration::* GPIO Configuration::* Display Interface Configuration::* Frame Buffer Configuration::* Keyboard Configuration::* Disc Interface Configuration::* Generic Peripheral Configuration::File: or1ksim.info, Node: Memory Controller Configuration, Next: UART Configuration, Up: Peripheral Configuration3.4.1 Memory Controller Configuration-------------------------------------The memory controller used in Or1ksim is the component implemented atOpenCores, and found in the top level SVN directory, `mem_ctrl'. It isdescribed in the document `Memory Controller IP Core' by RudolfUsselmann, which can be found in the `doc' subdirectory. It is amemory mapped component, which resides on the main OpenRISC Wishbonedata bus.The memory controller configuration is described in `section mc'. Thissection may appear multiple times, specifying multiple memorycontrollers.Warning: There are known to be problems with the current memorycontroller, which currently is not included in the regression testsuite. Users are advised not to use the memory controller in thecurrent release.Caution: There is no initialization code in the standard "newlib"library.The standard "uClibc" library assumes a memory controller mappedat 0x93000000 and will initialize the memory controller to expect64MB memory blocks, and any memory declarations _must_ reflectthis.If smaller memory blocks are declared with a memory controller,then sufficient memory will not be allocated by Or1ksim, but out ofrange memory accesses will not be trapped. For example declaring amemory section from 0-4MB with a memory controller enabled wouldmean that accesses between 4MB and 64MB would be permitted, buthaving no allocated memory would likely cause a segmentation fault.If the user is determined to use smaller memories with the memorycontroller, then custom initialization code must be provided, toensure the memory controller traps out-of-memory accesses.The following parameters may be specified.`enabled = 0|1'If 1 (true, the default), this memory controller is enabled. If0, it is disabled.Note: The memory controller can effectively also be disabledby setting an appropriate power on control register value(see below). However this should only be used if it isdesired to specifically model this behavior of the memorycontroller, not as a way of disabling the memory controllerin general.`baseaddr = VALUE'Set the base address of the memory controller's memory mappedregisters to VALUE. The default is 0, which is probably not asensible value.The memory controller has a 7 bit address bus, with a total of 1932-bit registers, at addresses 0x00 through 0x4c (address 0x0c andaddresses 0x50 through 0x7c are not used).`poc = VALUE'Specifies the value of the power on control register, The leastsignficant two bits specify the bus width (use 0 for an 8-bit bus,1 for a 16-bit bus and 2 for a 32-bit bus) and the next two bitsthe type of memory connected (use 0 for a disabled interface, 1for SSRAM, 2 for asyncrhonous devices and 3 for synchronousdevices).If other bits are specified, they are ignored with a warning.Caution: The default value, 0, corresponds to a disabled8-bit bus, and is likely not the most suitable value`index = VALUE'Specify the index of this memory controller amongst all the memorycontrollers. This value should be unique for each memorycontroller, and is used to associate specific memories with thecontroller, through the `mc' field in the `section memory'configuration (*note Memory Configuration: Memory Configuration.).The default value, 0, is suitable when there is only one memorycontroller.File: or1ksim.info, Node: UART Configuration, Next: DMA Configuration, Prev: Memory Controller Configuration, Up: Peripheral Configuration3.4.2 UART Configuration------------------------The UART implemented in Or1ksim follows the specification of theNational Semiconductor 16450 and 16550 parts. It is a memory mappedcomponent, which resides on the main OpenRISC Wishbone data bus.The component provides a number of interfaces to emulate the behaviorof an external terminal connected to the UART.UART configuration is described in `section uart'. This section mayappear multiple times, specifying multiple UARTs. The followingparameters may be specified.`enabled = 0|1'If 1 (true, the default), this UART is enabled. If 0, it isdisabled.`baseaddr = VALUE'Set the base address of the UART's memory mapped registers toVALUE. The default is 0, which is probably not a sensible value.The UART has a 3 bit address bus, with a total of 8 8-bitregisters, at addresses 0x0 through 0x7.`channel = "TYPE:ARGS"'Specify the channel representing the terminal connected to the UARTRx & Tx pins.`channel="file:`rxfile',`txfile'"'Read input characters from the file `rxfile' and write outputcharacters to the file `txfile' (which will be created ifrequired).`channel="xterm:ARGS"'Create an xterm on startup, write UART Tx traffic to thexterm and take Rx traffic from the keyboard when the xtermwindow is selected. Additional arguments to the xtermcommand (for example specifying window size may be specifiedin ARGS, or this may be left blank.`channel="tcp:VALUE"'Open the TCP/IP port specified by VALUE and read and writeUART traffic from and to it.Typically a telnet session is connected to the other end ofthis port.Tip: There is no registered port for Or1ksim telnet UARTconnection. Priviledged access is required to readtraffic on the registered "well-known" telnet port (23).Instead users should use port values in the "Dynamic" or"Private" port range, i.e. 49152-65535.`channel="fd:`rxfd',`txfd'"'Read and write characters from and to the existing opennumerical file descriptors, file `rxfd' and `txfd'.`channel="tty:device=/dev/ttyS0,baud=9600"'Read and write characters from and to a physical serial port.The precise device (shown here as `/dev/ttyS0') may vary frommachine to machine.The default value for this field is `"xterm:"'.`irq = VALUE'Use VALUE as the IRQ number of this UART. Default value 0.`16550 = 0|1'If 1 (true), the UART has the functionality of a 16550. If 0 (thedefault), it has the functionality of a 16450. The principaldifference is that the 16550 can buffer multiple characters.`jitter = VALUE'Set the jitter, modeled as a time to block, to VALUE milliseconds.Set to -1 to disable jitter modeling. Default value 0.Note: This functionality has yet to be implemented, so thisparameter has no effect.`vapi_id = VALUE'VALUE specifies the value of the Verification API (VAPI) baseaddress to be used with the UART. *Note Verification API:Verification API, for more details, which details the use of theVAPI with the UART.File: or1ksim.info, Node: DMA Configuration, Next: Ethernet Configuration, Prev: UART Configuration, Up: Peripheral Configuration3.4.3 DMA Configuration-----------------------The DMA controller used in Or1ksim is the component implemented atOpenCores, and found in the top level SVN directory, `wb_dma'. It isdescribed in the document `Wishbone DMA/Bridge IP Core' by RudolfUsselmann, which can be found in the `doc' subdirectory. It is amemory mapped component, which resides on the main OpenRISC Wishbonedata bus. The present implementation is incomplete, intended only tosupport the Ethernet interface (*note Ethernet Configuration::),although the Ethernet interface is not yet completed.DMA configuration is described in `section dma'. This section mayappear multiple times, specifying multiple DMA controllers. Thefollowing parameters may be specified.`enabled = 0|1'If 1 (true, the default), this DMA controller is enabled. If 0,it is disabled.`baseaddr = VALUE'Set the base address of the DMA's memory mapped registers toVALUE. The default is 0, which is probably not a sensible value.The DMA controller has a 10 bit address bus, with a total of 25332-bit registers. The first 5 registers at addresses 0x000 through0x010 control the overall behavior of the DMA controller. Thereare then 31 blocks of 8 registers, controlling each of the 31 DMAchannels available. Addresses 0x014 through 0x01c are not used.`irq = VALUE'Use VALUE as the IRQ number of this DMA controller. Default value0.`vapi_id = VALUE'VALUE specifies the value of the Verification API (VAPI) baseaddress to be used with the DMA controller. *Note VerificationAPI: Verification API, for more details, which details the use ofthe VAPI with the DMA controller.File: or1ksim.info, Node: Ethernet Configuration, Next: GPIO Configuration, Prev: DMA Configuration, Up: Peripheral Configuration3.4.4 Ethernet Configuration----------------------------Ethernet configuration is described in `section ethernet'. Thissection may appear multiple times, specifying multiple Ethernetinterfaces. The following parameters may be specified.The Ethernet MAC used in Or1ksim corresponds to the Verilogimplementation in project "ethmac". It's source code can be found inthe top level SVN directory, `ethmac'. It also forms part of theOpenRISC reference SoC, ORPSoC. It is described in the document`Ethernet IP Core Specification' by Igor Mohor, which can be found inthe `doc' subdirectory. It is a memory mapped component, which resideson the main OpenRISC Wishbone data bus.`enabled = 0|1'If 1 (true, the default), this Ethernet MAC is enabled. If 0, itis disabled.`baseaddr = VALUE'Set the base address of the MAC's memory mapped registers toVALUE. The default is 0, which is probably not a sensible value.The Ethernet MAC has a 7-bit address bus, with a total of 2132-bit registers. Addresses 0x54 through 0x7c are not used.Note: The Ethernet specification describes a Tx controlregister, `TXCTRL', at address 0x50. However this registeris not implemented in the Or1ksim model.`dma = VALUE'VALUE specifies the DMA controller with which this Ethernet isassociated. The default value is 0.Note: Support for external DMA is not provided in the currentimplementation, and this value is ignored. In any case thereis no equivalent field to which this can be matched in thecurrent DMA component implementation (*note DMAConfiguration: DMA Configuration.).`irq = VALUE'Use VALUE as the IRQ number of this Ethernet MAC. Default value 0.`rtx_type = "file"|"tap"'Specifies whether to use a TUN/TAP interface or file interface(the default) to model the external connection of the Ethernet.If a TUN/TAP interface is requested, Ethernet packets will be sentand received through the pesistent TAP interface specified inparameter `tap_dev' (see below).More details on configuring the TUN/TAP interface are given in theUsage section (*note Ethernet TUN/TAP Interface: Ethernet TUN/TAPInterface.).If a file interface (the default), is requested, the Ethernet willbe modelled by reading and writing from and to the files specifiedin the `rxfile' and `txfile' parameters (see below).Caution: If a file interface is specified, Or1ksim willterminate once the receive file specified by `rxfile' isexhausted.`rx_channel = RXVALUE'`tx_channel = TXVALUE'RXVALUE specifies the DMA channel to use for receive and TXVALUEthe DMA channel to use for transmit. Both default to 0.Note: As noted above, support for external DMA is notprovided in the current implementation, and so these valuesare ignored.`rxfile = "RXFILE"'`txfile = "TXFILE"'When `rtx_type' is 0 (see above), RXFILE specifies the file to useas input and TXFILE specifies the fie to use as output.The file contains a sequence of packets. Each packet consists of apacket length (32 bits), followed by that many bytes of data.Once the input file is empty, the Ethernet MAC behaves as thoughthere were no data on the Ethernet. The default values of theseparameters are `"eth_rx"' and `"eth_tx"' respectively.The input file must exist and be readable. The output file must bewritable and will be created if necessary. If either of theseconditions is not met, a warning will be given.Caution: Or1ksim will terminate once the RXFILE is exhausted.`tap_dev = "TAP"'When `rtx_type' is `"tap"' (see above), TAP_DEV specifies the TAPdevice to use for communication. This should be a persistent TAPdevice configured for the system (*note Ethernet TUN/TAPInterface: Ethernet TUN/TAP Interface.)`phy_addr = VALUE'VALUE specifies the address for emulated ethernet PHY (default 0).If there are multiple Ethernet peripherals, they should each have adifferent PHY value.`dummy_crc = 0|1'If 1 (true, the default), the length of the data transferred tothe core will be increased by 4 bytes, as though the CRC wereincluded.Note: This is for historical consistency with the OpenRISCEthernet hardware MAC, which passes on the CRC in the datapacket. This is unusual behavior for a MAC, but the OpenRISCLinux device drivers have been written to expect it.`phy_addr = VALUE'VALUE specifies the address for emulated ethernet PHY (default 0).If there are multiple Ethernet peripherals, they should each have adifferent PHY value.`vapi_id = VALUE'VALUE specifies the value of the Verification API (VAPI) baseaddress to be used with the Ethernet PHY. *Note Verification API:Verification API, for more details, which details the use of theVAPI with the DMA controller.File: or1ksim.info, Node: GPIO Configuration, Next: Display Interface Configuration, Prev: Ethernet Configuration, Up: Peripheral Configuration3.4.5 GPIO Configuration------------------------The GPIO used in Or1ksim is the component implemented at OpenCores, andfound in the top level SVN directory, `gpio'. It is described in thedocument `GPIO IP Core Specification' by Damjan Lampret and GoranDjakovic, which can be found in the `doc' subdirectory. It is a memorymapped component, which resides on the main OpenRISC Wishbone data bus.GPIO configuration is described in `section gpio'. This section mayappear multiple times, specifying multiple GPIO devices. The followingparameters may be specified.`enabled = 0|1'If 1 (true, the default), this GPIO is enabled. If 0, it isdisabled.`baseaddr = VALUE'Set the base address of the GPIO's memory mapped registers toVALUE. The default is 0, which is probably not a sensible value.The GPIO has a 6 bit address bus, with a total of 10 32-bitregisters, although the number of bits that are actively usedvaries. Addresses 0x28 through 0x3c are not used.`irq = VALUE'Use VALUE as the IRQ number of this GPIO. Default value 0.`vapi_id = VALUE'VALUE specifies the value of the Verification API (VAPI) baseaddress to be used with the GPIO. *Note Verification API:Verification API, for more details, which details the use of theVAPI with the GPIO controller. For backwards compatibility, thealternative name `base_vapi_id' is supported for this parameter,but deprecated.File: or1ksim.info, Node: Display Interface Configuration, Next: Frame Buffer Configuration, Prev: GPIO Configuration, Up: Peripheral Configuration3.4.6 Display Interface Configuration-------------------------------------Or1ksim models a VGA interface to an external monitor. The VGAcontroller used in Or1ksim is the component implemented at OpenCores,and found in the top level SVN directory, `vga_lcd', with no supportfor the optional hardware cursors. It is described in the document`VGA/LCD Core v2.0 Specifications' by Richard Herveille, which can befound in the `doc' subdirectory. It is a memory mapped component,which resides on the main OpenRISC Wishbone data bus.The current implementation provides only functionality to dump thescreen to a file at intervals.VGA controller configuration is described in `section vga'. Thissection may appear multiple times, specifying multiple VGA controllers.The following parameters may be specified.`enabled = 0|1'If 1 (true, the default), this VGA is enabled. If 0, it isdisabled.`baseaddr = VALUE'Set the base address of the VGA controller's memory mappedregisters to VALUE. The default is 0, which is probably not asensible value.The VGA controller has a 12-bit address bus, with 7 32-bitregisters, at addresses 0x000 through 0x018, and two color lookuptables at addresses 0x800 through 0xfff. The hardware cursorregisters are not implemented, so addresses 0x01c through 0x7fcare not used.`irq = VALUE'Use VALUE as the IRQ number of this VGA controller. Default value0.`refresh_rate = VALUE'VALUE specifies number of cycles between screen dumps. Defaultvalue is derived from the simulation clock cycle time (*noteSimulator Behavior: Simulator Behavior.), to correspond to dumping50 times per simulated second.`txfile = "FILE"'FILE specifies the base of the filename for screen dumps.Successive screen dumps will be in BMP format, in files with thename `FILENNNN.bmp', where NNNN is a sequential count of thescreen dumps starting at zero. The default value is `"vga_out"'.For backwards compatibility, the alternative name `filename' issupported for this parameter, but deprecated.File: or1ksim.info, Node: Frame Buffer Configuration, Next: Keyboard Configuration, Prev: Display Interface Configuration, Up: Peripheral Configuration3.4.7 Frame Buffer Configuration--------------------------------Caution: The frame buffer is only partially implemented. Itsconfiguration fields are described here, but the component shouldnot be used at this time. Like the VGA controller, it is designedto make screen dumps to file.Frame buffer configuration is described in `section fb'. This sectionmay appear multiple times, specifying multiple frame buffers. Thefollowing parameters may be specified.`enabled = 0|1'If 1 (true, the default), this frame buffer is enabled. If 0, itis disabled.`baseaddr = VALUE'Set the base address of the frame buffer's memory mapped registersto VALUE. The default is 0, which is probably not a sensiblevalue.The frame buffer has an 121-bit address bus, with 4 32-bitregisters, at addresses 0x000 through 0x00c, and a PAL lookuptable at addresses 0x400 through 0x4ff. Addresses 0x010 through0x3fc and addresses 0x500 through 0x7ff are not used.`refresh_rate = VALUE'VALUE specifies number of cycles between screen dumps. Defaultvalue is derived from the simulation clock cycle time (*noteSimulator Behavior: Simulator Behavior.), to correspond to dumping50 times per simulated second.`txfile = "FILE"'FILE specifies the base of the filename for screen dumps.Successive screen dumps will be in BMP format, in files with thename `FILENNNN.bmp', where NNNN is a sequential count of thescreen dumps starting at zero. The default value is `"fb_out"'.For backwards compatibility, the alternative name `filename' issupported for this parameter, but deprecated.File: or1ksim.info, Node: Keyboard Configuration, Next: Disc Interface Configuration, Prev: Frame Buffer Configuration, Up: Peripheral Configuration3.4.8 Keyboard Configuration (PS2)----------------------------------The PS2 interface provided by Or1ksim is not documented. It may bebased on the PS2 project at OpenCores, and found in the top level SVNdirectory, `ps2'. However this project lacks any documentation beyondits project webpage. Since most PS2 interfaces follow the Intel i8042standard, this is presumably what is expected with this device.The implementation only provides for keyboard support, which ismodelled as a file of keystrokes. There is no mouse support.Caution: A standard i8042 device has two registers at addresses0x60 (command) and 0x64 (status). Inspection of the code,suggests that the Or1ksim component places these registers ataddresses 0x00 and 0x04.The port of Linux for the OpenRISC 1000, which runs on Or1ksimimplements the i8042 device driver, anticipating these registersreside at their conventional address. It seems unlikel that thiscode will work.This component should be used with caution.Keyboard configuration is described in `section kbd'. This section mayappear multiple times, specifying multiple keyboard interfaces. Thefollowing parameters may be specified.`enabled = 0|1'If 1 (true, the default), this keyboard is enabled. If 0, it isdisabled.`baseaddr = VALUE'Set the base address of the keyboard's memory mapped registers toVALUE. The default is 0, which is probably not a sensible value.The keyboard PS/2 interface has an 3-bit address bus, with 2 8-bitregisters, at addresses 0x000 and 0x004.Caution: As noted above, a standard Intel 8042 interfacewould expect to find these registers at locations 0x60 and0x64, thus requiring at least a 7-bit bus.`irq = VALUE'Use VALUE as the IRQ number of this Keyboard interface. Defaultvalue 0.`rxfile = "FILE"'`file' specifies a file containing raw key stroke data, whichmodels the input from a physical keyboard. The default value is`"kbd_in"'.File: or1ksim.info, Node: Disc Interface Configuration, Next: Generic Peripheral Configuration, Prev: Keyboard Configuration, Up: Peripheral Configuration3.4.9 Disc Interface Configuration----------------------------------The ATA/ATAPI disc controller used in Or1ksim is the OCIDEC (OpenCoresIDE Controller) component implemented at OpenCores, and found in thetop level SVN directory, `ata'. It is described in the document`ATA/ATAPI-5 Core Specification' by Richard Herveille, which can befound in the `doc' subdirectory. It is a memory mapped component,which resides on the main OpenRISC Wishbone data bus.Warning: In the current release of Or1ksim, parsing of the ATAsection is broken. Users should not configure the disc interfacein this release.ATA/ATAPI configuration is described in `section ata'. This sectionmay appear multiple times, specifying multiple disc controllers. Thefollowing parameters may be specified.`enabled = 0|1'If 1 (true, the default), this ATA/ATAPI interface is enabled. If0, it is disabled.`baseaddr = VALUE'Set the base address of the ATA/ATAPI interface's memory mappedregisters to VALUE. The default is 0, which is probably not asensible value.The ATA/ATAPI PS/2 interface has an 5-bit address bus, with 832-bit registers. Depending on the version of the OCIDECATA/ATAPI interface selected (see `dev_id' below), not allregisters will be available.`irq = VALUE'Use VALUE as the IRQ number of this ATA/ATAPI interface. Defaultvalue 0.`dev_id = 1|2|3'This parameter specifies which version of the OCIDEC ATA/ATAPIinterface to model. The default value is 1.Version 1 supports only the `CTRL', `STAT' and `PCTR' registers.Versions 2 & 3 add the `FCTR' registers, Version 3 adds the `DTR'registers and the `RXD'/`TXD' registers.`rev = VALUE'Set the VALUE as the revision of the OCIDEC ATA/ATAPI interface.The default value is 1. The default value is 0. Its value shouldbe in the range 0-15. Larger values are truncated with a warning.This only affects the reset value of the `STAT' register, where itforms bits 24-27.`pio_mode0_t1 = VALUE'`pio_mode0_t2 = VALUE'`pio_mode0_t4 = VALUE'`pio_mode0_teoc = VALUE'These parameters specify the timings for use with ProgrammedInput/Output (PIO) transfers. They are specified as the number ofclock cycles - 2, rounded up to the next highest integer, or zeroif that would be negative. The values should not exceed 255. Ifthey do, they will be ignored with a warning.See the ATA/ATAPI-5 specification for explanations of each of thesetiming parameters. The default values are:pio_mode0_t1 = 6pio_mode0_t2 = 28pio_mode0_t4 = 2pio_mode0_teoc = 23`dma_mode0_tm = VALUE'`dma_mode0_td = VALUE'`dma_mode0_teoc = VALUE'These parameters specify the timings for use with DMA transfers.They are specified as the number of clock cycles - 2, rounded upto the next highest integer, or zero if that would be negative.The values should not exceed 255. If they do, they will beignored with a warning.See the ATA/ATAPI-5 specification for explanations of each of thesetiming parameters. The default values are:dma_mode0_tm = 4dma_mode0_td = 21dma_mode0_teoc = 213.4.9.1 ATA/ATAPI Device Configuration......................................Within the `section ata', each device is specified separately. Thedevice subsection is introduced bydevice VALUEVALUE is the device number, which should be 0 or 1. The subsectionends with `enddevice'. Note that if the same device number isspecified more than once, the previous values will be overwritten.Within the `device' subsection, the following parameters may appear:`type = VALUE'VALUEspecifies the type of device: 0 (the default) for "notconnected", 1 for hard disk simulated in a file and 2 for localsystem hard disk.`file = "FILENAME"'`filename' specifies the file to be used for a simulated ATAdevice if the file type (see `type' above) is 1. Default value`"ata_fileN"', where N is the device number.`size = VALUE'VALUE specifies the size of a simulated ATA device if the filetype (see `type' above) is 1. The default value is zero.`packet = 0|1'If 1 (true), implement the PACKET command feature set. If 0 (thedefault), do not implement the PACKET command feature set.`firmware = "STR"'Firmware to report in response to the "Identify Device" command.Default `"02207031"'.`heads = VALUE'Number of heads in the device. Default 7, use -1 to disable allheads.`sectors = VALUE'Number of sectors per track in the device. Default 32.`mwdma = 0|1|2|-1'Highest multi-word DMA mode supported. Default 2, use -1 todisable.`pio = 0|1|2|3|4'Highest PIO mode supported. Default 4.File: or1ksim.info, Node: Generic Peripheral Configuration, Prev: Disc Interface Configuration, Up: Peripheral Configuration3.4.10 Generic Peripheral Configuration---------------------------------------When used as a library (*note Simulator Library: Simulator Library.),Or1ksim makes provision for any additional peripheral to be implementedexternally. Any read or write access to this peripheral's memory mapgenerates "upcall"s to an external handler. This interface can supporteither C or C++, and was particularly designed to facilitate supportfor OSCI SystemC (see `http://www.systemc.org').Generic peripheral configuration is described in `section generic'.This section may appear multiple times, specifying multiple externalperipherals. The following parameters may be specified.`enabled = 0|1'If 1 (true, the default), this ATA/ATAPI interface is enabled. If0, it is disabled.`baseaddr = VALUE'Set the base address of the generic peripheral's memory mappedregisters to VALUE. The default is 0, which is probably not asensible value.The size of the memory mapped register space is controlled by the`size' paramter, described below.`size = VALUE'Set the size of the generic peripheral's memory mapped registerspace to VALUE bytes. Any read or write accesses to addresses withoffsets of 0 to VALUE-1 bytes from the base address specified inparameter `baseaddr' (see above) will be directed to the externalinterface.VALUE will be rounded up the nearest power of 2. It's defaultvalue is zero. If VALUE is not an exact power of two, accesses toaddress offsets of VALUE or above up to the next power of 2 willgenerate a warning, and have no effect (reads will return zero).`name = "STR"'This gives the peripheral the name `"STR"'. This is used toidentify the peripheral in error messages and warnings, and whenreporting its status. The default value is`"anonymous external peripheral"'.`byte_enabled = 0|1'`hw_enabled = 0|1'`word_enabled = 0|1'If 1 (true, the default), these parameters respectively enable thedevice for byte wide, half-word wide and word wide accesses. If 0,accesses of that width will fail.File: or1ksim.info, Node: Interactive Command Line, Next: Verification API, Prev: Configuration, Up: Top4 Interactive Command Line**************************If started with the `-f' flag, or if interrupted with `ctrl-C', Or1ksimprovides the user with an interactive command line. The commandsavailable, which may not be abbreviated, are:`q'Exit the simulator`r'Display all the General Purpose Registers (GPRs). Also shows thejust executed and next to be executed instructions symbolicallyand the state of the flag in the Supervision Register.`t'Execute the next instruction and then display register/instructioninformation as with the `r' command (see above).`run NUM [ hush ]'Execute NUM instructions. The register/instruction information isdisplayed after each instruction, as with the `r' command (seeabove) _unless_ `hush' is specified.`pr REG VALUE'Patch register REG with VALUE.`dm FROMADDR [ TOADDR ]'Display memory bytes between FROMADDR and TOADDR. If TOADDR isnot given, 64 bytes are displayed, starting at FROMADDR.Caution: The output from this command is broken (a bug).Or1ksim attempts to print out 16 bytes per row. However,instead of printing out the address at the start of each row,it prints the address (of the first of the 16 bytes) before_each_ byte.`de FROMADDR [ TOADDR ]'Disassemble code between FROMADDR and TOADDR. If TOADDR is notgiven, 16 instructions are disassembled.The disassembly is entirely numerical, and gives no symbolicinformation.`pm ADDR VALUE'Patch the 4 bytes in memory starting at ADDR with the 32-bit VALUE.`pc VALUE'Patch the program counter with VALUE.`cm FROMADDR TOADDR SIZE'Copy SIZE bytes in memory from FROMADDR to TOADDR.`break ADDR'Toggle the breakpoint set at ADDR.`breaks'List all set breakpoints`reset'Reset the simulator. Includes modeling a reset of the processor,so execution will restart from the reset vector location, 0x100.`hist'If saving the execution history has been configured (*noteSimulator Behavior: Simulator Behavior.), display the executionhistory.`stall'Stall the processor, so that control is passed to the debug unit.When stalled, the processor can execute no instructions. Thiscommand is useful when debugging the JTAG interface, used bydebuggers such as GDB.`unstall'Unstall the processor, so that normal execution can continue.This command is useful when debugging the JTAG interface, used bydebuggers such as GDB.`stats CATEGORY | clear'Print the statistics for the given CATEGORY, if available, orclear if `clear' is specified. The categories are:1Miscellaneous statistics: branch predictions (if branchpredictions are enabled), branch target cache model (ifenabled), cache (if enbaled), MMU (if enabled) and number ofaddtional load & store cycles.*Note Configuring the OpenRisc Achitectural Components: CoreOpenRISC Configuration, for details of how to enable thesevarious features.2Instruction usage statistics. Requires hazard analysis to beenabled (*note CPU Configuration: CPU Configuration.).3Instruction dependency statistics. Requires hazard analysisto be enabled (*note CPU Configuration: CPU Configuration.).4Functional unit dependency statistics. Requires hazardanalysis to be enabled (*note CPU Configuration: CPUConfiguration.).5Raw register usage over time. Requires hazard analysis to beenabled (*note CPU Configuration: CPU Configuration.).6Store buffer statistics. Requires the store buffer to beenabled (*note CPU Configuration: CPU Configuration.).`info'Display detailed information about the simulator configuration.This is quite a lengthy about, because all MMU TLB information isdisplayed.`dv FROMADDR [ TOADDR ] [ MODULE ]'Dump the area of memory between FROMADDR and TOADDR as Verilogcode for a synchronous, 23-bit wide SRAM module, named MODULE. IfTOADDR is not specified, then 64 bytes are dumped (as 16 32-bitwords). If MODULE is not specified, `or1k_mem' is used.To save to a file, use the redirection function (described afterthis table, below).`dh FROMADDR [ TOADDR ]'Dump the area of memory between FROMADDR and TOADDR as 32-bit hexnumbers (no `0x', or `32'h' prefix). If TOADDR is not specified,then 64 bytes are dumped (as 16 32-bit words).To save to a file, use the redirection function (described afterthis table, below).`setdbch'Toggle debug channels on/off. *Note Standalone Simulator:Standalone Simulator, for a description of specifying debugchannels on the command line.`set SECTION PARAM = VALUE'Set the configuration parameter PARA in section SECTION to VALUE.*Note Configuration: Configuration, for details of configurationparameters and their settings.`debug'Toggle the simulator debug mode. *Note Debug InterfaceConfiguration: Debug Interface Configuration, for information onthis parameter.Caution: This is effectively enabling or disabling the debugunit. It does not effect the remote GDB debug interface.However using the remote debug interface while the debug unitis disabled will lead to undefined behavior and likely crashOr1ksim`cuc'Enter the the Custom Unit Compiler command prompt (*note CUCConfiguration: CUC Configuration.).Caution: The CUC must be properly configured, for this tosucceed. In particular a timing file must be available andreadable. Otherwise Or1ksim will crash.`help'Print out brief information about each command available.`mprofile [-vh] [-m M] [-g N] [-f FILE] FROM TO'Run the memory profiling utility. This follows the same usage asthe standalone command (*note Memory Profiling Utility: MemoryProfiling Utility.).`profile [-vhcq] [-g FILE]'Run the instruction profiling utility. This follows the sameusage as the standalone command (*note Profiling Utility:Profiling Utility.).For all commands, it is possible to redirect the output to a file, byusing the redirection operator, `>'.COMMAND > FILENAMEThis is particularly useful for commands dumping a large amount ofoutput, such as `dv'.Caution: Unfortunately there is a serious bug with the redirectionoperator. It does not return output to standard output after thecommand completes. Until this bug is fixed, file redirectionshould not be used.File: or1ksim.info, Node: Verification API, Next: Code Internals, Prev: Interactive Command Line, Up: Top5 Verification API (VAPI)*************************The Verification API (VAPI) provides a TCP/IP interface to allowcomponents of the simulation to be controlled externally. Theinterface is polled for new requests on each simulated clock cycle.Components within the simulator may send responses to such requests.The inteface is an asynchronous duplex protocol. On the request sideit provides for simple commands, known as VAPI IDs (a 32 bit integer),with a single piece of data (also a 32 bit integer). On the send side,it provides for sending a single VAPI ID and data. However there is noexplicit command-response structure. Some components just acceptrequests (e.g. to set values), some just generate sends (to reportvalues), and some do both.Each component has a base ID (32 bit) and its commands will start fromthat base ID. This provides a simple partitioning of the command spaceamongst components. Request commands will be directed to the componentwith the closest base ID lower than the VAPI ID of the command.Thus if there are two components with base IDs of 0x200 and 0x300, anda request with VAPI ID of 0x203 is received, it will be directed to thefirst component as its command #3.The results of VAPI interactions are logged (by default in `vapi.log'unless an alternative is specified in `section vapi').Currently the following components support VAPI:Debug UnitAlthough the Debug Unit can specify a base VAPI ID, it is not usedto send commands or receive requests.Instead, if the base VAPI ID is set, all remote JTAG protocolexchanges are logged in the VAPI log file.UARTIf a base VAPI ID is specified, the UART sends details of anychars or break characters sent, with dteails of the line controlregister etc encoded in the data packet sent.This supports a single VAPI command request, but encodes asub-command in the top 8 bits of the associated data.`0x00'This stuffs the least significant 8 bits of the data into theserial register of the UART and the next 8 bits into the linecontrol register, effectively providing control of the nextcharacter to be sent or received.`0x01'The divisor latch bytes are set from the least significant 16bits of the data.`0x02'The line control register is set from bits 15-8 of the data.`0x03'The UART skew is set from the least significant 16 bits ofthe data`0x04'If the 16th most significant bit of the data is 1, startsending breaks, otherwise stop sending breaks. The breaksare sent or cleared after the number of UART clock dividerticks specified by the data (immediately if the data is zero).DMAAlthough the DMA unit supports a base VAPI ID in its configuration(`section dma'), no VAPI data is sent, nor VAPI requests currentlyimplemented.EthernetThe following requests are handled by the Ethernet. Specifiedsymbolically, these are the increments from the base VAPI ID of theEthernet. At present no implementation is provided behind theseVAPI requests.`ETH_VAPI_DATA (0)'`ETH_VAPI_CTRL (0)'GPIOIf a base VAPI ID is specified, the GPIO sends out on its baseVAPI ID (symbolically, GPIO_VAPI_DATA (0) offset from the baseVAPI ID) any changes in outputs.The following requests are handled by the GPIO. Specifiedsymbolically, these are the increments from the VAPI base ID of theGPIO.`GPIO_VAPI_DATA (0)'Set the next input to the commands data field`GPIO_VAPI_AUX (1)'Set the GPIO auxiliary inputs to the data field`GPIO_VAPI_CLOCK (2)'Add an external GPIO clock trigger of period specified in thedata field.`GPIO_VAPI_RGPIO_OE (3)'Set the GPIO output enable to the data field`GPIO_VAPI_RGPIO_INTE (4)'Set the next interrupt to the data field`GPIO_VAPI_RGPIO_PTRIG (5)'Set the next trigger to the data field`GPIO_VAPI_RGPIO_AUX (6)'Set the next auxiliary input to the data field`GPIO_VAPI_RGPIO_CTRL (7)'Set th next control input to the data fieldFile: or1ksim.info, Node: Code Internals, Next: GNU Free Documentation License, Prev: Verification API, Up: Top6 A Guide to Or1ksim Internals******************************These are notes to help those wanting to extend Or1ksim. This sectionassumes the use of a tag file, so file locations of entities'definitions are not in general provided. For more on tags, see theLinux manual page for `etags'. A tag file can be created with:make tags* Menu:* Coding Conventions::* Global Data Structures::* Concepts::* Internal Debugging::* Regression Testing::File: or1ksim.info, Node: Coding Conventions, Next: Global Data Structures, Up: Code Internals6.1 Coding Conventions for Or1ksim==================================This chapter provides some guidelines for coding, to facilitateextensions to Or1ksim_GNU Coding Standard_Code should follow the GNU coding standard for C(`http://www.gnu.org/prep/standards/'. If in doubt, put your codethrough the `indent' program._`#include' headers_All C source code files should include `config.h' before any otherfile.This should be followed by inclusion of any system headers (but seethe comments about portability and `port.h' below) and then by anyOr1ksim package headers.If `port.h' is required, it should be the first package header tobe included after the system headers.All C source code and header files should directly include anysystem or package header they depend on, i.e. not rely on anyother header having already included it. The two exceptions are1. All header files may assume that `config.h' has already beenincluded.2. System headers which impose portability problems should beincluded by using the package header `port.h', rather thanthe system headers themselves. This is the case for coderequiring* `strndup' (from `string.h')* Integer types (`intN_t', `uintN_t') (from `inttypes.h').* `isblank' (from `ctype.h')_`#include' files once only_All include files should be protected by `#ifndef' to ensure theirdefinitions are only included once. For instance a header file`X-Y.H' should surround its contents with:#ifndef X_Y__H#define X_Y__H<body of the include file>#endif /* X_Y__H */_Avoid `typedef'_The GNU coding style for C does not have a clear way to distinguishbetween user type name and user variables. For this reason`typedef' should be avoided except for the most ubiquitous userdefined types. This makes the code much easier to read.There are some `typedef' declarations in the `argtable2' libraryand the ELF and COFF headers, because this code is taken fromother places.Within Or1ksim legacy uses of `typedef' have largely been purged,except in the Custom Unit Compiler (*note Custom Unit Compiler(CUC) Configuration: CUC Configuration.).The remaining uses of `typedef' occur in two places:* `port/port.h' defines types to replace those in header filesthat are not available (character functions, stringduplication, integer types).`cpu/or1k/arch.h' defines types for the key Or1ksim entities:addresses (`oraddr_t'), unsigned register values (`uorreg_t')and signed register (`orreg_t') values.Where new types are defined, they should appear in one of these twofiles as appropriate. Or1ksim specific types appearing in`arch.h' should always have the suffix `_h'._Don't begin names with underscore_Names beginning with `_' are intended to be part of the Cinfrastructure. They should not be used in the simulator code._Keep Non-global top level entities static_All top level entities (functions, variables), which are notexplicitly part of a global interface should be declared static.This ensures that unwanted connections are not inadvertently builtacross the program._Use of `inline'_Code should not be declared `inline'. Modern compilers can workout for themselves what is best in this respect._Initialization_All data structures should be explicitly initialized. Inparticular code should not rely on static data structures beinginitialized to zero.The rationale is that in future static data structures may becomedynamic. This has been a particular source of bugs in Or1ksimhistorically.A specific case is with new peripherals, which should alwaysinclude a `start' function to pre-initialize all configurationparameters to sensible defaults_Configuration Validation_All configuration values should be validated, preferably whenencountered, if not when the `section' is closed, or otherwise atrun time when the parameter is first used.File: or1ksim.info, Node: Global Data Structures, Next: Concepts, Prev: Coding Conventions, Up: Code Internals6.2 Global Data Structures==========================`config'The global variable `config' of type `struct config' holds theconfiguration data for some of the Or1ksim components which arealways present. At present the components are:* The simulator defined in `section sim' (*note SimulatorConfiguration: Simulator Configuration.).* The Verification API (VAPI) defined in `section vapi' (*noteVerification API (VAPI) Configuration: Verification APIConfiguration.).* The Custom Unit Compiler (CUC), defined in `section cuc'(*note Custom Unit Compiler (CUC) Configuration: CUCConfiguration.).* The CPU, defined in `section cpu' (*note CPU Configuration:CPU Configuration.).* The data cache (but not the instruction cache), defined in`section dc' (*note Cache Configuration: CacheConfiguration.).* The power management unit, defined in `section pm' (*notePower Management Configuration: Power ManagementConfiguration.).* The programmable interrupt controller, defined in`section pic' (*note Interrupt Configuration: InterruptConfiguration.).* Branch prediciton, defined in `section bpb' (*note BranchPrediction Configuration: Branch Prediction Configuration.).* The debug unit, defined in `section debug' (*note DebugInterface Configuration: Debug Interface Configuration.).This struct is made of a collection of structs, one for eachcomponent. For example the simulator configuration is held in`config.sim'.`config'This is a linked list of data structures holding configuration datafor all sections which are not held in the main `config' datastructure. In general these are components (such as peripheralsand memory) which may occur multiple times. However it alsohandles some architectural components which may occur only once,such as the memory management units, the instruction cache, theinterrupt controller and branch prediction.`runtime'The global variable `runtime' of type `struct runtime' holds allthe runtime information about the simulation. To access thisvariable, `sim-config.h' must be included.This struct is itself made of 3 other structs, `cpu' (for CPU runtime state), `vapi' (for Verification API state) and `cuc' (forCustom Unit Compiler state).File: or1ksim.info, Node: Concepts, Next: Internal Debugging, Prev: Global Data Structures, Up: Code Internals6.3 Concepts============_Output Redirection_The current output stream is held in `runtime.cpu.fout'. Outputshould be explicitly written to this stream, or may use the`PRINTF' macro, which will write its arguments to this outputstream._Reset Hooks_Any peripheral may register a routine to be called when the theprocessor is reset by calling `reg_sim_reset', providing afunction and pointer to a data structure as arguments. On resetthat function will be called with the data stucture pointer asargument._Interrupts_An internal peripheral can model the effect of an interrupt beingasserted by calling `report_interrupt'. This is used for both edgeand level sensitive interrupts.The effect is to set the corresponding bit in the PICSR SPR and toqueue an interrupt exception to take place after the currentinstruction completes execution.Externally, the different interrupts require different mechanismsfor clearing. Level sensitive interrupts should be cleared bydeasserting the interrupt line, edge sensitive interrupts byclearing the corresponding bit in the PICSR SPR.Internally this amounts to the same thing (clearing the PICSPRbit), so a single function is provided, `clear_interrupt'. Notehowever that when level sensitive interrupts are configured, PICSRis read only, and can only be cleared by calling`clear_interrupt'. Using the two functions provided will ensurethe peripheral works correctly whichever type of interrupt is used.Note: Until an interrupt is cleared, all subsequentinterrupts are ignored with a warning.File: or1ksim.info, Node: Internal Debugging, Next: Regression Testing, Prev: Concepts, Up: Code Internals6.4 Internal Debugging======================The function `debug' is like `printf', but with an extra firstargument, which is the debug level. If the debug level specified inthe simulator configuration (*note Simulator Behavior: SimulatorBehavior.) is greater than or equal to this value, the remainingarguments are printed to the current output stream (*note OutputRedirection: Output Redirection.).File: or1ksim.info, Node: Regression Testing, Prev: Internal Debugging, Up: Code Internals6.5 Regression Testing======================Or1ksim now includes a regression test suite for both standalone andlibrary usage as described earlier (*note Building and Installing:Build and Install.). Running the tests requires that the OpenRISCtoolchain and DejaGNU are both installed.Tests are written using `expect', a derivative of TCL. Documentationof DejaGnu, `expect' and TCL are freely available on the Web. TheEmbecosm Application Note 8, `Howto: Using DejaGnu for Testing: ASimple Introduction' (`http://www.embecosm.com/download/ean8.html')provides a concise introduction.All test code is found in the `testsuite' directory. The key files anddirectories used are as follows.`global-conf.exp'This is the global DejaGNU configuration file used to set upparameters common to all tests. If the user has the environmentvarialbe `DEJAGNU' defined, it will be used instead, but this isnot recommended.`Makefile.am'This is the top level `automake' file for the testsuite. The onlychanges likely to be needed here is additional local cleanup offiles created by new tests.`README'This contains details of all the tests`config'This contains DejaGnu board configurations. Since the tests aregenerally run on a Unix host, this should just contain `Unix.exp'.`lib'This contains DejaGnu tool specific configurations. "Tool" has aspecific meaning in DejaGNU, referring just to a grouping oftests. In this case there are two such "tools", "or1ksim" and"libsim" for tests of the standalone tool and tests of the library.Corresponding to this, there are two tool specific configurationfiles, `or1ksim.exp' and `libsim.exp'. These contain `expect'/TCLprocedures for common use among the tests.`libsim.tests'`or1ksim.tests'These are the directories of tests of the Or1ksim library. Theyalso include Or1ksim configuration files and each has a`Makefile.am' file. `Makefile.am' should be updated wheneverfiles are added to this directory, to ensure they are included inthe distribution.`test-code'These are all the test programs to be compiled on the host (eachin its own directory). In general these are programs to supporttesting of the library, and build various programs linking in thelibrary.`test-code'These are all the test programs to be compiled with the OpenRISCtool chain to run with either standalone Or1ksim or the library.This directory includes its own `configure.ac', since it must setup a separate tool chain based on the target, not the host.To add a new test needs the following steps.* Put new host C code in its own directory within `test-code'. Addthe directory to the existing `Makefile.am' in the `test-code'directory and create a `Makefile.am' in the new directory to drivebuilding the test program(s). Don't forget to add the new`Makefile' to the top level `configure.ac' so it gets generated.Not all tests require code here.* Put new target C code in its own directory within `test-code-or1k'.Once again modify & create `Makefile.am'. This time modify the`configure.ac' in the `test-code-or1k' so the `Makefile' getsgenerated. The existing programs provide examples to start from,including custom linker scripts where needed.* Add one or more tests and configuration files to the relevant"tool" test directory. Use the existing tests as templates. Theymake heavy use of the `expect'/TCL procedures in the `config'directory to facilitate driving the tests.File: or1ksim.info, Node: GNU Free Documentation License, Next: Index, Prev: Code Internals, Up: Top7 GNU Free Documentation License********************************Version 1.2, November 2002Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USAEveryone is permitted to copy and distribute verbatim copiesof this license document, but changing it is not allowed.0. PREAMBLEThe purpose of this License is to make a manual, textbook, or otherfunctional and useful document "free" in the sense of freedom: toassure everyone the effective freedom to copy and redistribute it,with or without modifying it, either commercially ornoncommercially. Secondarily, this License preserves for theauthor and publisher a way to get credit for their work, while notbeing considered responsible for modifications made by others.This License is a kind of "copyleft", which means that derivativeworks of the document must themselves be free in the same sense.It complements the GNU General Public License, which is a copyleftlicense designed for free software.We have designed this License in order to use it for manuals forfree software, because free software needs free documentation: afree program should come with manuals providing the same freedomsthat the software does. But this License is not limited tosoftware manuals; it can be used for any textual work, regardlessof subject matter or whether it is published as a printed book.We recommend this License principally for works whose purpose isinstruction or reference.1. APPLICABILITY AND DEFINITIONSThis License applies to any manual or other work, in any medium,that contains a notice placed by the copyright holder saying itcan be distributed under the terms of this License. Such a noticegrants a world-wide, royalty-free license, unlimited in duration,to use that work under the conditions stated herein. The"Document", below, refers to any such manual or work. Any memberof the public is a licensee, and is addressed as "you". Youaccept the license if you copy, modify or distribute the work in away requiring permission under copyright law.A "Modified Version" of the Document means any work containing theDocument or a portion of it, either copied verbatim, or withmodifications and/or translated into another language.A "Secondary Section" is a named appendix or a front-matter sectionof the Document that deals exclusively with the relationship of thepublishers or authors of the Document to the Document's overallsubject (or to related matters) and contains nothing that couldfall directly within that overall subject. (Thus, if the Documentis in part a textbook of mathematics, a Secondary Section may notexplain any mathematics.) The relationship could be a matter ofhistorical connection with the subject or with related matters, orof legal, commercial, philosophical, ethical or political positionregarding them.The "Invariant Sections" are certain Secondary Sections whosetitles are designated, as being those of Invariant Sections, inthe notice that says that the Document is released under thisLicense. If a section does not fit the above definition ofSecondary then it is not allowed to be designated as Invariant.The Document may contain zero Invariant Sections. If the Documentdoes not identify any Invariant Sections then there are none.The "Cover Texts" are certain short passages of text that arelisted, as Front-Cover Texts or Back-Cover Texts, in the noticethat says that the Document is released under this License. AFront-Cover Text may be at most 5 words, and a Back-Cover Text maybe at most 25 words.A "Transparent" copy of the Document means a machine-readable copy,represented in a format whose specification is available to thegeneral public, that is suitable for revising the documentstraightforwardly with generic text editors or (for imagescomposed of pixels) generic paint programs or (for drawings) somewidely available drawing editor, and that is suitable for input totext formatters or for automatic translation to a variety offormats suitable for input to text formatters. A copy made in anotherwise Transparent file format whose markup, or absence ofmarkup, has been arranged to thwart or discourage subsequentmodification by readers is not Transparent. An image format isnot Transparent if used for any substantial amount of text. Acopy that is not "Transparent" is called "Opaque".Examples of suitable formats for Transparent copies include plainASCII without markup, Texinfo input format, LaTeX input format,SGML or XML using a publicly available DTD, andstandard-conforming simple HTML, PostScript or PDF designed forhuman modification. Examples of transparent image formats includePNG, XCF and JPG. Opaque formats include proprietary formats thatcan be read and edited only by proprietary word processors, SGML orXML for which the DTD and/or processing tools are not generallyavailable, and the machine-generated HTML, PostScript or PDFproduced by some word processors for output purposes only.The "Title Page" means, for a printed book, the title page itself,plus such following pages as are needed to hold, legibly, thematerial this License requires to appear in the title page. Forworks in formats which do not have any title page as such, "TitlePage" means the text near the most prominent appearance of thework's title, preceding the beginning of the body of the text.A section "Entitled XYZ" means a named subunit of the Documentwhose title either is precisely XYZ or contains XYZ in parenthesesfollowing text that translates XYZ in another language. (Here XYZstands for a specific section name mentioned below, such as"Acknowledgements", "Dedications", "Endorsements", or "History".)To "Preserve the Title" of such a section when you modify theDocument means that it remains a section "Entitled XYZ" accordingto this definition.The Document may include Warranty Disclaimers next to the noticewhich states that this License applies to the Document. TheseWarranty Disclaimers are considered to be included by reference inthis License, but only as regards disclaiming warranties: any otherimplication that these Warranty Disclaimers may have is void andhas no effect on the meaning of this License.2. VERBATIM COPYINGYou may copy and distribute the Document in any medium, eithercommercially or noncommercially, provided that this License, thecopyright notices, and the license notice saying this Licenseapplies to the Document are reproduced in all copies, and that youadd no other conditions whatsoever to those of this License. Youmay not use technical measures to obstruct or control the readingor further copying of the copies you make or distribute. However,you may accept compensation in exchange for copies. If youdistribute a large enough number of copies you must also followthe conditions in section 3.You may also lend copies, under the same conditions stated above,and you may publicly display copies.3. COPYING IN QUANTITYIf you publish printed copies (or copies in media that commonlyhave printed covers) of the Document, numbering more than 100, andthe Document's license notice requires Cover Texts, you mustenclose the copies in covers that carry, clearly and legibly, allthese Cover Texts: Front-Cover Texts on the front cover, andBack-Cover Texts on the back cover. Both covers must also clearlyand legibly identify you as the publisher of these copies. Thefront cover must present the full title with all words of thetitle equally prominent and visible. You may add other materialon the covers in addition. Copying with changes limited to thecovers, as long as they preserve the title of the Document andsatisfy these conditions, can be treated as verbatim copying inother respects.If the required texts for either cover are too voluminous to fitlegibly, you should put the first ones listed (as many as fitreasonably) on the actual cover, and continue the rest ontoadjacent pages.If you publish or distribute Opaque copies of the Documentnumbering more than 100, you must either include amachine-readable Transparent copy along with each Opaque copy, orstate in or with each Opaque copy a computer-network location fromwhich the general network-using public has access to downloadusing public-standard network protocols a complete Transparentcopy of the Document, free of added material. If you use thelatter option, you must take reasonably prudent steps, when youbegin distribution of Opaque copies in quantity, to ensure thatthis Transparent copy will remain thus accessible at the statedlocation until at least one year after the last time youdistribute an Opaque copy (directly or through your agents orretailers) of that edition to the public.It is requested, but not required, that you contact the authors ofthe Document well before redistributing any large number ofcopies, to give them a chance to provide you with an updatedversion of the Document.4. MODIFICATIONSYou may copy and distribute a Modified Version of the Documentunder the conditions of sections 2 and 3 above, provided that yourelease the Modified Version under precisely this License, withthe Modified Version filling the role of the Document, thuslicensing distribution and modification of the Modified Version towhoever possesses a copy of it. In addition, you must do thesethings in the Modified Version:A. Use in the Title Page (and on the covers, if any) a titledistinct from that of the Document, and from those ofprevious versions (which should, if there were any, be listedin the History section of the Document). You may use thesame title as a previous version if the original publisher ofthat version gives permission.B. List on the Title Page, as authors, one or more persons orentities responsible for authorship of the modifications inthe Modified Version, together with at least five of theprincipal authors of the Document (all of its principalauthors, if it has fewer than five), unless they release youfrom this requirement.C. State on the Title page the name of the publisher of theModified Version, as the publisher.D. Preserve all the copyright notices of the Document.E. Add an appropriate copyright notice for your modificationsadjacent to the other copyright notices.F. Include, immediately after the copyright notices, a licensenotice giving the public permission to use the ModifiedVersion under the terms of this License, in the form shown inthe Addendum below.G. Preserve in that license notice the full lists of InvariantSections and required Cover Texts given in the Document'slicense notice.H. Include an unaltered copy of this License.I. Preserve the section Entitled "History", Preserve its Title,and add to it an item stating at least the title, year, newauthors, and publisher of the Modified Version as given onthe Title Page. If there is no section Entitled "History" inthe Document, create one stating the title, year, authors,and publisher of the Document as given on its Title Page,then add an item describing the Modified Version as stated inthe previous sentence.J. Preserve the network location, if any, given in the Documentfor public access to a Transparent copy of the Document, andlikewise the network locations given in the Document forprevious versions it was based on. These may be placed inthe "History" section. You may omit a network location for awork that was published at least four years before theDocument itself, or if the original publisher of the versionit refers to gives permission.K. For any section Entitled "Acknowledgements" or "Dedications",Preserve the Title of the section, and preserve in thesection all the substance and tone of each of the contributoracknowledgements and/or dedications given therein.L. Preserve all the Invariant Sections of the Document,unaltered in their text and in their titles. Section numbersor the equivalent are not considered part of the sectiontitles.M. Delete any section Entitled "Endorsements". Such a sectionmay not be included in the Modified Version.N. Do not retitle any existing section to be Entitled"Endorsements" or to conflict in title with any InvariantSection.O. Preserve any Warranty Disclaimers.If the Modified Version includes new front-matter sections orappendices that qualify as Secondary Sections and contain nomaterial copied from the Document, you may at your optiondesignate some or all of these sections as invariant. To do this,add their titles to the list of Invariant Sections in the ModifiedVersion's license notice. These titles must be distinct from anyother section titles.You may add a section Entitled "Endorsements", provided it containsnothing but endorsements of your Modified Version by variousparties--for example, statements of peer review or that the texthas been approved by an organization as the authoritativedefinition of a standard.You may add a passage of up to five words as a Front-Cover Text,and a passage of up to 25 words as a Back-Cover Text, to the endof the list of Cover Texts in the Modified Version. Only onepassage of Front-Cover Text and one of Back-Cover Text may beadded by (or through arrangements made by) any one entity. If theDocument already includes a cover text for the same cover,previously added by you or by arrangement made by the same entityyou are acting on behalf of, you may not add another; but you mayreplace the old one, on explicit permission from the previouspublisher that added the old one.The author(s) and publisher(s) of the Document do not by thisLicense give permission to use their names for publicity for or toassert or imply endorsement of any Modified Version.5. COMBINING DOCUMENTSYou may combine the Document with other documents released underthis License, under the terms defined in section 4 above formodified versions, provided that you include in the combinationall of the Invariant Sections of all of the original documents,unmodified, and list them all as Invariant Sections of yourcombined work in its license notice, and that you preserve alltheir Warranty Disclaimers.The combined work need only contain one copy of this License, andmultiple identical Invariant Sections may be replaced with a singlecopy. If there are multiple Invariant Sections with the same namebut different contents, make the title of each such section uniqueby adding at the end of it, in parentheses, the name of theoriginal author or publisher of that section if known, or else aunique number. Make the same adjustment to the section titles inthe list of Invariant Sections in the license notice of thecombined work.In the combination, you must combine any sections Entitled"History" in the various original documents, forming one sectionEntitled "History"; likewise combine any sections Entitled"Acknowledgements", and any sections Entitled "Dedications". Youmust delete all sections Entitled "Endorsements."6. COLLECTIONS OF DOCUMENTSYou may make a collection consisting of the Document and otherdocuments released under this License, and replace the individualcopies of this License in the various documents with a single copythat is included in the collection, provided that you follow therules of this License for verbatim copying of each of thedocuments in all other respects.You may extract a single document from such a collection, anddistribute it individually under this License, provided you inserta copy of this License into the extracted document, and followthis License in all other respects regarding verbatim copying ofthat document.7. AGGREGATION WITH INDEPENDENT WORKSA compilation of the Document or its derivatives with otherseparate and independent documents or works, in or on a volume ofa storage or distribution medium, is called an "aggregate" if thecopyright resulting from the compilation is not used to limit thelegal rights of the compilation's users beyond what the individualworks permit. When the Document is included in an aggregate, thisLicense does not apply to the other works in the aggregate whichare not themselves derivative works of the Document.If the Cover Text requirement of section 3 is applicable to thesecopies of the Document, then if the Document is less than one halfof the entire aggregate, the Document's Cover Texts may be placedon covers that bracket the Document within the aggregate, or theelectronic equivalent of covers if the Document is in electronicform. Otherwise they must appear on printed covers that bracketthe whole aggregate.8. TRANSLATIONTranslation is considered a kind of modification, so you maydistribute translations of the Document under the terms of section4. Replacing Invariant Sections with translations requires specialpermission from their copyright holders, but you may includetranslations of some or all Invariant Sections in addition to theoriginal versions of these Invariant Sections. You may include atranslation of this License, and all the license notices in theDocument, and any Warranty Disclaimers, provided that you alsoinclude the original English version of this License and theoriginal versions of those notices and disclaimers. In case of adisagreement between the translation and the original version ofthis License or a notice or disclaimer, the original version willprevail.If a section in the Document is Entitled "Acknowledgements","Dedications", or "History", the requirement (section 4) toPreserve its Title (section 1) will typically require changing theactual title.9. TERMINATIONYou may not copy, modify, sublicense, or distribute the Documentexcept as expressly provided for under this License. Any otherattempt to copy, modify, sublicense or distribute the Document isvoid, and will automatically terminate your rights under thisLicense. However, parties who have received copies, or rights,from you under this License will not have their licensesterminated so long as such parties remain in full compliance.10. FUTURE REVISIONS OF THIS LICENSEThe Free Software Foundation may publish new, revised versions ofthe GNU Free Documentation License from time to time. Such newversions will be similar in spirit to the present version, but maydiffer in detail to address new problems or concerns. See`http://www.gnu.org/copyleft/'.Each version of the License is given a distinguishing versionnumber. If the Document specifies that a particular numberedversion of this License "or any later version" applies to it, youhave the option of following the terms and conditions either ofthat specified version or of any later version that has beenpublished (not as a draft) by the Free Software Foundation. Ifthe Document does not specify a version number of this License,you may choose any version ever published (not as a draft) by theFree Software Foundation.ADDENDUM: How to use this License for your documents====================================================To use this License in a document you have written, include a copy ofthe License in the document and put the following copyright and licensenotices just after the title page:Copyright (C) YEAR YOUR NAME.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2or any later version published by the Free Software Foundation;with no Invariant Sections, no Front-Cover Texts, and no Back-CoverTexts. A copy of the license is included in the section entitled ``GNUFree Documentation License''.If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,replace the "with...Texts." line with this:with the Invariant Sections being LIST THEIR TITLES, withthe Front-Cover Texts being LIST, and with the Back-Cover Textsbeing LIST.If you have Invariant Sections without Cover Texts, or some othercombination of the three, merge those two alternatives to suit thesituation.If your document contains nontrivial examples of program code, werecommend releasing these examples in parallel under your choice offree software license, such as the GNU General Public License, topermit their use in free software.File: or1ksim.info, Node: Index, Prev: GNU Free Documentation License, Up: TopIndex*****
