Beruflich Dokumente
Kultur Dokumente
CPU Basics
The computers CPU fetches, decodes, and executes
program instructions. The two principal parts of the CPU are the datapath and the control unit. Datapath consists of an arithmetic-logic unit and storage units (registers) that are interconnected by a data bus that is also connected to main memory. Control unit sequences no. of operations performed by the CPU. Makes sure the correct data is where it needs to be and at the correct time. The control unit determines which actions to carry out according to the values in a program counter register and a status register.
3
The Bus
PARALLEL BUS The CPU shares data with other system components by way of a data bus.
A bus is a set of wires that simultaneously convey a
The Bus
Buses have data lines, control lines, and address lines. The data lines transmits bits from one device to another
which device has permission to access the bus. Also transfer interrupts, clk synchronization signals
Address lines determine the location of the source or
The Bus
Typical bus transactions include:
Sending an address (for a read or write), Transferring data from memory to a register (a memory read), Transferring data to the memory from a register (a memory write). Reads and writes from peripheral devices. Each type of transfer occurs within a bus cycle, the time between two ticks of the bus clock. Due to the different types of information buses transport and the various devices that use the buses, buses themselves have been divided into different types: Processor-memory buses, I/O buses , backplane bus (so 7 all devices share one bus).
that initiate the transfer of data across the bus. For example, the CPU is a bus master and can use the control bus to issue a command to main memory to read the value of a variable. Allowing multiple bus masters can improve system performance.
Slave Devices: Devices that can only respond to
commands from other devices. For example, main memory is a slave device. It can only respond to commands from other devices asking it to read or write particular memory locations.
9
10
Distributed using collisiondetection: Any device can try to use the bus. If its data collides with the data of another device, it tries again.
Bus Cycles
Bus cycles control the flow of information
(data/commands/addresses) across the bus. One piece of information moves across the bus during each cycle. Types of Bus Cycles Synchronous: The length of the bus cycle is controlled by a clock and thus every bus cycle is the same length. Asynchronous: The length of a bus cycle is determined dynamically by the devices that are communicating. Control lines coordinate the operations using a complex protocol to enforce timing (Request / Ready / Acknowledge)
11
Clocks
Every computer contains at least one clock that
each instruction.
The clock frequency, measured in megahertz or gigahertz,
determines the speed with which all operations are carried out. Clock cycle time is the reciprocal of clock frequency.
A 2 GHz clock has a cycle time of 0.5 nanoseconds.
microseconds.
12
Clocks
Clock speed should not be confused with CPU
performance. The CPU time required to run a program is given by the general performance equation:
We can improve CPU performance when we reduce the number of instructions in a program, reduce the number of cycles per instruction, or reduce the number of nanoseconds per clock cycle.
13
Clocks
Role of Clock in Processors
single-cycle machine: does everything in one clock cycle instruction execution = up to 5 steps must complete 5th step before cycle ends
clock signal
14
through its input/output (I/O) subsystem. I/O devices connect to the CPU through various interfaces: I/O can be memory-mapped-- where the I/O device behaves like main memory from the CPUs point of view. Or I/O can be instruction-based, where the CPU has a specialized I/O instruction set.(involving interrupts)
15
Memory Organization
Computer memory is a linear array of addressable
storage cells that are similar to registers. Memory can be byte-addressable (most common), or word-addressable, where a word consists of two or more bytes. Memory is constructed of RAM chips, Memory is often referred to using the notation L x W (length x width). For example: 4M x 16 means the memory is 4M long (it has 4M = 22 x 220= 222words) and it is 16 bits wide (each word is 16 bits).
16
Memory Organization
Example: How many bits would you need to address
a 2M x 32 memory if (a) The memory is byteaddressable. (b) The memory is word-addressable? Solution: a)There are 2M x 4 bytes which equals 2 x 220 x 22=223 total bytes, so 23 bits are needed for an address b) There are 2M words which equals 2 x 220 = 221, so 21 bits are required for an address ByteAddressable
17
Word-
Power 0 1 2 3 4 5
2 ^ Power 1 2 4 8 16 32
Memory Organization
How does the computer access a memory location
6
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
64
128 256 512 1,024 2,048 4,096 8,192 16,384 32,768 65,536 131,072 262,144 524,288 1,048,576 2,097,152
address lines. The address lines count from 0 to 222 - 1 in binary. Each line is either on or off indicating the location of the desired memory element.
18
22
4,194,304
Memory Organization
Physical memory usually consists of more
than one RAM chip. Consequently, these chips are combined into a single memory module to give the desired memory size. For example, suppose you need to build a 32K x 16 memory and all you have are 2K x 8 RAM chips. You could connect 16 rows and 2 columns of chips together. Addresses for total memory must have 15 bits (there are 32K = 25 x 210 words to access) But each chip pair (each row) requires only 11 address lines (each chip pair holds only 2k= 21 x 210 words) chip 4 bits for 11 bits for word
select
select/chip
0 1 .. 10
19
0 . .. . . . .. .
Memory Interleaving
Access is more efficient when memory is organized into banks of chips with
the addresses interleaved across the chips (Memory interleaving is a way to distribute individual addresses over memory modules)
addresses so that each module contains consecutive addresses Low-order interleaved memory places consecutive words of memory in different memory modules.
Low-Order Interleaving
Byte Addresses
20
memory address select a module, and the high-order m bits name a location within that module. A request to access consecutive memory locations can keep several modules busy at the same time; that is with the appropriate buses using low-order interleaving, a read or write using one module can be started before a read or write using another module actually completes
Recall: (1) Memory addresses are unsigned binary
21
values, and (2) The number of items to be addressed determines the numbers of bits that occur in the
Interrupts
This concept deals with how computer components
22
interact with the processor. Interrupts: are events that alter (or interrupt) the normal flow of execution in the system. Reasons for triggering an interrupt I/O requests Arithmetic errors (e.g., division by zero) Arithmetic underflow or overflow Hardware malfunction User-defined break points (such as when debugging a program) Invalid instructions (usually resulting from pointer issues)
Types of Interrupts
An interrupt can be: Maskable (disabled or ignored) or nonmaskable (a high priority interrupt that cannot be disabled and must be acknowledged), can occur within or between instructions. May be synchronous (occurs at the same place every time a program is executed) or asynchronous (occurs unexpectedly). Can result in the program terminating or continuing execution once the interrupt is handled.
23
Functional Architecture MARIE: Machine Architecture that is Really Intuitive and Easy
MARIE has the following characteristics: Binary coded addresses Fixed word length Word (but not byte) addressable 4K words of main memory (this implies 12 bits per address) 16-bit data (words have 16 bits) 16-bit instructions, 4 for the opcode and 12 for the address A16-bit accumulator (AC) A16-bit instruction register (IR) A16-bit memory buffer register (MBR) A12-bit program counter (PC) A12-bit memory address register (MAR) An 8-bit input register An 8-bit output register 24
25
BUSES MARIE, assumes a common bus scheme. Each device connected to the bus has a number, and before the device can use the bus, it must be set to that identifying number. We also have some additional pathways to speed up execution. MBR ALU AC ALU AC MBR
26
set architecture (ISA) of a machine specifies the instructions that the computer can perform and the format for each instruction. The ISA is essentially an interface
27
however, if you examine what actually happens at the component level, each instruction involves multiple operations mini-instructions are being executed. These mini-instructions are called micro-operations and specify the elementary operations that can be performed on data stored in registers. The symbolic notation used to describe the behavior of micro-operations is called register transfer notation (RTN) or register transfer language (RTL).
28
Add X
The data value stored at address X is added to the AC.
This instruction causes an unconditional branch to the given address, X. Therefore, MAR X, MBR AC to execute this instruction, X M[MAR] MBR must be loaded into the PC. NOTE PC X Register transfer notation is a symbolic means of expressing what is happening in the system when a given instruction is executing. 29 RTN is sensitive to the data path, in that if multiple micro-operations must share the bus, they must be executed in a sequential fashion, one following
This instruction stores the contents of the AC in memory location X:
Store X
Jump X
30
represents the steps that a computer follows to run a program. The CPU fetches an instruction (transfers it from main memory to the instruction register) Decodes it (determines the opcode and fetches any data necessary to carry out the instruction), Gets the operand and Executes the instruction (performs the operation(s) indicated by the instruction).
31
32
33
A SIMPLE PROGRAM
34
35
36
sequence of steps correctly. In reality, there must be control signals to assert lines on various digital components to make things happen For example, when we perform an Add instruction in MARIE in assembly language, we assume the addition takes place because the control signals for the ALU are set to add and the result is put into the AC. The ALU has various control lines that determine which operation to perform. The question we need to answer is, How do these control lines actually become asserted?
37
Hardwired Control
The first approach is to physically connect all of the
38
control lines to the actual machine instructions. The instructions are divided up into fields, and different bits in the instruction are combined through various digital logic components to drive control lines. This is called hardwired control. The control unit is implemented using hardware (with simple NAND gates, flip-flops, and counters, for example). We need a special digital circuit that uses, as inputs, the bits from the opcode field in our instructions, bits from the flag (or status) register, signals from the bus, and signals from the clock. It should produce, as outputs, the control signals to drive the various components in the computer.
Decoding
0 000000
Registers
R0
9 01001
10 01010
8 01000
0 00000
32 100000
MUX To ALU
R8
A
MUX To ALU ALU
39
R31
uses software for control. All machine instructions are input into a special program, the microprogram, to convert the instruction into the appropriate control signals. The microprogram is essentially an interpreter, written in microcode, that is stored in firmware (ROM, PROM, or EPROM), which is often referred to as the control store. This program converts machine instructions of zeros and ones into control signals.
40
Assignments
Exercise 5,6,7,8,9,10
42