Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

BFM3333 Course: Microcontroller System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

BFM3333 Course:

MICROCONTROLLER SYSTEM
L2: Common Architecture of Microcontrollers

L2: Lesson outcome

To recognize the common structure of microcontrollers

www.ump.edu.my
LECTURE OUTLINES

- Basic elements of microcontrollers


- Advantages Of PIC microcontrollers
- Microcontroller architecture
- Microcontroller Components
- CPU

3
Basic elements of microchips
• Integrated circuits IC contains many electrical and
electronics components that are working together to build
memory, ALU, registrars run instructions, etc
• A Microcontroller is a VLSI (Very Large Scale
Integration) Integrated Circuit (IC) that contains electronic
computing unit and logic unit (combinely known as CPU).
• The microcontroller are decoding all given instructions
into the language of machine 0 or 1
• The data storage and conversion between the software and
hardware components in microcontrollers need to be so
accurate.

4
Basic elements of microchips

5
Basic elements of microchips

6
Basic elements of microchips

7
Basic elements of microchips

8
PIC Microcontroller Advantages

 Range of low end 8 bit microcontrollers.


 Smallest have only 8 pins, largest 40 pins.
 Typical chip is an 18 pin one.
 Very cheap, you can pick them up at less than £1 each
 Targeted at consumer products, burglar alarms etc.
 It is a RISC (Reduced Instruction Set Computer) design
 Only thirty seven instructions to remember
 Its code is extremely efficient, allowing the PIC to run
with typically less program memory than its larger
competitors.
 It is low cost, high clock speed
9
PIC Microcontroller Architecture

It is following Harvard structure

10
PIC Microcontroller Architecture

Advantage of Harvard architecture


• This is simpler and faster
• Separate program bus and data bus: can be different
widths!
• For example, PICs use:

PIC MICROCONTROLLER 8
• Data memory (RAM): a small number of 8bit registers
• Program memory (ROM): 12bit, 14bit or 16bit wide (in
• EPROM, FLASH, or ROM)

11
PIC Microcontroller Architecture

Example:
An add operation of the form a:=b+c must fetch 2
operands from
memory and write 1 operand to memory. In addition it is
likely to have to fetch 3 instructions from memory.
. With a single memory this will take 6 cycles.
. With 2 memories, we can fetch the instructions in
parallel with the data and do it in 3 cycles.

12
Common Microcontroller Architecture

13
CPU
 A central processing unit (CPU) is the electronic circuitry
within a microcontroller that carries out the instructions of
a computer program by performing the basic arithmetic,
logical, control and input/output (I/O) operations specified
by the instructions.
 CPU is the brain of a microcontroller.
 CPU connects every part of a microcontroller into a single
system.

14
CPU

CPU is responsible for fetching the instruction,


decodes it, then finally executed.

15
CPU
 A basic CPU consists of the data path, which executes instructions,
and of the control unit, which basically tells the data path what to do.

16
CPU
Parts of a CPU:
1. ALU - The arithmetic logic unit executes all calculations
within the CPU
2. CU - control unit, coordinates how data moves around
3.Registers, a memory location within the actual processor that
work at very fast speeds.
of calculations

17
CPU

It stores instructions which await to be decoded


or executed.
1.PC - program counter - stores address of the ->
next <- instruction in RAM
2.MAR - memory address register - stores the
address of the current instruction being executed
3.MDR - memory data register - stores the data
that is to be sent to or fetched from memory
4.CIR - current instruction register - stores actual
instruction that is being decoded and executed
5.ACC - accumulator - stores result

18
CPU: Control Unit

 The task of the control unit to determine which operation


should be executed next and to configure the data path
accordingly.
 To do so, another special register, the program counter
(PC), is used to store the address of the next program
instruction.
 The control unit loads this instruction into the instruction
register (IR), decodes the instruction, and sets up the
data path to execute it.
 Data path configuration includes
1. providing the appropriate inputs for the ALU
(from registers or memory),
2. selecting the right ALU operation,

19
CPU: Control Unit

3. and making sure that the result is written to the


correct destination (register or memory).
 The PC is either incremented to point to the next instruction
in the sequence, or is loaded with a new address in the
case of a jump or subroutine call. After a reset, the PC is
typically initialized to $0000.
 Traditionally, the control unit was hard-wired, that is, it basically
contained a look-up table which held the values of the control
lines necessary to perform the instruction, plus a rather complex
decoding logic.
 This meant that it was difficult to change or extend the instruction
set of the CPU.

20
CPU: Control Unit
 To ease the design of the control unit, Maurice Wilkes reflected
that the control unit is actually a small CPU by itself and could
benefit from its own set of microinstructions.
 In his subsequent control unit design, program instructions were
broken down into microinstructions, each of which did some small
part of the whole instruction (like providing the correct register for
the ALU).
 This essentially made control design a programming task: Adding a
new instruction to the instruction set boiled down to programming
the instruction in microcode. As a consequence, it suddenly became
comparatively easy to add new and complex instructions, and
instruction sets grew rather large and powerful as a result. This
earned the architecture the name Complex Instruction Set
Computer (CISC).
21
CPU: Control Unit
 Of course, the powerful instruction set
has its price, and this price is speed:
Microcoded instructions execute slower
than hard-wired ones.
 Furthermore, studies revealed that only
20% of the instructions of a CISC
machine are responsible for 80% of the
code (80/20 rule).
 This and the fact that these complex
instructions can be implemented by a
combination of simple ones gave rise to
a movement back towards simple hard-
wired architectures, which were
correspondingly called Reduced
Instruction Set Computer (RISC).
22
CPU: Arithmetic Logic Unit
 At the core of the CPU is the arithmetic logic unit (ALU),
which is used to perform computations (AND, ADD, INC, . . .
).
 Several control lines select which operation the ALU should
perform on the input data.
 The ALU takes two inputs and returns the result of the
operation as its output.
 Source and destination are taken from registers or from
memory.

23
CPU: Arithmetic Logic Unit

24
CPU: Arithmetic Logic Unit

25
CPU: Arithmetic Logic Unit

 In addition, the ALU stores some information


about the nature of the result in the status register (also
called condition code register):
Z (Zero): The result of the operation is zero.
N (Negative): The result of the operation is negative, that
is, the most significant bit (msb) of the result is set (1).
O (Overflow): The operation produced an overflow, that is,
there was a change of sign in a two’s complement
operation.
C (Carry): The operation produced a carry.

26
CPU: Register File

 The register file contains the working registers of the CPU.


 It may either consist of a set of general purpose registers
(generally 16–32, but there can also be more), each of which
can be the source or destination of an operation, or it
consists of some dedicated registers.
 Dedicated registers are e.g. an accumulator, which is used
for arithmetic/logic operations, or an index register, which is
used for some addressing modes.
 In any case, the CPU can take the operands for the ALU
from the file, and it can store the operation’s result back to
the register file.

27
CPU: Register File

Register TYPES:

28
CPU: Register File

29
CPU: Register File

30
CPU: Stack Pointer

 The stack is a portion of consecutive memory in the data


space which is used by the CPU to store return
addresses and possibly register contents during
subroutine and interrupt service routine calls.
 It is accessed with the commands PUSH (put something
on the stack) and POP (remove something from the
stack).
 To store the current fill level of the stack, the CPU
contains a special register called the stack pointer (SP),
which points to the top of the stack. Stacks typically grow
“down”, that is, from the higher memory addresses to the
lower addresses. So the SP generally starts at the end
of the data memory and is decremented with every push
and incremented with every pop.
31
CPU: Stack Pointer

 The reason for placing the stack pointer at the end of the
data memory is that your variables are generally at the
start of the data memory, so by putting the stack at the
end of the memory it takes longest for the two to collide.
 Since the SP must be initialized by the programmer, you must
look up how your controller handles the stack and either
initialize the SP to the last address in memory (if a push stores
first and decrements afterwards ) or to the last address
+ 1 (if the push decrements first).

32
Thank you

www.ump.edu.my 33

You might also like