Boolean Arithmetic. From Nand to Tetris Building a Modern Computer from First Principles. Chapter 2

Size: px
Start display at page:

Download "Boolean Arithmetic. From Nand to Tetris Building a Modern Computer from First Principles. Chapter 2"

Transcription

1 From Nand to Tetris Building a Modern Computer from First Principles Chapter 2 Boolean Arithmetic These slides support chapter 2 of the book The Elements of Computing Systems By Noam Nisan and Shimon Schocken MIT Press Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 1

2 Usage Notice You are welcome to use this presentation, or any part of it, in Nand to Tetris courses, or in other courses, as you see fit. Usage is free provided that it supports instruction in an educational, non-profit setting. Feel free to use the slides as-is, or modify them as needed. We ll appreciate it if you will give credit somewhere to Nand to Tetris, and put a reference to You are welcome to remove this slide from the presentation. If you make extensive changes to the slides, you can remove the copyright notice also. Happy teaching! Noam Nisam / Shimon Schocken Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 2

3 Chapter 2: Boolean arithmetic Binary numbers Binary addition Negative numbers Arithmetic Logic Unit Project 2 overview Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 3

4 bits 8 possibilities N bits 2 N possibilities Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 4

5 Representing numbers Binary Decimal Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 5

6 Representing numbers s 10s 1s ten Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 6

7 Representing numbers s 10s 1s ten = = 789 ten Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 7

8 Binary Decimal s 2s 1s two Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 8

9 Binary Decimal s 2s 1s two = = 5 ten Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 9

10 Binary Decimal Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 10

11 Binary Decimal b n b n-1 b n-2 b 1 b 0 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 11

12 Binary Decimal b n b n-1 b n-2 b 1 b 0 = n b i 2 i i=0 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 12

13 Binary Decimal b n b n-1 b n-2 b 1 b 0 = n b i 2 i i=0 Maximum value represented by k bits: k-1 = 2 k -1 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 13

14 Fixed word size Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 14

15 Fixed word size We will use a fixed number of bits. Say 8 bits Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 15

16 Fixed word size We will use a fixed number of bits. Say 8 bits = 256 values Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 16

17 Representing signed numbers We will use a fixed number of bits. Say 8 bits positive values negative values Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 17

18 Representing signed numbers We will use a fixed number of bits. Say 8 bits positive values That s one possible representation We ll use a better one, later negative values Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 18

19 Decimal Binary 87 ten Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 19

20 Decimal Binary 87 ten =???????? two Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 20

21 Decimal Binary 87 ten = 64 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 21

22 Decimal Binary 87 ten = Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 22

23 Decimal Binary 87 ten = Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 23

24 Decimal Binary 87 ten = Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 24

25 Decimal Binary 87 ten = Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 25

26 Decimal Binary 87 ten = =???????? two Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 26

27 Decimal Binary 87 ten = = two Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 27

28 Decimal Binary 87 ten = = two 32 8 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 28

29 Chapter 2: Boolean arithmetic Binary numbers Binary addition Negative numbers Arithmetic Logic Unit Project 2 overview Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 29

30 Boolean arithmetic Addition Subtraction Comparison (<,>,=) Multiplication Division implement get for free get for free postpone to software postpone to software Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 30

31 Addition ???????? Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 31

32 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 32

33 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 33

34 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 34

35 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 35

36 Addition ???? Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 36

37 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 37

38 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 38

39 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 39

40 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 40

41 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 41

42 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 42

43 Addition ???????? Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 43

44 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 44

45 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 45

46 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 46

47 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 47

48 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 48

49 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 49

50 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 50

51 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 51

52 Addition Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 52

53 Overflow Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 53

54 Overflow ???????? Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 54

55 Overflow Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 55

56 Building an Adder Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 56

57 Building an Adder Half adder: adds two bits Full adder: adds three bits Adder: adds two integers Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 57

58 Half adder carry bit a b sum carry sum bit Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 58

59 Half adder a b sum carry HalfAdder.hdl /** Computes the sum of two bits. */ CHIP HalfAdder { IN a, b; OUT sum, carry; } PARTS: // Put your code here: Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 59

60 Full adder Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 60

61 Full adder Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 61

62 Full adder carry bit sum bit Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 62

63 Full adder FullAdder.hdl /** Computes the sum of three bits. */ CHIP HalfAdder { IN a, b, c; OUT sum, carry; } PARTS: // Put your code here: Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 63

64 Multi-bit Adder Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 64

65 Multi-bit Adder Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 65

66 Multi-bit Adder Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 66

67 Multi-bit Adder Add16.hdl /* Adds two 16-bit, two s-complement values. * The most-significant carry bit is ignored. */ CHIP Add16 { IN a[16], b[16]; OUT out[16]; } PARTS: // Put you code here: Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 67

68 Chapter 2: Boolean arithmetic Binary numbers Binary addition Negative numbers Arithmetic Logic Unit Project 2 overview Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 68

69 Representing numbers (using 4 bits) Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 69

70 Representing numbers (using 4 bits) Using n bits, we can represent the positive integers in the range 0 2 n -1 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 70

71 Representing negative numbers Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 71

72 Possible solution: use a sign bit Use the left-most bit to represent the sign, -/+ Use the remaining bits to represent a positive number Complications: -0? x + (-x) is not 0 more complications Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 72

73 Two's Complement Represent the negative number -x using the positive number 2 n - x Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 73

74 Two's Complement (16-8) (16-9) (16-10) (16-11) (16-12) (16-13) (16-14) (16-15) Represent the negative number -x using the positive number 2 n - x Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 74

75 Two's Complement (16-8) (16-9) (16-10) (16-11) (16-12) (16-13) (16-14) (16-15) positive numbers range: 0 2 n-1-1 negative numbers range: -1-2 n - 1 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 75

76 Addition using two's complement Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 76

77 Addition using two's complement Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 77

78 Addition using two's complement Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 78

79 Addition using two's complement = 27 ten 1011 = 11 ten Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 79

80 Addition using two's complement = 27 ten 1011 = 27 ten Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 80

81 Addition using two's complement Two s complement rationale: representation is modulu 2 n addition is modulu 2 n = 27 ten 1011 = 27 ten Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 81

82 Computing -x Input: x Output: -x (in two's complement) Insight: if we solve this we ll know how to subtract: y x = y + (-x) Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 82

83 Computing -x Input: x Output: -x (in two's complement) Idea: 2 n x = 1 + (2 n - 1) - x two (some x example) Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 83

84 Computing -x Input: x Output: -x (in two's complement) Idea: 2 n x = 1 + (2 n - 1) - x two (some x example) Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 84

85 Computing -x Input: x Output: -x (in two's complement) Idea: 2 n x = 1 + (2 n - 1) - x two (some x example) (flip all the bits) Now add 1 to the result Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 85

86 Computing -x (example) Input: 4 Output: should be 12 (representing -4 in two s compelemt) Input: 0100 Flip the bits: 1011 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 86

87 Computing -x (example) Input: 4 Output: should be 12 (representing -4 in two s compelemt) Input: 0100 Flip the bits: Add one: 1 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 87

88 Computing -x (example) Input: 4 Output: should be 12 (representing -4 in two s compelemt) Input: 0100 Flip the bits: Add one: 1 Output: 1100 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 88

89 Computing -x (example) Input: 4 Output: should be 12 (representing -4 in two s compelemt) Input: 0100 Flip the bits: Add one: 1 To add 1: Flip all the bits from right to left, stop when the first 0 flips to 1 Output: 1100 = 12 ten Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 89

90 Chapter 2: Boolean arithmetic Binary numbers Binary addition Negative numbers Arithmetic Logic Unit Project 2 overview Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 90

91 Von Neumann Architecture Computer System CPU Input Memory ALU Output Contro l Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 91

92 The Arithmetic Logical Unit Computer System CPU Input Memory ALU Output Contro l Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 92

93 The Arithmetic Logical Unit The ALU computes a function on the two inputs, and outputs the result input1 f f : one out of a family of pre-defined arithmetic and logical functions input2 ALU f (input1, input2) Arithmetic functions: integer addition, multiplication, division,... logical functions: And, Or, Xor, Which functions should the ALU perform? A hardware / software tradeoff. Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 93

94 The Hack ALU Operates on two 16-bit, two s complement values Outputs a 16-bit, two s complement value Which function to compute is set by six 1-bit inputs out 0 Computes one out of a family of 18 functions 1 Also outputs two 1-bit values (to be discussed later). -1 x y zx nx zy ny f no!x!y -x -y x+1 y+1 x 16 bits x-1 ALU out y-1 y 16 bits x+y 16 bits x-y y-x x&y x y zr ng Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 94

95 The Hack ALU out x y zx nx zy ny f no!x!y -x -y x+1 y+1 x 16 bits x-1 ALU out y-1 y 16 bits x+y 16 bits x-y y-x x&y x y zr ng Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 95

96 The Hack ALU x y To cause the ALU to compute a function, set the control bits to one of the binary combinations listed in the table. control bits zx nx zy ny f no out x y zx nx zy ny f no !x !y x y x y+1 16 bits x-1 ALU out y-1 16 bits x+y 16 bits x-y y-x x&y x y zr ng Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 96

97 The Hack ALU in action: compute y-x 2. Evaluate the chip logic Load tools/builtinchips/alu.hdl 3. Inspect the ALU outputs 1. Set the ALU s inputs and control bits to some test values ( codes output y-x ) The built-in ALU implementation has some GUI side-effects Built-in ALU implementation Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 97

98 The Hack ALU in action: compute x & y Set to binary I/O format Inspect the ALU outputs Set the ALU s inputs and control bits to some test values ( codes compute x&y ) Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 98

99 Opening up the Hack ALU black box control bits x y out = f(control bits, x, y) Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 99

100 The Hack ALU operation pre-setting the x input pre-setting the y input selecting between computing + or & post-setting the output Resulting ALU output zx nx zy ny f no out if zx then x=0 if nx then x=!x if zy then y=0 if ny then y=!y if f then out=x+y else out=x&y if no then out=!out out(x,y)= zx nx zy ny f no x y 16 bits 16 bits ALU 16 bits out zr ng Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 100

101 The Hack ALU operation pre-setting the x input pre-setting the y input selecting between computing + or & post-setting the output Resulting ALU output zx nx zy ny f no out if zx then x=0 if nx then x=!x if zy then y=0 if ny then y=!y if f then out=x+y else out=x&y if no then out=!out out(x,y)= x y !x !y x y x y x y x+y x-y y-x x&y x y Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 101

102 ALU operation example: compute!x pre-setting the x input pre-setting the y input selecting between computing + or & post-setting the output Resulting ALU output zx nx zy ny f no out if zx then x=0 if nx then x=!x if zy then y=0 if ny then y=!y if f then out=x+y else out=x&y if no then out=!out out(x,y)= x y !x !y Example: compute!x x x: y y: x y Following 1 pre-setting: 1 0 x x: y y: x+y x-y Computation 1 and 1 post-setting: 1 y-x x&y: x&y 0 1 0!(x&y): (!x) 1 x y Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 102

103 ALU operation example: compute y-x pre-setting the x input pre-setting the y input selecting between computing + or & post-setting the output Resulting ALU output zx nx zy ny f no out if zx then x=0 if nx then x=!x if zy then y=0 if ny then y=!y if f then out=x+y else out=x&y if no then out=!out out(x,y)= Example: 1 compute 1 y-x x x: (2) y: (7) y !x Following 1 pre-setting: !y x x: y y: x y+1 Computation and post-setting: x-1 x+y: y-1!(x+y): (5) x+y x-y y-x x&y x y Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 103

104 The Hack ALU output control bits zx nx zy ny f no x y 16 bits 16 bits ALU 16 bits out zr ng if (out == 0) then zr = 1, else zr = 0 if (out < 0) then ng = 1, else ng = 0 These two control bits will come into play when we build the complete computer s architecture. Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 104

105 Perspective The Hack ALU is: Simple Elegant To implement it this ALU, you only need to know how to: Set a 16-bit value to Set a 16-bit value to Negate a 16-bit value (bit-wise) Compute plus or And on two 16-bit values That s it! Simplicity is the ultimate sophistication. Leonardo da Vinci Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 105

106 Chapter 2: Boolean arithmetic Binary numbers Binary addition Negative numbers Arithmetic Logic Unit Project 2 overview Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 106

107 Project 2 Given: All the chips built in Project 1 Goal: Build the following chips: HalfAdder FullAdder Add16 Inc16 ALU A family of combinational chips, from simple adders to an Arithmetic Logic Unit. Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 107

108 Half Adder a b sum carry HalfAdder.hdl /** Computes the sum of two bits. */ CHIP HalfAdder { IN a, b; OUT sum, carry; Implementation tip Can be built using two very elementary gates. } PARTS: // Put your code here: Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 108

109 Full Adder a b c sum carry FullAdder.hdl /** Computes the sum of three bits. */ CHIP HalfAdder { IN a, b, c; OUT sum, carry; } PARTS: // Put your code here: Implementation tips Can be built using two half-adders. Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 109

110 16-bit adder Add16.hdl Implementation tips An n-bit adder can be built from n full-adder chips The carry bit is piped from right to left The MSB carry bit is ignored. /* * Adds two 16-bit, two s-complement values. * The most-significant carry bit is ignored. */ CHIP Add16 { IN a[16], b[16]; OUT out[16]; } PARTS: // Put you code here: Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 110

111 16-bit incrementor Implementation tip The single-bit 0 and 1 values are represented in HDL as false and true. Inc16.hdl /* * Outputs in + 1. * The most-significant carry bit is ignored. */ CHIP Inc16 { IN in[16]; OUT out[16]; } PARTS: // Put you code here: Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 111

112 ALU Implementation tips Building blocks: Add16, and some gates built in project 1 Can be built with ~20 lines of HDL code ALU.hdl /** The ALU. */ // Manipulates the x and y inputs as follows: // if (zx == 1) sets x = 0 // 16-bit true constant // if (nx == 1) sets x =!x // bitwise Not // if (zy == 1) sets y = 0 // 16-bit true constant // if (ny == 1) sets y =!y // bitwise Not // if (f == 1) sets out = x + y // int. 2's-complement addition // if (f == 0) sets out = x & y // bitwise And // if (no == 1) sets out =!out // bitwise Not // if (out == 0) sets zr = 1 // 1-bit true constant // if (out < 0) sets ng = 1 // 1-bit true constant... Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 112

113 Project 2 Resources All the necessary project 2 files are available in: nand2tetris / projects / 02 Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 113

114 More resources HDL Survival Guide Hardware Simulator Tutorial nand2tetris Q&A forum All available in: Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 114

115 Best practice advice Try to implement the chips in the given order If you don t implement some of the chips required in project 2, you can still use them as chip-parts in other chips. Just rename the given stub-files; this will cause the simulator to use the built-in versions of these chips You can invent new, helper chips ; however, this is not required: you can build any chip using previously-built chips only Strive to use as few chip-parts as possible You will have to use chips implemented in Project 1 For efficiency and consistency s sake, use their built-in versions rather than your own implementation. Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 115

116 Chapter 2: Boolean arithmetic Binary numbers Binary addition Negative numbers Arithmetic Logic Unit Project 2 overview Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 116

117 From Nand to Tetris Building a Modern Computer from First Principles Chapter 2 Boolean Arithmetic These slides support chapter 2 of the book The Elements of Computing Systems By Noam Nisan and Shimon Schocken MIT Press Nand to Tetris / / Chapter 2 / Copyright Noam Nisan and Shimon Schocken Slide 117

Arithmetic Logic Unit (ALU)

Arithmetic Logic Unit (ALU) Arithmetic Logic Unit (ALU) Introduction to Computer Yung-Yu Chuang with slides by Sedgewick & Wayne (introcs.cs.princeton.edu), Nisan & Schocken (www.nand2tetris.org) and Harris & Harris (DDCA) Let's

More information

Boolean Arithmetic. Building a Modern Computer From First Principles.

Boolean Arithmetic. Building a Modern Computer From First Principles. Boolean Arithmetic Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 2: Boolean Arithmetic slide

More information

Boolean Logic. From Nand to Tetris Building a Modern Computer from First Principles. Chapter 1

Boolean Logic. From Nand to Tetris Building a Modern Computer from First Principles. Chapter 1 From Nand to Tetris Building a Modern Computer from First Principles Chapter 1 Boolean Logic These slides support chapter 1 of the book The Elements of Computing Systems By Noam Nisan and Shimon Schocken

More information

Elements of Computing Systems, Nisan & Schocken, MIT Press. Boolean Arithmetic

Elements of Computing Systems, Nisan & Schocken, MIT Press. Boolean Arithmetic Elements of Computing Systems, Nisan & Schocken, MIT Press www.idc.ac.il/tecs Boolean Arithmetic Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation contains lecture

More information

Introduction: From Nand to Tetris

Introduction: From Nand to Tetris Introduction: From Nand to Tetris Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Introduction slide

More information

Computer Architecture

Computer Architecture Computer Architecture Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 5: Computer Architecture

More information

Introduction: Hello, World Below

Introduction: Hello, World Below Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 www.idc.ac.il/tecs Introduction: Hello, World Below Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation

More information

Computer Architecture

Computer Architecture IWKS 3300: NAND to Tetris Spring 2018 John K. Bennett Computer Architecture Foundations of Global Networked Computing: Building a Modern Computer From First Principles This course is based upon the work

More information

Building a Virtual Computer

Building a Virtual Computer uilding a Virtual Computer From Gates to Operating System Student Researcher: Elisa Elshamy Faculty Mentor: Dr. Victoria Gitman bstract modern computer can carry a plethora of multifaceted computations.

More information

Arithmetic-logic units

Arithmetic-logic units Arithmetic-logic units An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the heart of a processor you could say that everything else in the CPU is there

More information

Assembler Human Thought

Assembler Human Thought Where we are at: Assembler Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy VM Translator Chapters 7-8 Assembly Language

More information

Basic Arithmetic (adding and subtracting)

Basic Arithmetic (adding and subtracting) Basic Arithmetic (adding and subtracting) Digital logic to show add/subtract Boolean algebra abstraction of physical, analog circuit behavior 1 0 CPU components ALU logic circuits logic gates transistors

More information

Computer Architecture

Computer Architecture omputer Architecture Building a Modern omputer From First Principles www.nand2tetris.org Elements of omputing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, hapter 5: omputer Architecture slide

More information

Assembler. Building a Modern Computer From First Principles.

Assembler. Building a Modern Computer From First Principles. Assembler Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 6: Assembler slide 1 Where we are

More information

CSC 220: Computer Organization Unit 10 Arithmetic-logic units

CSC 220: Computer Organization Unit 10 Arithmetic-logic units College of Computer and Information Sciences Department of Computer Science CSC 220: Computer Organization Unit 10 Arithmetic-logic units 1 Remember: 2 Arithmetic-logic units An arithmetic-logic unit,

More information

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.

More information

Binary Adders: Half Adders and Full Adders

Binary Adders: Half Adders and Full Adders Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order

More information

Chapter 6: Assembler

Chapter 6: Assembler Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 www.idc.ac.il/tecs Chapter 6: Assembler Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation contains

More information

Sequential Logic. Building a Modern Computer From First Principles.

Sequential Logic. Building a Modern Computer From First Principles. Sequential Logic Buildg a Modern Computer From First Prciples www.nand2tetris.org Elements of Computg Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 3: Sequential Logic slide 1 Usage

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides

More information

Advanced Computer Architecture-CS501

Advanced Computer Architecture-CS501 Advanced Computer Architecture Lecture No. 34 Reading Material Vincent P. Heuring & Harry F. Jordan Chapter 6 Computer Systems Design and Architecture 6.1, 6.2 Summary Introduction to ALSU Radix Conversion

More information

Arithmetic Operations

Arithmetic Operations Arithmetic Operations Arithmetic Operations addition subtraction multiplication division Each of these operations on the integer representations: unsigned two's complement 1 Addition One bit of binary

More information

Virtual Machine Where we are at: Part I: Stack Arithmetic. Motivation. Compilation models. direct compilation:... 2-tier compilation:

Virtual Machine Where we are at: Part I: Stack Arithmetic. Motivation. Compilation models. direct compilation:... 2-tier compilation: Where we are at: Virtual Machine Part I: Stack Arithmetic Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy Translator

More information

Von Neumann Architecture

Von Neumann Architecture Von Neumann Architecture Assist lecturer Donya A. Khalid Lecture 2 2/29/27 Computer Organization Introduction In 945, just after the World War, Jon Von Neumann proposed to build a more flexible computer.

More information

Virtual Machine. Part I: Stack Arithmetic. Building a Modern Computer From First Principles.

Virtual Machine. Part I: Stack Arithmetic. Building a Modern Computer From First Principles. Virtual Machine Part I: Stack Arithmetic Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 7:

More information

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation Complement Number Systems A complement number system is used to represent positive and negative integers A complement number system is based on a fixed length representation of numbers Pretend that integers

More information

THE LOGIC OF COMPOUND STATEMENTS

THE LOGIC OF COMPOUND STATEMENTS CHAPTER 2 THE LOGIC OF COMPOUND STATEMENTS Copyright Cengage Learning. All rights reserved. SECTION 2.5 Application: Number Systems and Circuits for Addition Copyright Cengage Learning. All rights reserved.

More information

Course overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken (

Course overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken ( Course overview Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken (www.nand2tetris.org) Logistics Meeting time: 2:20pm-5:20pm, Tuesday Instructor: 莊永裕 Yung-Yu Chuang Webpage: http://www.csie.ntu.edu.tw/~cyy/introcs

More information

Digital Logic Design Exercises. Assignment 1

Digital Logic Design Exercises. Assignment 1 Assignment 1 For Exercises 1-5, match the following numbers with their definition A Number Natural number C Integer number D Negative number E Rational number 1 A unit of an abstract mathematical system

More information

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26) Lecture Topics Today: Integer Arithmetic (P&H 3.1-3.4) Next: continued 1 Announcements Consulting hours Introduction to Sim Milestone #1 (due 1/26) 2 1 Overview: Integer Operations Internal representation

More information

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29 CS 31: Introduction to Computer Systems 03: Binary Arithmetic January 29 WiCS! Swarthmore Women in Computer Science Slide 2 Today Binary Arithmetic Unsigned addition Subtraction Representation Signed magnitude

More information

CS140 Lecture 03: The Machinery of Computation: Combinational Logic

CS140 Lecture 03: The Machinery of Computation: Combinational Logic CS140 Lecture 03: The Machinery of Computation: Combinational Logic John Magee 25 January 2017 Some material copyright Jones and Bartlett Some slides credit Aaron Stevens 1 Overview/Questions What did

More information

LECTURE 4. Logic Design

LECTURE 4. Logic Design LECTURE 4 Logic Design LOGIC DESIGN The language of the machine is binary that is, sequences of 1 s and 0 s. But why? At the hardware level, computers are streams of signals. These signals only have two

More information

Motivation. Compiler. Our ultimate goal: Hack code. Jack code (example) Translate high-level programs into executable code. return; } } return

Motivation. Compiler. Our ultimate goal: Hack code. Jack code (example) Translate high-level programs into executable code. return; } } return Motivation Jack code (example) class class Main Main { { static static int int x; x; function function void void main() main() { { Inputs Inputs and and multiplies multiplies two two numbers numbers var

More information

Computer Architecture and Organization: L04: Micro-operations

Computer Architecture and Organization: L04: Micro-operations Computer Architecture and Organization: L4: Micro-operations By: A. H. Abdul Hafez Abdul.hafez@hku.edu.tr, ah.abdulhafez@gmail.com, hafez@research.iiit.ac.in 1 Outlines 1. Arithmetic microoperation 2.

More information

Number System. Introduction. Decimal Numbers

Number System. Introduction. Decimal Numbers Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

More information

How a Digital Binary Adder Operates

How a Digital Binary Adder Operates Overview of a Binary Adder How a Digital Binary Adder Operates By: Shawn R Moser A binary adder is a digital electronic component that is used to perform the addition of two binary numbers and return the

More information

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Machine (Assembly) Language Human Thought

Machine (Assembly) Language Human Thought Where we are at: Machine (Assembly) Language Human Thought Abstract design hapters 9, 12 abstract interface H.L. Language & Operating Sys. ompiler hapters 10-11 abstract interface Virtual Machine Software

More information

Digital Systems. John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC. December 6, 2012

Digital Systems. John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC. December 6, 2012 Digital Systems John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC December 6, 2012 Contents 1 Logic Gates 3 1.1 Logic Gate............................. 3 1.2 Truth

More information

Course overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken (www.nand2tetris.org)

Course overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken (www.nand2tetris.org) Course overview Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken (www.nand2tetris.org) Logistics Meeting time: 2:20pm-5:20pm, Tuesday Classroom: CSIE Room 104 Instructor: 莊永裕 Yung-Yu

More information

Course overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken (

Course overview. Introduction to Computer Yung-Yu Chuang. with slides by Nisan & Schocken ( Course overview Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken (www.nand2tetris.org) Logistics Meeting time: 2:20pm-5:20pm, Tuesday Classroom: CSIE Room 101 Instructor: 莊永裕 Yung-Yu

More information

Arithmetic Processing

Arithmetic Processing CS/EE 5830/6830 VLSI ARCHITECTURE Chapter 1 Basic Number Representations and Arithmetic Algorithms Arithmetic Processing AP = (operands, operation, results, conditions, singularities) Operands are: Set

More information

Computer Organization and Levels of Abstraction

Computer Organization and Levels of Abstraction Computer Organization and Levels of Abstraction Announcements Today: PS 7 Lab 8: Sound Lab tonight bring machines and headphones! PA 7 Tomorrow: Lab 9 Friday: PS8 Today (Short) Floating point review Boolean

More information

IWKS 3300: NAND to Tetris Spring John K. Bennett. Assembler

IWKS 3300: NAND to Tetris Spring John K. Bennett. Assembler IWKS 3300: NAND to Tetris Spring 2018 John K. Bennett Assembler Foundations of Global Networked Computing: Building a Modern Computer From First Principles This course is based upon the work of Noam Nisan

More information

Computer Organization and Levels of Abstraction

Computer Organization and Levels of Abstraction Computer Organization and Levels of Abstraction Announcements PS8 Due today PS9 Due July 22 Sound Lab tonight bring machines and headphones! Binary Search Today Review of binary floating point notation

More information

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One

More information

COMBINATIONAL LOGIC CIRCUITS

COMBINATIONAL LOGIC CIRCUITS COMBINATIONAL LOGIC CIRCUITS 4.1 INTRODUCTION The digital system consists of two types of circuits, namely: (i) Combinational circuits and (ii) Sequential circuits A combinational circuit consists of logic

More information

Chapter 4 Arithmetic Functions

Chapter 4 Arithmetic Functions Logic and Computer Design Fundamentals Chapter 4 Arithmetic Functions Charles Kime & Thomas Kaminski 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Overview Iterative combinational

More information

Chapter 10: Compiler I: Syntax Analysis

Chapter 10: Compiler I: Syntax Analysis Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 Chapter 10: Compiler I: Syntax Analysis www.idc.ac.il/tecs Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This

More information

Arithmetic and Logical Operations

Arithmetic and Logical Operations Arithmetic and Logical Operations 2 CMPE2c x +y + sum Or in tabular form Binary Addition Carry Out Sum B A Carry In Binary Addition And as a full adder a b co ci sum 4-bit Ripple-Carry adder: Carry values

More information

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2.. Natural Binary Code (NBC). The positional code with base 2 (B=2), introduced in Exercise, is used to encode

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

Machine (Assembly) Language

Machine (Assembly) Language Machine (Assembly) Language Building a Modern Computer From First Principles www.nand2tetris.org Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org, Chapter 4: Machine Language

More information

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

More information

Software and Hardware

Software and Hardware Software and Hardware Numbers At the most fundamental level, a computer manipulates electricity according to specific rules To make those rules produce something useful, we need to associate the electrical

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant & O Hallaron s slides 1 Boolean Algebra Developed by

More information

Boolean Algebra and Logic Gates

Boolean Algebra and Logic Gates Boolean Algebra and Logic Gates Binary logic is used in all of today's digital computers and devices Cost of the circuits is an important factor Finding simpler and cheaper but equivalent circuits can

More information

ECE 341 Midterm Exam

ECE 341 Midterm Exam ECE 341 Midterm Exam Time allowed: 75 minutes Total Points: 75 Points Scored: Name: Problem No. 1 (8 points) For each of the following statements, indicate whether the statement is TRUE or FALSE: (a) A

More information

Combinational Circuits

Combinational Circuits Combinational Circuits Combinational circuit consists of an interconnection of logic gates They react to their inputs and produce their outputs by transforming binary information n input binary variables

More information

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS C H A P T E R 6 DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS OUTLINE 6- Binary Addition 6-2 Representing Signed Numbers 6-3 Addition in the 2 s- Complement System 6-4 Subtraction in the 2 s- Complement

More information

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand Digital Arithmetic Digital Arithmetic: Operations and Circuits Dr. Farahmand Binary Arithmetic Digital circuits are frequently used for arithmetic operations Fundamental arithmetic operations on binary

More information

CS 31: Intro to Systems Binary Arithmetic. Kevin Webb Swarthmore College January 26, 2016

CS 31: Intro to Systems Binary Arithmetic. Kevin Webb Swarthmore College January 26, 2016 CS 31: Intro to Systems Binary Arithmetic Kevin Webb Swarthmore College January 26, 2016 Reading Quiz Unsigned Integers Suppose we had one byte Can represent 2 8 (256) values If unsigned (strictly non-negative):

More information

Chapter 3: part 3 Binary Subtraction

Chapter 3: part 3 Binary Subtraction Chapter 3: part 3 Binary Subtraction Iterative combinational circuits Binary adders Half and full adders Ripple carry and carry lookahead adders Binary subtraction Binary adder-subtractors Signed binary

More information

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal Basic Definition REPRESENTING INTEGER DATA Englander Ch. 4 An integer is a number which has no fractional part. Examples: -2022-213 0 1 514 323434565232 Unsigned and -Coded Decimal BCD: -Coded Decimal

More information

ECEN 468 Advanced Logic Design

ECEN 468 Advanced Logic Design ECEN 468 Advanced Logic Design Lecture 26: Verilog Operators ECEN 468 Lecture 26 Operators Operator Number of Operands Result Arithmetic 2 Binary word Bitwise 2 Binary word Reduction 1 Bit Logical 2 Boolean

More information

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Verilog Dataflow Modeling

Verilog Dataflow Modeling Verilog Dataflow Modeling Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C. Spring, 2017 ldvan@cs.nctu.edu.tw http://www.cs.nctu.edu.tw/~ldvan/ Source:

More information

Chapter 3: Arithmetic for Computers

Chapter 3: Arithmetic for Computers Chapter 3: Arithmetic for Computers Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point Computer Architecture CS 35101-002 2 The Binary Numbering

More information

JAVA OPERATORS GENERAL

JAVA OPERATORS GENERAL JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

Register Transfer Language and Microoperations (Part 2)

Register Transfer Language and Microoperations (Part 2) Register Transfer Language and Microoperations (Part 2) Adapted by Dr. Adel Ammar Computer Organization 1 MICROOPERATIONS Computer system microoperations are of four types: Register transfer microoperations

More information

Question Total Possible Test Score Total 100

Question Total Possible Test Score Total 100 Computer Engineering 2210 Final Name 11 problems, 100 points. Closed books, closed notes, no calculators. You would be wise to read all problems before beginning, note point values and difficulty of problems,

More information

CMPE223/CMSE222 Digital Logic Design. Positional representation

CMPE223/CMSE222 Digital Logic Design. Positional representation CMPE223/CMSE222 Digital Logic Design Number Representation and Arithmetic Circuits: Number Representation and Unsigned Addition Positional representation First consider integers Begin with positive only

More information

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Binary Addition. Add the binary numbers and and show the equivalent decimal addition. Binary Addition The rules for binary addition are 0 + 0 = 0 Sum = 0, carry = 0 0 + 1 = 0 Sum = 1, carry = 0 1 + 0 = 0 Sum = 1, carry = 0 1 + 1 = 10 Sum = 0, carry = 1 When an input carry = 1 due to a previous

More information

Digital Design with FPGAs. By Neeraj Kulkarni

Digital Design with FPGAs. By Neeraj Kulkarni Digital Design with FPGAs By Neeraj Kulkarni Some Basic Electronics Basic Elements: Gates: And, Or, Nor, Nand, Xor.. Memory elements: Flip Flops, Registers.. Techniques to design a circuit using basic

More information

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages 14:332:231 DIGITAL LOGIC DESIGN Ivan Marsic, Rutgers University Electrical & Computer Engineering Fall 2013 Lecture #22: Introduction to Verilog Hardware Description Languages Basic idea: Language constructs

More information

Unit 3. Operators. School of Science and Technology INTRODUCTION

Unit 3. Operators. School of Science and Technology INTRODUCTION INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.

More information

Boolean logic. Boolean Algebra. Introduction to Computer Yung-Yu Chuang NOT AND NOT

Boolean logic. Boolean Algebra. Introduction to Computer Yung-Yu Chuang NOT AND NOT oolean lgebra oolean logic ased on symbolic logic, designed by George oole oolean variables take values as or. oolean expressions created from: NOT, ND, OR Introduction to Computer ung-u Chuang with slides

More information

Chapter 8: Virtual Machine II: Program Control

Chapter 8: Virtual Machine II: Program Control Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005 Chapter 8: Virtual Machine II: Program Control www.idc.ac.il/tecs Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken

More information

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up

More information

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators CSE 351: The Hardware/Software Interface Section 2 Integer representations, two s complement, and bitwise operators Integer representations In addition to decimal notation, it s important to be able to

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for

More information

Organisasi Sistem Komputer

Organisasi Sistem Komputer LOGO Organisasi Sistem Komputer OSK 8 Aritmatika Komputer 1 1 PT. Elektronika FT UNY Does the calculations Arithmetic & Logic Unit Everything else in the computer is there to service this unit Handles

More information

Computer Organization

Computer Organization Register Transfer Logic Department of Computer Science Missouri University of Science & Technology hurson@mst.edu 1 Note, this unit will be covered in three lectures. In case you finish it earlier, then

More information

Tailoring the 32-Bit ALU to MIPS

Tailoring the 32-Bit ALU to MIPS Tailoring the 32-Bit ALU to MIPS MIPS ALU extensions Overflow detection: Carry into MSB XOR Carry out of MSB Branch instructions Shift instructions Slt instruction Immediate instructions ALU performance

More information

Numerical Representations On The Computer: Negative And Rational Numbers

Numerical Representations On The Computer: Negative And Rational Numbers Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How are subtractions performed by the computer? Subtraction In

More information

ECE468 Computer Organization & Architecture. The Design Process & ALU Design

ECE468 Computer Organization & Architecture. The Design Process & ALU Design ECE6 Computer Organization & Architecture The Design Process & Design The Design Process "To Design Is To Represent" Design activity yields description/representation of an object -- Traditional craftsman

More information

Register Transfer and Micro-operations

Register Transfer and Micro-operations Register Transfer Language Register Transfer Bus Memory Transfer Micro-operations Some Application of Logic Micro Operations Register Transfer and Micro-operations Learning Objectives After reading this

More information

CS/COE 0447 Example Problems for Exam 2 Spring 2011

CS/COE 0447 Example Problems for Exam 2 Spring 2011 CS/COE 0447 Example Problems for Exam 2 Spring 2011 1) Show the steps to multiply the 4-bit numbers 3 and 5 with the fast shift-add multipler. Use the table below. List the multiplicand (M) and product

More information

CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014)

CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014) CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014) Name: USF ID: Problem Points Score 1 10 2 10 3 15 4 15 5 10 6 20 otal 80 Exam Rules Use the back of the exam paper as necessary. But indicate clearly

More information

Appendix A: Hardware Description Language (HDL) 1

Appendix A: Hardware Description Language (HDL) 1 Appendix A: HDL 231 Appendix A: Hardware Description Language (HDL) 1 Intelligence is the faculty of making artificial objects, especially tools to make tools. Henry Bergson (1859-1941) A Hardware Description

More information

COSC 243. Computer Architecture 1. COSC 243 (Computer Architecture) Lecture 6 - Computer Architecture 1 1

COSC 243. Computer Architecture 1. COSC 243 (Computer Architecture) Lecture 6 - Computer Architecture 1 1 COSC 243 Computer Architecture 1 COSC 243 (Computer Architecture) Lecture 6 - Computer Architecture 1 1 Overview Last Lecture Flip flops This Lecture Computers Next Lecture Instruction sets and addressing

More information

T02 Tutorial Slides for Week 2

T02 Tutorial Slides for Week 2 T02 Tutorial Slides for Week 2 ENEL 353: Digital Circuits Fall 2017 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 19 September, 2017

More information

EP1200 Introduction to Computing Systems Engineering. Computer Architecture

EP1200 Introduction to Computing Systems Engineering. Computer Architecture EP1200 Introduction to omputing Systems Engineering omputer Architecture Perspective on Machine and Assembly Languages Hack is a simple machine language Designed for the simple Hack computer architecture

More information

Extended Introduction to Computer Science CS1001.py. Lecture 5 Part A: Integer Representation (in Binary and other bases)

Extended Introduction to Computer Science CS1001.py. Lecture 5 Part A: Integer Representation (in Binary and other bases) Extended Introduction to Computer Science CS1001.py Lecture 5 Part A: Integer Representation (in Binary and other bases) Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants: Michal Kleinbort,

More information

Compiler I: Sytnax Analysis

Compiler I: Sytnax Analysis Elements of Computing Systems, Nisan & Schocken, MIT Press www.idc.ac.il/tecs Compiler I: Sytnax Analysis Usage and Copyright Notice: Copyright 2005 Noam Nisan and Shimon Schocken This presentation contains

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2011 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review for most of you, but we start

More information

Integer Representation

Integer Representation Integer Representation Announcements assign0 due tonight assign1 out tomorrow Labs start this week SCPD Note on ofce hours on Piazza Will get an email tonight about labs Goals for Today Introduction to

More information

2/5/2018. Expressions are Used to Perform Calculations. ECE 220: Computer Systems & Programming. Our Class Focuses on Four Types of Operator in C

2/5/2018. Expressions are Used to Perform Calculations. ECE 220: Computer Systems & Programming. Our Class Focuses on Four Types of Operator in C University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming Expressions and Operators in C (Partially a Review) Expressions are Used

More information

Chapter 10 Binary Arithmetics

Chapter 10 Binary Arithmetics 27..27 Chapter Binary Arithmetics Dr.-Ing. Stefan Werner Table of content Chapter : Switching Algebra Chapter 2: Logical Levels, Timing & Delays Chapter 3: Karnaugh-Veitch-Maps Chapter 4: Combinational

More information