Download Class 2.3 Von Neumann model ALU, Control Unit, IO

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Simple ALU
C=A+B;
$10=$8+$9
• How to perform this C language integer
operation in the computer C=A+B; ?
• The arithmetic/logic unit (ALU) of a
processor performs integer arithmetic
and logical operations
• An integer used as input to an
operation is called an operand.
• One operand for the ALU is always
contained in a register
• The other operand may be in a register
or may be part of the machine
instruction itself
This is the assembly instruction
equal to C=A+B;
add
$10,$8,$9
• The result of the operation is put into a
general purpose register
ALU - replace the operand by result
B=A+B;
$9=$8+$9
• This instruction puts the result of integer
addition in place of one of the operands
– register $9.
• As the operand already has participated
in the operation then its value could be
overwritten at the end of the operation.
• This operation uses less amount of
registers than the previous one.
This is the assembly instruction
equal to B=A+B;
add
$9,$8,$9
ALU instructions format
add
$10,$8,$9
Machine instructions that use the ALU specify four
things:
•
•
•
•
The operation to perform.
The first operand (often in a register).
The second operand (often in a register).
The register that receives the result.
Control Unit – Instruction representation
The control unit
• fetches instructions from memory
• decodes them
• to produce signals which control the other parts of the computer.
• Computer only understands 1s and 0s.
• For computer add $10,$8,$9 doesn’t mean anything.
• So the Instructions should be represented for the computer in binary form.
Here is the assembly language for the add instruction:
add $10,$8,$9
Here is the machine code it translates into:
0x01095020
Here is that as a bit pattern (the same machine code):
0000 0001 0000 1001 0101 0000 0010 0000
MIPS machine instructions are all 32 bits wide (4 bytes).
Control Unit – Sequential execution
• Normally, instructions are executed one after another
• In the same sequence that they have been placed in memory
• Starting with the lowest address and going up.
Program Counter
0x0040 0000
+4
0x0040 0004
+4
0x0040 0008
• Computer somehow should remember the instructions address
• There is a special address register for instruction:
• Program Counter (PC) – MIPS
• CS+IP - Intel
• It keeps the next instruction’s address to be fetched from the memory.
• After fetching of each instruction the computer increments this
register’s content to point to the next instruction.
Control Unit – Structure
•
•
•
After reading the instruction from the memory there should be some place to put
the instruction - Instruction Register
There should be some hardware to understand (decode) the instruction to be
able to run it properly - Instruction Decoder
The appropriate signals are sent by decoder to the different blocks of hardware
to perform the necessary action
Control Unit
Program Counter
Current
instruction
Next instruction’s
address
Memory
Program Code
0x01095020
Instruction Register
Data
Instruction Decoder
Control Unit
Arithmetic
Logical Unit
General Purpose
32 bit Registers
$0, $1, … , $31
Central Processing Unit
Input
Output
Control Unit – Machine Cycle
• Computer works proceeding sequentially one instruction at a
time.
• The computer endlessly cycles through three basic steps.
• Each cycle executes one machine instruction.
Von Neumann machine operation cycle
Fetch the Instruction.
• The program counter (PC) contains the address of the
1. Fetch instruction - The control unit retrieves instruction
current machine instruction.
from the memory.
• The instruction is fetched from memory.
2. Increment the address of instruction
Increment the PC.
3. Execute. As the Von Neumann computer has CISC behavior
• The address in the program counter is incremented by four.
then the cycle’s execution block is very complex.
• This allows to begin the next instruction preparation while
• Fetch operands. The control unit retrieves operands
the current instruction is processed.
from the memory.
• Instructions are executed and they perform necessary
Execute the Instruction.
operations in ALU with operands.
• The machine operation specified by the instruction is
• The result is written again into the memory.
performed.
• Input and Output devices are used when there is need
• MIPS has RISC behavior so the cycle’s execution block
to input or output the information.
should be very simple.
• MIPS ALU operations never directly access memory.
Control Point
A bit pattern that is fetched as an instruction is interpreted as an instruction.
• If the pattern can be interpreted as an instruction then it will be executed,
whatever it does.
• If the pattern makes no sense as an instruction then normal control flow is
interrupted.
• The control point of an executing program is the address in memory of the
instruction being executed.
• When an instruction is being executed (in the third step of the machine cycle) the
program counter holds the address of the instruction after the control point.
[0x0040000c]
[0x00400010]
...
[0x00400020]
Control Flow
jump 0x0040 0020
other instructions
...
ori $8, $0, 4
Program Counter
0x0040 0004
Control Point
0x0040 0000
Control Flow
• Normally the control point moves sequentially through the machine
instructions. On the MIPS this means it normally moves through
memory in steps of four bytes (32 bits) at a time.
• The execution sequence can be changed with a branch or a jump
machine instruction.
• The phrase flow of control means how the control point moves
through memory.
[0x0040000c]
[0x00400010]
...
[0x00400020]
Control Flow
jump 0x0040 0020
other instructions
...
ori $8, $0, 4
Program Counter
0x0040 0004
Control Point
0x0040 0000
Computer System Components. Bus.
•
•
•
•
In general all computers consist of components (processor, memory, controllers)
connected together with a bus.
Physically, a bus consists of many parallel wires, usually printed (in copper) on the
main circuit board of the computer.
Data signals, clock signals, and control signals are sent on the bus back and forth
between components.
A particular type of bus follows a carefully written standard that describes the
signals that are carried on the wires and what the signals mean.
Computer System Components. Input and Output.
Input/output controllers
• Receive input and output requests from the central processor
• and then send device-specific control signals to the device they control.
• They also manage the data flow to and from the device.
•
•
Often the I/O controllers are part of the electronics on the main circuit board
(the mother board) of the computer.
Sometimes a device requires its own controller which must be plugged into a
connector (an expansion slot) on the mother board.