1 / 42

EENG 449b/CPSC 439b Computer Systems Lecture 6 ARM Architecture & Programming

EENG 449b/CPSC 439b Computer Systems Lecture 6 ARM Architecture & Programming. Feb 1, 2005 Prof. Andreas Savvides Spring 2005 http://www.eng.yale.edu/courses/2005s/eeng449b. Where is ARM Today?. Announcements. Need to register for lab access Lab located in CO-40

Download Presentation

EENG 449b/CPSC 439b Computer Systems Lecture 6 ARM Architecture & Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EENG 449b/CPSC 439b Computer SystemsLecture 6 ARM Architecture & Programming Feb 1, 2005 Prof. Andreas Savvides Spring 2005 http://www.eng.yale.edu/courses/2005s/eeng449b

  2. Where is ARM Today?

  3. Announcements • Need to register for lab access • Lab located in CO-40 • You need to see Ed Jackson to get access to the lab • Take your Yale id with you • Reading for next lecture • Get by without and RTOS by Melkonian • Camera based projects: • Camera description lecture tomorrow • Prof. Eugenio Culurciello, AKW 000 @ 4:00pm

  4. Not the case when you have loads and stores!!!!

  5. 3-State ARM7 Pipeline

  6. Stalls in 3-stage pipeline

  7. How do we improve the design? • Where are the bottlenecks? • In the memory subsystem: we have a Von Neumann Architecture • Include separate Instruction and Data Caches • How do we minimize stalls from data dependencies? • ? • When does this solution not work? • Load instructions LDR rN, [..] ADD r2, r1, rN

  8. 5-stage ARM9 Improvement

  9. ARM Instructions 3-type instruction classification • Data processing • Data transfer • Control flow

  10. Data Processing Instructions • Arithmetic operations ADD r0, r1, r2; ADC r0, r1, r2; add w/curry r0 :=r1+r2+c SUB r0, r1, r2; SBC r0, r1, r2; r0 :=r1 – r2 + C – 1 etc … • Bitwise Logical Operations AND r0, r1, r2 OR r0, r1, r2 EOR r0, r1, r2 BIC r0, r1, r2; r0 := r1 and not r2

  11. Data Processing Instructions II • Register Movement Operations MOV r0, r2; r0 := r2 MVN r0, r2; r0 := not r2 • Comparison Operations CMP r1, r2 ; set cc on r1 – r2 CMN r1, r2; set cc on r1 + r2 TST r1, r2; set cc on r1 and r2 TEQ r1, r2; set cc on r1 xor r2 • Immediate Operands ADD r3, r3, #1; r3 := r3 + 1 AND r8, r7, #&ff;

  12. Data Transfer Instructions • Most common are load and store but there is support for multiple loads, • Register Indirect Addressing LDR r0, [r1] STR r0, [r1] LDR r0, [r1,#4] LDR r0, [r1,#4]! ; also increments r1 ; by the immediate

  13. Control Flow Instructions • Unconditional Branches B LABEL … LABEL … • Conditional Branches MOV r0, #0 LOOP … ADD r0, r0, #1 CMP r0, #10 BNE LOOP …

  14. Writing a simple assembly language program

  15. Reverse Engineering a Program • In the lab we will be using the GNU tools • Slight difference in syntax • As a first step we will compile and analyze programs • Main compiler arm-elf-gcc • To compile a program to assembly • arm-elf-gcc –S hello.c • Using objdump • Arm-elf-objdump –source hello

  16. Example Program #include <stdio.h> int a_global = 10; int foo (int arg ){ static foo_counts = 0; foo_counts++; return foo_counts + arg; } int main (void){ int nloops; char* charstr = "hello world\n"; for( nloops=0; nloops < 10; nloops ++){ printf("%s",charstr); foo(nloops); } return 0; }

  17. An Example Embedded System Application: A Mobile Terminal Processor Receipt Printer Radio Bar-code Scanner (IO_Scan) Serial Port RS232 Keyboard LCD Display

  18. Minimal Mobile Terminal Program int main(void) { Init_All(); for (;;) { IO_Scan(); // bar-code scanner IO_ProcessOutputs(); KBD_Scan(); // keyboard PRN_Print(); // printer LCD_Update(); // display RS232_Receive(); // serial port RS232_Send(); TIMER_Process(); // timer } // should never ever get here }

  19. int main(void) { Init_All(); for (;;) { IO_Scan(); IO_ProcessOutputs(); KBD_Scan(); PRN_Print(); LCD_Update(); RS232_Receive(); RS232_Send(); TIMER_Process(); } // should never ever get here } Each function is an independent task Tasks should return in a reasonable time Frequency of main loop execution is non-deterministic Tasks are event-driven Tasks do not execute unless a suitable message is received Minimal Mobile Terminal Program

  20. Task Requirements • Some tasks are periodic • Blink the LCD cursor once every second • Tasks may not need to run at the same frequency • Some tasks may be event triggered • RS-232 receive only needs to execute of there is a character received • PRN_Print() only needs to execute when a receipt is required • Need a method to communicate between tasks

  21. Event Driven Tasks & Task Communication Task 2 Task 1 Task3_PutEvent() Task3_PutEvent() Task3_GetEvent() Task 3 Task Event Queue

  22. Task Execution Frequency • Different tasks may need to execute at different frequencies OR • Task execution frequency may change during the lifetime of an application • Example: • You may not need to refresh the LCD every 1ms if the information to be displayed does not change • You may not want to delay execution of other tasks too long

  23. State-Driven LCD Driver(from Melkonian) void Window_Update(void) { switch (WinTaskState) { case WIN_TASK_IDLE: return; case WIN_TASK_CONST: UpdateWinConst(); WinTaskState++; break; case WIN_TASK_VARS: UpdateWinVars(); WinTaskState++; break; case WIN_TASK_GRAPH: UpdateWinGraph(); WinTaskState++; break; }}

  24. Software Timers • Timers are needed to provide multitasking ability to your software • Need to schedule a large number of periodic or single shot events • Blinking cursor • Flashing leds • Be able to put your device to sleep after some idle time • Timers in the implementation of communication protocols • You could use hardware timers for some tasks BUT • There is a very limited number of hardware timers compared to the needs of an application

  25. Designing a Software Timer Tasks deposit their events in a queue Application handler functions Handler for the hardware 10ms timer check Delta Queue For expired timers Software timer process

  26. Using A Software Timer • word TMR_InstallTimeoutHandler(word timer_handle, void(*timeout_func)(word, dword)) • word TMR_Start(word timer_handle, word timeout, dword parameter); • word TMR_Stop(word timer_handle);

  27. Features of RTOS (hard) • Structure - OS components and user defined Tasks • Multi-tasking • Provides hard time guarantee • Schedulability test guarantees task deadline • Priority Support • Pre-emption of tasks

  28. Drawbacks of RTOS • Interrupt latency of context switching may introduce inefficiency • Pre-emption requires extra attention to shared memory • Multi-tasking requires private stack for each task. • RTOS is difficult to debug • Commercial RTOS • Portability can be difficult • License Fee • Learning Curve

  29. Next-time • Programming assignment 1

More Related