Arithmetic Logic Unit (ALU)

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

The CPU The Central Presentation Unit What is the CPU?
The Fetch – Execute Cycle
Machine cycle.
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4 Computer Organization.
Control path Recall that the control path is the physical entity in a processor which: fetches instructions, fetches operands, decodes instructions, schedules.
CS1104: Computer Organisation School of Computing National University of Singapore.
Topics covered: CPU Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
ARITHMETIC LOGIC SHIFT UNIT
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
Execution of an instruction
Midterm Wednesday Chapter 1-3: Number /character representation and conversion Number arithmetic Combinational logic elements and design (DeMorgan’s Law)
Topics covered: CPU Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
The processor and main memory chapter 4, Exploring the Digital Domain The Development and Basic Organization of Computers.
Chapter 16 Control Unit Implemntation. A Basic Computer Model.
Chapter 7. Basic Processing Unit
16/07/2015CSE1303 Part B lecture notes 1 Hardware Implementation Lecture B17 Lecture notes section B17.
The Computer Processor
Basic Processing Unit (Week 6)
Lecture 13 - Introduction to the Central Processing Unit (CPU)
Micro-operations Are the functional, or atomic, operations of a processor. A single micro-operation generally involves a transfer between registers, transfer.
Computer Systems 1 Fundamentals of Computing The CPU & Von Neumann.
Chapter 5 Basic Processing Unit
Computer Science 210 Computer Organization The von Neumann Architecture.
Multiple-bus organization
EXECUTION OF COMPLETE INSTRUCTION
The CPU Central Processing Unit. 2 Reminder - how it fits together processor (CPU) memory I/O devices bus.
CPU Design. Introduction – The CPU must perform three main tasks: Communication with memory – Fetching Instructions – Fetching and storing data Interpretation.
Chapter 4 The Von Neumann Model
Computer Architecture Lecture 09 Fasih ur Rehman.
Cis303a_chapt04.ppt Chapter 4 Processor Technology and Architecture Internal Components CPU Operation (internal components) Control Unit Move data and.
Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit
Execution of an instruction
Fetch-execute cycle.
Computer Hardware A computer is made of internal components Central Processor Unit Internal External and external components.
Computer Structure & Architecture 7b - CPU & Buses.
ECE Computer Architecture Lecture Notes # 6 Shantanu Dutt How to Add To & Use the Basic Processor Organization To Execute Different Instructions.
Dale & Lewis Chapter 5 Computing components
Von Neumann Model Computer Organization I 1 September 2009 © McQuain, Feng & Ribbens The Stored Program Computer 1945: John von Neumann –
Chapter 3 Basic Processing Unit.
Basic Elements of Processor ALU Registers Internal data pahs External data paths Control Unit.
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Structure and Role of a Processor
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Lec 4-2 Five operations of the machine cycle Fetch- fetch the next program instruction from memory. (PC+1); instruction to IR Decode- decode the instruction.
1 Chapter 1 Basic Structures Of Computers. Computer : Introduction A computer is an electronic machine,devised for performing calculations and controlling.
3.1.4 Hardware a. describe the function and purpose of the control unit, memory unit and ALU (arithmetic logic unit) as individual parts of a computer;
Basic Processor Structure/design
Lecture 13 - Introduction to the Central Processing Unit (CPU)
Computer Science 210 Computer Organization
Computer Organization
Chapter 4 The Von Neumann Model
Chapter 4 The Von Neumann Model
Chapter 4 The Von Neumann Model
Basic Processing Unit Unit- 7 Engineered for Tomorrow CSE, MVJCE.
Functional Units.
COMS 161 Introduction to Computing
The Von Neumann Model Basic components Instruction processing
Some Fundamental Concepts
Chapter 7. Basic Processing Unit
Fundamental Concepts Processor fetches one instruction at a time and perform the operation specified. Instructions are fetched from successive memory locations.
Chapter 4 The Von Neumann Model
Basic Processing Unit UNIT-5.
The Stored Program Computer
GCSE OCR 1 The CPU Computer Science J276 Unit 1
Digital Circuits and Logic
Objectives Describe common CPU components and their function: ALU Arithmetic Logic Unit), CU (Control Unit), Cache Explain the function of the CPU as.
Computer Operation 6/22/2019.
Computer Architecture
COMPUTER ARCHITECTURE
Presentation transcript:

CSE 243: Introduction to Computer Architecture and Hardware/Software Interface Recap the last class.

Arithmetic Logic Unit (ALU) ALU is a purely combinatorial device: It has no memory or internal storage. It has 2 input vectors: These may be called the A- and B-vector or the R- and S-vector The inputs are as wide as the registers/system bus (e.g., 16, 32 bits) It has 1 output vector Usually denoted F

Arithmetic Logic Unit (ALU) (contd..) Sample functions performed by the ALU F = A+B F = A+B+1 F = A-B F = A-B-1 F = A and B F = A or B F = not A F = not B F = not A + 1 F = not B + 1 F = (not A) and B F = A and (not B) F = A xor B F = not (A xor B) F = A F = B

Arithmetic Logic Unit (ALU) (contd..) ALU is basically a black-box ALU Add XOR Sub control lines A B A, B Inputs Output F purely combinatorial logic(AND/OR/ NOT/NAND/NOR etc) inside the --no registers Carry in

Arithmetic and Logic Unit (ALU) (contd..) ALU connections to the bus Y ALU A B MUX Constant 4 ALU must have only one input connection from the bus. The other input must be stored in a holding register called Y register. A multiplexer selects among register Y and 4 depending upon select line. One operand of a two-operand instruction must be placed into the Y register before the other operand must be placed onto the bus. Select Control lines Carry-in Processor bus

Arithmetic and Logic Unit (ALU) (contd..) ALU connections to the bus Identical reasoning tells us that there must be an output register Z which collects the output of the ALU at the end of each cycle. This way, there can be --one operand in the Y register --one operand ON THE BUS --the result stored in the Z register Y Constant 4 Select MUX A B Control lines ALU Carry-in Z Processor bus

Performing an arithmetic operation Add the contents of registers R1 and R2 and place the result in R3. That is: R3 = R1 + R2 1. Place the contents of register R1 into the Y register in the first clock cycle. 2. Place the contents of register R2 onto the bus in the second clock cycle. Both inputs to the ALU are now valid. Select register Y, and assert the ALU command F=A+B. 3. In the third clock cycle, Z register has latched the output of the ALU. Thus the contents of the Z register can be copied into register R3.

Performing an arithmetic operation (contd..) Instruction Control Signals Z bus Memory Address lines MAR Data MDR PC decoder and control logic Clock cycle 1: R1out, Yin IR Y Constant 4 R1 R 2 Select MUX R 3 Add A B Sub R n 1 - ( ) ALU control ALU lines Carry-in XOR TEMP

Performing an arithmetic operation (contd..) Instruction Control Signals Z bus Memory Address lines MAR Data MDR PC decoder and control logic Clock cycle 2: R2out, SelectY, Add, Zin IR Y Constant 4 R1 R 2 SelectY MUX R 3 Add=1 A B Sub R n 1 - ( ) ALU control ALU lines Carry-in XOR TEMP

Performing an arithmetic operation (contd..) Instruction Control Signals Z bus Memory Address lines MAR Data MDR PC decoder and control logic Clock cycle 3: Zout, R3in IR Y Clock cycle 4: R3 has the sum. Constant 4 R1 R 2 SelectY MUX R 3 Add A B Sub R n 1 - ( ) ALU control ALU lines Carry-in XOR TEMP

Performing an arithmetic operation (contd..) Clock Cycle 1: R1out, Yin (Y=R1) Clock Cycle 2: R2out, SelectY, Add, Zin (Z = R1+R2) Clock Cycle 3: Zout, R3in (R3=Z)

Performing an arithmetic operation (contd..) Inputs of the ALU: Input B is tied to the bus. Input A is tied to the output of the multiplexer. Output of the ALU: Tied to the input of the Z register. Z register: Input tied to the output of the ALU. Output tied to the bus. Unlike Riin, Zin loads data from the output of the ALU and not the bus.

Performing an arithmetic operation (contd..) Events as seen by the system registers, bus, ALU over time. cycle: controls active what the bus sees what Y has output of ALU start of 1 R1out, Yin contents of R1 --unknown --unknown end of 1 R1out, Yin contents of R1 R1 --unknown = 2 R2out, F=A+B contents of R2 R1 F=A+B=R1+R2 but this is not valid yet 2 R2out, F=A+B,Zin contents of R2 R1 F=A+B=R1+R2 (now valid) 3 Zout,R3in contents of Z R1 --unknown 3 Zout, R3in contents of Z R1 --unknown (but R3 latches bus contents)

ALU operations RC = RA op RB Clock cycle 1: Move RA to Y register. RAout, Yin Clock cycle 2: Put RB on the bus, perform F = RA op RB, and transfer the result to Z. RBout, (RA op RB)=1, SelectY, Zin Clock cycle 3: Put Z on the bus, and load Z into RC. Zout, RCin

Fetching a word from memory Processor has to specify the address of the memory location where this information is stored and request a Read operation. Processor transfers the required address to MAR. Output of MAR is connected to the address lines of the memory bus. Processor uses the control lines of the memory bus to indicate that a Read operation is needed. Requested information are received from the memory and are stored in MDR. Transferred from MDR to other registers.

Fetching a word from memory (contd..) Connections for register MDR MDR Memory-b us data lines b out outE in inE MDRoutE and MDRinE control connection to external bus. MDRout and MDRin control connection to internal bus.

Fetching a word from memory (contd..) Timing of the internal processor operations must be coordinated with the response time of memory Read operations. Processor completes one internal data transfer in one clock cycle. Memory response time for a Read operation is variable and usually longer than one clock cycle. Processor waits until it receives an indication that the requested Read has been completed. Control signal (MFC) is used for this purpose. MFC is set to 1 by the memory to indicate that the contents of the specified location have been read and are available on the data lines of the memory bus.

Fetching a word from memory (contd..) MOVE (R1) R2 1. Load the contents of Register R1 into MAR. 2. Start a Read operation on the memory bus. 3. Wait for MFC response from the memory. 4. Load MDR from the memory bus. 5. Load the contents of MDR into Register R2. Steps can be performed separately, some may be combined. Steps 1 and 2 can be combined. - Load R1 to MAR and activate Read control signal simultaneously. Steps 3 and 4 can be combined. - Activate control signal MDRinE while waiting for response from the memory. Last step loads the contents of MDR into Register R2. Memory Read operation takes 3 steps.

Fetching a word from memory (contd..) MOVE (R1) R2: Memory operation takes 3 steps. Step 1: - Place R1 onto the internal processor bus. - Load the contents of the bus into MAR. - Activate the Read control signal. - R1out, MARin, Read. Step 2: - Wait for MFC from the memory. - Activate the control signal to load data from external bus to MDR. - MDRinE, WMFC Step 3: - Place the contents of MDR onto the internal processor bus. - Load the contents of the bus into Register R2. - MDRoutI, R2in

Storing a word into memory MOVE R2, (R1): Memory operation takes 3 steps. Step 1: - Place R1 onto the internal processor bus. - Load the contents of the bus into MAR. - R1out, MARin, Write. Step 2: - Place R2 onto the internal processor bus. - Load the contents of the internal processor bus into MDR. - Activate Write operation. . - R2out, MDRin, Write Step 3: - Place the contents of MDR into the external memory bus. - Wait for the memory write operation to be complete. - MDRoutE, WMFC

Execution of a complete instruction Add the contents of a memory location pointed to by Register R3 to register R1. ADD (R3) R1 To execute the instruction we must execute the following tasks: 1. Fetch the instruction. 2. Fetch the operand (contents of the memory location pointed to by R3.) 3. Perform the addition. 4. Load the result into R1.

Execution of a complete instruction Task 1: Fetch the instruction Recall that: - PC holds the address of the memory location which has the next instruction to be executed. - IR holds the instruction currently being executed. Step 1 - Load the contents of PC to MAR. - Activate the Read control signal. - Increment the contents of the PC by 4. - PCout, MARin, Read, Select4, Add, Zin. Step 2 - Update the contents of the PC. - Copy the updated PC to Register Y (useful for Branch instructions). - Wait for MFC from memory. - Zout, PCin, Yin, WMFC Step 3 - Place the contents of MDR onto the bus. - Load the IR with the contents of the bus. - MDRout, IRin

Execution of a complete instruction (contd..) Task 2. Fetch the operand (contents of memory pointed to by R3.) Task 3. Perform the addition. Task 4. Load the result into R1. Step 4: - Place the contents of Register R3 onto internal processor bus. - Load the contents of the bus onto MAR. - Activate the Read control signal. - R3out, MARin, Read Step 5: - Place the contents of R1 onto the bus. - Load the contents of the bus into Register Y (Recall one operand in Y). - Wait for MFC. - R1out, Yin, WMFC Step 6: - Load the contents of MDR onto the internal processor bus. - Select Y, and perform the addition. - Place the result in Z. - MDRout, SelectY, Add, Zin. Step 7: - Place the contents of Register Z onto the internal processor bus. - Place the contents of the bus into Register R1. - Zout, Rin

Execution of a complete instruction (contd..) Step Action 1 PC , MAR , Read, Select4, Add, Z out in in 2 Z , PC , Y , WMF C out in in 3 MDR , IR out in 4 R3 , MAR , Read out in 5 R1 , Y , WMF C out in 6 MDR , SelectY, Add, Z out in 7 Z , R1 , End out in

Branch instructions Recall that the updated contents of the PC are copied into Register Y in Step 2. Not necessary for ADD instruction, but useful in BRANCH instructions.: Branch target address is computed by adding the updated contents of the PC to an offset. Copying the updated contents of the PC to Register Y speeds up the execution of BRANCH instruction. Since the Fetch cycle is the same for all instructions, this step is performed for all instructions. Since Register Y is not used for any other purpose at that time it does not have any impact on the execution of the instruction.