05 Lec Memory - Architectures
05 Lec Memory - Architectures
2-1
Role of Memory in Embedded
Systems
Traditional roles: Storage and Communication for
Programs
2-6
Memory Map
of an ARM
CortexTM - M3
Architecture
Defines the
mapping of
addresses to
physical memory
Example:
Atmel AVR
Atmega328
28-pin DIP on an
Arduino Duemilanove
board
2-9
Another example
of use of an AVR
processor
The iRobot Create
Command
Module
2-12
Memory hierarchy
Cache:
A subset of memory addresses is mapped to SRAM
Accessing an address not in SRAM results in cache miss
A miss is handled by copying contents of DRAM to SRAM
Scratchpad:
SRAM and DRAM occupy disjoint regions of memory space
Software manages what is stored where
Segmentation
Logical addresses are mapped to a subset of physical
addresses
Permissions regulate which tasks can access which memory
See your textbook for more details.
2-13
Memory Hierarchy
Relevant features:
UART interface to iRobot
ADC to accelerometer
SysTick/other Timers
UART to Bluetooth
JTAG interface for programming
No floating point!
ARM Cortex M3
2-21
Statically-Allocated Memory in C
char x;
int main(void) {
x = 0x20;
…
}
2-22
Statically-Allocated Memory in C
with Limited Scope
void foo(void) {
static char x;
x = 0x20;
…
}
2-23
Variables on the Stack
(“automatic variables”)
void foo(void) {
char x;
x = 0x20;
…
}
char x;
void foo(void) {
x = 0x20;
…
}
Answer 1
What is meant by the
following C code:
char x;
void foo(void) {
x = 0x20;
…
}
char *x;
void foo(void) {
x = 0x20;
…
}
Answer 2
What is meant by the
following C code:
char *x;
void foo(void) {
x = 0x20;
…
}
char *x, y;
void foo(void) {
x = 0x20;
y = *x;
…
}
Answer 3
What is meant by the
following C code:
char *x, y;
void foo(void) {
x = 0x20;
y = *x;
…
}
char foo() {
char *x, y;
x = 0x20;
y = *x;
return y;
}
char z;
int main(void) {
z = foo();
…
}
void foo(void) {
char *x, y;
x = &y;
*x = 0x20;
…
}
stack
Answer 5
What is meant by the
following C code:
void foo(void) {
char *x, y;
x = &y;
*x = 0x20;
…
}
char foo() {
char y;
uint16_t x;
x = 0x20;
y = *x;
return y;
}
char z;
int main(void) {
z = foo();
…
}
What goes into z in the
Answer 6 following program:
char foo() {
char y;
uint16_t x;
x = 0x20;
y = *x;
return y;
}
char z;
int main(void) {
z = foo();
…
}
int main(void) {
int* result = foo(10); program counter, argument 10
and z go on the stack (and
... possibly more, depending on the
} complier)
void foo(uint16_t x) {
char y;
y = *x;
if (x > 0x100) {
foo(x – 1);
}
}
char z;
void main(…) {
z = 0x10;
foo(0x04FF);
…
}
Summary
Understanding memory architectures is essential
to programming embedded systems.