URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [gdb-5.0/] [sim/] [ppc/] [INSTALL] - Rev 1765
Compare with Previous | Blame | View Log
PSIM - model the PowerPC environmentCopyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>.----------------------------------------------------------------------Building PSIMThis file describes how to build the program PSIMo Walk through a basic buildo Discussion of PSIM's components andhow they relate to the build processo Detailed description of each of PSIM'scompile time configuration options----------------------------------------------------------------------BUILDING PSIM:PSIM 1.0.2 is included in GDB-4.16. To build PSIM you will need thefollowing:gdb-4.16.tar.gz Available from your favorite GNUftp sitegcc GCC version two includes suportfor long long (64bit integer)arrithemetic which PSIM uses. Henceit is recommended that you build PSIMusing GCC.Method:1. Unpack gdb$ cd .../scratch$ gunzip < gdb-4.16.tar.gz | tar xf -2. Configure gdbFirst consult the gdb documentation$ cd .../scratch$ cd gdb-4.16$ more README$ more gdb/READMEthen something like (I assume SH):$ CC=gcc ./configure \--enable-sim-powerpc \--target=powerpc-unknown-eabi \--prefix=/applications/psim4. Build (again specifying GCC)$ make CC=gccalternatively, if you are short on disk space or onlywant to build the simulator:$ ( cd libiberty && make CC=gcc )$ ( cd bfd && make CC=gcc )$ ( cd sim/ppc && make CC=gcc )5. Install$ make CC=gcc installor just$ cp gdb/gdb ~/bin/powerpc-unknown-eabisim-gdb$ cp sim/ppc/run ~/bin/powerpc-unknown-eabisim-run----------------------------------------------------------------------UPDATING PSIM:A PSIM is an ongoing development. Occasional snapshots which both contain newfeatures and fix old bugs are made available. See the ftp directory:ftp://ftp.ci.com.au/pub/psim/betaor ftp://cambridge.cygnus.com/pub/psim/betafor the latest version. To build/install one of these snapshots, youreplace the sim/ppc found in the gdb archive with with one from thesnapshot. Then just re-configure and rebuild/install.Procedure:0. A starting point$ cd gdb-4.161. Remove the old psim directory$ mv sim/ppc sim/old.ppc2. Unpack the new one$ gunzip < ../psim-NNNNNN.tar.gz | tar tf -$ gunzip < ../psim-NNNNNN.tar.gz | tar tf -3. Reconfigure/rebuild (as seen above):$ CC=gcc ./configure \--enable-sim-powerpc \--target=powerpc-unknown-eabi \--prefix=/applications/psim$ make CC=gcc----------------------------------------------------------------------UPDATES TO GDB:From time to time, problems involving the integration of PSIM into gdbare found. While eventually each of these problems is resolved therecan be periouds during which a local hack may be needed.At the time of writing the following were outstanding:ATTACH command:ftp://ftp.ci.com.au/pub/psim/gdb-4.15+attach.diff.gzor ftp://cambridge.cygnus.com/pub/psim/gdb-4.15+attach.diff.gzPSIM, unlike the other simulators found in GDB, is able to loadthe description of a target machine (including the initialstate of all processor registers) from a file.Unfortunatly GDB does not yet have a standard command thatfacilitates the use of this feature. Until such a command isadded, the patch (hack?) gdb-4.15+attach.diff.gz can be used toextend GDB's attach command so that it can be used to initializethe simulators configuration from a file.----------------------------------------------------------------------RUNNING PROGRAMS:See the file:ftp://ftp.ci.com.au/pub/psim/RUNor ftp://cambridge.cygnus.com/pub/psim/RUN----------------------------------------------------------------------COMPILE TIME CONFIGURATION OPTIONS:PSIM's compile time configuration is controlled by autoconf. PSIM'sconfigure script recognises options of the form:--enable-sim-<option>[=<val>]And can be specified on the configure command line (at the top levelof the gdb directory tree) vis:$ cd gdb-4.15$ CC=gcc ./configure \--target=powerpc-unknown-eabisim \--prefix=/applications/psim \--enable-sim-inline$ make CC=gccFor a brief list of PSIM's configuration options, configure --helpwill list them vis:$ cd sim/ppc$ ./configure --helpEach PSIM specific option is discussed in detail below.--enable-sim-cflags=<opts>Specify additional C compiler flags that are to be used when compilingjust PSIM.PSIM places heavy demands on both the host machine and its C compiler. So thatthe builder has better control over the compiler the above option can be usedto pass additional options to the compiler while PSIM is being built.Ex: No debug informationPSIM can be built with everything inline. Unfortunately, because ofall the debugging information generated the C compiler can grow veryvery large as a result. For GCC, the debug information can berestricted with the `-g0' option. To specify that this option shouldbe include in the CFLAGS when compiling the psim source code use:--enable-sim-cflags=-g0Ex: Additional optimization flagsA significant gain in performance can be achieved by tuning theoptimization flags passed to the C compiler. For instance on an x86you may consider:--enable-sim-cflags='-g0 -O2 -fno-strength-reduce -f...'--enable-sim-warnings=<flags>Turn on additional GCC specific checks.Some hosts (NetBSD, Linux, Solaris-2.5) have complete header filesthat include correct prototypes for all library functions. On suchhosts, PSIM can be built with many more than the standard C checksenabled. The option --enable-sim-warnings controls this.Ex: Default warningsWith just --enable-sim-warnings, the following -W options are enabled:-Werror -Wall -Wpointer-arith -Wmissing-prototypes.--enable-sim-opcode=whichSpecify the file containing the rules for generating the instructiondecode and execute functions from the file ppc-instructions.The form of the instruction decode and execute functions is controlledby an opcode table. It specifies: the combination of switchstatements and jump tables to use when decoding an instruction and howmuch of each instruction should be decoded before calling theinstruction execute function.PSIM includes a number of opcode tables:psim-opcode-simpleGenerates a small compact two level switch statementthat will compile quickly and run reasonably fast.This may be useful on a small machine.psim-opcode-complex(the default) A fairly aggressive instruction decodetable that includes the breaking out of a numberof special instruction cases (eg RA==0 vs RA!=0).psim-opcode-flatIdentical to complex except a switch statementis used. Ideal for when the icache is beingdisabled.psim-opcode-stupidIn addition to the instruction decodes performedby psim-opcode-complex, this also full decodes mtspr,mfspr, and branch instructions. The table generatedis very large and, as a consequence, only performswell on machines with large caches.ppc-opcode-test-1ppc-opcode-test-2Generate test (but workable) tables. These exercisePSIM's ability to generate instruction decode functionsthat are a combination of jump-tables and switch statements.The program igen generates the instruction tables from the opcodetable and the ppc-instruction table.--enable-sim-switchEnable/disable the use of a switch statement when looking up theattributes of a SPR register.The PowerPC architecture defines a number of Special Purpose Registers(SPR's). Associated with each of these registers are a number ofattributes (such as validity or size) which the instructionsmtspr/mfspr query as part of their execution.For PSIM, this information is kept in a table (ppc-spr-table). Theprogram dgen converts this table into lookup routines (contained inthe generated files spreg.h spreg.c) that can be used to query anSPR's attributes. Those lookup routines are either implemented asa table or alternatively as a number of switch statements:spr_table spr_info[] = { .... };int spr_length(sprs spr) { return spr_info[spr].length; }vsint spr_length(sprs spr) { switch (spr) { case ..: return ..; } }In general the first implementation (a table) is the most efficient.It may, however, prove that when performing an aggressive optimizationwhere both the SPR is known and the above function is being inlined(with the consequence that GCC can eliminate the switch statement)that the second choice is improves performance.In practice, only a marginal (if any benefit) has ever been seen.--enable-sim-duplicateCreate a duplicate copy of each instruction function hardwiringinstruction fields that would have otherwise have been variable.As discussed above, igen outputs a C function generated from the fileppc-instructions (using the opcode rules) for each of theinstructions. Thus multiple entries in the instruction decode tablesmay be pointing back at the same function. Enabling duplicate, willresult in psim creating a duplicate of the instruction's function foreach different entry in the instruction decode tables.For instance, given the branch instruction:0.19,6.BO,11.BI,16./,21.528,31.LK...if (LK) LR = (spreg)IEA(CIA + 4);...igen as part of its instruction lookup table may have generated twodifferent entries - one for LK=0 and one for LK=1. With duplicateenabled, igen outputs (almost) duplicate copies of branch function,one with LK hardwired to 0 and one with LK hardwired to 1.By doing this the compiler is provided with additional information thatwill allow it possibly eliminate dead code. (such as the assignmentto LK if LR==0).Ex: defaultBecause this feature is such a big win, --enable-sim-duplicate isturned on by default.Ex: A small machineOnly rarely (eg on a very small host) would this feature need to bedisabled (using: --disable-sim-duplicate).--enable-sim-filter=ruleInclude/exclude PowerPC instructions that are specific to a particularimplementation.Some of the PowerPC instructions included in the file ppc-instructionsare limited to certain specific PPC implementations. For instance,the instruction:0.58,6.RT,11.RA,16.DS,30.2:DS:64::Load Word AlgebraicIs only valid for the 64bit architecture. The enable-sim-filter flagis passed to igen so that it can `filter out' any invalidinstructions. The filter rule has the form:-f <name>thus:--enable-sim-filter='-f 64'(the default) would filter out all 64bit instructions.Ex: Remove floating point instructionsA given 32bit PowerPC implementation may not include floating pointhardware. Consequently there is little point in including floatingpoint instructions in the instruction table. The option:--enable-sim-filter='-f 64 -f f'will eliminate all floating point instructions from the instructiontable.--enable-sim-icache=sizeSet the size of the cache used to hold decoded instructions.Psim executes instructions in two separate steps:o instruction fetch/decodeo instruction executionFor a given instruction, the first stage need only be executed once(the first time the instruction is encountered) while the second stagemust be executed every time the program `executes' that instruction.Exploiting this, PSIM can maintain a cache of decoded instructions.It will then use the decoded instruction from the cache in preferenceto fetching/decoding the real instruction from memory.Ex: defaultBecause this feature is normally such a big win, it is enabled bydefault (with the cache size set to 1024 entries).The 1024 entries equals 4096 bytes (or one page) of instructions.Larger caches can be used but with caution - PSIM does not check foraddress aliasing within its instruction cache.Ex: disable the cacheThere may be cases (for instance where the cache has a low hit rate)where the psim performs better with no instruction cache. For suchsituations, the cache can be disabled vis: --disable-sim-icache.--enable-sim-inline[=module]Specify the inlining of one or more modules.Many architectures (in particular the x86) suffer from a largefunction call overhead. By eliminating function calls (throughinlining of functions) a large performance gain can be achieved.In PSIM, modules are inlined in one of two possible ways. Somemodules (such as the byte swapping code) can be inlined into anymodule that calls them. Other modules, due to complexinterdependencies, are only inlined as a group when compiling theexternal interface module psim.c.Ex: defaultBy default the modules endian (handle be/le), bits (manipulatebit-fields within words), cpu (the processor object) and events(timers) are inlined in any module that calls them. This gives areasonable performance gain with little additional compilationoverhead.Ex: recommended --enable-sim-inlineAssuming you machine is reasonably well configured, this option ishighly recommended. On the x86 several orders of magnitudeimprovement in performance is possible.Ex: fine tuningThe file std-config.h contains a detailed description of how theinlining works. Individual modules can be inlined by specifying them.For if you have a very large cache the model module could be inlinedwith:--enable-sim-inline=MODEL--enable-sim-bswap(x86 specific) Use the i486/P5/P6 byte swap instruction.PSIM contains generic byte swapping code. For the x86 (P[4-6]) PSIMcan be built so that it uses the bswap instruction instead of relyingon the compiler to generate byte swap code.Ex: defaultBy default, when compiling with GCC-2 on an i486/P5/P6 the bswapinstruction is used.--enable-sim-endian=endianSpecify the byte order of the target.By default, PSIM is able to execute both big and little endianexecutables. As a consequence, every byte swap routine includes atest to see if the byte swap is really needed. By specifying the byteorder of the target (and the host below) the need for this test can beeliminated.Clearly setting the byte order of the target is only useful when knownbefore hand.--enable-sim-hostendain=endAs above but for the host.Normally this option should not be needed. configure (autoconf) shoulddetermine the byte order of the host automatically. However if forsome reason there is a problem, this option can be used to overrideautoconf.--enable-sim-smp=nSet the maximum number of processors that PSIM can model.Psim can model (with small limitation discussed else where) amulti-processor PowerPC environment. While the overhead ofco-ordinating the execution of a number of processors is relativelysmall it is still significant when compared to handling only oneprocessor.This option only sets the maximum number of processors that can besimulated. The number active during a given simulation run usdetermined at run time.Ex: defaultBy default 5 processors are configured but only one is enabled.Additional processors can be enabled with the runtime option:-o '/openprom/options/smp 5'Ex: recommendedUnless you intend studying multi-processor systems there is little reason forhaving PSIM configured with SMP support. Specifying:--disable-sim-smpor --enable-sim-smp=0will eliminate any SMP such as:for (cpu = 0; cpu < nr_cpus; cpu++)...--enable-sim-xor-endian=nSet the byte-size of the bus involved in the PowerPC's xor endian byteswapping.The PowerPC's implementation of BE/LE mode is different to what aprogrammer may first expect. The details of this implementation arediscussed at length in PowerPC documentation.Ex: defaultBy default this is configured with a value of 8 (the bus size of most60x processors).Ex: recommendedUnless you are expecting to test/debug PowerPC be/le switching codethis option is of little use and should be disabled:--disable-sim-xor-endian--enable-sim-bitsize=nSpecify the bit size (32/64) of the PowerPC to be modelled.Note: By default 32 is specified. The implementation of the 64bitarchitecture is still under development.--enable-sim-hostbitsize=32|64As above but for the host.NOTE: Psim has yet to be built on a 64bit host.--enable-sim-env=envHardwire the PowerPC environment being modelled (user, virtual oroperating).The PowerPC architecture defines three different levels of compliance to itsarchitectural specification. These environments are discussed in detail inPowerPC publications.user - normal user programsvirtual - an extension of the user environment (includes timers)operating - kernel codeEx: defaultBy default all three environments are supported.Ex: recommendedIf you only intend running psim with user (or operating) code thenPSIM should be configured accordingly. For user code, it eliminates:support for timers and events and redundant VM calls.--enable-sim-timebaseEnable/disable the time base register.The PowerPC architecture (virtual environment) includes a time baseregister. Maintaining that register incurs an overhead inperformance that can be eliminated by eliminating time-base registersupport.Ex: defaultNormally this option is not used. Instead --enable-sim-env (above) usused to disable/enable features such as the timebase register.--enable-sim-alignment=alignControl the PowerPC's memory access alignment restrictions.The PowerPC in LE mode only allows memory transfers of a correctlyaligned size/address. The above option controls how misalignedaccesses are handled.strict All accesses must be correctly alignednonstrict Unaligned access allowed (the are splitinto a number of aligned accesses).Ex: defaultUnless otherwise specified PSIM will auto configure a BE program toallow miss-aligned accesses while a LE program will not.Ex: 604eThe recently announced 604e processor allows miss-aligned accesses in bothBE and LE modes. If modeling the 604e then you should specify:--enable-sim-alignment=nonstrict--enable-sim-traceInclude code to trace PSIM's internal progress (also controlled by the-t option).Checking to see if a trace message should be output slows down asimulation. Disabling this option (--disable-sim-trace) eliminatescompletely that code.--enable-sim-assertInclude the code that checks the correctness of parts of PSIM.Eliminating such code (--disable-sim-assert) eliminates internalconsistency tests and their overhead.--enable-sim-reserved-bitsInclude code to check that the reserved fields of the instruction arezero.The PowerPC architecture defines certain fields of some instructionsas reserved (`/'). By default, for each instruction, PSIM will checkthe reserved fields causing an invalid instruction exception if afield is invalid. Disabling this option eliminates this test. Thisis at the slight risk of PSIM treating an invalid instruction asvalid.--enable-sim-floatInclude support for hardware floating point.--enable-sim-monitor=monInclude support for basic instruction counting.If you are not interested in the performance of either you program orthe simulator then you can disable this option.--enable-sim-model=whichHardwire the processor that will be used as a reference when modelingexecution units.--enable-sim-default-model=whichSpecify the processor of choice for the execution unit model.--enable-sim-model-issueInclude support for the modeling of processor execution units.----------------------------------------------------------------------TYPICAL CONFIGURATION OPTIONS:VEA CODE ONLY:Here of note are:o ramp up the compiler options (someof the below are P5 specific).o disable anything not usedCC=gcc ./configure \--prefix=/applications/psim \--target=powerpc-unknown-eabi \--enable-sim-powerpc \--enable-sim-warnings \--enable-sim-inline \--disable-sim-smp \--enable-sim-duplicate \--enable-sim-endian=big \--disable-sim-xor-endian \--enable-sim-env=user \--disable-sim-reserved-bits \--disable-sim-assert \--disable-sim-trace \--enable-sim-cflags='-g0,-O2,-fno-strength-reduce,-fomit-frame-pointer'OEA CODE ONLY:The key configuration changes are:o turn off the instruction cache. The overheadof flushing and reloading it is greater thannot having a cache.o use a switch statement (ppc-opcode-flat) forthe instruction decode and then (-O3) fullyinline all functions.o --enable-sim-warnings is not present. GCC (2.7.2)gets confused by the instruction decode tablegenerated by igen (contains a perfect switch)and, as a consequence, generates a bogus warning.CC=gcc ./configure \--prefix=/applications/psim \--target=powerpc-unknown-eabi \--enable-sim-powerpc \--enable-sim-inline \--disable-sim-smp \--enable-sim-duplicate \--enable-sim-endian=big \--disable-sim-xor-endian \--enable-sim-env=operating \--disable-sim-reserved-bits \--disable-sim-assert \--disable-sim-trace \--enable-sim-opcode=ppc-opcode-flat \--disable-sim-icache \--enable-sim-cflags='-g0,-O3,-fno-strength-reduce,-fomit-frame-pointer'
