880 likes | 1.11k Views
Data Manipulation. 10/4/2014 Che-Rung Lee. What’s inside?. What is a computer?. Monitor, case, keyboard, mouse, speaker, scanner, webcam, printer, …. Inside the case. CPU, motherboard, adaptors, hard disk, memory, CDROM, …. We are going to talk about those. Central Processing Unit (CPU).
E N D
Data Manipulation 10/4/2014 Che-Rung Lee CS135602 Introduction to Information Engineering
What’s inside? What is a computer? • Monitor, case, keyboard, mouse, speaker, scanner, webcam, printer, … CS135602 Introduction to Information Engineering
Inside the case • CPU, motherboard, adaptors, hard disk, memory, CDROM, … We are going to talk about those. CS135602 Introduction to Information Engineering
Central Processing Unit (CPU) • An electronic circuit that can execute computer programs • Intel i7 • AMD K10 • IBM Cell • ARM Acorn • Sun SPARC • To understand CPU, we need to know what computer programs are. CS135602 Introduction to Information Engineering
Outline • Store program concept • Machine language • Program execution • Peripheral devices • Parallel architectures CS135602 Introduction to Information Engineering
Stored Program Concept "The final major step in the development of the general purpose electronic computer was the idea of a stored program..." Brian Randell CS135602 Introduction to Information Engineering
What’re the differences? TV: you can watch different channels. 麵包機: you can make different food. Swiss knife: you can use different tools Computer: you can … CS135602 Introduction to Information Engineering
Magic box You can add more functions to it. How? Program is like data to be input to computers. It can perform multiple functions at a time We will talk about this in the OS lesson.
Stored-program concept • Program: a sequence of instructions • Stored-program concept: a program can be encoded as bit patterns and stored in main memory. From there, the CPU can extract the instructions and execute them. • Advantage: programmable • We can use a single machine to perform different functions. CS135602 Introduction to Information Engineering
Problems • How to convert instructions to operations? • This is like Harry Porter’s spell. • There should be a control unit. • To control which function to perform. • To control which data to be operated. • How can the control unit understand the instructions? • What function units should be included? • CD players, game console, calculators, …? CS135602 Introduction to Information Engineering
Control unit Outline of the magic box Processingunit Storage unit for instructions and data Belt CS135602 Introduction to Information Engineering
Large temporary storage for data and instructions Small but fast temporary storage Processing tools von Neumann architecture general purpose electronic computer Figure 2.1 CPU and main memory connected via a bus CS135602 Introduction to Information Engineering
Machine Language What to do + Specified information CS135602 Introduction to Information Engineering
Compiler lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) You will learn it in CS2410 Assembly Language Program Assembler Machine Language Program Machine Interpretation Control Signal Specification ALUOP[0:3] <= InstReg[9:11] & MASK Computer programs temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; You are learning it in CS1355 High Level Language Program 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 This will be taught in CS4100 We are going to talk about those. CS135602 Introduction to Information Engineering
Example: a = b + c 1 1+2 3 2 CS135602 Introduction to Information Engineering
Represented by instructions CS135602 Introduction to Information Engineering
Instruction format • Store the data in register 5 to memory cell at address A7 Op-code: Specifies which operation to execute Operand: Gives more detailed information about the operation CS135602 Introduction to Information Engineering
Another example • JUMP to instruction at address 58H if the content of register 2 is the same as that of register 0 CS135602 Introduction to Information Engineering
The instruction repertoire • Which instructions should be included? • For example, swapping v[k] and v[k+1] Create a new instruction, called swp, which swaps data in two memory addresses. Using load and store instructions lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) swp 0($2), 4($2) Complex Instruction Set Computing (CISC) Reduced Instruction Set Computing (RISC) CS135602 Introduction to Information Engineering
Instruction types • Data Transfer • Copy data between CPU and main memory • E.g., LOAD, STORE, device I/O, • Control • Direct the execution of the program • E.g., JUMP, BRANCH, JNE (conditional jump), • Arithmetic/Logic • Use existing data values to compute a new value • E.g., AND, OR, XOR, SHIFT, ROTATE, etc. CS135602 Introduction to Information Engineering
Instruction types Data transfer Data transfer Arithmetic/Logic Data transfer Control CS135602 Introduction to Information Engineering
Program Execution CS135602 Introduction to Information Engineering
Program execution cycle CS135602 Introduction to Information Engineering
How to make a program “run”? Figure 2.10 The program from Figure 2.7 stored in main memory CS135602 Introduction to Information Engineering
Instruction fetch Figure 2.11 Performing the fetch step of the machine cycle CS135602 Introduction to Information Engineering
Processor Architecture Processor Memory Function unit Register 0 6C 1 1 6D 2 2 6E 3 Address bus 4 5 A0 15 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter A5 56 A6 30 Instruction register A7 6E A8 C0 A9 00 Controller
Fetch Instruction 1 Processor Memory Function unit Register Decode 0 6C 1 1 6D 2 2 6E 3 Address bus 4 A0 5 A0 15 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter 156C A5 56 A0 A2 A6 30 Instruction register A7 6E 156C A8 C0 A9 00 Controller
Decode Instruction 1 Processor Memory Function unit Register 0 6C 1 1 6D 2 2 6E 3 Control signal Address bus 4 5 A0 15 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter A5 56 Decode A2 A6 30 Instruction register A7 6E A8 156C C0 A9 00 Controller
Execute Instruction 1 Processor Memory Function unit Register 0 6C 1 1 6D 2 2 6E 3 Address bus 4 1 6C 5 A0 15 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter 1 A5 56 Decode A2 A6 30 Instruction register A7 6E A8 C0 156C A9 00 Controller
Fetch Instruction 2 Processor Memory Function unit Register 0 6C 1 1 6D 2 2 6E 3 Address bus 4 A2 1 5 A0 15 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter 166D A5 56 A2 A4 A6 30 Instruction register A7 6E 166D A8 C0 A9 00 Controller
Decode Instruction 2 Processor Memory Function unit Register 0 6C 1 1 6D 2 2 6E 3 Address bus 4 1 5 A0 15 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter A5 56 Decode A4 A6 30 Instruction register A7 6E A8 166D C0 A9 00 Controller
Execute Instruction 2 Processor Memory Function unit Register 0 6C 1 1 6D 2 2 6E 3 Address bus 4 6D 1 5 A0 15 2 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter 2 A5 56 Decode A4 A6 30 Instruction register A7 6E A8 C0 166D A9 00 Controller
Fetch Instruction 3 Processor Memory Function unit Register 0 6C 1 1 6D 2 2 6E 3 Address bus 4 A4 1 5 A0 15 2 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter 5056 A5 56 A4 A6 A6 30 Instruction register A7 6E 5056 A8 C0 A9 00 Controller
Decode Instruction 3 Processor Memory Function unit Register 0 6C 1 1 6D 2 2 6E 3 Address bus 4 1 5 A0 15 2 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter A5 56 Decode A6 A6 30 Instruction register A7 6E A8 5056 C0 A9 00 Controller
Adder Execute Instruction 3 Processor Memory Function unit Register 3 0 6C 1 1 6D 2 2 6E 3 Address bus 4 1 5 A0 15 2 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter A5 56 Decode A6 A6 30 Instruction register A7 6E A8 C0 5056 A9 00 Controller
Fetch Instruction 4 Processor Memory Function unit Register 0 3 6C 1 1 6D 2 2 6E 3 Address bus 4 A6 1 5 A0 15 2 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter 306E A5 56 A6 A8 A6 30 Instruction register A7 6E 306E A8 C0 A9 00 Controller
Decode Instruction 4 Processor Memory Function unit Register 0 3 6C 1 1 6D 2 2 6E 3 Address bus 4 1 5 A0 15 2 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter A5 56 Decode A8 A6 30 Instruction register A7 6E A8 306E C0 A9 00 Controller
Execute Instruction 4 Processor Memory Function unit Register 0 3 6C 1 1 6D 2 2 3 6E 3 Address bus 4 6E 1 5 A0 15 2 6 A1 6C A2 16 F A3 Data bus 6D A4 50 Program counter 3 A5 56 Decode A8 A6 30 Instruction register A7 6E A8 C0 306E A9 00 Controller
Instruction decode • How to map opcodes to desired circuits on a CPU? • For example: • 00b: add • 01b: or • 10b: jump • 11b: and CS135602 Introduction to Information Engineering
Interpretation of operand • The interpretation of operand depends on the op-code CS135602 Introduction to Information Engineering
Instruction execution • Uses logic circuits • Data transfer: load, store, … • Logic circuit for registers (Ex: flip-flops) • Control: jump, jump-equal, … • Change the value of program counter (PC) • Comparison logic circuit • Arithmetic/Logic: add, and, shift, … • Again, logic circuits (adder, as we have seen.) CS135602 Introduction to Information Engineering
Flip-flops • A logic circuit that can store one bit. • Upper input is used to set its stored value to 1 • Lower input is used to set its stored value to 0 • While both input lines are 0, the most recently stored value is preserved • Initially, both inputs and outputare 0 CS135602 Introduction to Information Engineering
Flip-flops: set value 1 The input signal 1 0 CS135602 Introduction to Information Engineering
Flip-flops: set value 0 Input (1,1) is undefined CS135602 Introduction to Information Engineering
Example of jump • JUMP to instruction at address 58H if the content of register 2 is the same as that of register 0 CS135602 Introduction to Information Engineering
Register 0 Register 2 XOR OR NOT : : Example of jump-equal • B258: JUMP to instruction at address 58H if the content of register 2 is the same as that of register 0 In case you forgot what XOR is 58H=01011000 set Program counter CS135602 Introduction to Information Engineering
Arithmetic/Logic Operations CS135602 Introduction to Information Engineering
Arithmetic/Logic operations • Arithmetic: add, subtract, multiply, divide • Precise action depends on how the values are encoded (two’s complement vs. floating-point) • Shift • circular shift (Rotate), logical shift, arithmetic shift • Logic: AND, OR, XOR, NOT • Masking CS135602 Introduction to Information Engineering
One bit full adder CS135602 Introduction to Information Engineering
4 bit parallel adder CS135602 Introduction to Information Engineering