0% found this document useful (0 votes)
25 views6 pages

ARM System Design Tutorial

1. The document describes exercises using the ARM assembler, linker, and debugger to simulate a "Hello World" program. 2. It provides detailed steps to assemble, link, load the program into the debugger, set breakpoints, step through execution, and view register contents. 3. The second exercise uses the Cheetah cache simulator to analyze the memory access pattern from the ARM simulation under different cache configurations including fully associative, direct mapped, and set associative caches of varying sizes.

Uploaded by

Mahesh9978
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views6 pages

ARM System Design Tutorial

1. The document describes exercises using the ARM assembler, linker, and debugger to simulate a "Hello World" program. 2. It provides detailed steps to assemble, link, load the program into the debugger, set breakpoints, step through execution, and view register contents. 3. The second exercise uses the Cheetah cache simulator to analyze the memory access pattern from the ARM simulation under different cache configurations including fully associative, direct mapped, and set associative caches of varying sizes.

Uploaded by

Mahesh9978
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Design and Test

of Systems-on-a-Chip
Universität Stuttgart Prof. Dr. H.-J. Wunderlich
Prof Dr. M. Berroth
Dipl.-Phys. V. Gherman
Dr. A. Virazel

SS 2002

Tutorial 3
System Design with ARM

This tutorial sheet contains "exercises" about ARM. You should read the text in advance and make yourself
familiar with the topic, e. g. by reading the relevant documentation on the tools.
Especially, you should read:
1. ARM presentation (see web page). Additional information can be founded in the Reference
Manual (Chapter 3: Assembler ; Chapter 4: ARM Instruction Set ; Chapter 7 : Symbolic Debugger)
2. The cheetah man page (type: man cheetah)

Exercise 1
Use the "Hello World" program presented in the following figure to make yourself familiar with the ARM
assembler, linker and symbolic debugger. Save this file as hs.s

Area declaration Comment


AREA HelloW, CODE, READONLY

SWI-WriteC EQU &0 ; output character in r0


SWI-Exit EQU &11 ; finish program

Assign value ENTRY ; code entry point


to label
ADR r1, TEXT ; r1-> "Hello World"
LOOP LDRB r0, [r1], #1 ; get next byte
CMP r0, #0 ; check for text end
SWINE SWI_WriteC ; if not end print ..
Label BNE LOOP ; .. and loop back
SWI SWI_Exit ; end of execution

TEXT = "Hello World" , &0a, &0d, 0

END
Enter data
End of file into the code

1. Simulating the “Hello World” program


• Step 1: Assemble program
socpraar:~/arm>armasm -g -o hello_world.o hello_world.s
• Step 2: Link program
socpraar:~/arm>armlink -o hello_world hello_world.o

1
• Step 3: Run Debugger/Simulator
socpraar:~/arm>armsd hello_world
A.R.M. Source-level Debugger vsn 4.45c (ARM Toolkit v2.02) [Mar 12 1996]
ARMulator vsn 1.08c [Feb 5 1996]
ARM7TDM, 2048Mbyte, MMU present, soft DEMON vsn 1.3, FPE, Little endian.
Memory map ...
00000000..80000000, 32-Bit, rw, R(N/S) = 135/80, W(N/S) = 135/80
Clock speed = 33.33MHz
Object program file hello_world
armsd:_
• Important Commands in armsd
help - Help
help <command> - Help on <command>
quit - Quit
go - run program
step - step through program
break @<label> - set break point
break - list all break points
unbreak - remove break point
registers - Display register contents
list - examine memory contents (instruction, hex & character format)
lsym - list symbols (e. g. labels)
print $clock - number of microseconds since simulation has started
print $memstats - print memory statistics & times
• Listing Memory Contents
armsd: l @loop
LOOP
+0000 0x00008084: 0xe4d10001 .... : ldrb r0,[r1],#1
+0004 0x00008088: 0xe3500000 ..P. : cmp r0,#0
+0008 0x0000808c: 0x1f000000 .... : swine 0x0
+000c 0x00008090: 0x1afffffb .... : bne LOOP
+0010 0x00008094: 0xef000011 .... : swi 0x11
Text
+0000 0x00008098: 0x6c6c6548 Hell : stcvsl p5,c6,[r12],#-0x120
+0004 0x0000809c: 0x6f57206f o Wo : swivs 0x57206f
+0008 0x000080a0: 0x0a646c72 rld. : beq 0x1923270
+000c 0x000080a4: 0x0000000d .... : andeq r0,r0,r13
...

2
• Simulation & Execution Control
armsd: b @loop
armsd: b
#1 hello_world break @LOOP
armsd: g
Breakpoint #1 at #hello_world, line 9 of hello_world.s
9 LOOP LDRB r0, [r1], #1 ; get next byte
armsd: s
Step completed at #hello_world, line 10 of hello_world.s
10 CMP r0, #0 ; check for text end
armsd: s
Step completed at #hello_world, line 11 of hello_world.s
11 SWINE SWI_WriteC ; if not end print...
armsd: u @loop
armsd: b
armsd: g
Hello World
Program terminated normally at #hello_world, line 13 of hello_world.s
13 SWI SWI_Exit ; end of execution
armsd:
• Displaying Register
armsd: r
r0 = 0x00000000 r1 = 0x000080a6 r2 = 0x00000020 r3 = 0x00000000
r4 = 0x00000000 r5 = 0x00000000 r6 = 0x00000000 r7 = 0x00000000
r8 = 0x00000000 r9 = 0x00000000 r10 = 0x00000000 r11 = 0x00000000
r12 = 0x000080a8 r13 = 0x00000000 r14 = 0x00008010
pc = 0x00008094 psr = %nZCvift_User32
armsd:
• Performance Estimation
Required:
a) Memory description
File "[Link]":
0 80000000 RAM 4 rw 135/80 135/80
...
address range (hex)
read time write time
word width (bytes) (normal/sequential access)

3
b) CPU clock speed
rapra01:~/arm>armsd -clock 50Mhz hello_worldA.R.M. Source-level
Debugger vsn 4.45c (ARM Toolkit v2.02) [Mar 12 1996]
ARMulator vsn 1.08c [Feb 5 1996]
ARM7TDM, 2048Mbyte, MMU present, soft DEMON vsn 1.3, FPE, Little
endian.
Memory map ... Check!
00000000..80000000, 32-Bit, rw, R(N/S) = 135/80, W(N/S) = 135/80
Clock speed = 50.00MHz
Object program file hello_worldarmsd: g
Hello World
Program terminated normally at #hello_world, line 13 of hello_world.s
13 SWI SWI_Exit ; end of execution

armsd: p $clock
12
armsd:
execution time in µs

2. Cache Simulation
Tool: Cheetah (University of Michigan)
• Step 1: Generate address trace
socpraar:~/arm>armsd-hex hello_world ...
File "memaccess":
...
0000801C (Load Word - sequential cycle)
00008020 (Load Word - sequential cycle)
00008058 (Load Instruction - sequential cycle)
0000805C (Load Instruction - sequential cycle)
00008030 (Load Word - non-sequential cycle)
...
• Step 2: Convert trace file
socpraar:~/arm>hexbin < memaccess > [Link]
• Step 3: Run cheetah
a. Fully-Associative Caches
cheetah < [Link] -Cfa -i128

... size increment

Addresses processed : 366 mode (fully-associative)


Line size : 16 bytes
Number of distinct lines 57
Cache size (bytes) Miss Ratio
128 0.218579
256 0.180328
384 0.177596
512 0.166667
640 0.161202
768 0.155738
896 0.155738
Miss ratio is 0.155738 for all bigger caches

4
b. Directly-Mapped Caches
cheetah < [Link] -Cdm -a4 -b12 -c12
log2(cache size) (4 KB)
...
mode log2(max. line size) (4 KB)
Addresses processed 366
Cache size: 4096 bytes log2(min. line size) (16 bytes)
Line size (bytes) Miss ratio
16 0.185792
32 0.117486
64 0.084699
128 0.068306
256 0.073770
512 0.073770
1024 0.073770
2048 0.095628
4096 0.112022

c. Set-Associative Caches
cheetah < [Link] -Csa -a4 -b8 -n2
log2(max. associativity)
...
mode log2(max. no. of sets)
Addresses processed: 366
Line size: 16 bytes
log2(min. no. of sets)
Miss Ratios
___________

Associativity
1 2 3 4
No. of sets
16 0.229508 0.174863 0.166667 0.158470
32 0.207650 0.158470 0.155738 0.155738
64 0.193989 0.155738 0.155738 0.155738
128 0.185792 0.155738 0.155738 0.155738
256 0.185792 0.155738 0.155738 0.155738

cache size
= 128 * 2 * 16 bytes
= 4 KB

5
Exercise 2
Consider the following program:
AREA prg, CODE, READONLY

SWI_Exit EQU &11

ENTRY

adr r0, size


ldr r1, [r0], #4 ; r0 now points to...
; ... "array"
ldr r2, [r0], #4

loop subs r1, r1, #1


beq done
ldr r3, [r0], #4
cmp r2, r3
movlo r2, r3
b loop

done swi SWI_Exit ; end of execution

AREA data, DATA


size DCD 8
array DCD 11, 17, 5, 23, 7, 3, 19, 2

END

a) What is the output of the program in register r2?


b) Simulate the program and verify your answer to a).

Exercise 3: Bubble sort


Implement a bubble sort algorithm for the ARM using the data part of the program of exercise 2.
Optimize your code for speed!

Common questions

Powered by AI

The cache simulation tool 'Cheetah' assesses cache performance in ARM systems by processing address traces that simulate memory access patterns. It evaluates cache configurations by simulating different cache architectures: fully-associative, directly-mapped, and set-associative caches. Key metrics considered include the addresses processed, line size, and cache size. Miss ratios, a critical performance indicator, are calculated and reported for each configuration, reflecting how efficiently the cache handles data access under varying associativity and line size scenarios. These metrics allow for performance tuning and architectural optimization in ARM systems .

To simulate an ARM program using the ARM symbolic debugger, follow these steps: Firstly, assemble the program using 'armasm' and link it with 'armlink'. Begin debugging by running 'armsd <program_name>'. Set breakpoints using 'break @<label>' to stop execution at specific points. Use 'go' to run and 'step' to execute the program line-by-line, observing the flow. Display register values with 'registers' and view memory with 'list'. Commands like 'print $clock' and 'print $memstats' provide additional execution insights. Remove breakpoints with 'unbreak', and terminate the debugger with 'quit' .

Different cache architectures significantly affect the miss ratio observed during ARM program execution. Fully-associative caches allow any memory block to be stored at any cache location, yielding lower miss ratios as cache size increases, observed as 0.155738 for caches larger than 896 bytes. Directly-mapped caches limit each memory block to a specific cache line, generally showing higher miss ratios but optimizing for larger line sizes, e.g., a miss ratio of 0.068306 with a 128-byte line size. Set-associative caches strike a balance by dividing the cache into multiple sets which can store multiple blocks, improving performance as associativity and set numbers increase, reflected by decreasing miss ratios with higher associativity and set counts .

The given ARM program performs a selection sort-like algorithm on the array, iterating through the elements to find and store the smallest value in register r2. Initially, r0 points to the "array" in memory. The program loads the size of the array, decrements it through a loop, compares elements loaded into r3 and r2, replacing r2 with the smaller element if needed. The loop repeats until all elements are checked, resulting in r2 holding the smallest value, which is 2 .

The ARM assembler program uses a series of instructions to manipulate and display the "Hello World" string. It initializes with an ADR instruction to set r1 to the address of the TEXT string, then enters a loop where it loads each byte of the string into r0 using the LDRB instruction. The CMP instruction checks if the byte is the null terminator, and if it is not, the SWINE instruction is used to invoke a software interrupt that writes the character to the output. The program loops back using the BNE (branch if not equal) instruction to continue until the null terminator is reached, at which point SWI SWI_Exit terminates the program .

The ARM symbolic debugger uses several commands to manage breakpoints and analyze program execution. 'Break @<label>' sets a breakpoint at a specific label, while 'break' lists all breakpoints and 'unbreak' removes them. The 'go' command runs the program, and 'step' allows stepping through the program one line at a time. Using 'registers' displays the current register states, and 'list' shows memory contents. 'lsym' lists program symbols, and 'print' commands like 'print $clock' and 'print $memstats' provide execution time and memory statistics .

Implementing a bubble sort in ARM assembly for speed optimization involves minimizing instruction cycles and memory access. Critical considerations include reducing the number of conditional checks with fewer branching instructions and optimizing data movement to the fewest instructions necessary. The algorithm should make comparisons and swaps directly through registers rather than memory, loop unrolling can be used to reduce the number of iteration cycles when dealing with a small, fixed-size dataset, and conditional execution could optimize branches. Efficient use of cache by accessing data sequentially would further enhance speed .

Clock speed configuration in the ARM debugging environment directly affects the simulation of program execution speed. During debugging, the clock speed determines how swiftly instructions are executed, with higher clock rates leading to faster processing. This configuration is set using the command 'armsd -clock' followed by the desired speed, such as 50MHz. This setting influences the timing of operations and performance estimates provided by the debugger, impacting measures like execution time in microseconds .

Comparative memory requirements for different cache configurations in ARM architecture affect performance by determining the cache's ability to quickly retrieve and store data. Fully-associative caches provide flexibility in storage, allowing high miss rate reduction as the cache size increases notably past 896 bytes. In contrast, directly-mapped caches, with stricter storage rules, show improved performance with larger line sizes, optimizing for average data retrieval times. Set-associative caches balance between the two, using multi-set storage to reduce miss rates by efficiently managing associativity, with distinct lines and cache sizes further fine-tuning performance. The cache memory required increases with associativity and set counts, optimizing for lower miss ratios and improved speed .

In the 'Hello World' ARM assembly program, assembler directives and labels are used to structure and control code execution. The 'AREA' directive specifies the code section as read-only, and 'ENTRY' marks the entry point. Labels like 'LOOP' and 'TEXT' act as anchors in code and data sections, respectively. The label 'LOOP' allows the branch instructions to create a continuous execution loop for outputting characters, while 'TEXT' anchors the string data. Execution flow is controlled using SWI commands that act as system calls to write characters and terminate the program .

You might also like