500 likes | 592 Vues
Explore how logic circuits can remember input using the "stubborn guy" metaphor. Learn how Matt's decision-making process at a party illustrates memory and feedback loop concepts in circuit design.
E N D
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 mind… So: • Matt decides to go to the party if Sue decides to go OR if he (Matt) had already planned to go.
OR 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 Matt Feedback Wire
OR 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. • If Sue decides to go... 1 Sue Matt
OR 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. • If Sue decides to go, Matt will go. 1 Sue 1 Matt 1
OR 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. • If Sue changes her mind… 0 Sue 1 Matt 1
OR 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. • If Sue changes her mind, Matt will still go! • Once he decides to go, we can’t get him to change his mind 0 Sue 1 Matt 1
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.
AND OR 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 Matt Rita Feedback Wire
AND OR 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. 0 Sue 0 Matt 1 0 0 Rita 0
AND OR 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. 1 Sue 0 Matt 1 0 0 Rita 0
AND OR 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. 1 Sue 1 Matt 1 1 0 Rita 1
AND OR 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. 0 Sue 1 Matt 1 1 0 Rita 1
AND OR 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. 0 – nothing changes: Sue can make Matt go, but cannot make him not go Sue 1 Matt 1 1 0 Rita 1
AND OR 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: • If he (Matt) had already planned to go AND Rita decides NOT to go. 0 Sue 1 Matt 1 1 1 Rita 1
AND OR 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. 0 Sue 1 Matt 0 1 1 Rita 1
AND OR 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. 0 Sue 1 Matt 0 0 1 Rita 1
AND OR 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. 0 Sue 0 Matt 0 0 1 Rita 1
AND OR 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. 0 Sue 0 Matt 0 0 1 Rita 0
AND OR 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. 0 Sue 0 Matt 0 0 0 Rita 0
AND OR 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. 0 Sue 0 Matt 1 0 0 Rita - no change 0
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
AND OR The (SR) Flip-Flop Set M Reset • 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 • M becomes 0 if Reset is turned on • Otherwise (if both are0), M just remembers its value
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
AND AND The Data Flip-Flop S D Write M R • Nothing happens unless Write = 1
AND AND 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.)
AND AND Using a Data Flip-Flop 0 S D 1 Write 0 M R 0 • Initially, Write = 0.Let’s say M = 1.
AND AND Using a Data Flip-Flop 0 S 0 D 1 Write 0 M R 0 1 • Initially, Write = 0.Let’s say M = 1. • First, set D to desired value, say 0.
AND AND Using a Data Flip-Flop 0 S 0 D 1 Write 1 M R 1 1 • Initially, Write = 0.Let’s say M = 1. • First, set D to desired value, say 0. • Then, set Write to 1.
AND AND Using a Data Flip-Flop 0 S 0 D 0 Write 1 M R 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
AND AND Using a Data Flip-Flop 0 S ? D 0 Write 0 M R 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.
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
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.
NOT A Subtle Problem ? D ? M 1 Write • For example, suppose a NOT gate connects M and D. • When Write = 1, M and D keep changing. We have no control.
NOT A Subtle Problem ? D ? M 1 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” “Inner door” M D M1 D1 D0 M0 Write W1 W0 • Two-Stage System to prevent D ever passing through directly to M (W0,W1 connected by NOT, so never 1 at the same time)
The “Airlock” Flip-Flop “Outer door” “Inner door” M D M1 D1 D0 M0 Write W1 W0 • 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” “Inner door” 0 M 1 1 D M1 D1 D0 M0 1 0 Write W1 W0 • We start with Write = 0. • Let’s say D is always NOT M; i.e. connected by NOT gateStart with D = 0, M = 1.
The “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
The “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
The “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
The “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
The “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, so M0 stays 0.
The “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)
The “Airlock” Flip-Flop “Outer door” “Inner door” M D M1 D1 D0 M0 Write W1 W0 • This is Real Memory!
Memory “Register”: 4 bits Data1 D M W Data2 D M W Data3 D M W Data4 D M Write W
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