FOCunit 2
FOCunit 2
• CPU Architecture
• Processor organization, register organization,
instruction cycle
• Introduction to Buses
• Interfacing buses (circuit diagrams not necessary),
concepts of address bus, data bus and control bus,
bus width (circuit diagrams not necessary)
• Input and Output
• External devices, I/O modules, Why DMA?, DMA
Internal parts of CPU
• A typical Asus P5N32-E SLI motherboard with constituent components is given below:
• 1. PCI SLOT (Peripheral Component Interconnect) : PCI slots are used to Insert or install
Add-on cards, such as LAN cards, Sound cards, Capture cards and TV tuner cards. There
are usually anywhere from 1 to 6 PCI slots available on the motherboard(above board
has 2 PCI slots. ), they have decreased in number and are being replaced by the PCI
Express 1x slots.
• 2. PCI-E 16x Slot : the most common slot for Graphics cards, the PCI Express 16x slots
provides 16 separate lanes or data transfer. These are the 16x speed versions, which are
currently the fastest. PCI-E16x allows up to 4 GB/s of peak bandwidth per direction, and
up to 8 GB/s concurrent bandwidth.
• 3. PCI-E 1x Slot : Single slot - In the PCIe 1x generation, each lane (1x) carries 250 MB/s
compared to 133 MB/s for the PCI slots. These can be used for expansion cards such as
Sound Cards, or Ethernet Cards.
various slots on motherboard
• 4. Northbridge: This allows communication between the CPU and the system memory and
PCI-E slots. It is a focal Point of Motherboard and It is also called as Memory Controller Hub.
• 5. ATX 12V 2X and 4 Pin Power Connection : This is one of two power connections that supply
power to the motherboard. This is the 4-pin connector which supplies electrical current to your
CPU. This connection will come from your Power Supply.
• 6. CPU-Fan Connection: This is where the CPU fan will connect. Using this connection over one
of the power supply will allow the motherboard to control the speed of the fan, based on the
CPU temperature.
• 7. Socket: This is where the CPU will plug in.
• 8. DIMM slots: DIMM (dual in-line memory module) slots are the place on your motherboard
where the RAM goes. DIMM's are by far and away the most used memory types in today's
computers. They vary in speeds and standards however and they need to match up to what
your motherboard has been designed to take. The four standards of DIMM's being used at the
moment are SDR (Single Data Rate), DDR (Double Data Rate), DDR2 and DDR3. The speeds of
memory can vary between 66Mhz to 1600Mhz.
various slots on motherboard
• 9. ATX Power Connector: This is the second of two power connections. This is the
main power connection for the motherboard, and comes from the Power Supply.
• 10. IDE connectors or PATA connectors : IDE full form is Integrated Device
Electronics. it supports IDE devices, such as Hard disks and CD and DVD drives.
Most drives today come with SATA connections.
• 11. Southbridge: This is the controller for components such as the PCI slots,
onboard audio, and USB connections.
• 12. SATA Connections : SATA full form is Serial Advanced Technology
Attachment. These are connect with serial ATA devices, such as Hard disk drives
and CD or DVD drives.
various slots on motherboard
• 13. Front Panel Connections: this is where we will hook in the connections from the
case. These are mostly the different lights on the case, such as power on, hard drive
activity etc. It is a block of connectors on a motherboard that control the power on,
power reset, beep code speaker and the LED light indicators on your PC case/chassis.
• 14. FDD Connection: The FDD is the Floppy Disk controller. Floppy Drive Connector is
used to connect floppy drives. It supports two floppy drives.
• 15. External USB Connections: There are usually a couple of these ports located on each
motherboard used for connecting pen drives and external hard drives, like Ipods or Mp3
players.
• 16. CMOS battery : The CMOS (complementary metal oxide semiconductor) battery in
the computer is used to store the hardware configuration settings. It also keeps a
record of the date and time when the computer is switched off. The CMOS battery is
inside the computer and attached to the system board (motherboard).
Processor organization
• The major components of the CPU are an arithmetic and logic unit
(ALU) and a control unit (CU).
• The ALU does the actual computation or processing of data.
• The CU controls the movement of data and instruction into and out of
the CPU and controls the operation of the ALU.
• The CPU is connected to the rest of the system through system bus.
Through system bus, data or information gets transferred between
the CPU and the other component of the system.
• The system bus may have three components:
Overview of CPU design
• Data Bus: Data bus is used to transfer the data between main
memory and CPU.
• Address Bus: Address bus is used to access a particular memory
location by putting the address of the memory location.
• Control Bus: Control bus is used to provide the different control signal
generated by CPU to different part of the system. As for example,
memory read is a signal generated by CPU to indicate that a memory
read operation has to be performed. Through control bus this signal is
transferred to memory module to indicate the required operation.
Overview of CPU design
• Registers are the smaller and the fastest accessible memory units in
the central processing unit (CPU). According to memory hierarchy,
the registers in the processor, function a level above the main
memory and cache memory. The registers used by the central unit
are also called as processor registers.
• A register can hold the instruction, address location, or operands.
Types of Registers
User-visible registers
• The control and status register holds the address or data that is
important to control the processor’s operation. The most important
thing is that these registers are not visible to the users.
• Four registers are essential to instruction execution:
Control and Status Registers
• Program Counter (PC):The program counter is a processor register that holds
the address of the instruction that has to be executed next. It is a processor
which updates the program counter with the address of the next instruction to
be fetched for execution.
• Instruction Register (IR): Contains the instruction most recently fetched. The
fetched instruction is loaded into an IR, It helps in analyzing the opcode and
operand present in the instruction.
• Memory Address Register (MAR):Contains the address of a location of main
memory from where information has to be fetched or information has to be
stored. Contents of MAR is directly connected to the address bus.
• Memory Buffer Register (MBR):Contains a word of data to be written to memory
or the word most recently read. Contents of MBR is directly connected to the
data bus.It is also known as Memory Data Register(MDR).
• The memory address registers (MAR) and memory buffer registers (MBR) are
used to move the data between processor and memory.
Register Organization
• Apart from these specific register, we may have some temporary registers.
• Processor Status Word-All CPU designs include a register or set of
registers, often known as the processor status word (PSW), that contains
status information.
• The PSW typically contains condition codes plus other status information.
Common fields or flags include the following:
• Sign: Contains the sign bit of the result of the last arithmetic operation.
• Zero :Set when the result is zero.
• Carry: Set if an operation resulted in a carry (addition) into or borrow
(subtraction) out of a high order bit.
Register Organization
• Equal : Set if a logical compare result is equal.
• Overflow : Used to indicate arithmetic overflow.
• Interrupt enable/disable: Used to enable or disable interrupts.
• Supervisor: Indicate whether the CPU is executing in supervisor or user mode.
• Certain privileged instructions can be executed only in supervisor mode, and certain areas
of memory can be accessed only in supervisor mode
• [note: The user state is the default (normal) state of operation, in which user programs
are executed. The supervisor state is a special mode of operation to which the user has
no access. When it is in the supervisor state, the processor and its actions are entirely
controlled by the Operating System (OS).
• The size of a register maybe 8, 16, 32, or 64 bits. In 32-bit CPU, each register is 32 bits
wide and it can manipulate 32 bits of data at a time. The modern PCs have 32-bit or 64-bit
registers and are referred to as 32-bit processors and 64-bit processors.]
Addressing Mode and its Types
• Advantage: In the register addressing mode there are no memory references as the value to be
operated is present in the register.
Disadvantage: Registers have limited address space. So, it has a limit on the size of value that can be
stored.
Types of Addressing Modes
• 2. Direct Addressing Mode
• The direct addressing mode is also known as Absolute Addressing mode. Here, the
instruction contains the address of the location in memory where the value of the
operand is stored.
• Here, the effective address is the address of memory location.
• EA = A
• For example, observe the examples below:
• Add R2, A
• Store R2, B
• The Add instruction includes the memory location A which has the value to be added to
the content of register R2. Similarly, the Store instruction has the address of memory
location B where the content of register R2 will be stored. Below we have a figure
showing the direct addressing of the operand A in the Add instruction of the example
above.
Types of Addressing Modes
• 2. Direct Addressing Mode
• Advantage: In the immediate addressing mode the memory reference is not required as the
value is explicitly present in the instruction
• Disadvantage: The instruction format provides a limited size for the operand. So, the
immediate addressing mode has limited space for immediate value.
Types of Addressing Modes
• 4. Register Indirect Addressing mode
• A processor register is used to hold the address of a memory location where the
operand is placed. This addressing mode allows executing the same set of instructions
for the different memory location. This can be done by incrementing the content of
register thereby pointing the new location each time.
• In higher-level language, it is referred to as pointers. The indirect mode is denoted by
placing the register inside the parenthesis.
• Here the effective address is the content of memory location present in the register.
EA=(R)
• Now, for example:
• Load R3, (R2) // Load R2, A
• The Load instruction above will load the value present at the memory location
contained by register R2 in the register R3. The figure below shows how the register R3
gets loaded with the value stored in the memory location held by register R2.
Types of Addressing Modes
• 4. Register Indirect Addressing mode
• Advantage: In the register indirect addressing mode the same set of instructions can be used
multiple times.
• Disadvantage: In the register indirect addressing mode the number of memory reference is more.
Types of Addressing Modes
• 5. Index Addressing Mode
• Index addressing mode is helpful when the instructions in the program are accessing the array or the large
range of memory addresses. In this mode, the effective address is generated by adding a constant to the
register’s content. The content of the register does not change.
• The symbolic representation of index addressing mode is denoted as:
• X(R)
• And the effective address is denoted by
• EA = X + (R)
• For example, consider the instruction below:
• Load R2, A
• Load R3, (R2)
• Load R4, 4(R2)
• Load R5, 8(R2)
• Load R6, 12(R2)
• The above instructions will load the register R3, R4, R5, R6 with the contents, present at the successive
memory addresses from memory location A correspondingly.
Types of Addressing Modes
• 5. Index Addressing Mode
• Load R2, A
• Load R3, (R2)
• Load R4, 4(R2)
• Load R5, 8(R2)
• Load R6, 12(R2)
• Advantage: The index addressing mode provides flexibility to specify memory locations.
• Disadvantage: The index addressing mode is complex to implement.
Types of Addressing Modes
• 6. Auto Increment Addressing Mode
• In auto-increment addressing mode once the content of the register is accessed by the
instruction the register’s content is incremented to refer the next operand.
• Symbolically it is represented as below:
• (R)+
• Here, the effective address is content of the register as it is enclosed by parenthesis. The content
of register which is referring to a memory location is incremented so that it could point the next
memory location where the next operand is stored.
Types of Addressing Modes
• 7. Auto Decrement Addressing Mode
• It is just opposite of auto-increment mode. In auto decrement mode the content of the register
is decremented initially and then the decremented content of the register is used as effective
address.
• Symbolically it is presented as:
• -(R)
• The auto-increment and decrement mode help to implement the stack structure.
Types of Addressing Modes
• 8. Relative Addressing Mode
• In the content above we have discussed the index addressing mode. There we were adding a
constant to the register content to refer the next operand address. In some computer instead of a
register, the program counter is used.
• The symbolic representation of relative address mode is
• X(PC)
• The effective address for it would be:
• EA = X + (PC)
• As here the operand addresses are found relative to the program counter. That’s why it is
referred to as relative address mode.
• Advantage: Relative addressing mode doesn’t require memory references.
• Disadvantage: Relative addressing mode doesn’t have any disadvantage as such.
Instruction Cycle
• A program consisting of the memory unit of the computer includes a series
of instructions. The program is implemented on the computer by going
through a cycle for each instruction.
• In the basic computer, each instruction cycle includes the following
procedures −
• It can fetch instruction from memory.
• It is used to decode the instruction.
• It can read the effective address from memory if the instruction has an
indirect address.
• It can execute the instruction.
• After the following four procedures are done, the control switches back to
the first step and repeats the similar process for the next instruction.
Instruction Cycle
Instruction Cycle
• Fetch Cycle
• The address instruction to be implemented is held at the program
counter. The processor fetches the instruction from the memory that
is pointed by the PC.
• Next, the PC is incremented to display the address of the next
instruction. This instruction is loaded onto the instruction register.
The processor reads the instruction and executes the important
procedures.
Instruction Cycle
• Execute Cycle
• The data transfer for implementation takes place in two methods are as
follows −
• Processor-memory − The data sent from the processor to memory or from
memory to processor.
• Processor-Input/Output − The data can be transferred to or from a
peripheral device by the transfer between a processor and an I/O device.
• In the execute cycle, the processor implements the important operations
on the information, and consistently the control calls for the modification
in the sequence of data implementation.
• These two methods associate and complete the execute cycle.
State Diagram for Instruction Cycle
State Diagram for Instruction Cycle
• Instruction Address Calculation − The address of the next instruction is
computed. A permanent number is inserted to the address of the earlier
instruction.
• Instruction Fetch − The instruction is read from its specific memory location to
the processor.
• Instruction Operation Decoding − The instruction is interpreted and the type of
operation to be implemented and the operand(s) to be used are decided.
• Operand Address Calculation − The address of the operand is evaluated if it has a
reference to an operand in memory or is applicable through the Input/Output.
• Operand Fetch − The operand is read from the memory or the I/O.
• Data Operation − The actual operation that the instruction contains is executed.
• Store Operands − It can store the result acquired in the memory or transfer it to
the I/O.
Computer Bus
• There will be many I/O devices connected through I/O modules to the
system. Each device will be identified by a unique address.
• When the processor issues an I/O command, the command contains
the address of the device that is used by the command. The I/O
module must interpret the address lines to check if the command is
for itself.
• Generally in most of the processors, the processor, main memory and
I/O share a common bus(data address and control bus).
External Devices
• I/O operations are accomplished through external devices that provide a
means of exchanging data between external environment and computer.
• An external device attaches to the computer by a link to an I/O module. An
external device linked to an I/O module is called peripheral device or
peripheral.
• External Devices can be categorized as:
• Human readable: suitable for communicating with computer user. For
example - video display terminals and printers.
• Machine readable: suitable for communicating with equipment. For
example – disks, sensor, actuators used in robotics application.
• Communication: suitable for communicating with remote devices. For
example – modems.
External Devices
• In the case of memory-mapped I/O, all the buses are the same for
both memory and I/O devices.
• Therefore, building a CPU that uses memory-mapped I/O is easier and
cheaper. Additionally, such CPUs consume less power due to reduced
complexity. One advantage of memory-mapped I/O is that we don’t
need separate instruction sets for accessing I/O devices. Instructions
used for accessing memory can be easily used for accessing I/O
devices.
Memory-mapped I/O
Isolated or I/O mapped I/O
• In the case of isolated I/O, we provide a separate address space other than
a memory address space to I/O devices. The addresses of I/O devices are
also referred to as ports. I/O devices and memory use the same address
and data bus. However, the control bus is different for data and memory:
• Therefore, isolated I/O becomes costlier compared to memory-mapped
I/O. The isolated I/O technique has its own dedicated instruction set for
accessing I/O devices. The CPUs that use isolated I/O are bigger and more
complex to build.
• For I/O devices, it doesn’t matter whether memory mapped or isolated I/O
is implemented. I/O devices behave in the same manner independent of
the I/O method implemented internally.
Isolated or I/O mapped I/O
DMA