Module-3
Module-3
MODULE: 3
Microprocessors versus Microcontrollers
A microprocessor is an electronic component that is used
by a computer to do its work. It is a central processing
unit on a single integrated circuit chip containing millions
of very small components including transistors, resistors,
and diodes that work together.
In contrast, the
traditional complex CISC RISC
5. Many instructions and many addressing 5.Fixed instructions and few addressing
There are a number of physical features that have driven the ARM
processor design.
The first AMBA buses introduced were the ARM System Bus (ASB)
and the ARM Peripheral Bus (APB). Later ARM introduced another
bus design, called the ARM High Performance Bus (AHB).
The Figure shows the memory trade-offs: the fastest memory cache is
physically located nearer the ARM processor core and the slowest
secondary memory is set further away.
Generally the closer memory is to the processor core, the more it costs
and the smaller its capacity
The cache is placed between main memory and the core. It is used to
speed up data transfer between the processor and main memory.
The memory width is the number of bits the memory returns on each
access—typically 8, 16, 32, or 64 bits.
The memory width has a direct effect on the overall performance and
cost ratio. Lower bit memories are less expensive, but reduce the
system performance.
Types:
There are many different types of memory:
2. Flash ROM It can keep stored data and information even when the
power is off. It can be electrically erased and reprogrammed.
The erasing and writing of flash ROM are completely software controlled
with no additional hardware required, which reduces the manufacturing
costs.
3. Dynamic random access memory (DRAM) is the most commonly used RAM for
devices. It has the lowest cost per megabyte compared with other types of RAM.
DRAM is dynamic—it needs to have its storage cells refreshed and given a new
electronic charge every few milliseconds, so you need to set up a DRAM
controller before using the memory.
4. Static random access memory (SRAM) is faster than the more traditional DRAM,
but requires more silicon area.
SRAM is static—the RAM does not require refreshing. The access time for SRAM
is considerably shorter than the equivalent DRAM. But cost of SRAM is high.
Embedded systems that interact with the outside world need some form
of peripheral device. A peripheral device performs input and output
functions for the chip by connecting to other devices or sensors that are
off-chip.
1. The standard interrupt controller sends an interrupt signal to the processor core when an
external device requests servicing.
The interrupt handler determines which device requires servicing by reading a device
bitmap register in the interrupt controller.
2. The vector interrupt controller (VIC) is more powerful than the standard interrupt
controller, because it prioritizes interrupts and simplifies the determination of which device
caused the interrupt.
EMBEDDED SYSTEM SOFTWARE:
Initialization code (or boot code) takes the processor from the reset state to a state where
the operating system can run.
Booting is the process of starting a computer.
It can be initiated by hardware such as a button press or by a software command.
The initialization code handles a number of administrative
tasks before handing control over to an operating system .
Memory remapping is must for ARM-based embedded systems. Here initialization code is
starts from ROM at power-up.
Then the initialization code remaps the memory map at address of RAM.
2. Diagnostics
Diagnostic code are often embedded in the initialization
code itself.
Diagnostic code tests the system whether the selected targets are
working fine or not.
Booting an image is the final phase, but first you must load the image.
Loading an image involves anything from copying an entire program including code
and data into RAM.
The arrows represent the flow of data, the lines represent the buses, and the boxes
represent either an operation unit or a storage area.
Data enters the processor core through the Data bus. The data may be an instruction to
execute or a data item.
Figure shows a Von Neumann implementation of the ARM—data items and instructions
share the same bus. (In contrast, Harvard implementations of the ARM use two different
buses).
Instruction Fetch: Fetches the instruction from the memory
Instruction Decoder: Decodes the instruction and identifies the opcode of the instruction.
Sign extend hardware: The sign extend hardware converts signed 8-bit and 16-bit numbers to 32-bit values
as they are read from memory and placed in a register.
ALU (arithmetic logic unit) or MAC (multiply-accumulate unit): Takes the register
values Rn and Rm from the A and B buses and computes a result.
Data processing instructions write the result in Rd directly to the register file.
Load and store instructions use the ALU to generate an address to be held in the
address register and broadcast on the Address bus.
Incrementer: For load and store instructions the incrementer updates the address
register before the core reads or writes the next register value from or to the next
sequential memory location.
Registers
General-purpose registers hold either data or an address.
They are identified with the letter r prefixed to the register number. For example, register
4 is given the label r4.
• All the registers shown are 32 bits in size.
• There are up to 18 active registers: 16 data registers and 2 processor status registers.
• The ARM processor has three registers assigned to a particular task or special function:
Register r13 is traditionally used as the stack pointer (sp) and stores the head of the stack
in the current processor mode.
Register r14 is called the link register (lr) and is where the core puts the return address
whenever it calls a subroutine.
Register r15 is the program counter (pc) and contains the address of the next instruction to
be fetched by the processor.
• In addition to the 16 data registers, there are two program status registers:
– cpsr and spsr (the current and saved program status registers, respectively).
• In current designs the extension and status fields are reserved for future use.
• The control field contains the
- processor mode,
-state, and
- interrupt mask bits.
• Abort Mode: The processor enters abort mode when there is a failed attempt to
access memory.
• Fast interrupt and interrupt request modes: Correspond to the two interrupt
levels available on the ARM processor.
• Supervisor mode: is the mode that an operating system kernel operates in.
• System mode: is a special version of user mode that allows full read-write
access to the cpsr.
Thumb State:
Similarly the Thumb instruction set (16 bits) is only active when the processor is in Thumb
state (T=1 and J=0).
In Thumb state the processor executes only Thumb 16-bit instructions. You cannot
intermingle ARM , Thumb, and Jazelle instructions
Jazelle State:
The Jazelle instruction set (8 bits) is only active when the processor is in Jazelle state (T=0
and J=1).
Jazelle executes 8-bit instructions and is a hybrid mix of software and hardware designed
to speed up the execution of Java byte-codes.
To execute Java byte-codes, Jazelle technology plus a Java virtual machine is required.
Interrupt Masks
• Interrupt masks are used to stop interrupt requests from interrupting the
processor.
• There are two interrupt request levels available on the ARM processor core
- interrupt request (IRQ) and
- fast interrupt request (FIQ).
• The cpsr has two interrupt mask bits, 7 and 6 (or I and F), which control the
masking of IRQ and FIQ, respectively.
• The I bit masks IRQ when set to binary 1, and similarly the F bit masks FIQ
when set to binary 1.
Condition Flags
For the condition flags a capital letter shows that the flag has been set.
Prior to execution, the processor compares the condition attribute with the
condition flags in the cpsr.
Execute processes the instruction and writes the result back to a register
Pipeline Executing Characteristics
The three instructions are placed into the pipeline sequentially.
In the first cycle, the core fetches the ADD instruction from memory.
In the second cycle, the core fetches the SUB instruction and decodes the ADD
instruction.
In the third cycle, both the SUB and ADD instructions are moved along the
pipeline. The ADD instruction is executed, the SUB instruction is decoded, and
the CMP instruction is fetched.
This procedure is called filling the pipeline.
Exceptions, Interrupts, and the Vector
Table
When an exception or interrupt occurs, the processor sets the pc to a specific
memory address.
The entries in the vector table are instructions that branch to specific routines
designed to handle a particular exception or interrupt.
Each vector table entry contains a form of branch instruction pointing to the
start of a specific routine.
Reset vector:
is the location of the first instruction executed by the processor when power
is applied. This instruction branches to the initialization code.
• There are three hardware extensions ARM wraps around the core:
- cache and Tightly Coupled Memory(TCM),
- memory management, and
- the coprocessor interface.
Cache and Tightly Coupled Memory(TCM),
The cache is a block of fast memory placed between main memory and the core.
It allows for more efficient fetches from some memory types.
With a cache the processor core can run for the majority of the time without
having to wait for data from slow external memory.
It combines both data and instruction into a single unified cache, as shown in the
following Figure.
The second form, attached to the Harvard-style cores, has separate caches for
data and instruction, as shown in the following Figure.
A cache provides an overall increase in performance, but at the expense of
predictable execution.
But the real-time systems require the code execution to be deterministic— the
time taken for loading and storing instructions or data must be predictable.
This is achieved using a form of memory called tightly coupled memory (TCM).
TCM is fast SRAM located close to the core and guarantees the clock cycles
required to fetch instructions or data.
It is usually necessary to have a method to protect the system from applications trying to
make inappropriate accesses to hardware.
MPUs employ a simple system that uses a limited number of memory regions.
These regions are controlled with a set of special coprocessor registers, and each
region is defined with specific access permissions. This type of memory
management is used for systems that require memory protection.
More than one coprocessor can be added to the ARM core via the coprocessor
interface.
The coprocessor can be accessed through a group of dedicated ARM instructions
that provide a load-store type interface.
The coprocessor can also extend the instruction set by providing a specialized
group of new instructions.
These new instructions are processed in the decode stage of the ARM pipeline.