Administrivia - PowerPoint PPT Presentation

About This Presentation
Title:

Administrivia

Description:

Abstraction in action -- This is a piece of a carry-ripple adder. Universal. Circuit ... Delay while waiting for the carry to ripple. One solution add larger blocks ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 82
Provided by: davidd5
Category:

less

Transcript and Presenter's Notes

Title: Administrivia


1
Administrivia
  • Assignments
  • Labs
  • Questions??
  • Class questions cs111_at_cs.princeton.edu
  • Goes to dpd and the TAs
  • Hand in lab assignments cs111_at_princeton.edu
  • Goes to a file.

2
Adding Decimal Numbers
4 6 5 5 4 3
We all know that the answer is 1008 but how do
we do this?
3
Adding Decimal Numbers
4 6 5 5 4 3
Start from the right 53 8 and there is no carry
4
Adding Decimal Numbers
4 6 5 5 4 3
8
Start from the right 53 8 and there is no carry
Next, 64 10 Write the 0, carry the 1
5
Adding Decimal Numbers
1 4 6 5 5 4
3 0 8
Start from the right 53 8 and there is no carry
Next, 64 10 Write the 0, carry the 1
6
Adding Decimal Numbers
1 4 6 5 5 4
3 0 8
Start from the right 53 8 and there is no carry
Next, 64 10 Write the 0, carry the 1
Finally, 145 10 Write the 0, carry the 1
7
Adding Decimal Numbers
1 1 4 6 5 5 4
3 1 0 0 8
Start from the right 53 8 and there is no carry
Next, 64 10 Write the 0, carry the 1
Finally, 145 10 Write the 0, carry the 1
8
Adding Decimal Numbers
1 1 4 6 5 5 4
3 1 0 0 8
Start from the right 53 8 and there is no
carry Next, 64 10 Write the 0, carry the
1 Finally, 145 10 Write the 0, carry the 1
At each stage, take 2 addends (5 and 3 or 6 and 4
or 4 and 5) and a bit telling whether there is
a carry and produce a sum bit and a bit telling
if there is a carry.
9
Bad news
  • It is inconvenient to add decimal numbers in a
    computer
  • Truth tables are easier than addition tables
  • The universal method wants to work from truth
    tables

10
Bad news/Good News
  • Bad news It is inconvenient to add decimal
    numbers in a computer
  • Truth tables are easier than addition tables
  • The universal method wants to work from truth
    tables
  • Good news the same thing works for binary
    numbers

11
Adding Binary Numbers
  • At each stage, take 2 addends and a bit telling
    whether there is a carry and produce a sum bit
    and a bit telling if there is a carry.

12
Adding Binary Numbers (cont.)
1 1 1 0 1 1 1 1 _______________
1 1 0 0
0 0 0 0 1 1 1 0 1 1 1 10
13
Sidebar what are binary numbers
  • Base 2 rather than base 10
  • Decimal numbers
  • We write (1234)10 to represent a decimal number
    that has 4 units, 3 tens, 2 hundreds and 1
    thousand.
  • (1234)10 1 x103 2 x102 3 x101 4 x100

14
Sidebar what are binary numbers
  • Base 2 rather than base 10
  • Decimal numbers
  • We write (1234)10 to represent a decimal number
    that has 4 units, 3 tens, 2 hundreds and 1
    thousand.
  • (1234)10 1 x103 2 x102 3 x101 4 x100
  • Binary numbers
  • We write (1001)2 to represent a decimal number
    that has 1 unit, 0 2s, 0 4s and 1 8.
  • (1001)2 1 x23 0 x22 0 x21 1 x20

15
Adding Binary Numbers
  • At each stage, take 2 addends and a bit telling
    whether there is a carry and produce a sum bit
    and a bit telling if there is a carry.

16
Adding Binary Numbers
At each stage, take 2 addends and a bit telling
whether there is a carry and produce a sum bit
and a bit telling if there is a carry. We can
build a black box to do this
addend
Sum bit
addend
carry bit out
carry bit in
17
Adding Binary Numbers
  • Write the numbers as
  • X4 X3 X2 X1 X0
  • Y4 Y3 Y2 Y1 Y0
  • Represent the sum as
  • C Z4 Z3 Z2 Z1 Z0

18
Adding Binary Numbers
  • Write the numbers as
  • X4 X3 X2 X1 X0
  • Y4 Y3 Y2 Y1 Y0
  • Represent the sum as
  • C Z4 Z3 Z2 Z1 Z0
  • Start with X0, Y0, 0 in, Z0 and C0 out
  • Then X1,Y1,C0 in and Z1 and C1 out.
  • And so on

19
Adding Binary Numbers
At the ith stage
ith bit of X
Universal Circuit
ith bit of Z
ith bit of Y
carry bit out
carry bit
Abstraction in action -- This is a piece of a
carry-ripple adder
20
Carry-Ripple Adder
Z1
Z2
Universal Circuit
X2
Z0
Universal Circuit
X1
Universal Circuit
X0
C2
Y2
Y0
Y1
C1
C0
0
Fixed at 0
X2 X1 X0 Y2 Y1
Y0 C2 Z2 Z1 Z0
21
Whats inside the box?
Zi
Universal Circuit
Xi
Yi
Cout
Cin
22
Whats inside the box?
Zi
Universal Circuit
Xi
Yi
Cout
Cin
Do the problem set and find out
23
Carry ripple adders
  • Useful for some applications
  • Too slow for other
  • Delay while waiting for the carry to ripple
  • One solution add larger blocks
  • Details on the homework assignment

24
Arithmetic Logical Unit (ALU)
  • This is the part of the CPU that does arithmetic
    and comparison operations
  • Weve built a piece of the ALU
  • With abstraction, we could build the other parts
  • Multiplication/subtraction/division
  • Comparison
  • Then we would write a language to let the user
    talk to the ALU (programming)

25
Pause
  • Questions??
  • How to build the other parts of the ALU?
  • Use abstraction
  • Back to representing information

26
Representing information
  • How do we represent characters?
  • How many characters might we want to represent?
  • What characters might we want to represent?

27
Representing information
  • How do we represent characters?
  • How many characters might we want to represent?
  • What characters might we want to represent?
  • A-Z 26
  • A-Z and a-z 52
  • All the keys on my keyboard 104
  • Maybe a power of 2? 128
  • Maybe an even power of 2? 256
  • Maybe an even bigger power of 2? 65536

28
Representing characters
  • ASCII is the American Standard Code for
    Information Interchange. It is a 7-bit code.
  • Many 8-bit codes contain ASCII as their lower
    half
  • The ASCII standard was published by the United
    States of America Standards Institute (USASI) in
    1968.

29
Unicode
  • Universal Character Set (UCS) contains all
    characters of all other character set
    standards. It also guarantees round-trip
    compatibility, i.e., conversion tables can be
    built such that no information is lost when a
    string is converted from any other encoding to
    UCS and back.
  • UCS contains the characters required to
    represent almost all known languages. This
    includes apart from the many languages which use
    extensions of the Latin script also the
    following scripts and languages Greek,
    Cyrillic, Hebrew, Arabic, Armenian, Gregorian,
    Japanese, Chinese, Hiragana, Katakana, Korean,
    Hangul, Devangari, Bengali, Gurmukhi, Gujarati,
    Oriya, Tamil, Telugu, Kannada, Malayam,
    Thai, Lao, Bopomofo, and a number of others. Work
    is going on to include further scripts like
    Tibetian, Khmer, Runic, Ethiopian, Hieroglyphics,
    various Indo-European languages, and many others.
  • Its intended to use 31 bits (32768 possible
    characters)

30
What do we do in practice
  • Problems
  • Bits represent too little too many are needed
  • Decimal numbers dont translate well into bits
  • So,
  • Group into blocks of 4 and 8 bits
  • 8 bits 256 characters, holds ASCII
  • 8 bits make 1 byte things are organized into
    bytes
  • 4 bits make 1 nibble

31
Shorthand Hexadecimal
32
Sidebar what are hexadecimal numbers
  • Base 16 rather than base 10
  • Decimal numbers
  • We write (1234)10 to represent a decimal number
    that has 4 units, 3 tens, 2 hundreds and 1
    thousand.
  • (1234)10 1 x103 2 x102 3 x101 4 x100
  • Hexadecimal numbers
  • We write (2AC4)16 to represent a decimal number
    that has 1 units, 12 16s, 10 256s and 2
    65,536s
  • (2AC4)16 1 x163 0 x162 0 x161 1 x160

33
Hexadecimal
  • We can add numbers
  • 112, 224, 448, 48C, 28A,
  • We can combine 2 hexadecimal numbers to make a
    byte.
  • Its easier to read than 0s and 1s
  • In ASCII
  • hex 41 through 5A represent A to Z
  • Hex 61 through 7A represent a to z

34
Memory
35
Memory
  • Logic circuits weve seen so far have no memory.
    They just transform input to output.
  • Can we make logic circuits that remember?

36
The Stubborn Guy
  • Matt really likes Sue, but he doesnt
    likechanging his mind so
  • Matt decides to go to the party if Sue decides to
    go OR if he (Matt) already feels like going.

37
The Stubborn Guy Feedback
  • Matt decides to go to the party if Sue decides to
    go OR if he (Matt) already feels like going.

Sue
Matt
Feedback Wire
38
The Stubborn Guy Feedback
  • Matt decides to go to the party if Sue decides to
    go OR if he (Matt) already feels like going.
  • If Sue decides to go...

1
Sue
Matt
39
The Stubborn Guy Feedback
  • Matt decides to go to the party if Sue decides to
    go OR if he (Matt) already feels like going.
  • If Sue decides to go, Matt will go.

1
Sue
1
Matt
1
40
The Stubborn Guy Feedback
  • Matt decides to go to the party if Sue decides to
    go OR if he (Matt) already feels like going.
  • If Sue changes her mind

0
Sue
1
Matt
1
41
The Stubborn Guy Feedback
  • Matt decides to go to the party if Sue decides to
    go OR if he (Matt) already feels like going.
  • If Sue changes her mind, Matt will still go!
  • Once he decides to go, we cant ever get Matt to
    change his mind.

0
Sue
1
Matt
1
42
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR if he (Matt) already feels like going,
    UNLESS Rita decides to go.

43
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

44
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

Sue
Matt
Rita
Feedback Wire
45
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
0
Matt
1
0
Rita
0
0
46
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

1
Sue
0
Matt
1
0
Rita
0
0
47
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

1
Sue
1
Matt
1
1
Rita
0
1
48
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
1
Matt
1
1
Rita
0
1
49
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0 nothing changes
Sue
1
Matt
1
1
Rita
0
1
50
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
1
Matt
1
1
Rita
1
1
51
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
1
Matt
0
1
Rita
1
1
52
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
1
Matt
0
0
Rita
1
1
53
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
0
Matt
0
0
Rita
1
1
54
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
0
Matt
0
0
Rita
1
0
55
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
0
Matt
0
0
Rita
0
0
56
Enter Rita
  • Matt doesnt like Rita
  • Matt decides to go to the party if Sue decides to
    go OR
  • If he (Matt) already feels like going AND Rita
    decides NOT to go.

0
Sue
0
Matt
1
0
Rita
0
0
57
The Flip-Flop
Set
M
Reset
  • M becomes 1 if Set is turned on
  • M becomes 0 if Reset is turned on
  • Otherwise (if Set and Reset are both 0), M just
    remembers its value

58
The Flip-Flop
S
M
R
  • M becomes 1 if Set is turned on
  • M becomes 0 if Reset is turned on
  • Otherwise (if Set and Reset are both 0), M just
    remembers its value

59
The Data Flip-Flop
S
D
Write
M
R
  • Nothing happens unless Write 1

60
The Data Flip-Flop
S
D
Write
M
R
  • Nothing happens unless Write 1
  • If Write 1, then M becomes set to D
  • Once Write 0 again, M just keeps its value.(It
    ignores D.)

61
Using a Data Flip-Flop
0
S
D
1
Write
0
M
R
0
  • Initially, Write 0. Lets say M 1.

62
Using a Data Flip-Flop
0
S
0
D
1
Write
0
M
R
0
1
  • Initially, Write 0. Lets say M 1.
  • First, set D to desired value, say 0.

63
Using a Data Flip-Flop
0
S
0
D
1
Write
1
M
R
1
1
  • Initially, Write 0. Lets say M 1.
  • First, set D to desired value, say 0.
  • Then, set Write to 1.

64
Using a Data Flip-Flop
0
S
0
D
0
Write
1
M
R
1
1
  • Initially, Write 0. Lets say M 1.
  • First, set D to desired value, say 0.
  • Then, set Write to 1.
  • This causes M to be reset to 0.

65
Using a Data Flip-Flop
0
S
?
D
0
Write
0
M
R
0
1
  • Initially, Write 0. Lets say M 1.
  • First, set D to desired value, say 0.
  • Then, set Write to 1.
  • This causes M to be reset to 0.
  • Finally set Write back to 0. Now D irrelevant.

66
The Data Flip-Flop
D
M
Write
  • If Write 0, M just keeps its value.(It ignores
    D.)
  • If Write 1, then M becomes set to D

67
A subtle problem
D
M
??
Write
  • When Write 1, then M D.
  • If we have some feedback between M and D,then
    circuit could go haywire.

68
A subtle problem
?
D
?
M
1
Write
  • For example, suppose NOT gate connectsM and D.
  • When Write 1, M and D keep changing. We have
    no control.

69
A subtle problem
?
D
?
M
1
Write
  • We want to control the feedback, so thateach
    time we set Write to 1 and then back to 0, M
    stores only the last value of D
  • (In this case, M should invert itself once each
    time we set Write to 1 and back to 0)

70
Airlock Flip-Flop
Outer door
Inner door
M
D
M1
D1
D0
M0
Write
W1
W0
  • Two-Stage System to prevent feedback loop.

71
Airlock Flip-Flop
Outer door
Inner door
M
D
M1
D1
D0
M0
Write
W1
W0
  • We start with Write 0.
  • Lets say D is always NOT M.Start with D 0, M
    1.

72
Airlock Flip-Flop
Outer door
Inner door
0
M
1
1
D
M1
D1
D0
M0
1
0
Write
W1
W0
  • We start with Write 0.
  • Lets say D is always NOT M.Start with D 0, M
    1.

73
Airlock Flip-Flop
Outer door
Inner door
0
M
1
1
D
M1
D1
D0
M0
0
1
Write
W1
W0
  • Want to store D in memory.
  • Set Write to 1

74
Airlock Flip-Flop
Outer door
Inner door
0
M
1
0
D
M1
D1
D0
M0
0
1
Write
W1
W0
  • Want to store D in memory.
  • Set Write to 1
  • Outer flip-flop sets M0 D0 0
  • Inner flip-flop ignores D1 since W1 0

75
Airlock Flip-Flop
Outer door
Inner door
0
M
1
0
D
M1
D1
D0
M0
1
0
Write
W1
W0
  • Now, set Write back to 0

76
Airlock Flip-Flop
Outer door
Inner door
0
M
0
0
D
M1
D1
D0
M0
1
0
Write
W1
W0
  • Now, set Write back to 0
  • Now Inner flip-flop sets M D1 0

77
Airlock Flip-Flop
Outer door
Inner door
1
M
0
0
D
M1
D1
D0
M0
1
0
Write
W1
W0
  • Because of feedback, D might change to (NOT M) ,
    which is 1
  • But Write 0, so Outer flip-flop ignores
    D,and so M0 stays 0.

78
Airlock Flip-Flop
Outer door
Inner door
1
M
0
0
D
M1
D1
D0
M0
1
0
Write
W1
W0
  • So memory does not change until we toggle
    Write.
  • (toggle means change from 0 to 1 or vice versa)

79
Airlock Flip-Flop
Outer door
Inner door
M
D
M1
D1
D0
M0
Write
W1
W0
  • This is Real Memory!

80
Memory Register 4 bits
Data1
D
M
W
Data2
D
M
W
Data3
D
M
W
Data4
D
M
Write
W
81
Review
  • We have used the Universal method to build
  • ALU
  • Memory
  • Next steps
  • State machines to computer with memory
  • Building the computer
  • Writing a program to use the computer
Write a Comment
User Comments (0)
About PowerShow.com