Memory Memory The logic and arithmetic circuits weve

  • Slides: 50
Download presentation
Memory

Memory

Memory • The logic and arithmetic circuits we’ve seen so far have no memory.

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?

The Stubborn Guy • Matt really likes Sue, but he doesn’t like changing his

The Stubborn Guy • 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.

He Needs Feedback (from Himself) • Matt decides to go to the party if

He Needs Feedback (from Himself) • 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 Sue OR Feedback Wire Matt

The Stubborn Guy: Feedback • Matt decides to go to the party if Sue

The Stubborn Guy: Feedback • Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go. Sue 1 OR • If Sue decides to go. . . Matt

The Stubborn Guy: Feedback • Matt decides to go to the party if Sue

The Stubborn Guy: Feedback • Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go. Sue 1 OR 1 • If Sue decides to go, Matt will go. 1 Matt

The Stubborn Guy: Feedback • Matt decides to go to the party if Sue

The Stubborn Guy: Feedback • Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go. Sue 0 OR 1 • If Sue changes her mind… 1 Matt

The Stubborn Guy: Feedback • Matt decides to go to the party if Sue

The Stubborn Guy: Feedback • Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go. Sue 0 OR 1 Matt 1 • • If Sue changes her mind, Matt will still go! Once he decides to go, we can’t get him to change his mind

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • 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 • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • 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. Sue OR Rita AND Feedback Wire Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 1 Rita 0 AND 0 0 0 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 1 OR 1 Rita 0 AND 0 0 0 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 1 OR 1 Rita 0 AND 1 1 1 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 1 Rita 0 AND 1 1 1 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • 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. Sue 0 – nothing changes: Sue can make Matt go, but cannot make him not go 1 Matt OR 1 Rita 0 AND 1 1

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

Enter Rita • 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: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 1 Rita 1 AND 1 1 1 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 0 Rita 1 AND 1 1 1 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 0 Rita 1 AND 1 0 1 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 0 Rita 1 AND 1 0 0 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 0 Rita 1 AND 0 0 0 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 0 Rita 0 AND 0 0 0 Matt

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the

Enter Rita • Matt doesn’t like Rita • Matt decides to go to the party if Sue decides to go OR: • Sue If he (Matt) had already planned to go AND Rita decides NOT to go. 0 OR 1 Rita 0 - no change AND 0 0 0 Matt

What Sue and Rita Can Do • Sue can make Matt go, but cannot

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

The (SR) Flip-Flop Set OR Reset M AND • M becomes 1 if Set

The (SR) Flip-Flop Set OR Reset M AND • 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 Flip-Flop S M R • M becomes 1 if Set is turned on

The Flip-Flop S M R • 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

What We Really Want D M W • Nothing happens unless Write = 1

What We Really Want D M W • 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

The Data Flip-Flop AND D Write M AND • S Nothing happens unless Write

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

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

The Data Flip-Flop AND D S Write M AND 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. )

Using a Data Flip-Flop AND D Write S 0 M AND • 0 Initially,

Using a Data Flip-Flop AND D Write S 0 M AND • 0 Initially, Write = 0. Let’s say M = 1. 0 R 1

Using a Data Flip-Flop AND D 0 Write 0 S 0 M AND 1

Using a Data Flip-Flop AND D 0 Write 0 S 0 M AND 1 • Initially, Write = 0. Let’s say M = 1. • First, set D to desired value, say 0. 0 R 1

Using a Data Flip-Flop AND D 0 Write 0 S 1 M AND 1

Using a Data Flip-Flop AND D 0 Write 0 S 1 M AND 1 • Initially, Write = 0. Let’s say M = 1. • First, set D to desired value, say 0. • Then, set Write to 1. 1 R 1

Using a Data Flip-Flop AND D 0 Write 0 S 1 M AND 1

Using a Data Flip-Flop AND D 0 Write 0 S 1 M AND 1 1 • 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 R 0

Using a Data Flip-Flop AND D ? Write 0 S 0 M AND 0

Using a Data Flip-Flop AND D ? Write 0 S 0 M AND 0 1 • 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. R 0

The Data Flip-Flop D M Write • If Write = 0, M just keeps

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

Are We Done?

Are We Done?

A Subtle Problem D M Write • When Write = 1, then M =

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. ? ?

A Subtle Problem ? D M 1 ? NOT Write • For example, suppose

A Subtle Problem ? D M 1 ? NOT Write • For example, suppose a NOT gate connects M and D. • When Write = 1, M and D keep changing. We have no control.

A Subtle Problem ? D M 1 ? NOT Write • We want to

A Subtle Problem ? D M 1 ? NOT Write • 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)

The “Airlock” Flip-Flop “Outer door” D Write • D 0 W 0 M 0

The “Airlock” Flip-Flop “Outer door” D Write • D 0 W 0 M 0 “Inner door” D 1 M W 1 Two-Stage System to prevent D ever passing through directly to M (W 0, W 1 connected by NOT, so never 1 at the same time)

The “Airlock” Flip-Flop “Outer door” D Write D 0 M 0 W 0 “Inner

The “Airlock” Flip-Flop “Outer door” D Write D 0 M 0 W 0 “Inner door” D 1 M W 1 • 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.

The “Airlock” Flip-Flop “Outer door” D 0 Write 0 D 0 M 0 W

The “Airlock” Flip-Flop “Outer door” D 0 Write 0 D 0 M 0 W 0 “Inner door” 1 D 1 1 M W 1 • 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.

The “Airlock” Flip-Flop “Outer door” D 0 Write 1 D 0 M 0 W

The “Airlock” Flip-Flop “Outer door” D 0 Write 1 D 0 M 0 W 0 • Want to store D in memory. • Set Write to 1 “Inner door” 1 D 1 0 W 1 M 1 1 M

The “Airlock” Flip-Flop “Outer door” D 0 Write 1 • • D 0 W

The “Airlock” Flip-Flop “Outer door” D 0 Write 1 • • D 0 W 0 M 0 “Inner door” 0 D 1 0 W 1 Want to store D in memory. Set Write to 1 “Outer” flip-flop sets M 0 = D 0 = 0 “Inner” flip-flop ignores D 1 since W 1 = 0 M 1 1 M

The “Airlock” Flip-Flop “Outer door” D 0 Write 0 • D 0 M 0

The “Airlock” Flip-Flop “Outer door” D 0 Write 0 • D 0 M 0 W 0 Now, set Write back to 0 “Inner door” 0 D 1 1 W 1 M 1 1 M

The “Airlock” Flip-Flop “Outer door” D 0 Write 0 D 0 M 0 W

The “Airlock” Flip-Flop “Outer door” D 0 Write 0 D 0 M 0 W 0 “Inner door” 0 D 1 1 W 1 • Now, set Write back to 0 • Now “Inner” flip-flop sets M = D 1 = 0 M 1 0 M

The “Airlock” Flip-Flop “Outer door” D 1 Write 0 D 0 W 0 M

The “Airlock” Flip-Flop “Outer door” D 1 Write 0 D 0 W 0 M 0 “Inner door” 0 D 1 1 M 1 0 M W 1 • Because of feedback, D might change to (NOT M) , which is 1 • But Write = 0, so “Outer” flip-flop ignores D, so M 0 stays 0.

The “Airlock” Flip-Flop “Outer door” D 1 Write 0 D 0 W 0 M

The “Airlock” Flip-Flop “Outer door” D 1 Write 0 D 0 W 0 M 0 “Inner door” 0 D 1 1 M 1 0 W 1 • So memory does not change until we “toggle” Write. • (“toggle” means change from 0 to 1 or vice versa) M

The “Airlock” Flip-Flop “Outer door” D Write • D 0 M 0 W 0

The “Airlock” Flip-Flop “Outer door” D Write • D 0 M 0 W 0 This is Real Memory! “Inner door” D 1 W 1 M

Memory “Register”: 4 bits Data 1 D M W Data 2 D M W

Memory “Register”: 4 bits Data 1 D M W Data 2 D M W Data 3 D M W Data 4 Write D W M

Review • We have used the Universal method to build – ALU – 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