1 / 28

Computer architecture, part 1:

What we’ll cover for this lecture topic: What is a CPU? How is a program executed by the CPU? Boolean logic Binary circuits that can add!. Computer architecture, part 1:. The CPU. Central Processing Unit (CPU) : Carries out the program’s instructions!

owena
Télécharger la présentation

Computer architecture, part 1:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What we’ll cover for this lecture topic: What is a CPU? How is a program executedby the CPU? Boolean logic Binary circuits that can add! Computer architecture, part 1: The CPU

  2. Central Processing Unit (CPU): Carries out theprogram’s instructions! Operates on data it finds in the computer’s memory. Also calledMicroprocessor Includes all binary circuits that carry out arithmetic & logic operations---reduced to a single IC. CPU has four key parts that we will examine: Control Unit Arithmetic & Logic Unit Registers Clock And, of course, wires that connect everything together.

  3. CONTROL UNIT(CU): circuitry for coordinating machine’s activities. Controls sequence of operations. • ARITHMETIC & LOGIC UNIT(ALU): circuitry to perform data manipulation (arithmetic & logic). • Registers: Temporary storage areas. Holds information applicable to the currentoperation. • Clock: Triggers start and stop of all CPU operations. (heartbeat) CPU Two main functional units: CUALU Registers clock

  4. CPUs support a set of very simple instructions that typically fall into the following categories: Data movement (load, store, copy…) Arithmetic/logical (add, subtract, compare..) Program control (branch, halt…) Very primitive commands (operations) executed by the CPU [logical structure] These commands are implemented as electronic binary circuits [physical structure] which can transform the 0s and 1s. BASIC INSTRUCTION SET

  5. Instructions are given to the processor in the form of a program… so it knows what circuits to use, in what order; and fromwhere the data should be read or to where it should be stored. Sample of a partial Basic instructionset Instr:Meaning: STO Store data in a particular memory location ADD Add two numbers together SUB Subtract one number from another MUL Multiply two numbers DIV Divide two numbers INC Increment a number by adding 1 CMP Compare two numbers to see if they are equal JMP Jump to a specific position in the instruction code

  6. More specifically: A program consists of a sequence of instructions. EACH instruction specifies both: The operation to perform The address of the data it will transform in that operation (if necessary). • Instructions are stored and processed in machinelanguage--also called microcode. • Like everything else (e.g. like ASCII characters, pixels of an image, …) machine language consists solely of bit patterns.

  7. Machinelanguageor Machine Code a/k/amicrocode • ML bit patterns are based directly on CPU’s instructionset(on its binary circuits). So who created them? • CPU chip: designed to recognize certain bit patterns as representing certain ML instructions, which correspond directly to certain available binary circuits. • Each ML instruction contains a fixed-length instruction code that: • Identifies the operation to perform: op code • Tells the CPU how to determine the operands For example:assume a 4-bit op-code + two 6-bit operands = one 16 bit instruction

  8. Before it can process a M.L. instruction, the CPU must fetch it from main memory. The CPU must keep track of its position in the instruction code. It uses a bookmark of sorts. The offset at which the next instruction starts is stored in a special register, called the ProgramCounter or Instruction Pointer. Important digression… who knows if bits in memory are data or program … ? increments to memory address of next instruction ... E.G.: An ADD instruction in a 16-bit machine language: 0101 110011 111100 Op-code:Operands:(RAM or Register addresses) 0101110011 111100

  9. Processor: simple minded! repeats same steps over & over... Putting it all together MACHINE CYCLE:“Instruction-Execution cycle” Processing of a single machine-level instruction (one Op Code) in a basic machine. Instruction Cycle: in the Control Unit 1.FETCH • Fetches instruction (from memory) at address given by instruction pointer; copies it into CU storage register. 2.COPY & DECODE • Copies op code into instruction register, operands into address registers. • Interprets instruction. ALU is invoked to perform decoded operation for any ALU ops (enters Execution Cycle) 3. ADVANCE INSTRUCTION POINTER (counter) • Pointer incremented; contains memory address of next instruction that will be fetched. 9

  10. Imprecise data representation, and a vast simplification-- but general concepts are correct. 1 2b Advance pointer Enter execute cycle 3 000011 110011 0101 2a Copy & Decode 111100 Fetch • 0101 110011 111100 , A single Instruction cycle (Add) PROCESSOR 000001 ALU CONTROL UNIT Pointer Address reg Instr. reg. Address reg Storage register MEMORY 85datashown in base 10 0101 1100 1111 1100 #000001 #000010 #110011 …. 65datashown in base 10 0111 1110 0111 1110 #000011 #000100 #111100 …. 10

  11. Imprecise data representation, and a vast simplification-- but general concepts are correct. 1 2b Advance pointer Enter execute cycle 3 000101 111001 0111 2a Copy & Decode 111110 Fetch • 0111 111001 111110 , Another single Inst Cycle (Divide) PROCESSOR 000011 ALU CONTROL UNIT Pointer Address reg Instr. reg. Address reg Storage register MEMORY 85datashown in base 10 0101 1100 1111 1100 #000001 #000010 #110011 …. 65datashown in base 10 0111 1110 0111 1110 #000011 #000100 #111100 …. 11

  12. Execution cycles vary, depending on the op code. Eg: load register R03 with contents of memory cell 47: Just for culture: The CU causes the load to occur. CU activates ALU circuitry, which performs the actual Op Code. EG: MUL, ADD, DIV, … Execution Cycle: by the CU/ALU E.G: an arithmetic operation: ADD 1. LOAD • Data copied from memory to ALU register. 2. ADD • Data values are added in ALU adder circuitry. 3. COPY • Result stored in ALU accumulator. 4. STORE • Result copied from ALU to memory. 12

  13. 85 2 3 Enter execute cycle Result copied to Accumulator 85+ 65 = 150 65 Data values added 150 1 4 Data loaded to registers 150 Result stored in memory Execution cycle PROCESSOR C.U. ALU Register Register Adder Accumulator MEMORY 85datashown in base 10 0101 1100 1111 1100 #111110 …. #000001 #000010 #110011 …. 65datashown in base 10 0111 1110 0111 1110 #000011 #000100 #111100 ….

  14. Boolean algebra: solve complex math problems by reducing them to questions answered by Y/N. Logic gate:Mathematical operation that handles only data that is represented in one of only two states: TRUE/FALSE Physical gate: electronic device that transforms binary input(s) to produce a single binary output, according to its transformation rule. Many computer binary circuits employ complex Boolean logic to perform various tasks. Such circuits can test the truth of propositions by making comparisons, as well as carry out complex calculations. Gates: AND, OR, NOT Boolean logic

  15. Truth tables COOL Parents Homework? Clean? AND truth table AND truth table AND truth table OR truth table NOT truth table 2 Inputs 2 Inputs 1 Output 1 Output 1Input 1 Output 0 0 0 0 0 0 1 0 1 1 1 0 1 0 1 1 1 1 STRICT Parents Stubborn child Homework? Clean? 0 111 0 0 0 1 1 0 • Engineers design binary computer circuits using gates based on truth tables. • Gates: building blocks of all digital devices! • Such circuits can carry out +, –, *, /, comparisons, and many complex operations.

  16. Remember, the fundamental part of the digital computer is the switch. A switch simply lets current either flow completely or not at all (binary) : Relay: mechanical switch Vacuum tubes: electronic switch Transistors: electronic switch ICs: use many transistors on a circuit board Speed of computer determined by how fast a switch “switches”! Digital Logic

  17. How does a transistor work? Transistor Current trying to flow through If input voltage is low (binary 0) the switch opens and the current cannot pass through. Transistor(Switch) Input Voltage If input voltage is high (binary 1), the switch closes and the current passes through freely.

  18. Transistors are only switches. They simply determine whether or not current can pass through a wire. Transistors are used to create logic gates. These gates perform logic operations on the input voltages and give the result in form of an output voltage. Let’s construct a few simple gates to see how this works… Logic Gates

  19. NOT gate When input is low, then switch is open, and high current flows to output. When input is high, then switch is closed, and the current is grounded (instead of passing into output), therefore the output voltage is low. Steady current (high) Output Voltage Input Voltage logical operator: NOTLow input becomes high output.High input become low output. Ground(low)

  20. NAND gate (NOT AND) If both inputs are High, then current passes through, and output is Low. If either input is Low, switch closes, and output is High. Input Voltage 2 Input Voltage 1 Steady current(high) Ground(low) Output Voltage

  21. NOR gate (NOT OR) If both inputs are Low, then neither switch is closed, and output is High.If either input is High, a switch opens, and output is Low. Steady current (high) Output Voltage Input Voltage 1 Input Voltage 2 Ground(low) Ground(low)

  22. We have only created NOT, NAND, and NOR. We wanted ANDs and ORs as well… Just feed output of NAND and NOR into NOT gate. Actually, all boolean logic expressions can be constructed just from NAND or from NOR – complete! Demo: 4-bit half adder Digital Logic

  23. 1 1 1 OR AND Output Bit + 1 AND 0 NOT 0 0 Carry Bit How can binary circuits ADD? 0 1 You will not have to reconstruct diagrams! But you should know how to evaluate Boolean ops. 16

  24. 0 1 1 OR AND Output Bit + 0 AND 1 NOT 1 1 Carry Bit How can binary circuits ADD? 1 0 17

  25. Subtraction Addition using two’s complement representation Multiplication Repeated addition (with bit shifting) Division Repeated subtraction (with bit shifting) Basically, a computer just adds. What about other operations?

  26. Important digression! What kind of code do programmers use? High-level language (source code) Machine language (object code) e.g.: Turing Translator(Compiler) Source Code • What is the only kind of code a CPU understands? Machine Codeor Object code • So, what has to occur before the CPU can execute a source-code program? Translationor Compilation

  27. An Analogy Carbon-based unit JOHNNY, age 4 (obeys orders to transform raw material into tasty sandwiches.) Basic Instruction Set: Simple commands hecan do: Go, Bring, Unwrap, … Child brain, hands, skills he uses. Grandpa’s commands: “Please make 2 p&j sandw’s on rye!” Mom:Grandpa language to Child Talk Child-talkinstructions to Johnny that heunderstands: GO to pantry. BRING bread & PB to kitchen. UNWRAP bread. PULLOUT 4 slices …. 20

  28. Silicon-based unit CPU(obeys orders to transformraw data into meaningful info.) STO; ADD; SUB; MUL; DIV; INC; CMP; JMP… Johnny what Johnny can do Basic Instruction Set: Primitive commands (log’l) itcan do Computer circuits (phy’l) it uses Source code Answer := Num1 + Num2 Grandpa’scommand Translator prog: Source to object Mom translates Object code (Low-level ML) so CPU can understand it: Child talk LOAD M012 R07 LOAD M013 R08 ADDR07R08 R02 STORE R09 M033 0010 00001100 0111 0010 00001101 10000101011110000010 00110010 00100001 asbinarycodes 21

More Related