M3 General Purpose
M3 General Purpose
M3 General Purpose
2
Introduction
• General-Purpose Processor
– Processor designed for a variety of computation tasks
– Low unit cost, in part because manufacturer spreads NRE
over large numbers of units
• Motorola sold half a billion 68HC05 microcontrollers in 1996 alone
– Carefully designed since higher NRE is acceptable
• Can yield good performance, size and power
– Low NRE cost, short time-to-market/prototype, high
flexibility
• User just writes software; no processor design
– a.k.a. “microprocessor” – “micro” used when they were
implemented on one or a few chips rather than entire rooms
Embedded Systems Design: A Unified 3
Hardware/Software Introduction, (c) 2000 Vahid/Givargis
Basic Architecture
– Datapath is general
– Control unit doesn’t PC IR
store the algorithm –
the algorithm is
I/O
“programmed” into the
Memory
memory
• Store 10 11
– Write register to PC IR
memory location
I/O
Memory
...
10
...
11
• Fetch Processor
ALU
into IR Controller Control
/Status
– PC: program
counter, always Registers
points to next
instruction PC IR
100 R0 R1
load R0, M[500]
– IR: holds the
fetched instruction I/O
• Decode Processor
ALU
instruction means Controller Control
/Status
Registers
PC 100 IR R0 R1
load R0, M[500]
I/O
ALU
memory to datapath Controller Control
register /Status
Registers
10
PC 100 IR R0 R1
load R0, M[500]
I/O
• Execute Processor
ALU
the ALU Controller Control
/Status
– This particular
instruction does Registers
I/O
ALU
register to memory Controller Control
/Status
– This particular
instruction does Registers
I/O
PC=100 Processor
Fetch Exec. Store
Fetch Decode ops results
Control unit Datapath
ALU
clk Controller Control
/Status
Registers
10
PC 100 IR R0 R1
load R0, M[500]
I/O
PC=100 Processor
Fetch Exec. Store
Fetch Decode ops results
Control unit Datapath
ALU
clk Controller Control +1
/Status
PC=101
Fetch Exec. Store Registers
Fetch Decode ops results
clk
10 11
PC 101 IR R0 R1
inc R1, R0
I/O
PC=100 Processor
Fetch Exec. Store
Fetch Decode ops results
Control unit Datapath
ALU
clk Controller Control
/Status
PC=101
Fetch Exec. Store Registers
Fetch Decode ops results
clk
10 11
PC 102 IR R0 R1
store M[501], R1
PC=102
Fetch Exec. Store
Fetch Decode ops results I/O
ALU
buses, memory data Controller Control
interface /Status
bit, even 64
• PC size determines I/O
ALU
period Controller Control
/Status
– Must be longer than
longest register to Registers
register delay in
entire processor PC IR
– Memory access is
often the longest I/O
Memory
Wash 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
Non-pipelined Pipelined
Dry 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
Fetch-instr. 1 2 3 4 5 6 7 8
Decode 1 2 3 4 5 6 7 8
Execute 1 2 3 4 5 6 7 8
Instruction 1
Store res. 1 2 3 4 5 6 7 8
Time
pipelined instruction execution
Processor Processor
• Princeton
– Fewer memory
wires
• Harvard
– Simultaneous Program
memory
Data memory Memory
(program and data)
program and data
memory access
Harvard Princeton
Memory
...
• Instruction Set
– Defines the legal set of instructions for that processor
• Data transfer: memory/register, register/register, I/O, etc.
• Arithmetic/logical: move register through ALU and back
• Branches: determine next PC value when not just PC+1
Embedded Systems Design: A Unified 22
Hardware/Software Introduction, (c) 2000 Vahid/Givargis
A Simple (Trivial) Instruction Set
Immediate Data
Register-direct
Register address Data
Register
Register address Memory address Data
indirect
Data
SwitchOn:
LPT Connection Pin I/O Direction Register Address
mov dx, 3BCh + 0 ; base + 0 for register #0 1 Output 0th bit of register #2
in al, dx ; read the current state of the port
or al, 01h ; set first bit (masking) 2-9 Output 0th bit of register #2
out dx, al ; write it out to the port
10,11,12,13,15 Input 6,7,5,4,3th bit of register #1
Done: pop dx ; restore the content
pop ax ; restore the content
14,16,17 Output 1,2,3th bit of register #2
CheckPort endp
execution MOV
MOV
R0, 1324
R1, file_name
--
--
system call “open” id
address of file-name
the OS L2:
• Development processor
– The processor on which we write and debug our programs
• Usually a PC
• Target processor
– The processor that the program will run on in our embedded
system
• Often different from the development processor
• Compilers
C File C File Asm.
– Cross compiler
File
• Runs on one
Compiler Assembler
processor, but
generates code for
Binary
File
Binary
File
Binary
File
another
• Assemblers
Linker
Debugger
Library
Exec.
• Linkers
Profiler
File
• Debuggers
Verification Phase
•
Implementation Phase
Profilers
Embedded Systems Design: A Unified 32
Hardware/Software Introduction, (c) 2000 Vahid/Givargis
Running a Program
Sources: Intel, Motorola, MIPS, ARM, TI, and IBM Website/Datasheet; Embedded Systems Programming, Nov. 1998
down 0001
Mov2 M[dir] = RF[rn]
to Fetch