Embedded Processor Notes Unit1
Embedded Processor Notes Unit1
Many Arm-based devices are used all over the world and are one of the
popular architectures within the devices. The architecture can be divided
into A, R, and M profiles.
ARM Processors derive their name from the acronym "Advanced RISC
Machines," signifying their connection to the broader family of CPUs that
adhere to the RISC architecture. In essence, Advanced RISC Machines
have laid the foundation for the architecture of ARM processors, giving
them their distinctive name.
architectural simplicity
compact size
reduced complexity. This inherent simplicity allows for optimal
performance when integrated into a system, delivering high levels
of efficiency.
RISC Design: ARM processors follow the RISC design philosophy, which
emphasizes simplicity and efficiency. They have a streamlined instruction
set with fixed-length instructions, a large set of general-purpose registers,
and a load/store architecture.
• The ARM is a Von Neumann, load/store architecture i.e. only 32-bit data
bus for both instruction and data. Also for the load/store instruction access
memory.
• First models had only a 26-bit program counter, limiting the memory
space to 64 MB.
bytes, 16 bit half-words or 32 bit words and may be seen as a byte line
that has ARMv7 design. There are 3 sub families within the ARM cortex
family:
b) Booth multiplier
c) Barrel shifter
d) Control unit
e) Register file
• The ARM processor co jointly has other components like the Program
status register, which contains the processor flags (Z, S, V and C).
• The modes bits conjointly exist within the program standing register, in
addition to the interrupt and quick interrupt disable bits;
Some special registers: Some registers are used like the instruction,
memory data read and write registers and memory address register.
[Link] encoder: The encoder is used in the multiple load and store
instruction to point which register within the register file to be loaded or
kept. Priority encoders help to load the instruction and to store it in the
specified register in order to manage the files. This helps to identify the
registers and instructions easily in the architecture.
2. Multiplexers: Several multiplexers are accustomed to the management
operation of the processor buses.
3. Arithmetic Logic Unit (ALU): The ALU has two 32-bits inputs. The
primary comes from the register file, whereas the other comes from the
shifter. Status registers flags modified by the ALU outputs. The V-bit
output goes to the V flag as well as the Count goes to the C flag. Whereas
the foremost significant bit really represents the S flag, the ALU output
operation is done by NOR ed to get the Z flag. The ALU has a 4-bit
function bus that permits up to 16 opcodes to be implemented. 32-bit
inputs are used in Arithmetic and Logic Unit which comes from register
files and shifter. The outputs are modified in register flags. There are C
flag, V flag, S flag and Z flag. 16 opcodes can be implemented with the
help of 4-bit function bus in the microprocessor. V-bit output goes to the V
flag and C output to the C flag and so on.
4. Booth multiplier factor: The multiplier factor has 3 32-bit inputs and the
inputs return from the register file. The multiplier output is barely 32-Least
Significant Bits of the merchandise. The entity representation of the
multiplier factor is shown in the above block diagram. The multiplication
starts whenever the beginning 04 input goes active. Fin of the output goes
high when finishing.
The shifter has different control inputs coming back from the instruction
register. The Shift field within the instruction controls the operation of the
barrel shifter. This field indicates the kind of shift to be performed. The
quantity by which the register thought to be shifted is contained in an
immediate field within the instruction or it might be the lower 6 bits of a
register within the register file.
7. Incremented:
• For load and store instructions, the incremented updates the contents of
the address register before the processor core reads or writes the next
register value from or to the consecutive memory location.
• The processor core continues the execution of instruction. Only when an
exception or interrupt occurs, the normal execution flow is changed.
8. Address Register: This holds the address generated by the load and
store instructions and places it on the address bus.
[Link] file : This is a bank of 32-bit registers used for storing data
items.
MOV R0, R1, ASR #2. R0 will have the value of R1 Arithmetic; moved
right by 2 bits after this instruction is executed.
(4) Rotate to the right. This will rotate the value of a register by n bits,
ex:
MOV R0, R1, ROR R2. R0 will have the value of R1 rotated right
for R2 times once this instruction is executed.
(5) Extend right rotation This is comparable to Rotate right by one bit with the
carry flag put into the MSB, The value of register R1 will be rotated right
through carry by 1 bit once this instruction is executed.
Addressing Modes for Memory Access Operand
To access memory, load and store instructions are utilised, as previously
mentioned. The various memory
access addressing modes are as follows:
(i) Register indirect addressing mode
(ii) Indirect addressing mode for relative registers
(iIi) Indirect addressing method with a base index
(iv) Scale register addressing mode as a base
As demonstrated in the examples for each addressing method, offset addressing,
pre-index addressing, and post index addressing are all available.
(i) Register indirect addressing mode
A register is utilised in this addressing mechanism to provide the address of the
memory region to be accessed.
LDR R0, [R1] is an example. This instruction loads the 32-bit word at the
memory location contained in register R0 into register R0.
(ii) Indirect addressing mode for relative registers
An instantaneous value applied to a register generates the memory address in
this addressing style. This method of addressing allows for both pre- and post-
indexing.
For example, (a) LDR R0, [R1, #4]
This instruction loads the register R0 with the word at the memory regions
computed by adding the constant address included in the R1 register value 4 to
the memory address stored in the R1 register,
e.g. (b) LDR R0, [R1, #4]!
This is a type of addressing that comes before the index. This instruction is the
same as (a) in that it sets the new address in R1, i.e. R1 (R1 + 4).
e.g. (c)’LDR, [R1], #4
This is referred to as post-index addressing. This instruction loads the word at
the memory location supplied in register R1 into register R0. It will then
compute the new address by multiplying R1 by 4 and storing it in R1.
(ii) Indirect addressing method with a base index
The memory address is produced by adding the values of two registers in this
addressing scheme.. For example,
(a) LDR R0, [R1, R2]
Pre indexing and post indexing is also supported.
This instruction will load the word at the memory address determined by adding
register R1 and register R2 into register R0.
For example,
(b) LDR R0, [R1, R2]! This is pre-index addressing.
This instruction loads the word at the memory location supplied in register R1
into register R0. The new address will then be calculated by adding the value in
register R2 to register R1 and placed in R1.
(iii) Scaled register addressing mode as a base
The memory address is produced by adding a register value to another register
that is moved left in this addressing scheme. This addressing technique allows
for pre-indexing and post-indexing.
For ex: (a) LDR R0, [R1, R2, LSL #2]
The word at the memory location computed by adding register leith register R2
shifted left by 2 bits will be loaded into register R0 using this command. For
instance, (b) LDR RO,[R1, R2, LSL #2]!
ARM Registers
Basically there are two types of registers –
General purpose registers and Special purpose registers.
General purpose registers hold either data or an address. The letter r is prefixed
to the register number to identify them. For example, the label r4 is assigned to
register 4. Figure depicts the active registers that are available in user mode,
which is a protected state that is often utilized for running programmes. There
are seven various modes that the CPU may work in, which we shall go through
momentarily. The registers in this example are all 32 bits in size. Up to 18 active
registers are available: 16 data registers and 2 processor status registers. The
data registers are labeled r0 through r15 by the programmer. The ARM
processor contains three registers: r13, r14, and r15, each of which is allocated
to a specific duty or unique function. To distinguish them from the other
registers, they are typically given separate labels. The coloured registers
indicate which special-purpose registers have been allocated.
Register 13 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 15 is the program counter (PC) and contains the address of the next
instruction to be fetched by the processor.
Few of these registers are actually banked and different registers are available
for different processor modes.
SP ( Stack Pointer )
The stack pointer, often known as the SP register, is located in register r13.
Each exception mode has its own version of r13, pointing to a stack
specialised to that mode.
Temporary values are stored in the stack.
LR ( The link register )
The Link register, also known as register r14, is used to store the subroutine’s
return address.
When an exception occurs, the version of r14 in the exception mode is set to
the address after the instruction is executed.
SPSR is a copy of the CPSR just before an exception has occurred.
PC ( Program Counter )
The Program Counter, sometimes known as the PC, is located in register r15.
It’s used to determine which instruction will be executed next.
The PC is referred to as an instruction pointer because it stores the address of
the next instruction.
CPSR (Current Processor Status Register )
•Current processor status register (CPSR) contains the current status of the
processor.
•This includes various conditional code flags, Interrupt Status Processor mode
and other status and control information.
•The exception modes also have a saved processor status register (SPSR), that is
used to preserve the value of CPSR when the associated exception occurs.
•Because the User and System modes are not exception modes, there is no
SPSR available.
SPSR (Saved Processor Status Register)
In the exception modes there is an additional Saved Processor Status register
(SPSR) which holds information on the processor’s state before the system
changed into this mode i.e. the processor status just before an exception.
ARM Pipelining
Pipelining is a design method or procedure that improves the efficiency of data
processing in computer and microcontroller processors. By keeping the CPU in
a continuous fetching, decoding, and execution process known as (the F&E
cycle).
RISC (Reduced instruction set computer) employs a pipelining approach to
execute instructions. Pipelining in ARM boosts execution speed.
by retrieving the instruction and executing it while other instructions are
being decoded and executed at the same time.
As a result, the memory system and CPU can run continually.
Each ARM family has a distinct pipeline architecture.
3-s pipeline is the mechanism a RISC processor uses to execute instructions.
Using a pipeline speeds up execution by fetching the next instruction while
other instructions are being decoded and executed. One way to view the
pipeline is to think of it as an automobile assembly line, with each stage
carrying out a particular task to manufacture the vehicle.
3-Stage Pipelining Schematic
Fetch retrieves a memory instruction.
Decode identifies the to-be-executed instruction.
The instruction is processed by Execute, and the result is written back to the
register.
The speed of execution is boosted by overlapping the aforementioned steps of
execution of various instructions.
The pipelining technique allows the core to execute an instruction once every
cycle, resulting in higher throughput
Interrupt vectors
Hardware interrupts can be used for lots of different purposes. Some interrupts
might occur extremely often (many tens of thousands of times per second) – in
the case of fast peripherals, such as SPI, or a serial port set to a very high baud
rate. This in itself is fine, but we need to be careful with overhead. Interrupts
“eat away” processor time from the main processing task – if we’re not careful,
we could end up consuming more time than the processor has (and cause it to
totally lock up).
Then again, some interrupts are very infrequent, at least on a µC’s MHz
performance scale. The solution to get high performance is called “interrupt
vectoring” and causes each type of interrupt to jump to a different ISR. The first
words in flash memory are reserved precisely for this purpose, and are normally
set up to hold the addresses of each of the ISRs. This means that when any
specific ISR is called, it will know exactly what just happened and can do
whatever is needed (i.e. copy some data in or out), to then return quickly.
ARM COPROCESSORS
Coprocessors can be attached to the ARM processor. A coprocessor extends the
processing features of a core by extending the instruction set or by providing
configuration registers. 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. Consider, for example,
coprocessor 15: The ARM processor uses coprocessor 15 registers to control the
cache, TCMs, and memory management. The coprocessor can also extend the
instruction set by providing a specialized group of new instructions. For
example, there are a set of specialized instructions that can be added to the
standard ARM instruction set to process vector floating-point (VFP) operations.
These new instructions are processed in the decode stage of the ARM pipeline.
If the decode stage sees a coprocessor instruction, then it offers it to the relevant
coprocessor. But if the coprocessor is not present or doesn't recognize the
instruction, then the ARM takes an undefined instruction exception, which
allows you to emulate the behavior of the coprocessor in software.
Coprocessor-only model
The MPI coprocessor-only or native model has the MPI processes launched and
residing solely on the coprocessor. MPI libraries, the application, and other
needed libraries are uploaded to the coprocessors. Then an application can be
launched from the host or from the coprocessor. Once the application is running,
MPI network communications between other coprocessors (either on the local
node or to other network fabric connected nodes) are managed by the Intel®
Coprocessor Communications Link (Intel® CCL) services. Intel CCL provides
underlying services to the MPI library to select the optimal transport for MPI
messages. One such Intel CCL transport mechanism is the peer-to-peer PCI
Express DMA support described in Chapter 8 to directly transfer message data
between the coprocessor’s memory and a peer InfiniBand (IB) adapter without
host memory staging. Figure 9.5 illustrates the MPI Coprocessor-Only model.
More details on the structure and components of Intel CCL are described later in
this chapter.
Coprocessor Interface
The Armv8 architecture also includes a coprocessor interface designed to allow
the integration of hardware accelerators that extend the compute capabilities of
the Cortex-M processor. The coprocessors are not peripherals in that they do not
provide an interface to the external World like an ADC. Typically, the
coprocessor will be an accelerator for specific algorithms such as a DSP or
cryptographic accelerator. Each coprocessor is tightly coupled to the Cortex-M
processor to provide a low latency interface. Dedicated single cycle instructions
are used to move 32- or 64-bit data to and from the Cortex-M processor
registers. The Armv8-M architecture provides control and data channels for up
to eight separate coprocessors with an addressing scheme shown in Table 7.4
When an Armv8-M-based microcontroller is fitted with a coprocessor, the
silicon vendor will typically provide a supporting library of functions that are
used to access the coprocessor features. For example, the NXP lpc55s69 is a
Cortex-M33-based microcontroller that includes a cryptographic coprocessor
and a DSP coprocessor. Both are supported by vendor libraries so you don’t
need to do any low-level code development.
ARM Interrupt Structure
A collection of reduced instruction set computer (RISC) instruction set
architectures for computer processors that are tailored for different contexts is
known as ARM (stylized in lowercase as an arm; originally an abbreviation for
Advanced RISC Machines. System-on-a-chip (SoC) and system-on-module
(SOM) designs, which combine various components including memory,
interfaces, and radios, are examples of devices that other firms design and
manufacture using one or more of the architectures that ARM Ltd. develops and
licenses. Additionally, it develops cores that use these instruction set
architectures and licenses these designs to a large number of businesses, who
then use them to create their own products.
The ARM design has gone through multiple iterations. The original ARM1
featured a 32-bit internal structure but only supported 64 MB of main memory
due to its 26-bit address space. The ARMv3 series, which has a 32-bit address
space, abolished this restriction, while subsequent generations up to ARMv7
maintained this constraint. With its new 32-bit fixed-length instruction set, the
2011-released ARMv8-A architecture gained capability for 64-bit address space
and 64-bit arithmetic. Arm Ltd. also released a number of additional instruction
sets for various rules. Simultaneous multithreading (SMT) has been added more
recently for fault tolerance or improved performance.
For light, portable, battery-powered devices like smartphones, laptops, and
tablet computers, as well as other embedded systems, ARM processors are
preferred because they are less expensive, consume less power, and generate
less heat than their competitors. However, ARM processors are widely
employed in servers and desktop computers, notably Fukuku, which will hold
the record for the fastest supercomputer from 2020 until 2022. As of 2022,
ARM will have created over 230 billion ARM chips, making it the most popular
and most abundant family of instruction set architectures (ISA). To include or
exclude optional capabilities, there are currently variants of the popular Cortex
cores, older “classic” cores, and specialized SecurCore cores available for each
of these.
Structure of ARM interrupt:
The following points help us in understanding the structure of ARM interrupt:
All interrupts are disabled on startup for the ARM CPU until the
initialization code turns them on. The Processor Status Registers’ bit can be
changed to enable or disable the interrupts (PSR or CPSR where C stands
for current). The CPSR also determines whether the processor is decoding
Thumb instructions and the processor mode (SVC, System, User, etc.). The
application can read and write to the CPSR in its entirety when operating in
privileged mode, but it can only read the CPSR when operating in non
privileged mode. The processor enters the appropriate interrupt or exception
mode in response to an interrupt or exception, which causes a portion of the
main registers to be banked, swapped out, or replaced with set mode
registers.
The interrupt masks’ ability to be enabled and disabled is controlled by bits.
The two interrupt inputs on the ARM processor can both be regarded as
general-purpose interrupts. Interrupt Request (IRQ) and Fast Interrupt
Request are the names of the first and second, respectively (FIQ)
The regular sequential execution of instructions can be stopped by one of
seven events on the ARM processor. Since not all events are created equal,
the processor must adopt a priority strategy because these events may occur
simultaneously. For instance, since it happens when the power to the ARM
processor is switched, the Reset has the highest priority. As a result, a reset
supersedes all other events when it happens. The only exception to this rule
is a Reset event, which takes precedence over all other events when a Data
Abort occurs. Since the ARM processor must recognize the event with the
highest importance when several events are happening at once, this priority
mechanism is crucial.
The vector table begins at 0x00000000, as was indicated in earlier chapters
(ARMx20 processors can optionally locate the vector table address to
0xffff0000). A vector table is a collection of ARM instructions that control
the computer (i.e. B, MOV, and LDR). These commands cause the computer
to jump to a certain area that can deal with a particular exception or
interrupt. Since the FIQ vector is at the end of the table, it can avoid using
the B or LDR instruction. The FIQ handler can now begin execution at the
FIQ vector point. By preventing the pipe from having to be flushed when
the PC is moved, FIQs can conserve processor cycles.
From an interrupt handler returning The return address from an interrupt or
execution handler must be changed because of the processor pipeline. An
offset will be present in the address that is kept in the link register. As a
result, the offset value must be deducted from the link register.
The interrupt stacks being set up Depending on the hardware being utilized
and the RTOS needs, the interrupt stack may be put in a different location.
The target system will crash if the Interrupt Stack extends into the Interrupt
vector. Unless a check is made on the stack’s extension and a way is
provided to deal with that problem when it happens. The IRQ mode stack
must first be set up before an interrupt may be enabled. Normally, this is
completed in the system’s initialization code. Knowing the stack’s
maximum size is crucial because it allows for the interrupt stack to be
allocated that much space. Possible memory configurations with a linear
address space are shown below.
Interrupt handler installation and chaining. The vector table can be fixed for
ROM and/or FlashROM based devices without the need for installation.
These systems often copy the entire vector table from ROM to RAM as a
block without the need to install individual vectors. Since memory tends to
be remapped during initialization, this method is typically employed.
Placing a vector entry for the IRQ address (0x00000018) or FIQ address
(0x0000001C) so that the entry links to the proper handler is the first step in
installing an interrupt handler. Chaining entails inserting a new entry while
saving the current vector entry. The original handler may regain control if
the newly added handler is unable to handle a certain interrupt source by
calling the saved vector entry.
Another interrupt may occur inside the presently called handler thanks to
nested interrupt handlers. This is accomplished by re-enabling the interrupts
before the current interrupt has been fully handled by the handler. This
feature makes the system more complex for real-time systems. A system
failure could result from subtle timing problems introduced by this
complexity. These small issues can be very challenging to fix. In order to
prevent issues of this nature, the nested interrupt technique needs to be
carefully constructed. In order to prevent the next interrupt from filling
(overflowing) the stack or corrupting any of the registers, context restoration
is protected from interruption.
If nested interrupts are supported, many common issues can be seen as a
result of a rise in complexity. A race condition that results in a cascade of
interrupts is one of the key issues. The handler will experience constant
interruptions up until the point at which the interrupt stack overflows or the
registers become damaged. When designing, efficiency and safety must be
balanced. This entails writing code defensively, assuming issues will arise.
When possible, the system should examine the stack and take precautions to
prevent register corruption.
Multiple interrupts can be handled using a re-entrant interrupt handler,
where interruptions are prioritized. This is significant because interrupts
with a higher priority must have a smaller latency. The typically nested
interrupt handler is unable to perform this kind of filtering. Re-enabling
interrupts early on in the interrupt handler to achieve minimal interrupt
latency is the primary distinction between a re-entrant interrupt handler and
a nested interrupt handler.
A prioritized interrupt handler will assign a priority level to a specific
interrupt source as opposed to the simple and nested interrupt handlers,
which service interruptions on a first-come, first-served basis. The sequence
in which the interrupts are handled is determined by a priority level. A
desirable property in an embedded system is that a higher-priority interrupt
will take precedence over a lower-priority interrupt.