Top Banner
Memory
50

Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

Memory

Page 2: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output.

• Can we make circuits that remember?

Memory

Page 3: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt really likes Sue, but he doesn’t like changing his mind… So:

• Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go.

The Stubborn Guy

Page 4: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go.

• Two inputs to Matt’s decision: Sue, and his own state

OR

SueMatt

FeedbackWire

He Needs Feedback (from Himself)

Page 5: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go.

• If Sue decides to go...

OR

SueMatt

1

The Stubborn Guy: Feedback

Page 6: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go.

• If Sue decides to go, Matt will go.

OR

SueMatt

11

1

The Stubborn Guy: Feedback

Page 7: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go.

• If Sue changes her mind…

OR

SueMatt

01

1

The Stubborn Guy: Feedback

Page 8: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go.

• If Sue changes her mind, Matt will still go!• Once he decides to go, we can’t get him to change his mind

OR

SueMatt

01

1

The Stubborn Guy: Feedback

Page 9: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

Enter Rita

Page 10: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

Feedback Wire

Enter Rita

Page 11: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

0

0

0

0

1

Enter Rita

Page 12: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

1

0

0

0

0

1

Enter Rita

Page 13: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

1

0

1

1

1

1

Enter Rita

Page 14: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

0

1

1

1

1

Enter Rita

Page 15: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0 – nothing changes: Sue can make Matt go, but cannot make him not go

0

1

1

1

1

Enter Rita

Page 16: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita (maybe together they can make him not go)

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

1

1

1

1

1

Enter Rita

Page 17: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

1

1

1

1

0

Enter Rita

Page 18: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

1

1

1

0

0

Enter Rita

Page 19: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

1

0

1

0

0

Enter Rita

Page 20: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

1

0

0

0

0

Enter Rita

Page 21: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

0

0

0

0

0

Enter Rita

Page 22: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• Matt doesn’t like Rita

• Matt decides to go to the party if Sue decides to go OR:

• If he (Matt) had already planned to go AND Rita decides NOT to go.

OR

AND

Sue

Rita

Matt

0

0

0

0

0

1

Enter Rita

- no change

Page 23: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

What Sue and Rita Can Do

• Sue can make Matt go, but cannot make him not go

• Rita can make Matt not go, but cannot make him go

Page 24: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

OR

AND

Set

Reset

M

• M becomes 1 if Set is turned on

• M becomes 0 if Reset is turned on

• Otherwise (if both are 0), M just remembers its value

The (SR) Flip-Flop

Page 25: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• M becomes 1 if Set is turned on

• M becomes 0 if Reset is turned on

• Otherwise (if both are 0), M just remembers its value

S

R

M

The Flip-Flop

Page 26: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D

W

M

What We Really Want

• 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.)

• So, to set M to a value and store it as long as desired, set D to that value, then set W to 1 and then back to 0

Page 27: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

AND

AND

• Nothing happens unless Write = 1

S

R

MD Write

The Data Flip-Flop

Page 28: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

AND

AND

• 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.)

S

R

MD Write

The Data Flip-Flop

Page 29: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

AND

AND

• Initially, Write = 0. Let’s say M = 1.

S

R

MD Write 0

0

0

1

Using a Data Flip-Flop

Page 30: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

AND

AND

• Initially, Write = 0. Let’s say M = 1.

• First, set D to desired value, say 0.

S

R

MD Write 0

0

0

10

1

Using a Data Flip-Flop

Page 31: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

AND

AND

• Initially, Write = 0. Let’s say M = 1.

• First, set D to desired value, say 0.

• Then, set Write to 1.

S

R

MD Write 1

0

1

10

1

Using a Data Flip-Flop

Page 32: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

AND

AND

• Initially, Write = 0. Let’s say M = 1.

• First, set D to desired value, say 0.

• Then, set Write to 1.

• This causes M to be reset to 0.

• Note use of abstraction with regard to SR flip-flop

S

R

MD Write 1

0

1

00

1

Using a Data Flip-Flop

Page 33: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

AND

AND

• Initially, Write = 0. Let’s 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 is irrelevant.

S

R

MD Write 0

0

0

0?

1

Using a Data Flip-Flop

Page 34: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• If Write = 0, M just keeps its value. (It ignores D.)

• If Write = 1, then M becomes set to D

D

Write

M

The Data Flip-Flop

Page 35: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

Are We Done?

Page 36: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• When Write = 1, then M = D.

• If we have some feedback between M and D,then circuit could go haywire.

D

Write

M ??

A Subtle Problem

Page 37: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• For example, suppose a NOT gate connects M and D.

• When Write = 1, M and D keep changing. We have no control.

D

Write

M NOT

1

?

?

A Subtle Problem

Page 38: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

• We want to control the feedback, so that each 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)

D

Write

M NOT

1

?

?

A Subtle Problem

Page 39: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• Two-Stage System to prevent D ever passing through directly to M (W0,W1 connected by NOT, so never 1 at the same time)

D M

The “Airlock” Flip-Flop

Page 40: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• We start with Write = 0.

• Let’s say D is always NOT M; i.e. connected by NOT gate.Start with D = 0, M = 1.

D M

The “Airlock” Flip-Flop

Page 41: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• We start with Write = 0.

• Let’s say D is always NOT M; i.e. connected by NOT gateStart with D = 0, M = 1.

D M

0

0

1

1 1

The “Airlock” Flip-Flop

Page 42: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• Want to store D in memory.

• Set Write to 1

D M

1

0

0

1 1

The “Airlock” Flip-Flop

Page 43: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• 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

D M

1

0

0

0 1

The “Airlock” Flip-Flop

Page 44: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• Now, set Write back to 0

D M

0

0

1

0 1

The “Airlock” Flip-Flop

Page 45: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• Now, set Write back to 0

• Now “Inner” flip-flop sets M = D1 = 0

D M

0

0

1

0 0

The “Airlock” Flip-Flop

Page 46: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• Because of feedback, D might change to (NOT M) , which is 1

• But Write = 0, so “Outer” flip-flop ignores D, so M0 stays 0.

D M

0

1

1

0 0

The “Airlock” Flip-Flop

Page 47: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• So memory does not change until we “toggle” Write.

• (“toggle” means change from 0 to 1 or vice versa)

D M

0

1

1

0 0

The “Airlock” Flip-Flop

Page 48: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

D1

W1

M1D0

W0

M0

“Outer door” “Inner door”

Write

• This is Real Memory!

D M

The “Airlock” Flip-Flop

Page 49: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

DM

W

DM

W

DM

W

DM

WWrite

Data1

Data2

Data3

Data4

Memory “Register”: 4 bits

Page 50: Memory. The logic and arithmetic circuits we’ve seen so far have no memory. They just transform input to output. Can we make circuits that remember? Memory.

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