Download presentation

Presentation is loading. Please wait.

Published byWalker Washburn Modified about 1 year ago

1

2
Our First Real System

3
Review On our way to building a computer… Computers We are here Logic Circuits: Universal Method 0’s & 1’s Represent Info with 0’s & 1’s (aka bits) Memory Circuits

4
The System Clock “500 Mhz Pentium III computer…” What does “500 Mhz” mean? It refers to the speed of the System Clock. (actually this is only one of the clocks…) All digital systems have such “Clocks,” even traffic lights and elevator control systems.

5
Clocks: Some Terminology Think of System Clock as a heart. How fast it beats is measured in Hertz (Hz) which means “cycles per second” Prefixes: Kilo =1,000 Mega =1,000,000 Giga =1,000,000,000

6
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 0

7
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 1

8
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 0

9
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 1

10
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 0

11
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 1

12
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 0

13
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 1

14
The System Clock (cont.) Rough idea: System takes a “step” every time the System Clock beats. We’ll see how this works in an example. In real life, Clock is a Quartz crystal, which sends out 0’s and 1’s on a wire. In every cycle, it changes from 0 to 1 and back to 0 0

15
Our System: A Traffic Light

16
Intersection of two one-way roads

17
A Traffic Light Intersection of two one-way roads Car Sensors B A

18
Traffic Light System Clock Traffic Lights don’t have to act very fast. Let’s say the System Clock only beats once every 4 seconds. This is 0.25 Hz. (a few Billion times slower than your PC)

19
Traffic Light Design How do we go about designing the Traffic Light? First, let’s think about all the possible States of the traffic light.

20
Traffic Light Intersection of two one-way roads Car Sensors B A

21
Light A Light B

22
Light A Light B Possible States

23
Light A Light B Possible States

24
Light A Light B Possible States

25
Light A Light B Possible States

26
Light A Light B Actually Only 4 Possibilities

27
Traffic Light Design We figured out some possible States of the Traffic Light. Next, we should think logically about how the Traffic Light should behave. For now, we will try to keep it simple. (Suppose these are infrequently used country roads.)

28
Light A Light B How should the Light behave? Car Sensors B A

29
Light A Light B Traffic Light Behavior IF A=1 AND B=0

30
Light A Traffic Light Behavior IF A=1 AND B=0 Otherwise Light B

31
Light A Traffic Light Behavior IF A=1 AND B=0 Always Otherwise Light B

32
Light A Traffic Light Behavior IF A=1 AND B=0 Always Otherwise Light B Otherwise IF A=0 AND B=1

33
Light A Traffic Light Behavior IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always

34
Light A Traffic Light Behavior IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always Note: Clock beats every 4 sec. So Light is Yellow for 4 sec.

35
Light A Traffic Light State Machine IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always Note: Clock beats every 4 sec. So Light is Yellow for 4 sec.

36
Traffic Light Design We’ve figured out the logical behavior of the Traffic Light in terms of a State Machine: We know what the states are. For each state, given any input, we know which state to go to next. How do we build it?

37
Traffic Light Design Thinking this through: Our machine needs to:

38
Traffic Light Design Thinking this through: Our machine needs to: Remember which state it is in (Memory)

39
Traffic Light Design Thinking this through: Our machine needs to: Remember which state it is in (Memory) Given the state it is in and input values, it must determine which state to go to next (Logic)

40
Traffic Light Design Thinking this through: Our machine needs to: Remember which state it is in (Memory) Given the state it is in and input values, it must determine which state to go to next (Logic) And that’s all !

41
Traffic Light Design Problem 1: Remember which state it is in (Memory) How do represent the states? We could keep one bit of memory for whether Light A is Green or not, whether it is Yellow or not, … This would take 6 bits of memory. There is a much simpler way!

42
Traffic Light Design Problem 1: Remember which state it is in (Memory) How do represent the states? Answer: Just number them (using binary numbers). We have 4 states. Call them 00, 01, 10, 11. We (human designers) will keep track of what these names mean.

43
Light A Traffic Light States IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always

44
Light A Traffic Light States IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always 00 01 10 11

45
Traffic Light Design Problem 2: Given the state it is in and input values, it must determine which state to go to next (Logic) Answer:

46
Traffic Light Design Problem 2: Given the state it is in and input values, it must determine which state to go to next (Logic) Answer: Build a Truth Table Use Universal Method!

47
Traffic Light Behavior Build A Truth Table for next state / Output M 1 M 2 ABD 1 D 2 Light A RedLight B Red …

48
Light A Traffic Light Behavior IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always 00 01 10 11

49
Traffic Light Behavior Build A Truth Table for next state / Output M 1 M 2 ABD 1 D 2 Light A RedLight B Red … 00100110

50
Light A Traffic Light Behavior IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always 00 01 10 11

51
Traffic Light Behavior Build A Truth Table for next state / Output M 1 M 2 ABD 1 D 2 Light A RedLight B Red … 00100110 01**1010

52
Light A Traffic Light Behavior IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always 00 01 10 11

53
Traffic Light Behavior Build A Truth Table for next state / Output M 1 M 2 ABD 1 D 2 Light A RedLight B Red … 00100110 01**1010 10011101

54
Light A Traffic Light Behavior IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always 00 01 10 11

55
Traffic Light Behavior Build A Truth Table for next state / Output M 1 M 2 ABD 1 D 2 Light A RedLight B Red … 00100110 01**1010 10011101 11**0001

56
Light A Traffic Light Behavior IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always 00 01 10 11

57
Traffic Light Behavior Build A Truth Table for next state / Output M 1 M 2 ABD 1 D 2 Light A RedLight B Red … 00100110 01**1010 10011101 11**0001 00000010 …………………

58
Traffic Light Design We understand how to represent which state the system is in (so we can store it in Memory) We understand how the system can determine which state to go to next (Logic) Let’s put it together…

59
Traffic Light Design Input: Sensor A Input: Sensor B

60
Traffic Light Design 2-bit Memory Register Current State Write Sensor A Sensor B M1M1 M2M2 D1D1 D2D2

61
Traffic Light Design 2-bit Memory Register Write Sensor A Sensor B Logic For Next State & Output 6 Outputs: for each Light Current State Next State

62
Traffic Light Design 2-bit Memory Register Write Sensor A Sensor B Logic For Next State & Output 6 Outputs: for each Light Current State

63
Traffic Light Design 2-bit Memory Register Clock Sensor A Sensor B Logic For Next State & Output 6 Outputs: for each Light Current State

64
Design for Any State Machine Memory Register Clock Inputs Logic For Next State & Output Outputs Current State Many bits

65
State Machines in Real Life Elevator control systems Car control systems VCR’s Alarm Clocks Personal Computers … Just about everything!

66
More Sophisticated Designs Just add more states, more inputs, more outputs, more rules… Example: Add a longer delay before Traffic Light changes from Yellow to Red. (Say 8 seconds instead of 4.)

67
Light A Traffic Light Behavior IF A=1 AND B=0 Always IF A=0 AND B=1 Otherwise Light B Otherwise Always

68
More Sophisticated Designs Note that the new “delay” states we added correspond to the SAME combinations of lights as other states (Red/Yellow). The purpose of the new states is only to add delays. Logical states need not correspond to different observable states of the machine!

69
More Sophisticated Designs Can also add other State Machines!

70
More Sophisticated Designs Example (Fairness): We might want a separate Timer machine for the Traffic Light: If cars keep coming, Light should decide after 3 minutes to switch lights. A Timer is just a state machine that keeps counting beats of the Clock

71
More Sophisticated Designs Inputs Outputs Timer State Machine Main State Machine

72
Next Time: Computers! State Machines that you can program

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google