| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
MOTOR Powe Labo rato Manual Jose Noel Serrano, Walter Guiot, Luis
Top Searches for this datasheetInstructor's Manual MOTOR Powe Labo rato Manual Jose Noel Serrano, Walter Guiot, Luis Eisen Montalvo Department Electrical Computer Engineering University Puerto Chuck Corley PowerPC Applications Engineering Motorola Editor: Cruz Rivera Department Electrical Computer Engineering University Puerto VOLUME DISCLAIMERS Motorola Inc. 1999 Portions hereof International Business Machines Corp. 1991-1995. rights reserved. This document contains information product under development Motorola IBM. Motorola reserve right change discontinue this product without notice. Information this document provided solely enable system software implementers PowerPC microprocessors. There express implied copyright patent licenses granted hereunder Motorola design, modify design fabricate circuits based information this document. PowerPC microprocessors embody intellectual property Motorola IBM. However, neither Motorola assumes responsibility liability aspects performance, operation, other attributes microprocessor marketed other party third party. Neither Motorola considered agent representative other, neither assumed, created, granted hereby right authority other, third party, assume create express implied obligations behalf. Information such data sheets, well sales terms conditions such prices, schedules, support, product vary between parties selling product. Accordingly, customers wishing learn more information about products marketed given party should contact that party. Both Motorola reserve right modify this manual and/or products described herein without further notice. NOTHING THIS MANUAL, ERRATA SHEETS, DATA SHEETS, OTHER SUPPORTING DOCUMENTATION, SHALL INTERPRETED CONVEYANCE MOTOROLA EXPRESS WARRANTY KIND IMPLIED WARRANTY, REPRESENTATION, GUARANTEE REGARDING MERCHANTABILITY FITNESS PRODUCTS PARTICULAR PURPOSE. Neither Motorola assumes liability obligation damages kind arising application these materials. warranty other obligations products described herein shall undertaken solely marketing party customer, under separate sale agreement between marketing party customer. absence such agreement, liability assumed Motorola, IBM, marketing party damages, actual otherwise. "Typical" parameters vary different applications. operating parameters, including "Typicals," must validated each customer application customer's technical experts. Neither Motorola convey license under their respective intellectual property rights rights others. Neither Motorola makes claim, warranty, representation, express implied, that products described this manual designed, intended, authorized components systems intended surgical implant into body, other applications intended support sustain life, other application which failure product could create situation where personal injury death occur. Should customer purchase products such unintended unauthorized application, customer shall indemnify hold Motorola their respective officers, employees, subsidiaries, affiliates, distributors harmless against claims, costs, damages, expenses, reasonable attorney fees arising directly indirectly, claim personal injury death associated with such unintended unauthorized use, even such claim alleges that Motorola negligent regarding design manufacture part. Motorola registered trademarks Motorola, Inc. Motorola, Inc. Equal Opportunity/Affirmative Action Employer. logo registered trademarks, Microelectronics trademark International Business Machines Corp. PowerPC name, PowerPC logotype, PowerPC trademarks International Business Machines Corp. used Motorola under license from International Business Machines Corp. International Business Machines Corp. Equal Opportunity/Affirmative Action Employer. INTRODUCTION This laboratory manual contains experiments PowerPC Excimer Board presented increasing order complexity. experiments range from memory mapping problems system benchmarking integer floating point number representation conversion. assumed that student basic understanding assembly languages. There natural progression experiments leading Dhrystone Linpack benchmarking PowerPC603e that forms basis Excimer board. Specifically, experiments guide student through following topics: code compilation, code download, DINK functions (resident monitor program), keyboard input, assembly language programming, linking assembly language code. There also experiments memory mapping Flash programming. Each experiment structured follows: Problem Statement, Objectives, Background Information, Procedure, Questions, References. Problem Statement provides brief indication tasks that will performed. Objectives section presents specific educational objectives that will upon successful completion experiment. Background information section presents brief description theory behind devices, instructions, functional units, and/or methods followed conduction experiment. Procedure section presents step-by-step guide experiment. Questions section seeks guide student through meaningful analysis what he/she performed part experiment. Finally, References section presents additional references with material that useful experiment hand. addition these sections, Instructor's Manual contains Results Troubleshooting section. This laboratory manual contains experiments designed familiarize students with PowerPC architecture Excimer Laboratory Board. manual meant serve standalone textbook PowerPC instruction architecture (ISA), rather designed companion PowerPC book technical reference. Each experiment designed that students will with significant number useful subroutines that used other more complex programming problems. Additional references PowerPC architecture Excimer board found CONTENTS Experiment Metaware Tutorial Write compile simple program. Experiment DINK Tutorial Download program Excimer some utilities. Experiment Useful DINK Functions Write program that will input from echo display. Discuss various utilities interest. Experiment Excimer Memory Compile, download, execute program which blinks on-board LEDs Experiment Control from Keyboard Write debug program turn on-board LEDs varying integer counts. Experiment Simple Scanf Function Excimer Develop function taking character input from terminal emulator's keyboard attached Excimer through serial port converting number characters decimal values used other programs. Experiment Introduction Assembly Language Programming Write simple assembly language program. Experiment Linking Assembly Language code Link previous code fragments. Experiment Converting Integers Floating Point Develop assembly language subroutine convert integer value read from PowerPC time base facility (double) floating point number representing seconds. (Contributed Chuck Corley, Motorola) Experiment #10: Dhrystone Benchmarking Write debug program count integer number cycles required execute Dhrystone benchmark. Experiment #11: Linpack Benchmarking Write debug program time microseconds (floating point) execution Linpack benchmark. Experiment #12: Cache Impact Benchmark Metrics Write single program time performance Dhrystone Linpack with caches enabled disabled. Experiment #13: Flash Write program that copies itself into Flash begins executing from there. Experiment Metaware Tutorial Problem Statement: this experiment student will develop compile program that will calculate first Fibonacci Numbers using Metaware PowerPC compiler. (Contributed Noel Serrano). Objectives: Upon completion this laboratory experience, students will able write, debug compile program using Metaware Code Warrior compilers write recursive function that will generate first Fibonacci Numbers Background Information: This experiment designed take through major steps required implement simple algorithm generation first Fibonacci numbers using Metaware compilers Excimer board. Metaware compiler facilitates code writing, debugging, optimization. More information compiler obtained from www.metaware.com. Fibonacci sequence represents series that first elements remaining elements obtained simply adding last numbers next. example, first Fibonacci Numbers (the first element sequence, included) are: Fibonacci numbers arose from solution following problem posed year 1225: Suppose have pair rabbits that produce another pair productive offspring when they reach month that each successive pair offspring same. Furthermore, assume rabbits never die. many rabbits will there after months? solution follows: after months there pairs rabbits, number pairs month will plus number pairs born. However, since pairs only born pairs least month old, there will kn-1 pairs, that kn+1 kn-1, which simply rule generating Fibonacci Numbers. More information fascinating world Fibonacci Numbers their applications found Procedure: Write language program that will calculate first Fibonacci numbers. Hint: recursive function. able print numbers DINK32 interface (this will discussed more detail future experiments) will need following code your program redefine default printf function with provided DINK. Also printf function should contain only variable. #define printf dink_printf unsigned long (*dink_printf)() (unsigned long (*)())) 0x6270; Type your program text file using notepad edit save directory have chosen contain your code. Compile code with hcppc command included with Metaware compiler using following command command prompt hcppc -Hppc603 file.c Note: "file.c" stands code file. name your code file wish, remember chosen name hcppc command. result from this command will "file.o", which object file. more information about options compiler type hcppc Link object files using ldppcl command invoke linker program included with Metaware compiler using following command Command Prompt: ldppc start_addr=70000 file.o Note: "file.o" object file generated last step. object file will named exactly named code file.) result from this step will file "a.hex", file that will later downloaded Excimer board. start_addr=70000 option that specifies where does your code going paced memory Excimer Board. more information about linker type ldppc References: Metaware High C/C++ Compiler http://www.metaware.com Suggested Code: fibonacci(int #define printf dink_printf unsigned long (*dink_printf)() (unsigned long (*)()) 0x6270; main() fib_no index while (index fib_no fibonacci(index); printf("Fibonacci number index is", index); printf(" %d\n", fib_no); index++; return fibonacci(int number) switch (number) case return case return default return (fibonacci(number-1) fibonacci(number-2)); Troubleshooting: student able Print DINK interface: verify that address pointer address matches that DINK version use. This done through command DINK verifying that address printf matches provided this manual. Experiment DINK Tutorial Problem Statement: This experiment designed introduce student DINK interface. tutorial download code Excimer board some useful DINK debugging utilities also presented. (Contributed Noel Serrano). Objectives: Upon completion this laboratory experience, students will able download their programs Excimer board using DINK interface. debug programs using DINK built-in debugging tools. Background Information: Excimer board contains debugging interface called DINK. This interface enables connect evaluation board through serial cable using terminal program. This enables developer have continuous communication with evaluation board, allowing insight into board's state time. terminal screen your program should look like this. Figure DINK32 terminal client More information DINK found Procedure: First make sure have your evaluation board connected using serial cable provided serial port (COM1). Open your terminal client configure connect through COM1 using following parameters. Parameter Protocol Port Baud Rate Data Bits Parity Stop Bits RTS/CTS Value Serial COM1 9600 Enabled Turn evaluation board press Connect your terminal client. should able initialization window with DINK32_603e prompt presented figure shown below (see step Compile program created experiment number using Metaware compiler. ready download your program Excimer board execution. first terminal client running DINK32 interface type This command will expect receive data from keyboard serial port (COM1). proceed send file from terminal client. This done selecting command like Send Text File Send ASCII (this vary from terminal client other). browse a.hex created directory where compiled your program. your program typing 70000 DINK32 program. your code correct have been successful downloading code should output like following. Hint: table below presents some useful commands case need debug your program, view memory register contents, and/or breakpoints program tracing. more information type help <command> DINK prompt. Command Memory Display Registry Display Disassemble Trace Breakpoint Assemble Format <addr> regdisp <addr> <addr> <addr> <addr> Description Displays memory area specified address Displays register specified Disassemble code starting specified address location Begin tracing program specified address. continue tracing type Sets breakpoint specified address Provides with option changing part assembly from DINK Interface accessing through address code line. References: Motorola, Designing Minimal PowerPC System, PowerPC Application Note: AN1769/D, 1998. Conclusions: Students should able note that: DINK works similarly other evaluation board environments DINK provides functionality that enables user modify memory, registers, assembly code DINK provides breakpoint trace capabilities debugging purposes Troubleshooting: student able communicate with DINK: verify connections COM1 port board check correct settings terminal client Experiment Useful DINK Functions Problem Statement: this experiment student introduced useful functions that contained within DINK Interface. (Contributed Noel Serrano). Objectives: Upon completion this laboratory experience, students will able work with more advanced DINK functions them future laboratories. Background Information: DINK interface provides functions that facilitate development programs Excimer board. Among functions included DINK some that allow programmer capture data from keyboard print screen. Other functions control parts Excimer board configuration like enabling timer, cache, etc. This laboratory will give overview basic these functions will teach access them your programs. There command included DINK that display list these functions with their branch labels corresponding addresses. command corresponding output will look like this. DINK32_603e >>st Current list DINK branch labels: KEYBOARD: get_char: 0x1e4c4 write_char: 0x5eb4 TBaseInit: 0x39e0 TBaseReadLower: 0x3a04 TBaseReadUpper: 0x3a20 CacheInhibit: 0x3a3c InvEnL1Dcache: 0x3a5c DisL1Dcache: 0x3aa4 InvEnL1Icache: 0x3ac8 DisL1Icache: 0x3b00 BurstMode: 0x3bfc RamInCBk: 0x3c3c RamInWThru: 0x3c7c dink_loop: 0x55e8 dink_printf: 0x6270 Current list USER branch labels: DINK32_603e these functions accessed through your code casting function that will point address DINK. code that defines function would look like following example printf function. #define printf dink_printf unsigned long (*dink_printf)() (unsigned long (*)()) 0x6270; following section present examples three DINK functions. get_char This function enables programmer capture characters from keyboard through DINK interface. get_cahr function accessed using following code: #define getchar dink_get_char unsigned long (*dink_get_char)() (unsigned long (*)()) 0x1e4c4; This will enable capture characters from keyboard. syntax reading character from keyboard would char LED; getchar(); write_char This function enables programmer display characters terminal screen that running DINK. write_char function accesed using following code. #define writechar dink_write_char unsigned long (*dink_write_char)() (unsigned long (*)())0x5eb4; This will enable output characters screen. sysntax displaying single characters from keyboard would char `N'; writechar(LED); dink_printf -This functions provide programmer option displaying string characters DINK interface also provide user ability including runtime variable, either char integer, this string. done using dink_printf function using same syntax #define printf dink_printf unsigned long (*dink_printfr)() (unsigned long (*)())0x6270; This will enable print message DINK also include variables included your code. DINK printf function only include variable statement like which contain number variables. printf("Fibonacci number index is", index); There other important functions that used control many aspects Excimer board. These briefly described table below explained details included DINK manuals. Functions TBaseInit TBaseReadLower Address 0x39e0 0x3a04 Description Initializes time base register Reads lower half time base register TBaseReadUpper CacheInhibit InvEnL1Dcache DisL1Dcache InvEnL1Icache DisL1Icache BurstMode References: 0x3a20 0x3a3c 0x3a5c 0x3aa4 0x3ac8 0x3b00 0x3bfc Reads upper half time base register. Turns caches. Invalidate Enable data cache. Disable data cache. Invalidate Enable instruction cache. Disable instruction cache. Sets burst mode. Motorola, Designing Minimal PowerPC System, PowerPC Application Note: AN1769/D, 1998. Suggested Code: This section code used define DINK functions language program. user will only need modyfy address function name. #define function_name dink_function_name unsigned long (*dink_function_name)() (unsigned long (*)()) hex_addr; Troubleshooting: student able access DINK functions: verify casting correct. verify that he/she using correct address. Experiment Excimer Memory Problem Statement: This experiment requires compilation, downloading, execution language program which blinks Excimer Board's STATUS ERROR Light Emitting Diodes (LEDs). (Contributed Noel Serrano, Luis Walter Guiot, Gunther Costas). Objectives: Upon completion this laboratory experience, students will able write compile program download execute PowerPC Assembly object code locate LEDs within Excimer's memory apply methodology needed turn LEDs Background Information: PowerPC family microprocessors based memory mapped input/output scheme. Under this scheme, input port thought read-only memory location, while output port treated like write-only memory location. microprocessor's address used select peripheral device (port location), data used transmit receive data to/from device, Transfer Type signals used convey directionality information transfer. memory Excimer Board shown Figure memory indicates that total addressable locations, Excimer Board allocates each Static RAM, Fast devices, Slow devices Flash [1]. course, Excimer board only uses fraction memory locations allocated each type memory devices. Excimer Board configured with SRAM, 4MBs Flash ROM, some indicators. example, there's STATUS located 0x40200000, while ERROR specified 0x40600000. STATIC 0x0000_0000 0x3FFF_FFFF FAST 0x4000_0000 0x7FFF_FFFF SLOW 0x8000_0000 0xBFFF_FFFF FLASH 0xC000_0000 0xFFFF_FFFF STATUS LED: 0x4020_0000 ERROR LED: 0x4060_0000 Figure Excimer's Memory Map. this experiment required write program that will blink (repeatedly turn off) STATUS ERROR LEDs alternatively. LEDs turned on/off clearing/setting (fourth least significant bit) these locations. reason this negative logic that LEDs connected common anode configuration, shown Figure case seven segment display. Figure Common Anode configuration. LEDs will turn when cathode ground level (Excimer Output asserted low) successfully blink LED, must carefully select delay timing. Remember that microprocessor turn quickly that will blinking effect. Since your program will written simple "for" loop instruction job. (counter=0;counter parameter; counter++); Note: counter must declared unsigned long program. value parameter will define delay time. There other ways accomplish time delay, example using PowerPC's internal timer register. These techniques will demonstrated successive experiments. Procedure: Write simple code that alternatively blinks Status Error LEDs times. Compile code with hcppc command included with Metaware compiler using following command command prompt hcppc -Hppc603 file.c Note: "File.c" stands code file. name your code file wish, remember chosen name hcppc command. result from this command will "file.o", which object file. Link object files using ldppcl command invoke linker program included with Metaware compiler using following command Command Prompt: ldppc start_addr=70000 file.o Note: "File.o" object file generated last step. object file will named exactly named code file.) result from this step will file "a.hex". DINK32 application your Windows terminal. Download "a.hex" file, which resulted from last step. write DINK monitor. terminal will appear, "Set Keyboard Port". Press Transfer->Send Text File communication terminal's menu. Find your "a.hex" file select file will downloaded Excimer board. Execute program writing 70000" terminal. Observe behavior on-board LED's. What happens decrease/increase value parameter your loop statement? References: Motorola, Designing Minimal PowerPC System, PowerPC Application Note: AN1769/D, 1998. Suggested Code: This program will blink status Error LEDs alternatively times. After that, both LEDs will shut down. 0xfffff will cause visible delay 300MHz PowerPC*/ Main unsigned long count; loop; (loop loop loop++) *(char (0x40200000) 0x00; //turn status *(char (0x40600000) 0x08; //turn error for(count count 0xfffff; count ++); *(char (0x40200000) 0x08; //turn status *(char (0x40600000) 0x00; //turn error for(count count 0x1fffff; count ++); *(char (0x40600000) 0x08; Conclusions: Students should able note that: speed, which drives PowerPC microprocessor, very fast thus blinking effect might perceived. different loop parameters, will remain different time period. LED's configured Common Anode (negative terminal connected together). Troubleshooting: student able turn check that: address being written either 0x40600000 0x40200000. suitable value time delay loop been defined. student compiled, linked downloaded program correctly. Experiment Control from Keyboard Problem Statement: This experiment requires compilation, downloading, execution language program which blinks Excimer Board's ERROR Light Emitting Diode (LEDs) number times specified user input. (Contributed Noel Serrano Objectives: Upon completion this laboratory experience, students will able DINK functions presented experiment print DINK interface capture single characters from keyboard echo them DINK interface Procedure: Write program that will blink board LED's based user input. program should user which wants blink many times. Hint: create this program program created previous experiment Useful DINK Functions. References: Motorola, Designing Minimal PowerPC System, PowerPC Application Note: AN1769/D, 1998. Suggested Code: #include <stdio.h> #define #define #define getchar dink_get_char putchar dink_write_char printf dink_printf void blink_leds(int addr, unsigned long (*dink_get_char)() (unsigned long (*)()) 0x1e4c4; unsigned long (*dink_write_char)(char) (unsigned long (*)(char)) 0x5eb4; unsigned long (*dink_printf)() (unsigned long (*)()) 0x6270; main() decimal_no; char LED; char number; printf ("\nSelect want blink:\n"); printf ("\tS Press Status LED\n"); printf ("\tE Press Error LED\n"); printf ("\tQ Press Quit\n"); getchar(); Read typed Character (LED 'e') printf ("\nEnter number times (1-9) LED: number??? number getchar(); }while !((number '0') (number '9')) putchar(number); echo typed character decimal_no number blink_leds(0x40600000, decimal_no); else (LED 's') printf ("\nEnter number times (1-9) Status LED: number getchar(); }while !((number '0') (number '9')) putchar(number); decimal_no number -48; blink_leds(0x40200000, decimal_no); while return blink blink void blink_leds(int addr, unsigned long count; loop; (loop loop loop++) *(char (addr) 0x00; //turn error for(count count 0xfff00; count ++); *(char (addr) 0x08; //turn error for(count count 0xfff00; count ++); *(char (0x40600000) 0x08; Conclusions: Students should able note that: PowerPC Excimer Board program obtain data from user Keyboard. getchar function useful cases need more than character input, implementation scanf function would useful. Troubleshooting: student able Access DINK interface functions: command verify that address DINK functions matches ones provided this manual. Blink LEDs: verify memory mapping each LEDs. Experiment simple scanf function Excimer Problem Statement: this experiment student will develop function taking character input from terminal emulator's keyboard attached Excimer through serial port converting number characters decimal values used other programs. (Contributed Chuck Corley, Motorola) Objectives: Upon completion this laboratory experience, students will able substitute getchar putchar equivalent functions available DINK same functions normally found <stdio.h> recognize ASCII character values returned from getchar() echo them back putchar() convert digit characters input through keyboard into decimal integer values other programs utilize DINK's print output function display resulting decimal value Background Information: Texts programming describe input program. example, Waite Group's Primer Plus says: library contains several input functions, scanf() most general them, read variety formats. course, input keyboard text because keys generate text characters: letters, digits, punctuation. When desire enter, say, integer 2002, type characters want store that numerical value rather than string, your program convert string characterby-character numerical value. that what scanf() does! converts string input into various forms: integers floating-point numbers, characters, strings. inverse printf(), which converts integers, floating-point numbers, characters, strings text that displayed screen. Like printf(), scanf() uses control string followed list arguments. control string indicates into which formats input converted. DINK software Excimer provides input output functions that save programmer from having interact directly with duart that receives input sends output terminal. However these functions level complex function like scanf(). Nevertherless, many programs that desire Excimer call scanf() function because it's widespread use. this experiment, will write your function my_scanf() substitute #define directive) scanf() function that compiler encounter programs intended Excimer. Likewise will define dink_printf() substitute printf() link dink_printf() into your programs. Then will have input output functions other programs. keep my_scanf() simple will assume that only control string converting inputs decimal format. Your my_scanf() function should accept control string argument then ignore return decimal value second (and last) argument functional call. Later experiments require more sophisticated substitute functions scanf(), this simple decimal input routine will widely applicable. Eximer's dink_printf() does accept control string ignores floating-point character formats. will only print decimal numbers (%d), hexadecimal numbers (%x), strings (%s) then only such format printf statement. Procedure: Write language program which asks user input number through keyboard then outputs number input positive decimal number. separate file write program my_scanf(char, int) which reads characters from keyboard, echoes those that digits, carriage return assigns decimal value second argument my_scanf(). Hint: While ignoring non-digit characters acceptable simplification, want check backspace delete characters take appropriate action user attempts correct numerical input. Write header file which equates function name scanf my_scanf printf dink_printf. header file equate dink_printf address where stored revealed DINK's symtab (symbol table) command. Include this header file your test program. Example: File support.h Equates functions used Excimer Exercise equivalent functions defined DINK my_scanf.c NOTE: DINK function addresses change because DINK changes, addresses here must changed accordingly. Modification history: 19Jan99,CJC Original #define #define printf dink_printf scanf my_scanf extern void my_scanf(const char unsigned long (*dink_printf)() (unsigned long (*)()) 0x6368; Your my_scanf() function will getchar() putchar(). Write header file equates these DINK's get_char write_char. Write header file which equates dink_get_char() dink_write_char() addresses where they stored revealed DINK's symtab (symbol table) command. Include this header file my_scanf.c program. Example: File excimer.h Provides addresses functions defined DINK Excimer board used programs. addresses functions taken from xref.txt file generated linker. When version DINK downloaded target, make sure functions' addresses changed accordingly match with addresses being generated. Modification history: 21Oct98,My Created ExcDemo 19Jan99,CJC Modified with my_scanf code. #define #define getchar dink_get_char putchar dink_write_char Addresses DINK functions. unsigned long (*dink_get_char)() (unsigned long (*)()) 0x1e5e4; unsigned long (*dink_write_char)(char) (unsigned long (*)(char)) 0x5fac; Link your input/output test program my_scanf program. Download resulting S-record file Excimer, execute confirm that echoes only digit characters returns correct decimal value your program carriage return. References: Waite Group's Primer Plus (1990: Howard Sams Carmel, Suggested Code: file "testscanf.c" test harness Excimer Experiment prove my_scanf() function. Modification History: 990121 Original #include "support.h" void main(void) decimal_no; printf ("Enter decimal number: scanf("%d", &decimal_no); printf ("\nDecimal number \n", decimal_no); file "support.c" Defines alternative scanf function provided stdio.h when running Dhrystone benchmarks DINK. Created: 990119 Modified: #include "excimer.h" void my_scanf(char *fmt, char no_runs while ((ch getchar()) 0xd) Carriage return? 0x7f) 0x8)) Delete? putchar(0x8); Backspace putchar(0x20); Overprint space. putchar(0x8); Backspace Assume modulo arithmetic subtract last digit added. no_runs no_runs else '0') '9')) digit? putchar(ch); Echo Accumulate value. no_runs (no_runs 48); ASCII character equals digit. no_runs; Assign second value. file "makefile" SUPPORT SUPPORTOPT OPTLEV TARGFLAGS -Hppc$(CPU) c:\sw\metaware\hcppc\bin\hcppc -Ic:\sw\metaware\hcppc\inc -Hnocopyr -nofsoft $(OPTLEV) $(TARGFLAGS) c:\sw\metaware\hcppc\bin\asppc -big_si LKOPT -Bbase=0x70000 main -Bnoheader -Bhardalign -xo=$(@) -Cglobals -Csections -Csymbols -Ccrossref $(@D)\xref.txt LINK c:\sw\metaware\hcppc\bin\ldppc $(LKOPT) testscanf.src: testscanf.o my_scanf.o $(LINK) testscanf.o my_scanf.o testscanf.o: testscanf.c $(CC) testscanf.c testscanf.o $(SUPPORTOPT) my_scanf.o: my_scanf.c $(CC) my_scanf.c my_scanf.o $(SUPPORTOPT) Conclusions: Students should able note that: Characters received from keyboard bytes ASCII encoded information. Input/Output functions normally available standard libraries given computer available exist different, simpler forms small, embedded evaluation system like Excimer Programmers write their input/output routines link routines that provided embedded system. Hard-coding addresses embedded routines dangerous linking code routines relocated DINK revisions. Troubleshooting: student able started. Suggest that student develop debug program host computer including <stdio.h> before substituting DINK routines downloading Excimer. This should clarify ASCII encoding digits conversion decimal number. Recognize carriage return character. Eximer will continous loop accepting echoing input. Additional printf() statements which output each character read will reveal value provided duart carriage return character.Troubleshooting: Experiment Introduction Assembly Language Programming Problem Statement: this experiment student introduced PowerPC instruction architecture through development assemblylLanguage routine. (Contributed Eisen Montalvo-Ruiz) Objectives: Upon completion this laboratory experience, students will able write compile assembly language subroutine Metaware Assembler directives understand instruction register PowerPC Background Information: PowerPC Register PowerPC architecture levels privileges, user mode, supervisor mode. supervisor mode registers available programmer, while user mode only subset registers available. going focus user mode this laboratory. user mode available PowerPC registers include General Purpose Registers (GPRs), Floating-Point Registers (FPRs), Condition Register (CR), Floating-Point Status Condition Register (FPSCR), register, Link Register (LR) Count Register (CTR). addition, there read-only registers, associated with Time Base Facility (TBU TBL). GPRs used manipulate integer data. They come sizes, according implementation processor. 32-bit GPRs 32-bit PowerPC 64-bits 64-bit PowerPC. They used source destination registers integer instructions. FPRs used with floating-point instructions. They bits wide independently implementation, manipulate single- double floating-point data. Related these registers FPSCR. contains floating-point exception signal bits, excluding summary bits, exception summary bits, exception enable bits, rounding control bits. 32-bit register, divided into eight 4-bit fields. This register contains results certain arithmetic operations provides testing branching. register indicates overflows carry conditions integer operations. register register like GPRs, their size depends implementation. supplies branch target address Branch Conditional Link Registers instructions. holds loop count that decremented during execution appropriately coded branch instructions. Time Base Facility consists 64-bit register, divided 32-bit registers, Time Base Upper (TBU) Time Base Lower (TBL). These registers will used future laboratory, where will learn more about them. PowerPC Instruction PowerPC Instruction very powerful extensive. contains around instructions, excluding suffices. don't have space cover them. now, going work with Integer Arithmetic, Load Store, Flow Control instructions. general description format instructions will given. More information obtained from PowerPC programming references. Integer Instruction Integer Arithmetic Instructions add, subtract, multiply, divide integer numbers. immediate values registers. Also, register register instructions available. general description format instructions follows. Immediate Values opcode SIMM where destination register, source register SIMM Signed Immediate value. Register Register opcode where destination register source registers. Integer Compare Instructions These instructions used conjunction with branch instructions control flow program. They affect such that branch instructions choose their target address based what happened previous instruction. course, they could used only comparing. Immediate Values opcode SIMM where register want compare Signed Immediate value Register Register opcode where register want compare register Load Store Instruction Load Store instructions allow data movement between memory register locations. They have three addressing modes. anyone them, address calculation will zero instead value Register Indirect with Immediate Index Addressing opcode SIMM(rA) loading then destination register. will contain value that stored memory address that SIMM value register storing then memory address that SIMM with value register will contain value stored register Register Indirect with Index Addressing opcode loading then destination register. will contain value that stored memory address that value register value register storing then memory address that value register with value register will contain value stored register Register Indirect Addressing opcode loading then destination register. will contain value that stored memory address that value register storing then memory address that value register will contain value stored register Branch Instructions These instructions commonly used with compare instructions. place branch after compare, using result make decision. opcode label where label address code where want branch assembler takes care translating label address. Metaware Assembler Directives assembler directives instructions assembler configure data where code data memory. most useful are: .text identifies where code section starts. .data mark start data section .word <value> reserves space word memory .org <address> starting address following code and/or data .global <label> makes this routine public one. comments line, they must begin with "!". addition, labels branching. They must with semicolon must beginning line, with without code same line. Metaware Assembly Compilation compiling your code using Metaware, must through steps. First compile code using asppc, Metaware Assembler. asppc filename.o filename.s extension file must *.s. this Assembler recognizes file. option tells assembler name object file. don't default name same code file with extension. second step convert object Motorola record again address code data section. elf2hex .text:0x70000,.data:0x70100 filename.hex filename.o option used tell where section file starts memory. this case, .text section will start address 0x70000 .data section 0x70100. option name output file. tells program generate Motorola record filename.o file object file. Procedure: Write assembly language routine that multiplies Matrices. Remember: where matrix dimension. Hint: start matrices memory, know where code look data. Also, make flexible, change size matrices without making changes your code. References: Motorola, PowerPC Microprocessor Family: Programming Environments 32-Bit Microprocessors, MPCFPE32B/AD, 1/97. Suggested Code: !file "matmult.s" Assembly Language program multiply matrices 990321 Register usage: Pointer start data section miscellaneous Pointer matrix Pointer column matrix holds temporary result calculations CODE Section .org 0x60000 .text .global mat_mult mat_mult: addic !Clear addi cmpw another_i: addi addi r12, 108(r9) exit r10, r12, 108(r9) !Load immediate shifted !Pointer data section !Load R5>=R12 then !goto exit, else !Clear !Load immediate shifted !Pointer data section !Load R12<=0 then !goto incr_i, else !Clear !Load immediate shifted !Pointer data section cmpwi r12, incr_i another_j: addi addi r11, r12, 108(r9) !Load R12<=0 then !goto incr_j, else !Pointer using !Pointer using !Pointer !Load immediate shifted !Pointer data section !Load !Pointer using !Pointer using !Pointer !Add start address data section !Load !Aik*Bkj !R12=i+j !Pointer !Load !Cij+=Aik*Bkj !Store !Increment !Load R12>R11 then !goto another_k, else !Increment !Load immediate shifted !Pointer data section !Load R12>R10 then !goto another_j, else !Increment !Load immediate shifted !Pointer data section cmpwi r12, incr_j another_k: mulli slwi r12, r11, addi lwzx r12, r12, r12, mulli r12, r11, slwi r10, r12, r12, r12, r12, 36(r12) mullw r12, incr_k: addi cmpw incr_j: addi addi cmpw incr_i: addi addi r10, r10, r12, 108(R9) r12, another_j r11, r11, r12, 108(r9) r12, another_k r12, r12, r12, 72(r8) r12, r12, r12, 72(r8) cmpw exit: r12, 108(R9) another_i !Load R5<R12 then !goto another_i, else !exit !DATA section .org 0x600d0 .data matrix_a: .word .word .word .word .word .word .word .word .word matrix_b: .word .word .word .word .word .word .word .word .word matrix_c: .word .word .word .word .word .word .word .word .word .word Conclusions: Students should able note that: Programming assembly complex. However, increase performance smaller size resulting code makes worth some cases. This routine alone very useful, next laboratory going show interface assembly routine C/C++ program. Troubleshooting: student able started. Suggest that student code multiplication program until they have proven their algorithm. they still having difficulty, disassembly program could provide insight. Experiment Linking Assembly Language Code Problem Statement: This experiment introduces student linking PowerPC assembly language code. (Contributed Eisen Montalvo-Ruiz) Objectives: Upon completion this laboratory experience, students will able call assembly routine from C/C++ program know PowerPC function-calling sequence Background Information: following information excerpted directly from Chapters "High C/C++ Programmer's Guide PowerPC". This document obtained from Metware through their website. Making assembly routine callable from program able call assembly language routine from program must insert this piece code before assembly routine: .text .align .global name name: going "name" call routine from program. Calling assembly routine from each assembly function want call, have declare external. Then pragma directive Alias linking internal name external name. following code should make clearer: extern foobar(); #pragma Alias(foobar,"name"); void main() foobar(); Function-Calling Sequence most difficult parts assembly language programming parameter passing function calls. Fortunately, PowerPC function-calling parameter passing among easiest realm assembly programming. Here goes brief description this process. want more information, read books reference section. Stack-Frame Layout Figure shows memory stack frame organization PowerPC system. Every function needs establish their stack frame, stack frame only necessary function going call another function. Figure Standard Stack Frame High Address Back-Chain Word Floating-point register save area General register save area onditional register save area FPSCR save area Local variable space (padding allowed here only) Parameter list area Link register save word Stack frame header Stack grows down Stack frame most recently called function Stack Pointer Address Back-Chain Word stack frame grows downward from high memory address, 16-byte aligned. doesn't have maximum size minimum. minimum stack frame consists stack-frame header, with padding 16-byte alignment. padding must occur within local variable area. Stack pointer points Back-Chain word most recently called function. This forms linked list stack frames. stack frame include following areas required function: Floating-point register save area non-volatile floating-point registers modified General register save area non-volatile general registers modified save area condition register fields modified FPSCR save area floating-point status control register bits modified Local variable space local variables function mapped registers Parameter list area allocated caller function; must large enough contain arguments that caller stores save word contents link register they were time entry function Back-chain word pointer previous stack frame's back-chain word parameter list area preserved across function calls must follow stack frame header immediately. Register usage Table contains usage status registers function calling process. Non-volatile registers "belong" calling function. called function wants them, must save their values before using registers restore them before returning. Volatile registers preserved across function calls, them without saving them. Also can't dedicated reserved registers. corrupt system them. Table PowerPC Register Usage Register Name r3-r4 r5-r10 r11-r12 r14-r30 f2-f8 f9-f13 f14-f31 Status Volatile Dedicated Dedicated Volatile Volatile Volatile Reserved Non-Volatile Non-Volatile Volatile Volatile Volatile Volatile Non-Volatile Usage Language-specific purposes Stack frame pointer, always valid Reserved system Parameter passing return values Parameter passing Language-specific purposes Small data area pointer Local variables Local variables "environment pointer" Language-specific purposes Parameter passing return values Parameter passing Scratch Local variables FPSCR0-23 FPSCR24-31 Parameter passing Volatile Volatile Non-Volatile Non-Volatile Non-Volatile Volatile Volatile Volatile Volatile Volatile Volatile Volatile Modifiable Condition Register fields, each four bits wide (Bit Floating-point invalid operation exception) Link Register Count Register Fixed-Point Exception Register Floating-Point Status Control Register (Exception-enable rounding-control bits) maximum eight integer arguments passed general purpose registers through maximum eight floating-point arguments passed through number parameters less than maximum, unneeded registers contain undefined values. parameters passed those registers, function must allocate stack frame. should allocate minimum space needed parameters that registers. function wants return value, table shows they passed, according their type. Table PowerPC Function Return Values Function Return Type float double long enum short char pointer type long long unsigned long Return Regis- Comment Returned unsigned signed integer appropriate), zero- signed-extended bits necessary Returned with lower-addressed word higher-addressed word struct(less than equal bytes) union(less than equal bytes) long double struct(greater bytes) than Storage Buffer returned following steps occurred: struct union first stored 8-byte aligned memory area. low-addressed word loaded into high-addressed word loaded into address this buffer passed hidden argument Metaware Compiling When combining assembly can't compile like last laboratory. This example compiling assembly using hcppc, Metaware C/C++ compiler. hcppc -Hppc603 -Hldopt=-e,main -Hldopt=-B,start_addr=70000 -Hldopt=-x -Hldopt=-m c_code.c assembly_code.s option -Hppc603 tells compiler generate PowerPC code. -Hldopt options passed linker. value after equal sign option value after comma value option. example tells linker what function starting point code. this example, starting point main function. values. most useful start_addr. tells where code starts memory. this example, code starts 0x70000. generates list file code. standard output screen. redirection send output file. finally tells linker generate Motorola records, ready downloaded Excimer Board. last parameters filenames Assembly code. output code will named "a.hex". Procedure: Write assembly language routine that multiplies matrices language program that asks user size matrices, their initial values shows resulting matrix. program should call assembly routine. Hint: assembly routine made last laboratory. followed hint that laboratory, shouldn't need make many changes. References: Motorola, PowerPC Microprocessor Family: Programming Environments 32-Bit Microprocessors, MPCFPE32B/AD, 1/97. Suggested Code: file MatrixMult.c program that calls assembly routine. asks user size initial values matrices then shows results their multiplication. 990407 #define scanf my_scanf Useful Functions #define getchar dink_get_char #define putchar dink_write_char #define printf dink_printf void my_scanf(char Pointers functions Dink Memory unsigned long (*dink_get_char)() (unsigned long (*)()) 0x1e4c4; unsigned long (*dink_write_char)(char) (unsigned long (*)(char)) 0x5eb4; unsigned long (*dink_printf)() (unsigned long (*)()) 0x6270; Assembly Routine extern matrixmult(int size, *result, *mata, *matb); Alias(internal name, external name) #pragma Alias (matrixmult,"matmult") *mata; First Matrix *matb; Second Matrix *matc; Resultant Matrix size; Matrices Size *malloc(unsigned int); Memory Allocation function proto*/ void main() temp; user size printf("Enter size matrices scanf("%d",&size); printf("\n"); Separate memory matrices mata malloc(size*size); matb malloc(size*size); matc malloc(size*size); user initial values for(int j=0; j<size; j++) for(int m=0; m<size; m++) printf("A%d",j+1); printf("%d ",m+1); scanf("%d", &temp); printf("\n"); mata[j*size+m]=temp; printf("B%d",j+1); printf("%d ",m+1); scanf("%d", &temp); printf("\n"); matb[j*size+m]=temp; Clear resultant matrix memory matc[j*size+m]=0; Calling assembly routine matrixmult(size, matc, mata, matb); Display results for(i=0; i<size; i++) printf("| for(l=0; l<size; l++) printf("%d ",mata[i*size+l]); printf("| if((i+1)==(size/2)) printf("*"); else printf(" printf(" for(l=0; l<size; l++) printf("%d ",matb[i*size+l]); printf("| if((i+1)==(size/2)) printf("="); else printf(" printf(" for(l=0; l<size; l++) printf("%d ",matc[i*size+l]); printf("|"); printf("\n"); User Input Function Chuck Corley void my_scanf(char *fmt, char no_runs while ((ch getchar()) 0xd) Carriage return? 0x7f) 0x8)) Delete? putchar(0x8); Backspace putchar(0x20); Overprint space. putchar(0x8); Backspace Assume modulo arithmetic subtract last digit added. no_runs no_runs else '0') '9')) digit? putchar(ch); Echo Accumulate value. no_runs (no_runs 48); ASCII character equals digit. no_runs; Assign second value. Memory Allocation Function Chuck Corley *malloc(unsigned size) static buffer[2048]; static *next buffer; next; next ((size ~7); (next buffer sizeof(buffer)) Terminate executing zero. asm(".long 0"); return !file "matmult.s" Assembly Language program multiply matrices 990407 Parameters: size pointer matrix pointer matrix pointer matrix Register usage: temp offset current value cell matrix offset current value cell matrix offset current value cell matrix CODE Section .org 0x60000 .text .align .global matmult matmult: r14, r14, !Clear r17, r17, !Clear cmpw another_i: another_j: another_k: mullw slwi lwzx mullw slwi lwzx r14, exit r15, r15, r16, r16, r18, r18, r18, r18, r19, r19, r19, r19, r14, r18, r18, r16, r19, r19, i>=size then !goto exit, else !Clear !Clear !Offset using !Offset using !Multiply we're loading words, bytes !Load !Offset using !Offset using !Multiply we're loading words, bytes !Load !Aik*Bkj !Cij+=Aik*Bkj !Increment k<size then !goto another_k, else !Offset using !Offset using !Multiply we're using words, bytes !Store !Clear Temp another cell !Increment j<size then mullw r17, r21, r23, r23, incr_k: addi cmpw r16, r16, r16, another_k save_val: mullw r20, r14, r20, r20, slwi r20, r20, stwx r17, r17, r17, incr_j: addi cmpw r15, r15, r15, incr_i: addi cmpw exit: another_j r14, r14, r14, another_i !goto another_j, else !Increment i<size then !goto another_i, else !exit Conclusions: Students should able note that: Linking assembly routines very important those cases where complexity problem hand requires high level language where performance certain routines within problem crucial. Troubleshooting: student able parameters assembly function: list file know where assembly function parameters memory. Then look assembly code program call assembly function. Before call will where code putting parameters registers assembly function. This could help understand function-calling sequence. Experiment Converting Integers Floating Point Problem Statement: This experiment requires development assembly language subroutine convert integer value read from PowerPC time base facility (double) floating point number representing seconds. (Contributed Chuck Corley, Motorola) Objectives: Upon completion this laboratory experience, students will able write assemble assembly language subroutine call assembly language subroutine from program values returned convert integer numbers PowerPC floating point representation convert time base count values seconds wall clock time Background Information: PowerPC architecture requires each microprocessor implementation provide time base facility (TB), 64-bit structure that consists 32-bit registers time base upper (TBU) time base lower (TBL). User level applications permitted read-only access which useful timing program execution providing time reference. update frequency time base system-dependent algorithm converting current value time base time also system-dependent. MPC603e microprocessor used Excimer board increments one-fourth SYSCLK (bus) frequency. Excimer does have real time clock chip would found most computers. cleared each power-up they initial value supervisor mode). facility then counts one-fourth SYSCLK frequency from this initial value. Excimer cannot relate value real time without user assistance like setting watch. SYSCLK crystal controlled 66.6666MHz (see oscillator board U15), therefore increments 16,666,667 times second. When exceeds 232, carry-out increments TBU. Thus, will increment every 257.7 seconds total range 1.1x1012 seconds approximately 35,000 years. This number better represented application programs floating point value. PowerPC architecture represents double precision floating point values 64-bit format shown Figure FRACTION Figure Floating-Point Double-Precision Format Where (sign bit) (exponent bias) FRACTION (fraction) numeric values, significand consists leading implied concatenated right with FRACTION. normalized numbers unnecessary deal with denormalized floating point numbers this excercise) implied first left binary point. Normalized numbers interpreted follows: NORM (-1)S 2(EXP 1023) (1.FRACTION) range covered magnitude normalized double-precision floating-point number approximately: 2.2x10-308 10308 double precision exponent biased adding 1023 that positive negative exponents represented without sign exponent. Example exponents shown Table Biased Exponent (Binary) 111_1111_1111 111_1111_1110 111_1111_1101 100_0000_0000 011_1111_1111 111_1111_1110 000_0000_0001 000_0000_0000 Unbiased Exponent (Double-Precision) Reserved infinities NaNs +1023 +1022 -1022 Reserved zeros denormalized numbers Table Biased Exponent Format Examples integer values converted double precision floating point representation shown Table Since would take 35,000 years test conversion program upper limits this experiment should include test program that supplies these example values integer-tofloating point assembly-language conversion routine verifies that correct floating point value returned. last column Table shows floating point value converted seconds given Excimer's 66MHz clock. count (decimal) 524,288 1.57e6 3.67e6 (hex) 0000_0000 0000_0000 0000_0000 0000_0000 0000_0000 0000_0000 (hex) 0000_0000 0000_0001 0000_0002 0008_0000 0018_0000 0038_0001 biased (dec) +1023 +1024 +1042 +1043 +1044 FRACTION (hex) 0_0000_0000_0000 0_0000_0000_0000 0_0000_0000_0000 0_0000_0000_0000 8_0000_0000_0000 C_0000_8000_0000 Floating Value (hex) 0000_0000_0000_0000 3FF0_0000_0000_0000 4000_0000_0000_0000 4120_0000_0000_0000 4138_0000_0000_0000 414C_0000_8000_0000 Seconds (dec) 0.00 6.00e-8 1.20e-7 3.15e-2 9.44e-2 2.20e-1 1.67e7 3.22e9 1.29e10 1.58e16 1.84e19 0000_0000 0000_0000 0000_0003 0038_0001 FEDC_BA98 00FE_502B C000_0401 4000_5001 4001_0005 7654_3210 +1046 +1054 +1056 +1076 +1086 F_CA05_6000_0000 8_0000_8020_0000 A_0002_8008_0000 C_0000_A000_8002 F_DB97_530E_CA86 416F_CA05_6000_0000 41E8_0000_8020_0000 4208_0002_8008_0000 434C_0000_A000_8002 43EF_DB97_530E_CA86 1.00 1.93e2 7.73e2 9.46e8 1.10e12 Table Example Floating Point Conversions Procedure: Write assembly language routine which accepts unsigned integer arguments returns double float value. Suggestion: Assembly language routines used primarily speed access hardware resources that otherwise available). make this routine faster, using static branch prediction. example, value zero tested special case form unlikely. Likewise, values over unlikely (why would there conditional branch this value?) Hint: find assembly language instructions cntlzw rlwnm very useful. Write program which calls assembly language routine with example values Table check that returns correct floating point value. Reminder: DINK Version 10.5 provides dink_printf routine that used print results terminal. However, will format floating point numbers; results will have displayed unsigned long values. there construct which will permit viewing 32bit memory locations both unsigned long double? Write assembly language routine that reads Excimer's facility and, using Excimer's clock speed 66.6666Mhz, returns seconds double-precision floating point number. Caution: must read separate instructions. unlikely, possible, that could increment between reading these registers. Consider sequence 0x0000_0000, 0xFFFF_FFFF; 0x0000_0001, 0x0000_0000. What would error your assembly language routine first value second value TBL? Would reading registers reverse order avoid this problem? Suggestions: This assembly language routine useful other programs. Saving standalone file "timer.s" then linking with this other programs will make more useful. header file, e.g. "Excimer.h," might convenient place define constants like EXCIMER_BUS_SPEED that could change other PowerPC systems. Write program which outputs zero twenty second count terminal emulator time with stopwatch. (Using dink_printf display seconds integer decimal numbers acceptable). References: Motorola, PowerPC Microprocessor Family: Programming Environments 32-Bit Microprocessors, MPCFPE32B/AD, 1/97. Suggested Code: file "Excimer.h" Header file Excimer-unique constants Excimer oscillator (U15 PWB) runs 66.6666MHz #define BUS_FREQUENCY 66666667 ticks/sec Excimer clock. double TICS_PER_SEC BUS_FREQUENCY/4; frequency integer MHz. IBUS_MHz BUS_FREQUENCY/1000000; Excimer does support <stdio.h>. DINK it's print routine called dink_print which supports limited number format types (decimal-%d, hex-%x, string-%s, etc). Redefining printf point dink_print function, enables standard programs downloaded Excimer print terminal. address dink_print available from symbol table command (symtab) DINK. version DINK Excimer updated from Motorola website address dink_print must updated here. #define printf dink_print unsigned long (*dink_print)() (unsigned long 0x6368; file "Exercise.h" Header file common typedefs Exercise? Chuck Corley struct TB_View unsigned long TBU_View; unsigned long TBL_View; union DPFP_View struct TB_View TB_FPasGPR_View; double TB_FP_View; struct TB_View TB_GPR_View; DPFP_View TB_FP_test; 981218 struct Test_struct union !file "dtime.s" (For Metware High C/C++ Compiler/Assembler) Assembly language routine convert 64-bit PowerPC facility Double-precision, floating-point number. (Plus additional routines testing.) 981216 Register usage: (upper bits floating point value) (lower bits floating point value) TBU(time base upper read from loaded test) TBL(time base lower read from loaded test) leading zeroes register shift count +/-(zeroes accumulator final EXPonent value DPFP number shift count where +/-(zeroes -11) constant register link register storage #define 269; !Special purpose register numbers #define 268; .data Local_storage: .double .text .global dtime .global get_HID1 .global conversion_test !For CodeWarrior: !asm double conversion(double TICS) conversion: cntlzw r7,r5 !Find leading zeroes TBU. Preserve addi r9,r0,32 !Will need several places. Create addi r10,r0,11 !Create constant subf. r8,r7,r9 will hold EXP. Currently leading zeroes) beq+ tbu_is_zero !TBU never incremented? (Zeroes=32?) (Most likely) subf. bge+ r7,r10,r7 r8,r8,r9 tbu_lt_8yrs !No. more than 2^^52? (Zeroes<11?) (Z-11) !Final exponent will leading zeroes). TB>2^^52, shift bits right. (Not likely) tbu_gt_8yrs: subf rlwnm rlwnm rlwnm !for Z<11: tbu>>n=(11-Z); !fpl tbu<<n=(32-(11- Z))|tbl>>n=(11-Z); r7,r7 !rlwnm shift count (11-Z) -(Z-11) r9,r7,r9 !rlwnm shift count 32-n (11-Z) r3,r5,r9,12,31 !Shift right Mask [0:11]. r4,r5,r9,0,10 !Shift remaining bits left 32-(11-Z) r6,r6,r9,0,31 !Shift right r4,r6,r4 rest shifted left with shifted right. form_exponent bias exponent into FPU. tbu_lt_8yrs: subf rlwnm rlwnm !for Z>=11: !fpl=tbl<<n=(Z- 11); r9,r7,r9 !Form shift count (11-Z) r3,r5,r7,12,31 !Shift left (Z-11). Mask [0:11]. r5,r6,r9 !Shift bits right 32-(Z-11). r3,r3,r5 shifted left with shifted right. r6,r6,r7,0,31 !Shift remainder left (Z-11). r4,r6,r5 !XORing with same value shifted right like ANDing form_exponent !fpl with mask zeroes bits [32-(Z-11):31]. !Find leading zeroes TBL. !EXP leading zeroes). tbu_is_zero: cntlzw r7,r6 subf. r8,r7,r9 beqsubf. bge- tbl_is_zero r7,r10,r7 tbl_lt_63ms !Entire count exactly zero? (Not likely) !No. less than 2^^20? (zeroes 11?) not, will have shift bits right. (Most likely) tbl_gt_63ms: !for z<11: tbl>>n=(11-z); tbl<<n=(32-(11-z)); r7,r7 !rlwnm shift count (11-Z) -(Z-11) subf r9,r7,r9 !rlwnm shift count 32-n (11-Z) rlwnm r3,r6,r9,12,31 !Shift right Mask [0:11]. rlwnm r4,r6,r9,0,10 !Shift remaining bits left form_exponent tbl_lt_63ms: !for z>=11: tbl<<(z-11); rlwnm r3,r6,r7,12,31 !Shift left (Z-11). Mask bits 0-11. r4,r4,r4 !fpl form_exponent tbl_is_zero: r3,r3,r3 r4,r4,r4 compute_seconds !for Z=32 z=32: !Unlikely result that zero. Prepare !return zeroes floating point value. form_exponent: addi r8,r8,1022 !Add bias (1023) exponent rlwinm r8,r8,20,1,12 !Biased will (63-(leading zeroes TB)+1023). r3,r3,r8 compute_seconds: Local_storage@h Local_storage@l 0(r5) 4(r5) 0(r5) !Load back 64bit float fdiv f1,f2,f1 !Divide clock ticks second !Return time seconds double Routine passed sample values TBL. Returns unsigned long. !For CodeWarrior: !asm struct TB_View conversion_test(unsigned long Upper, unsigned long Lower, double TICS) conversion_test: r5,r3,r3 !Use test values passed r6,r4,r4 substitutes values read from mflr !Save return address. conversion !Convert into mtlr !Return !For CodeWarrior: r3,Local_pointer(SP)!Return pointer storage location. Routine passed sample values TBL. Returns seconds double. !For CodeWarrior: !asm double float_test(unsigned long Upper, unsigned long Lower, double TICS) float_test: mflr mtlr r5,r3,r3 r6,r4,r4 !Use test values passed substitutes values read from !Save return address. conversion !Convert into !Return double fpr1 Routine reads TBL. Returns seconds double. !For CodeWarrior: !asm double dtime(double dtime: read_TB: mfspr r5,TBU mfspr r6,TBL mfspr r7,TBU subf. r7,r5,r7 bgtread_TB mflr conversion mtlr TICS) !Get TBU. !Get TBL. !Get again. !Did increment between reading TBL? read them again. (Not likely) !Save return address. !Convert into Routine reads HID1 (PLL_CFG) register. Returns get_HID1: mfspr r3,1009 !Get HID1 register. file "test_program.c" Tests operation assy language routine convert PowerPC TimeBase values from integer floating point values. Chuck Corley 981214 #include <stdlib.h> #include "Excimer.h" File Excimer board-specific constants #include "Exercise.h" File common typedefs this exercise struct TB_View conversion_test(int, int, double); Given freq, returns time seconds. void main(void) MAX_EXAMPLES; struct Test_struct Example[] Consider Case1: Z<11; Case2: Z>=11; Case3: z<11; Case4: z>=11; Case5: Z=z=32; Case5: leading zeroes. 0x00000000, 0x00000000, 0x00000000, 0x00000000}, Case4: Single treat implied bit. Move from TB[32+31] DPFP[11]. 0x00000000, 0x00000001, 0x3FF00000, 0x00000000}, Case4: Single treat implied bit. Move from TB[32+30] DPFP[11]. 0x00000000, 0x00000002, 0x40000000, 0x00000000}, Case4: Single treat implied bit. Move from TB[32+12] DPFP[11]. 0x00000000, 0x00080000, 0x41200000, 0x00000000}, Case4: FRACTION starting TB[32+12]. Move DPFP[12:31]. 0x00000000, 0x00180000, 0x41380000, 0x00000000}, Case3: FRACTION starting TB[32+11]. Move DPFP[12:32]. Check DPFP[32]=1. 0x00000000, 0x00380001, 0x414C0000, 0x80000000}, Case3: FRACTION (One sec) starts TB[32+9]. Move DPFP[12:34]. DPFP[32:34]=6? 0x00000000, 0x00FE502B, 0x416FCA05, 0x60000000}, Case3: FRACTION TB[33:63]. FPU[12:31]=TBL[1:20]. FPL[0:10]=TBL[21:31]. 0x00000000, 0xC0000401, 0x41E80000, 0x80200000}, Case2: FRACTION-TB[31:63]. FPU[12]=TBU[31]. FPU[13:31]=TBL[0:18]. FPL[0:12]=TBL[19:31].*/ 0x00000003, 0x40005001, 0x420A0002, 0x80080000}, Case1: FRACTION-TB[11:63]. FPU[12:31]=TBU[11:30]. FPU[0]=TBU[31]. FPL[1:31]=TBL[0:30].*/ 0x00380001, 0x40010005, 0x434C0000, 0xA0008002}, Case1: TB[1:63]. FPU[12:31]=TBU[1:20]. FPL[0:10]=TBU[21:31]. FPL[11:31]=TBL[0:20].*/ 0xFEDCBA98, 0x76543210, 0x43EFDB97, 0x530ECA86}, struct Test_struct Result; MAX_EXAMPLES sizeof(Example) sizeof(Example[0]); (i=0; MAX_EXAMPLES; i++) These printf formats restrictive dink_print routine. printf("TBU= printf("TBL= conversion_test TICS_PER_SEC); printf(" ERROR!\n"); printf("FPU= printf("FPL= %x\n", useful This useful Excimer because can't print floating point result. check CodeWarrior Mac. CJC*/ Result.TB_FP_test.TB_FP_View TICS_PER_SEC); printf("FPR %4.2e \n", Result.TB_FP_test.TB_FP_View); return; file "watch.c" Reads PowerPC Time Base Facility Excimer prints twenty second count terminal emulator. Chuck Corley 981214 #include <stdlib.h> #include "Excimer.h" File Excimer board-specific constants #include "Exercise.h" File common typedefs double dtime(double); Given freq, returns time seconds. unsigned long get_HID1(); Returns HID1 register. void main(void) double begin_time, current_time, delta_time 0.0, seconds 0.0; int_seconds; unsigned long HID1_Reg; printf("PowerPC Timer Test.\n"); printf("Beginning twenty second count assuming speed 66.67MHz.\n"); printf("Please time me.\n"); printf("If your stopwatch time differs significantly from seconds, \n"); printf("we compute actual speed.\n"); begin_time dtime(TICS_PER_SEC); (int_seconds int_seconds int_seconds++) /*Countup start.*/ while (delta_time 1.0) current_time dtime(TICS_PER_SEC); delta_time current_time (int_seconds) begin_time; delta_time 0.0; switch (int_seconds) case break; Delay stopwatch ready. case printf("Start now!\n"); Begin timing zero seconds. break; case printf("%d second\n", int_seconds); break; printf("If your time seconds,\n"); printf("bus speed your_time) 66.67MHz.\n"); Bonus Exercise. Given speed, calculate processor (core) speed.*/ HID1_Reg get_HID1() Move HID1[0:3] [28:31] printf("HID1 indicates PLL_CFG=%x.\n", HID1_Reg printf("If bus=%dMHz, IBUS_MHz); switch (HID1_Reg) case 0x4: PLL_CFG 0b0100 printf("Core Freq(2x)=%dMHz 2*IBUS_MHz); printf("VCO Freq(2x)=%dMHz\n", 2*IBUS_MHz); break; case 0x5: PLL_CFG 0b0101 printf("Core Freq(2x)=%dMHz 2*IBUS_MHz); printf("VCO Freq(4x)=%dMHz\n", 4*IBUS_MHz); break; case 0x6: PLL_CFG 0b0110 printf("Core Freq(2.5x)=%dMHz (int)(2.5*(float)IBUS_MHz)); printf("VCO Freq(2x)=%dMHz\n", 5*IBUS_MHz); break; case 0x8: PLL_CFG 0b1000 printf("Core Freq(3x)=%dMHz 3*IBUS_MHz); printf("VCO Freq(2x)=%dMHz\n", 6*IBUS_MHz); break; case 0xe: PLL_CFG 0b1110 printf("Core Freq(3.5x)=%dMHz ",(int)(3.5*(float)IBUS_MHz)); printf("VCO Freq(2x)=%dMHz\n", 7*IBUS_MHz); break; case 0xa: PLL_CFG 0b1010 printf("Core Freq(4x)=%dMHz 4*IBUS_MHz); printf("VCO Freq(2x)=%dMHz\n", 8*IBUS_MHz); break; case 0x7: PLL_CFG 0b0111 printf("Core Freq(4.5x)=%dMHz ",(int)(4.5*(float)IBUS_MHz)); printf("VCO Freq(2x)=%dMHz\n", 9*IBUS_MHz); break; case 0xb: PLL_CFG 0b1011 printf("Core Freq(5x)=%dMHz 5*IBUS_MHz); printf("VCO Freq(2x)=%dMHz\n", 10*IBUS_MHz); break; case 0x9: PLL_CFG 0b1001 printf("Core Freq(5.5x)=%dMHz ",(int)(5.5*(float)IBUS_MHz)); printf("VCO Freq(2x)=%dMHz\n", 11*IBUS_MHz); break; case 0xd: PLL_CFG 0b1101 printf("Core Freq(6x)=%dMHz 6*IBUS_MHz); printf("VCO Freq(2x)=%dMHz\n", 12*IBUS_MHz); break; case 0x3: PLL_CFG 0b0011 printf("PLL bypass!\n"); break; case 0xf: PLL_CFG 0b0011 printf("CLOCK OFF! this be???\n"); break; default: printf("ERROR INVALID PLL_CFG!"); HID1 switch return; default: printf("%d seconds\n", int_seconds); int_seconds switch Conclusions: Students should able note that: 64-bit rotate instruction would very useful synthesized 32-bit PowerPC architecture. PowerPC Embedded Application Binary Interface (EABI) specifies arguments passed assembly language routine values returned. syntax assembly language programs varies widely among compiler/assembler vendors. only pass data between integer registers (GPRs) floating point registers (FPRs) PowerPC writing reading memory. With wise register set, memory access pass information from GPRs FPRs only memory access assembly language routine needs thus improving performance. Troubleshooting: student able started. Suggest that student code conversion program until they have proven their algorithm. they still having difficulty, disassembly program could provide insight. desired returned values from function calls. This good opportunity breakpoints examine registers determine expected value being returned. Experiment Dhrystone Benchmarking Problem Statement: this experiment student will adapt popular Dhrystone benchmark execute Excimer board. Objectives: Upon completion this laboratory experience, students will able verify popular industry metric processor performance embedded applications, Dhrystone Version MIPs, PowerPC 603e microprocessor Excimer board. compare processor performance, measured Dhrystone, published values other processors. compare code generation instruction scheduling, resulting performance, several competing compilers Dhrystone benchmark. substitute more highly optimized routines built-in library functions provided compiler vendors improve performance. utilize dtime function Experiment measure elapsed time benchmark's execution. Background Information: Compararative performance computers popular topic computer scientists, computer architects, computer salesmen. Many performance measurements, benchmarks, have been used over last several decades compare various aspects computer performance. Some benchmarks involve running real applications, e.g. compiling compiler calculating spreadsheet, which heavily dependent resources particular operating system. Others small synthetic benchmarks designed representative workload class larger applications which meaningful work easier across various operating systems architectures. Dhrystone benchmark synthetic benchmark developed Reinhold Weicker SiemensNixdorf early eighties. first published "Communications ACM" vol. 27., (Oct. 1984), 1013 1030. easily ported many different operating environments results many computers widely published. embedded processors, where operating system system resources limited, been most often quoted performance measure. popular because provides number MIPS that compared quickly with other computers. (Vax MIPS calculated dividing number times that Dhrystone benchmark completes second number Dhrystones second performed now-ancient 11/780 from Digital Equipment Corporation.) other hand, widely disparaged because small that fits entirely within first level cache most modern microprocessors compiler vendors soon made game optimizing ever-higher MIPs numbers. Motorola publishes Dhrystone MIPs numbers PowerPC 603e processor Excimer board because number often requested. After first loop through benchmark, resides entirely cache PowerPC microprocessor. that point performance varies linearly with frequency results reflect efficiency micro-architecture effectiveness compiler generating code capitalize Motorola's published numbers 1.41 MIPs Mhz. Excimer board running 133Mhz keep comfortably cool still environment), that equates MIPs. Dhrystone benchmark (and numerous others) available it's official source code anonymous 'ftp.nosc.mil' directory 'pub/aburto'. address 128.49.192.51. Instructions exe- cuting benchmark "rules" execution available there well. Comparative results many computers available from same site from various news groups including 'comp.benchmarks'. Procedure: Download Dhrystone Version benchmark from site. Read associated instructions compilation execution. will find that benchmark calls library functions strcpy strcmp inside measurement loop printf scanf outside measurement loop. will also find that benchmark calls timer function dtime() that returns count seconds double floating point number. will need assemble link assembly language code from Experiment which reads PowerPC time base facility converts integer value time seconds based Excimer's 66Mhz speed. Reminder: Function calls such printf will have equated dink_printf routine print results terminal. Dhrystone also queries user scanf function number times benchmark. scanf function using DINK's getchar writechar will have written substituted number times through benchmark hard coded. hardcoding number runs, certain variable instead constant, constant would change benchmark inside measurement loop. Motorola makes changes benchmark which would unfairly change result when compared other results. Compile Dhrystone source code files, link dtime() function, execute benchmark Excimer board. Compare your results Motorola's published numbers. Hint: Maximum performance will obtained only when running entirely cache. SRAM access Excimer during execution then program running entirely from internal cache. DINK's regmod command needed enable instruction data cache (regmod HID0 value 8000c000). early versions DINK also require modifying data memory mapping unit (DMMU) make data accesses cacheable (regmod rbat1l value 00000012). Examine disassembled code. strcmp library function offers opportunity performance enhancement. Many libraries compare strings byte time. Motorola provides library highly optimized functions including strcmp their website assembly language strcmp from this library shown below. Notice that when possible this function compares strings four bytes word time, thus reducing memory this case, cache) accesses 75%. Assemble link this strcmp function place stdlib function. performance improve? Copyright, Motorola, Inc. Rights Reserved. This software contains proprietary confidential information Motorola, Inc. Use, disclosure reproduction prohibited without prior express written consent Motorola, Inc. #-#-# strcmp(const unsigned char* source1, const unsigned char* source2); Returns: value source1 source2 value source1 source2 value source1 source2 #-.set .set .set _eq,2 _cr0,0 _cr1,1 #aix# .toc #aix#T.strcmp: #aix# .strcmp[tc], strcmp[ds] #aix# .align #aix# .globl strcmp[ds] #aix# .csect strcmp[ds] #aix# .long .strcmp[pr],TOC[tc0],0 #aix# .globl .strcmp[pr] #aix# .csect .strcmp[pr] #aix#.strcmp: .sect .text .align .extern strcmp strcmp: #nt# .reldata #nt# .globl strcmp #nt#strcmp: #nt# .long .strcmp,.toc #nt# .text #nt# .globl .strcmp #nt#.strcmp: temporary source1 pointer, result, mask first words source2 pointer 0x80808080 0x01010101 source2 word source1 word temporary source1 pointer temporary index pointers both word aligned. r0,r3,r4 rlwinm. r0,r0,0,30,31 addis r6,r0,0x0101 r10,r3 Byte_By_Byte Generate initial index word containing first byte will loaded. Compute mask bits bytes prior first words that loaded. rlwinm r11,r3,3,27,28 r3,-1 rlwinm r12,r10,0,30,31 subfic r11,r11,32 r12,r12 r3,r3,r11 Complete setup word aligned loop. r6,r6,0x0101 lwzx r8,r12,r10 lwbrx r8,r12,r10 r8,r8,r3 Mask unused bytes. slwi r5,r6,7 subfc r0,r6,r8 andc r9,r5,r8 lwzx r7,r12,r4 lwbrx r7,r12,r4 and. r11,r0,r9 addi r4,r4,-4 addi r12,r12,4 r7,r7,r3 Mask unused bytes. Source1_Has_Null #le# #le# Word_Loop: subfc. lwzx #le# lwbrx subfc andc and. addi lwzx #le# lwbrx r3,r8,r7 Words_Differ r8,r12,r10 r8,r12,r10 r0,r6,r8 r9,r5,r8 r11,r0,r9 r12,r12,4 r7,r12,r4 r7,r12,r4 Word_Loop Source1_Has_Null: terminated loop because null byte. Shift both words right null byte LSB. Can't this with cntlzw because borrow byte preceeding null value one. rlwinm. r10,r8,0,0,7 r9,24 shift rlwinm. r10,r8,0,8,15 r9,16 shift rlwinm. r10,r8,0,16,23 r9,8 shift r9,0 shift: r7,r7,r9 subfc r8,r8,r9 r3,r7,r8 Words_Differ: terminated loop because words differ does have null byte. Return based unsigned comparison. subfe r3,r3,r3 nand r3,r3,r3 r3,r3,1 Byte_By_Byte: strcmp byte time. r9,0(r3) r0,0(r4) subfc. r3,r0,r9 bnelr Byte_Loop: cmpi _cr1,0,r9,0 _cr1,Null_Byte lbzu r9,1(r10) lbzu r0,1(r4) subfc. r3,r0,r9 Byte_Loop Null_Byte: r3,r0 References: "Communications ACM" vol. 27., (Oct. 1984), 1013 1030. Suggested Code: File "dry1.h" Defines functions defined support.c used dhry21a.c #define printf my_printf #define fprintf my_fprintf #define fopen my_fopen #define fclose my_fclose #define exit my_exit extern my_printf(const char extern my_fprintf(const char extern FILE my_fopen(); extern my_fclose(); extern void my_exit(); file "support.c" This file provides substitutes some library function calls used Dhrystone which DINK doesn't support. number dhrystone loops here. #define NUMBER_OF_RUNS 10000000 #include <stdarg.h> These magic addresses DINK functions. unsigned long (*dink_printf)() (unsigned long (*)()) 0x6638; version malloc that will only supply 2048 bytes total. char *malloc(unsigned size) static char buffer[2048]; static char *next buffer; char next; next ((size ~7); (next buffer sizeof(buffer)) Terminate executing zero. asm(".long 0"); return Scanf used only read number times through loop. /*ARGSUSED*/ void scanf(char *fmt, NUMBER_OF_RUNS; This only will handle printf calls dhrystone. DINK printf doesn't work floating point, convert value here integer. my_printf(const char *fmt, sign; char *neg_zero_fmt; double round, fraction, val; va_list va_start (ap, fmt); (strcmp(fmt, "%7.1lf \n") "%6d.%1d \n"; neg_zero_fmt round 0.05; fraction 10.0; goto fake_float; else (strcmp(fmt, "%10.1lf \n") "%9d.%1d \n"; neg_zero_fmt round 0.05; fraction 10.0; goto fake_float; else (strcmp(fmt, "VAX MIPS rating %10.3lf \n") "VAX MIPS rating %9d.%03d \n"; neg_zero_fmt "VAX MIPS rating round 0.0005; fraction 1000.0; fake_float: va_arg(ap, double); (val sign -val; else sign Round value. round; val; fraction fraction; sign neg_zero_fmt; sign; else va_arg(ap, int); va_arg(ap, int); va_arg(ap, int); dink_printf(fmt, a3); va_end (ap); -%1d.%03d \n"; -%1d.%1d \n"; -%1d.%1d \n"; Dummy calls exit, fopen, fprintf, fclose. void my_exit() my_fopen() return my_fprintf() my_fclose() Conclusions: Students should able note that: "There lies, damn lies, benchmarks, that order". Dhrystone benchmark small enough understand, opportunities optimization, port easily various computer environments. Dhrystone benchmark string intensive resulting performance metric meaningless applications involving other workloads, e.g. extensive mathematical calculations manipulation. compilers created equal. sample compilers shipped Excimer generate vastly different code, instruction scheduling, results this benchmark. However, biggest impact probably comes from Motorola hand-coded strcmp function. Like most vendors, Motorola strives provide best benchmark results possible marketing reasons. Troubleshooting: student able time function. suggested code Experiment provides double dtime(double TICS_PER_SECOND) function which easily modified provide timing information this benchmark. Link with DINK supplied printf other functions. Check addresses respective functions DINK using symtab command. results print from dhry21a.c program. dink_printf will accept floating point formats. results will have typecast unsigned long print. loss accuracy insignificant. Experiment Running Linpack Benchmark (Debugging Stage) Problem Statement: this experiment student will adapt popular Linpack benchmark execute Excimer board. (Contributed Walter Guiot Luis Objectives: Upon completion this laboratory experience, students will able verify popular industry metric processor performance embedded applications, Linpack, PowerPC 603e microprocessor Excimer board. compare processor performance, measured Linpack, published values other processors. compare code generation instruction scheduling, resulting performance, several competing compilers Linpack benchmark. compare processor performance, measured Linpack, with performance given manufacturer. Background Information: LINPACK collection subroutines used benchmark performance computers analysis solving linear equations linear least-squares problems. LINPACK solves linear systems whose matrices general, banded, symmetric indefinite, symmetric positive definite, triangular, tridiagonal square. LINPACK routines constructed such that locality reference maximized. language version obtained: References: David Patterson, John Hennessy, Conputer Organization Design Hardware Software Interface Morgan Kaufmann Publishers, Francisco, California 1994. http://www.netlib.org/linpack/ Linpack Benchmark: Procedure: Download linpack benchmark from sites such http://www.netlib.org/linpack ftp://ftp.nosc.mil/pub/aburto. Read included documentation regarding compaling instruction. Modify source code make compatible with Dink instructions such dink_printf. Remember that dink_printf does support floating point, function will have developed handle floating point, refer experiment printf function Dhrystone benchmark. Compile source code link with dtime() function develop experiment file dtime.s developed experiment used. PowerPC 603e performance information from manufacturer compare with results obtained with linpack. Suggested Code: ***This experiment still ebugging phase necessary send floating point numbers screen.*** !file "dtime.s" (For Metware High C/C++ Compiler/Assembler) Assembly language routine convert 64-bit PowerPC facility Double-precision, floating-point number. (Plus additional routines testing.) 981216 (Contributed Chuck Corley, Motorola) Register usage: (upper bits floating point value) (lower bits floating point value) TBU(time base upper read from loaded test) TBL(time base lower read from loaded test) leading zeroes register shift count +/-(zeroes accumulator final EXPonent value DPFP number shift count where +/-(zeroes -11) constant register link register storage #define 269; !Special purpose register numbers #define 268; .data Local_storage: .double .text .global dtime .global get_HID1 .global conversion_test !For CodeWarrior: !asm double conversion(double TICS) conversion: cntlzw r7,r5 !Find leading zeroes TBU. Preserve addi r9,r0,32 !Will need several places. Create addi r10,r0,11 !Create constant subf. r8,r7,r9 will hold EXP. Currently leading zeroes) beq+ tbu_is_zero !TBU never incremented? (Zeroes=32?) (Most likely) subf. bge+ r7,r10,r7 r8,r8,r9 tbu_lt_8yrs !No. more than 2^^52? (Zeroes<11?) (Z-11) !Final exponent will leading zeroes). TB>2^^52, shift bits right. (Not likely) tbu_gt_8yrs: subf rlwnm rlwnm rlwnm !for Z<11: tbu>>n=(11-Z); !fpl tbu<<n=(32-(11- Z))|tbl>>n=(11-Z); r7,r7 !rlwnm shift count (11-Z) -(Z-11) r9,r7,r9 !rlwnm shift count 32-n (11-Z) r3,r5,r9,12,31 !Shift right Mask [0:11]. r4,r5,r9,0,10 !Shift remaining bits left 32-(11-Z) r6,r6,r9,0,31 !Shift right r4,r6,r4 rest shifted left with shifted right. form_exponent bias exponent into FPU. tbu_lt_8yrs: subf rlwnm rlwnm !for Z>=11: !fpl=tbl<<n=(Z- 11); r9,r7,r9 !Form shift count (11-Z) r3,r5,r7,12,31 !Shift left (Z-11). Mask [0:11]. r5,r6,r9 !Shift bits right 32-(Z-11). r3,r3,r5 shifted left with shifted right. r6,r6,r7,0,31 !Shift remainder left (Z-11). r4,r6,r5 !XORing with same value shifted right like ANDing form_exponent !fpl with mask zeroes bits [32-(Z-11):31]. !Find leading zeroes TBL. !EXP leading zeroes). !Entire count exactly zero? (Not likely) !No. less than 2^^20? (zeroes 11?) not, will have shift bits right. (Most likely) tbu_is_zero: cntlzw r7,r6 subf. r8,r7,r9 beqtbl_is_zero subf. r7,r10,r7 bgetbl_lt_63ms tbl_gt_63ms: !for z<11: tbl>>n=(11-z); tbl<<n=(32-(11-z)); r7,r7 !rlwnm shift count (11-Z) -(Z-11) subf r9,r7,r9 !rlwnm shift count 32-n (11-Z) rlwnm r3,r6,r9,12,31 !Shift right Mask [0:11]. rlwnm r4,r6,r9,0,10 !Shift remaining bits left form_exponent tbl_lt_63ms: !for z>=11: tbl<<(z-11); rlwnm r3,r6,r7,12,31 !Shift left (Z-11). Mask bits 0-11. r4,r4,r4 !fpl form_exponent tbl_is_zero: r3,r3,r3 r4,r4,r4 compute_seconds !for Z=32 z=32: !Unlikely result that zero. Prepare !return zeroes floating point value. form_exponent: addi r8,r8,1022 !Add bias (1023) exponent rlwinm r8,r8,20,1,12 !Biased will (63-(leading zeroes TB)+1023). r3,r3,r8 compute_seconds: Local_storage@h Local_storage@l 0(r5) 4(r5) 0(r5) !Load back 64bit float fdiv f1,f2,f1 !Divide clock ticks second !Return time seconds double Routine passed sample values TBL. Returns unsigned long. !For CodeWarrior: !asm struct TB_View conversion_test(unsigned long Upper, unsigned long Lower, double TICS) conversion_test: r5,r3,r3 !Use test values passed r6,r4,r4 substitutes values read from mflr !Save return address. conversion !Convert into mtlr !Return !For CodeWarrior: r3,Local_pointer(SP)!Return pointer storage location. Routine passed sample values TBL. Returns seconds double. !For CodeWarrior: !asm double float_test(unsigned long Upper, unsigned long Lower, double TICS) float_test: mflr !Use test values passed substitutes values read from !Save return address. conversion !Convert into r5,r3,r3 r6,r4,r4 mtlr !Return double fpr1 Routine reads TBL. Returns seconds double. !For CodeWarrior: !asm double dtime(double TICS) dtime: read_TB: mfspr r5,TBU !Get TBU. mfspr r6,TBL !Get TBL. mfspr r7,TBU !Get again. subf. r7,r5,r7 !Did increment between reading TBL? bgtread_TB read them again. (Not likely) mflr !Save return address. conversion !Convert into mtlr Routine reads HID1 (PLL_CFG) register. Returns get_HID1: mfspr r3,1009 !Get HID1 register. Conclusions: Troubleshooting: Make sure using correct address dink_printf function. Make necessary changes handle floating point. timer funciton develop experiment ones provided with benchmark. Experiment Cache Impact Benchmark Metrics (Debugging Stage) Problem Statement: this experiment student will compare Linpack benchmark results with cache memory disabled results with cache memory enabled. (Contributed Walter Guiot Luis Objectives: Upon completion this laboratory experience, students will able compare processor performance, measured Linpack, with without cache enabled. understand advantages cache memory computer system. Background Information: Cache memory special type random access memory (RAM) that stores most recently used instructions and/or data from larger main memory system. Cache memory accessed faster than regular RAM. Cache memory categorized levels. Level (L1) cache memory same chip microprocessor. Level (L2) later levels usually separate memory chips. microprocessor first looks instructions cache, there miss) goes next level, continues looking from level level until reaching main memory worst case mass storage device, such disk drives hard drives. These memory chips typically static (SRAM) modules that need electromagnetically refreshed DRAM does. These characteristics make cache memory faster more expensive than regular RAM. There slight catch with cache memory, there cache miss, then takes around more clocks cycle access data from DRAM, ROM. this reason cache that small could theoretically decrease performance. 603e provides independent 16-Kbyte, four-way set-associative instruction data caches. cache line bytes length. caches least recently used (LRU) replacement policy. caches provide 64-bit interface instruction fetch unit load/store unit. surrounding logic selects, organizes, forwards requested information requesting unit. Write operations cache performed byte basis, complete read-modify-write operation cache occur each cycle. load/store instruction fetch units provide caches with address data instruction fetched. Procedure: Develop assembly program enable disable cache memory. Refer PowerPC 603e manual registers involve enabling disabling cache. Follow procedure experiment "Running Linpack Benchmark". Link assembly code developed here code experiment benchmark with cache enable note results. Disable cache benchmark again, compare both results state your conclusions. Questions: References: Company: What Cache? What is.cache memory? MPC603e EC603e RISC Microprocessors User's Manual Suggested Code: Troubleshooting: Make sure using correct registers enabling dissabling cache. Refer troubleshooting experiment "Running Linpack benchmark". Experiment Flash (Debugging Stage) Problem Statement: This experiment requires development assembly language program starting Programmer Space location $70000 that will copy program which resides location $71000 free space Flash location. Program copied into Flash will auto-execute from present location. (Contributed Eisen Montalvo-Ruiz). Objectives: Upon completion this laboratory experience, students will able Write assemble assembly language subroutine. Execute piece code that will turn copy another piece code Flash execute Write assembly code directly into Flash space means assembly code. Background Information: microprocessor-based system needs memory devices hold data program instructions. Memories classified volatile non-volatile. basic difference between both realms memories that volatile memories looses data contents when power removed from semiconductor chip while non-volatile memories holds data contents even when power removed. This some very interesting implications, which must remain clear microprocessor based system designers since both types memory have their advantages disadvantages well typical use. volatile memory used when system execute dedicated application. Take example your computer. When turn executes self-initialization procedure call "booting". does know what BIOS (Binary Input Output System) dedicated application initialization stored non-volatile type memory. this program means erased, computer will just never able restart! Once computer starts, application executed anything decide. would quite expensive, space prohibiting, have applications would like have computer stored non-volatile silicon memory chips. Instead have found quite useful store applications magnetic other type media then write them bank volatile type silicon memory, which fast cope with microprocessor need instructions execute. This volatile memory written over over repeatedly. when power longer applied memory array, information forever lost. Typical volatile memory, (such RAM) load Operative Systems (OS) application want execute computer. Only necessary instructions reside RAM. responsible loading with necessary instructions they needed. disadvantage non-volatile memory cells that they have short life usually rewritten more than specified number times. They also significantly slower than volatile memories. have come accept that there need both types memory. This Excimer board equipped with RAM, which volatile type memory Flash ROM, which non-volatile memory. this time must familiar with fact that Excimer board "operative system" use, called DINK32. This Monitor program stored Flash responsible initializing peripheral activity within Power 603e evaluation board. When press reset, this dedicated application executes takes over board. This monitor also enables user registers memory space with commands such Memory Display (MD), Register Display (RD) Monitor even online assembler disassembler that enables user code enter code manually. Excimer also needs operate. That variable and/or data must written since this value change continuously. provided needed Excimer operate. Fortunately developers, this also loaded with applications trying exploit power embedded 603e CPU. testing evaluation purposes, will hold instructions (which must downloaded periodically with help that traced watched using DINK32 tools. ultimate goal Engineer using evaluation board such Excimer, create free running application capable self-supporting itself. other words that specified application such control embedded system without need computer. This implies that Engineer code will always present Excimer Board only downloaded once. currently downloading code every time need execute Eventually will reach time when your code will totally debugged. would really appropriate make Evaluation Board stand-alone unit with your code dedicated application. goal this laboratory experiment show write Flash area that dedicated application coded this non-volatile memory. architecture suggested procedure write simple program that writes another code into Flash ROM. more advanced option, "writer program" could RESET vector address where will begin writing "written code". safety feature, that DINK32 still available after flash updated, "written code" user application executed DINK32 itself. true DINK32 pointer saved from previous vector table. program will have ability either jump short code (which blinker code) DINK32. rogram Flash ROM: Excimer board 4Mbytes Flash where DINK32 monitor resides. Nevertheless, user defined applications recorded this memory space long some precautions taken. recall that monitor longer working, successive Flash recording might easy possible with existing hardware). Flash chips being interfaced Power 603E Excimer board AMD's AM29LV800B Mbits memory modules. Detailed information erase program Flash cells found AM29LV800B Data Sheet. Some introductory information follows, advised students read proposed Application Note. FLASH chip already contains control unit inside each FLASH chip. that needed erase, read program byte, sector entire chip commands which will chip into predefined state. Once state defined corresponding commands sent chip Data Bus, internal control logic will rest. States which entered are: Sector Protect, Sector Unprotect, Autoselect, Erase Sector, Erase Chip, Erase Suspend, Erase Resume, Program, Reset Unlock Bypass Device programming occurs executing Program Command sequence. This initiates Embedded Program algorithm-an internal algorithm that automatically times program pulse widths verifies proper cell margin. Unlock Bypass mode facilitates faster programming times requiring only write cycles program data instead four. Instead using common Program Command step command) Unlock Bypass Command Sequence (refer Table AM29LV800B Data Sheet). Device erasure occurs executing Erase Command sequence. This initiates Embedded Erase algorithm-an internal algorithm that automatically preprograms array already programmed) before executing erase operation. During erase, device automatically times erase pulse widths verifies proper cell margin. host system detect whether program erase operation complete observing RY/BY# pin, reading (Data# Polling) (toggle) status bits. After program erase cycle been completed, device ready read array data accept another command. sector erase architecture allows memory sectors erased reprogrammed without affecting data contents other sectors. device fully erased when shipped from factory. AM29LV800B Data Sheet explains other mentioned states. Also enter exit mentioned modes operation clearly seen Tables said document. careful. although very specific telling addresses where specific data written, implementation Excimer board changed these parameters. four Flash chips were assembled Excimer Board (configured memory bank double words) redefines addresses expected data from memory chips. First definition Power 603E Microprocessor data big-endian while Flash data little-endian device. This means that what Microprocessor actually Flash ROM! Data reversed (and that simple mirroring words) that Flash understands. other words whatever data AM29LV800B Data Sheet tells send Flash, reversed before actually sent. NOTE: This actually programmer's job. Programmer could develop subroutine mirror word else he/she could hand before actually writing assembly code. other very important fact have mind that memory mapping suggests left shifting. That observing Excimer implementation schematic) less significant bits used select memory space inside memory device itself (recall that PowerPC address big-endian while flash devices little-endian. That address lines A31, ones connected memory device. They actually less significant address lines Power 603e). These three address lines fact used Excimer memory control FPGA select four memory chips. That Excimer implementation Schematic there different line each (write enables) control signals while (Chip Select) (Output Enable) shared. NOTE: Since three less significant address lines used only chip selection while programming, every address present AM29LV800B Data Sheet (including command sequence well sector segregation) shifted left following required rules Excimer boards since address line shifted three data lines reversed. Rule converting from expected address (found AM29LV800B Data Sheet) shifted address (Excimer Memory Mapped) left shift address reverse data example: address 0x555 0x2aa8 (0b0101 0101 0101 0b0010 1010 1010 1000) Rule converting from reversed (little Endian Little Endian) reversed (Little Endian Endian). reverse data line example: data 0xaa 0x55 (0b1010 1010 (bit reversed) 0b0101 0101) following sequences, address data already been shifted well reversed. should have trouble using these examples. recall that will need make reference AM29LV800B Data Sheet when trying search sectors specific addresses. Entering Autoselect mode Write address: 0x2aa8 with data: 0x55555555 Write address: 0x1550 with data: 0xaaaaaaaa Write address: 0x2aa8 with data: 0x09090909 Manufacturer Read address: 0x0000 data: 0x80008000 Device Read address: 0x0008 data: 0x5B445B44 Sector Protect status each sector: Read address: 0x[SA] data: 0x00000000 protected Read address: 0x[SA] data: 0x80008000 protected Reset sequence exit autoselect mode: Write address: 0x0000 with data: 0x0f0f0f0f Erasing flash sector sequence: Write address: 0x2AA8 with data: 0x55555555 Write address: 0x1550 with data: 0xAAAAAAAA Write address: 0x2AA8 with data: 0x01010101 Write address: 0x2AA8 with data: 0x55555555 Write address: 0x1550 with data: 0xAAAAAAAA Write address: sector address with data: 0x0C0C0C0C Programming flash memory: Write address: 0x2AA8 with data: 0x55555555 Write address: 0x1550 with data: 0xAAAAAAAA Write address: 0x2AA8 with data: 0x05050505 Write address: Word address with data programmed some notes: Flash device change zero cell bit, visa versa. Thus, good practice erase memory first before writing Otherwise after writing, memory corrupted, since zero can't changed back one. some cases play with byte recorded. example cell byte 0x55 programmed want write 0x11, done without erasing cell. This good idea when there only bytes programmed, would wise when programming large amounts data. Erasing only done sector time entire chip, erase only portion sector. smallest amount flash erase complete sector. (Refer Table AM29LV800B Data Sheet sector addresses remember shift left address). careful when erasing sector. There might important code code) sector. References: AM29LV800B Data Sheet (www.amd.com) FL.C Source Code Suggested Code: sets code available this section. first thing student should properly send commands Flash chips. Since writing erasing hazardous Excimer health, recommended that experiments performed before erasing programming attempted. This will allow students practice Assembly Language Programming interface ships using data supplied AM29LV800B Data Sheet with already shifted addresses inverted data. first code snippet shows enter Autoselect Mode. Students will able check memory spaces specified data. method memory display byte information shows specified data (note inversion will noted) command sequence been successful. Otherwise, more steps might correct (Check troubleshooting section more information possible errors). .text .global readflash readflash: r12, r12, r13, r13, !Clearing Registers r12, 65472 addi r12, r12, !R12 contains $FFC00000 !Register12 contains address $FFC00008 !This address used request Autoselect mode data !specified Flash data sheet shift !Clearing Register !Register contains $FFC00000 !Register contains $FFC02AA8 !This address used send first step into !Autoselect sequence specified Flash data !sheet shift !Clearing Register !Register contains $FFC00000 !Register contains address $FFC01550 !This address used send second step into !Autoselect sequence specified Flash data !sheet shift !Clearing Register !Through this steps, data $AAAAAAAA which will !sent Flash first step Autoselect !sequence, assembled. Note that reversal been !accounted for. r14, r14, r14, 65472 addi r14, r14, 10920 r15, r15, r15, 65472 addi r15, r15, 5456 r16, r16, addi r16, r16, slwi r16, r16, addi r16, r16, slwi r16, r16, addi r16, r16, slwi r16, r16, addi r16, r16, r17, r17, r17, 21845 addi r17, r17, 21845 !Register contains data $AAAAAAAA !Clearing Register !Data $55555555 assembled through this steps. This !the data that will sent second step !Autoselect sequence. reversal been taken care !Clearing Register !Data $09090909 assembled through this steps. This !word sent Flash differentiate command !sequence from others. This data specific !Autoselect mode. r18, r18, addi r18, r18, slwi r18, r18, addi r18, r18, slwi r18, r18, addi r18, r18, slwi r18, r18, addi r18, r18, stwx r17, r14, addi r14, r14, stwx r17, r14, stwx r16, r15, addi r15, r15, stwx r16, r15, subi r14, r14, stwx r18, r14, addi r14, r14, stwx r18, r14, !Register contains data $09090909 !Store $55555555 data $FFC02AA8 !First sequence step taken care written both memory banks. !Store $AAAAAAAA data $FFC01550 !Second sequence step taken care written both memory banks. !Subtract from that address FFC02AA8 !once again available. !Store $09090909 data $FFC02AA8 !Third step into Autoselect sequence taken care writen both memory banks. this moment, Flash Autoselect Mode. memory reads will return !Autoselect Mode Information such Manufacturer Device Sector Protect !Verification status. exit Autoselect Mode, Autoselect Reset sequence Hardware !reset must performed. lwzx r19, r12, !Loading into Register Manufacturer first !memory bank. addi r12, r12, lwzx r20, r12, !Loading into Register Manufacturier second !Memory Bank second snippet code actually subroutine needed write byte. Extreme care must taken when writing data Flash Excimer easily become corrupt inoperating. Students encouraged practice free sector (preferably sector 16), which will certainly erased, else erased without fear damaging Check AM29LV800B Data Sheet further Excimer sector division information. Refer troubleshooting section problems regarding difficulty write data Flash. .text .global writeflash writeflash: r13, r13, r12, r12, r12, 65472 addi r12, r12, 10920 !xor r14, r14, !lis r14, 65472 !addi r14, r14, 10924 r15, r15, r15, 65472 addi r15, r15, 5456 r16, r16, addi r16, r16, slwi r16, r16, addi r16, r16, slwi r16, r16, addi r16, r16, slwi r16, r16, addi r16, r16, r17, r17, r17, 21845 addi r17, r17, 21845 !Clearing Register !Clearing Register !Register contains Address $FFC00000 !Register contains Address $FFC02AA8 !Clearing Register !Register contains Address $FFC00000 !Register contains Address $FFC02AAC !Clearing Register !Register contains Address $FFC00000 !Register contains Address $FFC01550 !Clearing Register !Through this steps, data $AAAAAAAA which will !sent Flash first step Autoselect !sequence, assembled. Note that reversal been !accounted for. !Register contains data $AAAAAAAA !Clearing Register !Data $55555555 assembled through this steps. This !the data that will sent second step !Autoselect sequence. reversal been taken care !Clearing Register !Data $05050505 assembled through this steps. This !word sent Flash differentiate command !sequence from others. This data specific !Autoselect mode. r18, r18, addi r18, r18, slwi r18, r18, addi r18, r18, slwi r18, r18, addi r18, r18, slwi r18, r18, addi r18, r18, stwx r17, r12, addi r12, r12, stwx r17, r12, !Register contains data $05050505 !Store $55555555 data Address $FFC02AA8 !First sequence step taken care written both memory banks. stwx r16, r15, addi r15, r15, stwx r16, r15, subi r12, r12, stwx r18, r12, addi r12, r12, stwx r18, r12, r19, r19, r19, 65484 r20,r20,r20 r20, !Store $AAAAAAAA data $FFC01550 !Second sequence step taken care written both memory banks. !Subtract from that address FFC02AA8 !once again available. !Store $05050505 data Address $FFC02AA8 !Third sequence step taken care written both memory banks. !Clearing !Register !Clearing !Register Register contains Address $FFCC0000 Register contains data $00000055 stwx r20, r19, !Program $00000055 data FLASH Address $FFCC0000 this moment, data will have been programmed into $FFCC0000 /*-* main.c 29/4/99 This code writes program FlashROM sets booting vector program written. There's some problem with FlashROM. Right program stuck with trying write correctly FlashROM. have tried same program with different Excimer Boards results different. Although second time write some information correctly. think FlashROM damaged. #include <stdio.h> #define #define #define getchar dink_get_char putchar dink_write_char printf dink_printf void blink_leds(int addr, unsigned long (*dink_get_char)() (unsigned long (*)()) 0x1e4c4; unsigned long (*dink_write_char)(char) (unsigned long (*)(char)) 0x5eb4; unsigned long (*dink_printf)() (unsigned long (*)()) 0x6270; #define flash #define addr1 #define addr2 #define #define #define #define #define #define #define #define void void void void void void void void zerosones allas allfives zeroscs zerosfives zerosfours zerosnines allzeros 0xffc00000 0x2aa8 0x1550 0x01010101 0xaaaaaaaa 0x55555555 0x0c0c0c0c 0x05050505 0x04040404 0x09090909 0x00000000 erase_sector(int); program(unsigned unsigned int); unlock_bypass(); write_word(unsigned unsigned int); unlock_bypass_reset(); leds_main(); blink_leds(int addr, blank(); void main() unsigned *addr (unsigned *)0xffd00000; unsigned *prog (unsigned *)0x0; unsigned size //Borrar sector donde estara codigo erase_sector(7); //Escribir nuestro codigo FlashROM /*unlock_bypass(); size (unsigned int)blank (unsigned int)leds_main; for(unsigned i=0; i<size/4; i++) prog (unsigned *)((unsigned int)leds_main i*4); printf("%x (unsigned int)prog); //program(addr+i, *prog); write_word(addr+i, *prog); unlock_bypass_reset();*/ prog (unsigned *)((unsigned int)leds_main); write_word(addr, *prog); //Traer sector MDink //Cambiar Boot Pointer vector table //Borrar sector MDink //Reescribir sector FlashROM //Rebootear void erase_sector(int sector) unsigned *sect, *command; sect=0; if(sector<4) //Sector less switch(sector) case sect break; case sect break; case sect break; case sect else if(sector>18) return; else (unsigned *)(0x0 flash); (unsigned *)((0x2000<<3) flash); (unsigned *)((0x3000<<3) flash); (unsigned *)((0x4000<<3) flash); sect (unsigned command (unsigned *)(flash addr1); *command allfives; command +=1; *command allfives; command (unsigned *)(flash addr2); *command allas; command +=1; *command allas; command (unsigned *)(flash addr1); *command zerosones; command +=1; *command zerosones; command (unsigned *)(flash addr1); *command allfives; command +=1; *command allfives; command (unsigned *)(flash addr2); *command allas; command +=1; *command allas; printf("%x (unsigned int)sect); *sect void program(unsigned *addr, unsigned word) unsigned *command; command (unsigned *)(flash addr1); *command allfives; command +=1; *command allfives; command (unsigned *)(flash addr2); *command allas; command +=1; *command allas; command (unsigned *)(flash addr1); *command zerosfives; command +=1; *command zerosfives; printf("%x (unsigned int)addr); printf("%x\n", word); *addr word; void unlock_bypass() unsigned *command; command (unsigned *)(flash addr1); *command allfives; zeroscs; command +=1; *command allfives; command (unsigned *)(flash addr2); *command allas; command +=1; *command allas; command (unsigned *)(flash addr1); *command zerosfours; command +=1; *command zerosfours; void write_word(unsigned *addr, unsigned word) unsigned *command; command (unsigned *)(flash); *command zerosfives; command +=1; *command zerosfives; printf("%x (unsigned int)addr); printf("%x\n", word); *addr word; void unlock_bypass_reset() unsigned *command; command (unsigned *)(flash); *command zerosnines; command +=1; *command zerosnines; command (unsigned *)(flash); *command allzeros; command +=1; *command allzeros; void leds_main() decimal_no; char LED; char number; printf ("\nSelect want blink:\n"); printf ("\tS Press Status LED\n"); printf ("\tE Press Error LED\n"); printf ("\tQ Press Quit\n"); getchar(); (LED 'e') printf ("\nEnter number times (1-9) blink Error LED: number getchar(); }while !((number '0') (number '9')) putchar(number); decimal_no number blink Other recent searchesUG191 - UG191 UG191 Datasheet REJ03B0156-0122 - REJ03B0156-0122 REJ03B0156-0122 Datasheet NCV7356 - NCV7356 NCV7356 Datasheet GMW3089 - GMW3089 GMW3089 Datasheet AC-162D - AC-162D AC-162D Datasheet
Privacy Policy | Disclaimer |