cs 31 intro to systems digital logic
play

CS 31: Intro to Systems Digital Logic Martin Gagn Swarthmore - PowerPoint PPT Presentation

CS 31: Intro to Systems Digital Logic Martin Gagn Swarthmore College January 31, 2017 Youre going to want scratch papr today borrow some if needed. Quick Announcements Late Policy Reminder 3 late days total for the whole


  1. CS 31: Intro to Systems Digital Logic Martin Gagné Swarthmore College January 31, 2017 You’re going to want scratch papr today … borrow some if needed.

  2. Quick Announcements • Late Policy Reminder • 3 late days total for the whole semester • Lab work • Start early, especially multi-week labs • Readings • Only the page linked, no further links

  3. Today (and Thursday) • Hardware basics • Machine memory models • Digital signals • Logic gates • Manipulating/Representing values in hardware • Adders • Storage & memory (latches)

  4. The system stack c program compiler software shell operating system Starting this week This class memory CPU hardware circuits gates transistors electrical engineering wires

  5. Hardware Models (1940’s) • Harvard Architecture: CPU Program Data (Control and Memory Memory Arithmetic) Input/Output • Von Neumann Architecture: CPU Program (Control and and Arithmetic) Data Memory Input/Output

  6. Von Neumann Architecture Model • Computer is a generic computing machine: • Based on Alan Turing’s Universal Turing Machine

  7. Von Neumann Architecture Model • Computer is a generic computing machine: • Based on Alan Turing’s Universal Turing Machine ➔ The hardware only ever executes one program: Initialize program counter Repeat forever: { fetch instruction indicated by program counter increment the program counter execute the instruction }

  8. Von Neumann Architecture Model • Computer is a generic computing machine: • Based on Alan Turing’s Universal Turing Machine • Stored program model: computer stores program rather than encoding it (feed in data and instructions) • No distinction between data and instructions memory • 5 parts connected by buses (wires): • Memory, Control, Processing, Input, Output Cntrl Unit | Processing Unit Memory Input/Output addr bus cntrl bus data bus

  9. Memory • Stores instructions and data. • Addressable, like array indices. • addr 0, 1, 2, … (In CPU:) • Memory Address Register: address to read/write • Memory Data Register: value to read/write Cntrl Unit | Processing Unit Memory Input/Output addr bus cntrl bus data bus

  10. Central Processing Unit (CPU) • Processing Unit: executes instructions selected by the control unit • ALU (arithmetic logic unit): simple functional units: ADD, SUB, AND, OR, etc. • Registers: temporary storage directly accessible by instructions • Control unit: determines the order in which instructions execute • PC: program counter: address of next instruction • IR: instruction register: holds current instruction • clock-based control: clock signal+IR trigger state changes

  11. Input/Output • Keyboard • Files on the hard drive • Network communication Cntrl Unit | Processing Unit Memory Input/Output addr bus cntrl bus data bus

  12. Digital Computers • All input is discrete (driven by periodic clock) • All signals are binary (0: no voltage, 1: voltage) data, instructions, control signals, arithmetic, clock • To run program, need different types of circuits Circuits to Circuits to CPU RAM execute store program ALU, Cntrl, Cntrl & Storage program data and instructions instructions Storage and support reading that act on and writing program data addressable storage bus locations

  13. Goal : Build a CPU (model) Three main classifications of HW circuits: 1. ALU: implement arithmetic & logic functionality (ex) adder to add two values together 2. Storage: to store binary values (ex) Register File: set of CPU registers, Also: main memory (RAM) 3. Control: support/coordinate instruction execution (ex) fetch the next instruction to execute

  14. Abstraction User / Programmer Wants low complexity Applications Specific functionality Software library Reusable functionality Operating system Manage resources Complex devices Compute & I/O

  15. Abstraction Hardware Circuits Logic Gates Transistors Here be dragons. Complex devices (Electrical Engineering) Compute & I/O … (Physics)

  16. Logic Gates Input: Boolean value(s) (high and low voltages for 1 and 0) Output: Boolean value result of boolean function Always present, but may change when input changes And Or Not a a a out out out b b out = a & b out = a | b out = ~ a A B A & B A | B ~A 0 0 0 0 1 0 1 0 1 1 1 0 0 1 0 1 1 1 1 0

  17. More Logic Gates Note the circle on the output. This means “negate it.” NAND NOR a a out out b b out = ~(a & b) out = ~(a | b) A B A NAND B A NOR B 0 0 1 1 0 1 1 0 1 0 1 0 1 1 0 0

  18. Combinational Logic Circuits • Build up higher level processor functionality from basic gates Acyclic Network of Gates Inputs Outputs Outputs are boolean functions of inputs Outputs continuously respond to changes to inputs

  19. What does this circuit output? And Or Not X Output Y Clicker Choices X Y Out A Out B Out C Out D Out E 0 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 1 1 0

  20. What can we do with these? • Build-up XOR from basic gates (AND, OR, NOT) A B A ^ B Q: When is A^B ==1 ? 0 0 0 0 1 1 1 0 1 1 1 0

  21. Which of these is an XOR circuit? And Or Not Draw an XOR circuit using AND, OR, and NOT gates. I’ll show you the clicker options after you’ve had some time.

  22. Which of these is an XOR circuit? A: B: A A B B C: D: A A B B E: None of these are XOR.

  23. Checking the XOR circuit A^B == (~A & B) | (A & ~B) A B out = A^B A:0 B:0 A^B: A:1 B:0 A^B: 1 0 A:0 B:1 A^B: A:1 B:1 A^B: 0 1

  24. Abstracting the XOR circuit A^B == (~A & B) | (A & ~B) A B out = A^B A B A ^ B 0 0 0 0 1 1 1 0 1 XOR = 1 1 0 A out = A^B B

  25. Digital Circuits - Building a CPU Three main classifications of HW circuits: 1. ALU: implement arithmetic & logic functionality (ex) adder to add two values together 2. Storage: to store binary values (ex) Register File: set of CPU registers 3. Control: support/coordinate instruction execution (ex) fetch the next instruction to execute HW Circuits Logic Gates Transistor

  26. Digital Circuits - Building a CPU Three main classifications of HW circuits: 1. ALU: implement arithmetic & logic functionality (ex) adder to add two values together Start with ALU components (e.g., adder, logic circuits) Combine (with multiplexer) into ALU! HW Circuits Logic Gates Transistor

  27. Arithmetic Circuits • 1 bit adder: A+B • Two outputs: 1. Obvious one: the sum 2. Other one: ?? A B Cout Sum(A+B) 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0

  28. Which of these circuits is a one-bit adder? A B Sum(A+B) Cout 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 A: B: A A Sum Sum B B C out C out C: D: A A Sum Sum B B C out C out

  29. More than one bit? • When adding, sometimes have carry in too 0011010 + 0001111

  30. One-bit (full) adder A B Cin Sum Cout Need to include: 0 0 0 0 0 0 1 0 1 0 Carry-in & Carry-out 1 0 0 1 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 1 1 1 1 C in = A 1-bit B Sum adder C out

  31. One-bit (full) adder A B Cin Sum Cout Need to include: 0 0 0 0 0 0 1 0 1 0 Carry-in & Carry-out 1 0 0 1 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 1 1 1 1 C in cout A cout HA = A B cout sum 1-bit B Sum HA adder sum cin C out

  32. Multi-bit Adder (Ripple-carry Adder) 0 A 0 A 3 1-bit 1-bit B 0 Sum 0 B 3 Sum 3 adder adder C out C out … A 1 1-bit B 1 Sum 1 adder C out A N-1 1-bit B N-1 Sum N-1 A 2 adder 1-bit B 2 Sum 2 adder C out C out

  33. Three-bit Adder (Ripple-carry Adder) 0 0 Carry in 1-bit 1 adder A 0 010 (2) A 1 A 2 = 1 Sum 0 + 011 (3) 1-bit 3-bit 1 Sum 1 adder adder B 0 Sum 2 B 1 B 2 0 1-bit 0 adder Carry out

  34. Arithmetic Logic Unit (ALU) • One component that knows how to manipulate bits in multiple ways • Addition • Subtraction • Multiplication / Division • Bitwise AND, OR, NOT, etc. • Built by combining components • Take advantage of sharing HW when possible (e.g., subtraction using adder)

  35. Simple 3-bit ALU: Add and bitwise OR 3-bit inputs A and B: A 0 A 1 Sum 0 3-bit A 2 Sum 1 adder Sum 2 B 0 B 1 At any given time, we B 2 only want the output from ONE of these! Or 0 Or 1 Or 2

  36. Simple 3-bit ALU: Add and bitwise OR Extra input: control signal to select Sum vs. OR 3-bit inputs A and B: A 0 A 1 Sum 0 3-bit A 2 Sum 1 adder Sum 2 B 0 B 1 Circuit that takes B 2 in Sum 0-2 / Or 0-2 and only outputs Or 0 one of them, based on control Or 1 signal. Or 2

  37. Which of these circuits lets us select between two inputs? A: B: Input 1 Input 1 Control Control Signal Signal Input 2 Input 2 C: Input 1 Control Signal Input 2

Recommend


More recommend