Docsity

Embeded system Concepts Arm processor, Lecture notes of Embedded Control Systems

Toggle sidebar
bg1
Embedded Systems
Dr Santanu Chaudhury
Department of Electrical Engineering
IIT Delhi
Lecture 5
ARM Processor
In the last class we had discussed PIC processors which were targeted primarily for low
end applications. Today, we shall start our discussions on ARM processor which are
basically 32 bit processors and are meant for particularly high end applications, in fact,
applications which involve more complex computations.
(Refer Slide Time 01:27 min)
If you look at history of ARM processors, it was first developed at Acron computer
limited of Cambridge England between 1983 and 85. It is just after 1980 when the
concept of RISC was introduced at Stanford and Berkley. Subsequently ARM limited
was formed in 1990 and what ARM popularized is a concept of ARM core, the processor
core which they have licensed to a number of other manufactures to made variety of
chips around that same processor core.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Embeded system Concepts Arm processor and more Lecture notes Embedded Control Systems in PDF only on Docsity!

Embedded Systems Dr Santanu Chaudhury Department of Electrical Engineering IIT Delhi Lecture 5 ARM Processor

In the last class we had discussed PIC processors which were targeted primarily for low end applications. Today, we shall start our discussions on ARM processor which are basically 32 bit processors and are meant for particularly high end applications, in fact, applications which involve more complex computations.

(Refer Slide Time 01:27 min)

If you look at history of ARM processors, it was first developed at Acron computer limited of Cambridge England between 1983 and 85. It is just after 1980 when the concept of RISC was introduced at Stanford and Berkley. Subsequently ARM limited was formed in 1990 and what ARM popularized is a concept of ARM core, the processor core which they have licensed to a number of other manufactures to made variety of chips around that same processor core.

So, what we shall be starting is it is just not a family of processors but conceptually a CPU architecture which may figure in a number of different chips intended for embedded applications. The ARM architecture is based upon RISC architecture but it is not a purely RISC architecture because it has been enhanced to meet requirements of embedded applications.

So, the basic idea is that taken RISC code that is basic idea where RISC architecture, in ARM we shall find various enhancements which have been made into it to make it more suited for embedded applications. And these actually distinguish ARM from other typical RISC processors. There are various variations of this architecture, in fact the whole idea is that this architecture has undergone a number of versions and these versions have been implemented into number of processors having distinct identities and numbers. So, here we have listed four such versions, version 1, version 2, version 3, version 4 you will find that initially the processor was a 26 bit addressing processor, it had no multiply or provision for core processors. The version 2 really made a 32 bit addressing mode. Version 3 really made it into a 32 bit addressing regis capable and version 2 included multiply as an option. Now, this is a definite departure from PIC.

PIC, like other simple micro-controllers simply support add and subtract operations. Here, in this instructions set itself I have got multiply. In fact we shall see also variations of multiply in the instruction set of all. In fact version 4 was characterized by enhanced set of instruction and in version 4 itself they introduced what is called the thump mode and this version is called version 4T which included a 16 bit mode. Now, this 16 bit mode obviously implies what that given the cell memory if I can use 16 bit instructions I can pack additional instructions. So, I can use this effectively same memory for more instructions and thereby I can increase code density. And this is particularly useful when you really do not require 32 bit operations. And this embedding of a 16 bit variant inside the 32 bit architecture came in version and that is being refer to as version 4T is for thumb. Then you have got version 5T which is superset of 4T adding new instructions and the version 5TE add its signal processing instructions. In fact the instruction which are targeted for signal processing applications into the basic set. In fact this is again are departure from classical RISC concept.

This data part is organized in such a way that the operands are not directly fetched from memory because that is the basic feature of a RISC. So the operands are typically stored in the register file and instruction typically use 2 source registers and single result or destination registers wherever required, okay. If the operation involves just 2 registers then obviously the third register will not be there. But the more interesting thing is last two points, there is a barrel shifter on the data path which can preprocess data before it enters ALU. What is the Barrel shifter? Barrel shifter is basically a combinational circuit which can shift the data bits to the left or to the right by arbitrary number of positions in the same cycle itself. If I look at a classical shift register, in a classical shift registers involving flip flops what happens, the number of shifts require the equivalent number of clock cycles because a shifting takes place on the basis of clock. But here it is combinational circuits so that the shift takes place at one go itself. In fact the shift takes place in the same instruction cycle. This is very basic enhancement in the ARM data path. The other interesting feature is the increment and decrement logic which can operate on the registers independent of the ALU. So, you have got a facility for implementation of what we call auto increment and auto decrement addressing modes. In fact this is not uncommon with SISC processors but these has been brought in ARM to facilitate certain operations that is particularly block move kind of operations and that way it is an enhancement on the key RISC model.

So let us look at the basic ARM organization. Now what is interesting here is that this is the register bank that we were talking about. The register bank is connected to the ALU where two data parts one is your A bus, another data part is your B bus and this B bus goes via the Barrel shifter. So, this Barrel shifter can actually preprocess the data which can come from one of this source registers; and the Barrel shifter can shift to the left, shift to the right or even rotate the data before it is fed to the ALU. Now, since all of these are basically, ALU also, combinational circuit, Barrel shifter is also combinational circuit. So, the entire, all these operations that is operation that ALU carries out as well as operation that Barrel shifter carries out can take place in one cycle itself and that actually splits up to the operation execution speed. Now, what you find here is that I can use my register bank for generation of the address as well, okay. In fact the PC address is, PC also is part of the register bank and that can generate the address. As well as the other register banks, okay can be made use of for generation for manipulation of address. Because registers are in a way symmetric they can have both address as well as the data and they can be operated in a symmetric way. The PC generates the address for the instruction. Now here, we have not indicated whether it would be an Harvard or VanNeuman architecture typically, okay. So, what we have concentrating primarily here, the data path. So, what will find in this case this incremental block, this incremental block enables you to decrement or increment the register values independent of the ALU. In fact the PC value can be incremented and put back to the registers so on and so forth. Other operations can also be done with this registers using this incremented and decremented block. This is the instruction decode and control and that provides a control signal and what you have shown here is this is a basic block where my address bus is 0 to

in variety of other processor as well. This link register is a register where return address is put whenever a subroutine is called. So, whenever a subroutine is called the return address typically you will expect the model wise, we have talked about earlier in the contest of PIC; the return address goes into stack. In PIC, it was a hardware stack different from the program or data area. Here, we have got a single link register and in the link register the return address is put in. Then r15 is the program counter and obviously the current instruction what is being executed will be pointed to by the content of r15.

(Refer Slide Time 20:09 min)

Now, depending on the context registers r13 and r14 can also be used as general purpose registers, although this is not a very common usage because you understood that r13 and r14 has got a special role to play. The, any instruction which use r0 can as well be used to any other GPR, okay and in addition there are 2 status registers. CPSR, current program status register and SPSR what is called saved program status register. These are basically the status registers which are not data registers. So, here in this registers effectively the status of the current execution is being captured. In fact this status can include status of your program as well as that of the processor. The r15, the register is the, is basically the PC, so these instructions, so this is, this will be a 32 bit wide because that will have the address.

And when it is operating in your 32 bit mode, that is not in the mode, all instructions will be 32 bit and the addresses are also 32 bit and what we assume that all instructions are word aligned. That means all 32 bit instructions start at 32 bit boundary; this is very important, okay. And what does that imply, that implies that PC value is stored effectively in bits from 2 to 31, bit numbers 2 to 31, with bits 1, 0 effectively undefined or not really useful for referring to an instruction. Now, obviously this discussion refers to one fact that my 32 bit address in ARM refers to byte locations. Each byte with associated with a unique address so, if I am talking about 32 bit boundaries that means effectively I am talking about what blocks of 4 bytes. So, if I have one instruction starting at location 0 then that instruction will occupy location 0, 1, 2 as well as 3, fine. The next instruction would be located at 4 so, therefore these 2 bits, the least significant bits of PC that is r15 or in a way do not care for operations, okay. So, that is why we say that PC value is effectively stored in bits from 2 to 31.

maximum value, it is all ones. And if I had 1 to it the actually 32 bit content would become 0, okay. Now, I may not like the 32 bit, 32 bit value to becomes 0,I may like it to stick to all oneโ€™s. That is a maximum value be retained. Now, that is enabled in saturation arithmetic and that is required for a number of signal processing tasks. In fact the architecture 5TE has got signal processing extension and that is why this Q flag, the saturation arithmetic flag becomes significant or important or relevant with respective to that architecture. The processors modes, why are these processor modes are there? They are there to define various kinds of registers; their visibility as well as rights to what we call modify CPSR register. So, we call the processor modes either privileged or non-privileged mode. In a privileged mode you expect to have full read-write access to the CPSR. In a non-privileged mode only read access to the control field of CPSR but read-write access to the condition flags.

(Refer Slide Time 26:57 min)

Now, try to understand this- what is the implication of these privileged and non- privileged modes. In a privileged mode what can happen actually, in a privileged modes as you can change the control bits that means you can have a full read as well as write access of the control bits. You can actually change the processor mode, you can enable, disable the interrupts. So, this is a privileged operation. In a non- privileged mode, these control fields can be simply read but can not be changed, but the condition flags which can change because of an arithmetic operation would normally reflect the status of the arithmetic operation and that should be remain write enable even in non-privileged modes.

So, typically you will find that when we talk about these kind of operations, a typically user program is expected to run in a non- privileged mode because in user program is normally not expected to change the control bits. And in a privileged mode typically you will expect the OS or the supervisory cell to run. Since we are targeting for ARM for more sophisticated applications, typically there would be an OS running in an ARM based system under which user programs are expected to execute. The OS is typically expected to be running in privileged mode and user applications running in non- privileged mode. In fact ARM has got 7 modes and these 7 modes can be now classified as privileged and non- privileged. In fact the privileged modes are abort first interrupt request, supervisor system and another is undefined. What are they? We shall just look at and non- privileged this user mode and user mode is used for programs and applications.

(Refer Slide Time 29:51 min)

Now, privileged modes represent different scenarios. Abort is a mode when there is a failed attempt to access memory. This can happen for variety of reasons but this reasons we shall look at when we consider the memory architecture subsequently. But this is a particular mode in which the processor goes in when it detects that there is a failure to access the memory location.

And it is also targeted for supervisory applications; many of the OS routines can be configured to run in the system mode. The undefined mode, processer enters this undefined mode when it encounters an undefined instruction that means when you are trying to use an illegal op-code for undefined instruction, the instruction undefined for particular processor, then it goes into an undefined. So, what you have found is that these privileged modes are primarily targeted for OS handling of special error conditions as well as that of interrupts and user mode is a mode intended for running user applications. Now, these modes have got associated with them a very interesting capability to manage the registers. So, we go into the concept of what we call banked register in ARM architecture. ARM has got 37 registers in all and typically 20 registers are hidden from program at different times.

So, they are not visible registers and they are actually called banked registers and this banked registers becomes available only when processors is in a particular mode. In fact processors modes other than system mode have a set of associated banked registers that are subset of these 16 registers that we have talked about in the user mode, okay. And these banked registers have one-to-one mapping with the user mode registers, okay; this banked registers have one-to-one mapping with the user mode registers. So, what happens, let us look at this, so I have use I am operating, let us say in a user mode, by some means I am in the user mode. So, in the user mode there are the 16 data registers which are available, okay and the current program which is getting executed, that status would get reflected in the CPSR register. Now, if the processor goes into some other mode, let us say that FIQ mode. FIQ is what- first interrupt; IRQ is interrupt request model. Now, in an FIQ mode, what we will find that I have got banked register r8, r9, r10, r11, r12 becoming available as well as r13 and r14. What does that mean? These registers, I told you as got a one-to-one correspondence with the registers in the user mode that means effectively what I am getting in a first interrupt mode, I am getting a fresh copy of r8 to r14. I am getting a fresh copy of r8 to r14.

what you get in these modes what are called SPSR. So, what is the SPSR- save program state register. So, CPSR is copied into SPSR which becomes available in FIQ mode. So, when I return from this mode to say user mode, I have to take this content of SPSR back to CPSR because CPSR would be storing the current status; so when I am going back I should have the current status of the computation back with me. So, pictorially what we say here on the abort SPSR is each privileged mode except system mode has associated with it a save program status register or SPSR.

(Refer Slide Time 38:07 min)

This SPSR is used to save the status of CPSR when the privileged mode is entered in order that the user state can be fully restored when the user process is resumed; this is particularly the job of SPSR. So, now if you summarize what we have saved that in the user mode I have got these 16 registers as well as CPSR. In FIQ mode what I have got, I have got same r0 to r7 registers as that of user mode but a fresh copy of these registers, okay. Similar thing in IRG; IRG have got I can use the registers same as that of r0 to r12 that fresh copy of r13 and r1,4 okay and CPSR is showing here. So, this CPSR is copied into SPSR.

But, obviously in FIQ mode I got to have a CPSR which will reflect the state of the processors in that mode during execution of that program, okay. So, effectively what we are telling is that in these modes if you have writing onto this registers I shall overwrite the original data. See, if I have to save this data, if I have to get this data back, I need to save it in the stack. But in case of FIQ, I get a fresh copy of registers; so I need not save this register save on to the stack and thereby have reduced software latency.