Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simple ALU 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.

Similar presentations


Presentation on theme: "Simple ALU 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."— Presentation transcript:

1 Simple ALU 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 The result of the operation is put into a general purpose register C=A+B; $10=$8+$9 add $10,$8,$9 This is the assembly instruction equal to C=A+B;

2 ALU - replace the operand by result 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. B=A+B; $9=$8+$9 add $9,$8,$9 This is the assembly instruction equal to B=A+B;

3 ALU instructions format 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. add $10,$8,$9

4 Control Unit – Instruction representation 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). The control unit fetches instructions from memory decodes them to produce signals which control the other parts of the computer.

5 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. 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.

6 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

7 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. Fetch the Instruction. The program counter (PC) contains the address of the current machine instruction. The instruction is fetched from memory. Increment the PC. The address in the program counter is incremented by four. This allows to begin the next instruction preparation while the current instruction is processed. Execute the Instruction. The machine operation specified by the instruction is performed. MIPS has RISC behavior so the cycle’s execution block should be very simple. MIPS ALU operations never directly access memory. Von Neumann machine operation cycle 1.Fetch instruction - The control unit retrieves instruction from the memory. 2.Increment the address of instruction 3.Execute. As the Von Neumann computer has CISC behavior then the cycle’s execution block is very complex. Fetch operands. The control unit retrieves operands from the memory. Instructions are executed and they perform necessary operations in ALU with operands. The result is written again into the memory. Input and Output devices are used when there is need to input or output the information.

8 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.

9 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.

10 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.

11 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.


Download ppt "Simple ALU 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."

Similar presentations


Ads by Google