CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng.
Part 3: von Neumann Architecture von Neumann Architecture Our goal: understand the basics of von Neumann architecture, including memory, control unit and arithmetic logic unit understand the basics of machine language instructions know how control unit works with machine instructions
Part 3: von Neumann Architecture Overview: why von Neumann architecture a rough idea about how von Neumann architecture works? main memory in von Neumann architecture arithmetic logic unit in von Neumann architecture control unit in von Neumann architecture
Why von-neumann architecture All computers more or less based on the same basic design, the von Neumann Architecture! what ever it be a multi-million dollar mainframe or a Palm Pilot. The von Neumann architecture describes a general framework, or structure, that a computer's hardware, programming, and data should follow, and the central idea is stored program, i.e. program and data reside in memory in the format of binary
How von-neumann architecture works stores both data and instructions Arithmetic Logic Unit (ALU) instruction do arithmetic logic operation requested by program data program Input Device Main Memory Output Device address instruction interprets the instructions in memory and causes them to be executed Program Control Unit (CC) communicate with outside world, e.g. screen, keyboard, storage device
How von-neumann architecture works Step 1. send data and program 1+1 to main memory through input device Arithmetic Logic 2Unit =2 (ALU) 1 + instruction Step 4. ALU store results to memory data 1+1 program Input Device Main Memory Output Device Step 2. CC read + instruction from memory according to address Step 3. CC send instruction to ALU, and then read data 1 and 1 from memory to ALU according to address address 11 + 12 Program Control + Unit (CC) instruction Step 5. output results from memory to output device through instruction
Memory What is memory? Structure of memory Basic operations on memory
What is memory Memory A storage unit consisting of many memory cells with a fixed size. Each cell has an address associated with it: 0, 1, Each cell has two important characteristics: (1) its address (where it is), (2) its contents (what s stored at the given location).
Structure of memory Memory width (W) How many bits is each memory cell, typically one byte (=8 bits) Address width (N) How many bits used to represent each address, determines the maximum memory size = address space If address width is N-bits, then address space is 2 N (0,1,...,2 N -1) 0 1 2 N 0000000000000001... 1 bit 2 N Address space the number of uniquely identifiable memory locations. 2 N -1 W 9
Structure of memory: an example For example, for a 256 Mbyte memory, suppose its memory width is 8 bits (or 1 bytes) What is its address space? 2 28 What is its address width? 28 bits
Structure of memory: an example For another example a memory space is as follows: 000 001 010 011 100 0000 0110 101 110 0000 0010 111 what is its memory width? 8 bits what is its address space? 8 what is its address width? 3 bits what is the content of memory location address 100? (0000 0110)
Basic operations to memory Operations on Memory Fetch (address): Fetch a copy of the content of memory cell with the specified address. Non-destructive, copies value in memory cell. Store (address, value): Store the specific value into the memory cell specified by address. Destructive, overwrites the previous value of the memory cell.
Basic operations to memory: an example Question: How does processing unit get data to/from memory? MAR: Memory Address Register MDR: Memory Data Register Fetch (Address): 1. Load the address (A) into the MAR. 2. Copy the content of memory cell with specified address into MDR. Store (Address, Value): MAR MDR MEMORY 1. Load the address (A) into MAR; load the value into MDR 2. copy content of MDR into memory cell with specified address.
Arithmetic Logic Unit - ALU What is ALU? Structure of ALU
What is ALU The ALU performs mathematical operations (+, -, x, /, ) logic operations (=, <, >, and, or, not,...) In today's computers integrated into the CPU Consists of: Circuits to do the arithmetic/logic operations. Registers (fast storage units) to store intermediate computational results. Bus that connects the two.
Structure of ALU Registers: very fast local memory cells, that store operands of operations and intermediate results. CCR (condition code register), a special purpose register that stores the result of <, =, > operations ALU circuitry: Contains an array of circuits to do mathematical/logic operations. Bus: Data path interconnecting the registers to the ALU circuitry. R0 R1 R2 Rn ALU circuitry GT EQ LT
Control Unit What is Control Unit? Machine Language Instructions in Control Unit How Control Unit Works
What is control unit Program is stored in memory as machine language instructions, in binary The task of the control unit is to execute programs by repeatedly: Fetch from memory the next instruction to be executed. Decode it, that is, determine what is to be done. Execute it by issuing the appropriate signals to the ALU, memory, and I/O subsystems. Continues until the HALT instruction
What is machine language instruction A machine language instruction consists of: Operation code/opcode, telling which operation to perform Address field(s)/operands, telling the memory addresses of the values on which the operation works. So, a machine language instruction = Opcode + Operands
Machine language instruction: an example For Example: ADD X, Y - Opcode ADD tell the ALU to execute the add function - X and Y is the address of memory cell - execute ADD X,Y means ADD content of memory locations X and Y, and store back in memory location Y. Assume: opcode for ADD is 9 in decimal, and addresses X=99, Y=100 in decimal How to represent this instruction in memory of computer? suppose the memory width for opcode and address is 8 bits and 16 bits, respectively Opcode (8 bits) Address 1 (16 bits) Address 2 (16 bits) 00001001 0000000001100011 0000000001100100
Machine language instruction: an example suppose X=4 and Y=6, con(x) = 6 and con (Y) =2 After execute the instruction ADD X,Y before execute instruction after execute instruction X Y 000 0000 0000 001 0000 0000 010 0000 0000 011 0000 0000 100 0000 0110 101 0000 0000 110 0000 0010 111 0000 0000 Content of address X is 6 Content of address Y is 2
Typical machine instructions Notation: We use X, Y, Z to denote address of memory cells Assume only one register R (for simplicity) Use English-like descriptions (should be binary) Data Transfer Instructions LOAD X Read content of memory location X to R STORE X Write content of R to memory location X MOVE X, Y Copy content of memory location X to location Y
Typical machine instructions: an example For example: LOAD X means read the content of memory location X to register R Suppose X=2, and memory with address 4 is assigned as R X memory space 000 0000 0000 001 0000 0110 after execute instruction 000 0000 0000 001 0000 0110 010 0011 0000 010 0011 0000 register R 011 0000 0000 100 0000 0000 011 0000 0000 100 0011 0000 101 0000 0000 101 0000 0000
Typical machine instructions Arithmetic ADD X, Y, Z CON(Z) = CON(X) + CON(Y) ADD X, Y CON(Y) = CON(X) + CON(Y) ADD X R = CON(X) + R similar instructions for other operators, e.g. SUBTR,OR,... Compare COMPARE X, Y Compare the content of memory cell X to the content of memory cell Y and set the condition codes (CCR) accordingly.
Typical machine instructions: an example For example: Compare X, Y means compare the content of memory cell X to the content of memory cell Y and then set the condition codes (CCR) accordingly. Suppose X=2, Y=4, and address 5 is assigned as CCR memory space CCR X Y 000 0000 0000 001 0000 0110 010 0000 1000 011 0000 0000 100 0000 0000 101 0000 0000 after execute instruction con(x)=8,con(y)=0,and the logic result of compare instruction is true, the second bit in CCR is the flag of greater than, it set to 1 if greater than is true 101 0000 0010
Typical machine instructions Branch JUMP X Load next instruction from memory location X JUMPGT X Load next instruction from memory location X only if GT flag in CCR is set, otherwise load statement from next sequence location as usual JUMPEQ, JUMPLT, JUMPGE, JUMPLE,JUMPNEQ Control HALT Stop program execution.
Thank you for your attendance Any questions?