Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay 2 The D FlipFlop The RS flipflop stores one bit of information.

Similar presentations


Presentation on theme: "CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay 2 The D FlipFlop The RS flipflop stores one bit of information."— Presentation transcript:

1 CS1Q Computer Systems Lecture 11 Simon Gay

2 Lecture 11CS1Q Computer Systems - Simon Gay 2 The D FlipFlop The RS flipflop stores one bit of information. To store a 1 we have to input 1 on the S wire. To store a 0 we have to input 1 on the R wire. It would usually be more convenient to input the value we want to store, either 0 or 1, on a single input line. The D flipflop is a simple extension of the RS flipflop which allows this.

3 Lecture 11CS1Q Computer Systems - Simon Gay 3 The D FlipFlop We use the following diagrammatic representation of a D flipflop. A register (multi-bit storage unit) can be built from D flipflops. Here is a 4 bit register:

4 Lecture 11CS1Q Computer Systems - Simon Gay 4 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T

5 Lecture 11CS1Q Computer Systems - Simon Gay 5 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T 0 1 Suppose the stored value is 0 initially.

6 Lecture 11CS1Q Computer Systems - Simon Gay 6 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T 0 1 clock pulse

7 Lecture 11CS1Q Computer Systems - Simon Gay 7 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T 1 0 D input is stored.

8 Lecture 11CS1Q Computer Systems - Simon Gay 8 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T 1 0 clock pulse

9 Lecture 11CS1Q Computer Systems - Simon Gay 9 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T 0 1 D input is stored.

10 Lecture 11CS1Q Computer Systems - Simon Gay 10 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T 0 1 clock pulse

11 Lecture 11CS1Q Computer Systems - Simon Gay 11 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T 1 0 D input is stored.

12 Lecture 11CS1Q Computer Systems - Simon Gay 12 The T FlipFlop If the Q output of a D flipflop is connected to the D input, the resulting circuit changes state (from 0 to 1, or from 1 to 0) at every clock tick. This is a T (for trigger) flipflop. DQ Q T This is an example of the general structure of a sequential circuit (Lecture 10 Slide 3). There is one bit of memory, and at each clock cycle, the memory is updated by storing the negated output from the previous cycle.

13 Lecture 11CS1Q Computer Systems - Simon Gay 13 A Binary Counter When counting in binary, each bit changes its value when the bit to its right changes from 1 to 0. 0000 0001 0010 0011 0100 a negative edge causes the bit on the left to change

14 Lecture 11CS1Q Computer Systems - Simon Gay 14 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits

15 Lecture 11CS1Q Computer Systems - Simon Gay 15 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 000assume outputs are 0

16 Lecture 11CS1Q Computer Systems - Simon Gay 16 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 000 0 11 initially clock is 0

17 Lecture 11CS1Q Computer Systems - Simon Gay 17 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 100 1 01 clock becomes 1 Q0 changes

18 Lecture 11CS1Q Computer Systems - Simon Gay 18 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 100 0 01 clock becomes 0

19 Lecture 11CS1Q Computer Systems - Simon Gay 19 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 010 1 10 clock becomes 1 Q0 changes Q1 changes changes from 0 to 1

20 Lecture 11CS1Q Computer Systems - Simon Gay 20 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 010 0 10 clock becomes 0

21 Lecture 11CS1Q Computer Systems - Simon Gay 21 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 110 1 00 clock becomes 1 Q0 changes

22 Lecture 11CS1Q Computer Systems - Simon Gay 22 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 110 0 00 clock becomes 0

23 Lecture 11CS1Q Computer Systems - Simon Gay 23 A Binary Counter T flipflops can be used to build a circuit which counts in binary, advancing by 1 on each clock cycle. Assuming that the flipflops are positive edge triggered, we need to convert a negative edge on an output into a positive edge on the next clock input. TTT CLOCK not Q0Q1Q2 a 3 bit counter the same idea works for any number of bits 001 1 11 clock becomes 1 Q0 changes changes from 0 to 1 Q1 changes Q2 changes

24 Lecture 11CS1Q Computer Systems - Simon Gay 24 A Binary Counter This design is sometimes called a ripple counter because of the way that the change in output propagates from bit to bit. When the outputs are 111, the next clock cycle changes the state to 000. The design can be extended to any number of bits.

25 Lecture 11CS1Q Computer Systems - Simon Gay 25 A Counter Application A 2 bit counter can be used to complete the design of a traffic light controller. The counter generates the binary numbers from 0 to 3 in sequence, and the circuit from Lecture 9 converts these numbers into the correct outputs for the Red, Amber and Green lights. Exercise: Why is this not quite a perfect traffic light controller?

26 Lecture 11CS1Q Computer Systems - Simon Gay 26 Finite State Machines A finite state machine is a system which can be in one of a finite number of states, and can change state. A change of state is called a transition. Example: traffic lights. red red & amber green amber Here there are four states, labelled with the lighting combinations. We think of the transitions as being caused by an external timer or clock. This is a transition diagram.

27 Lecture 11CS1Q Computer Systems - Simon Gay 27 Finite State Machines Example: 3 bit binary counter. 000001 010 011 100101 110 111 Usually the initial state is specified: in this case, probably 000.

28 Lecture 11CS1Q Computer Systems - Simon Gay 28 Finite State Machines A finite state machine is sometimes called a finite state automaton (plural: automata), and often abbreviated to FSM or FSA. An FSM is an abstract description or specification of a system with several possible states: for example, a sequential circuit. There are many variations of the basic idea. We can consider unlabelled transitions (as in the previous examples); labelled transitions in which the labels are viewed as inputs; outputs, which can be associated with either states or transitions; distinguished states with particular meanings. FSMs pop up all over Computing Science. In fact, every computer is a FSM, although it is often convenient to pretend that computers have unlimited memory and an infinite number of possible states.

29 Lecture 11CS1Q Computer Systems - Simon Gay 29 Finite State Machines Example: telephone. on hookoff hook ringing conversationringing conversation pick up dial answer put down incomingpick up put down Transitions are labelled but we’re not describing how each transition is activated. Of course this example leaves out many details of the real telephone system!

30 Lecture 11CS1Q Computer Systems - Simon Gay 30 Finite State Machines Example: web site. Any web site can be viewed as a finite state machine. Each state is a page, and each link is a transition to another state (page). Exercise: pick a web site and start to draw the transition diagram for the FSM which describes its structure. (Actually, many web sites contain dynamically generated pages which make it difficult to describe them as FSMs, but there is often an overall structure which can be thought of as an FSM.) This idea could help to answer questions like: Are all pages reachable? Is it easy to return to the home page?

31 Lecture 11CS1Q Computer Systems - Simon Gay 31 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal

32 Lecture 11CS1Q Computer Systems - Simon Gay 32 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101

33 Lecture 11CS1Q Computer Systems - Simon Gay 33 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101

34 Lecture 11CS1Q Computer Systems - Simon Gay 34 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 101011 accepted

35 Lecture 11CS1Q Computer Systems - Simon Gay 35 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101

36 Lecture 11CS1Q Computer Systems - Simon Gay 36 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101

37 Lecture 11CS1Q Computer Systems - Simon Gay 37 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101

38 Lecture 11CS1Q Computer Systems - Simon Gay 38 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101101 accepted

39 Lecture 11CS1Q Computer Systems - Simon Gay 39 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101

40 Lecture 11CS1Q Computer Systems - Simon Gay 40 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101

41 Lecture 11CS1Q Computer Systems - Simon Gay 41 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 10101

42 Lecture 11CS1Q Computer Systems - Simon Gay 42 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1010110101 accepted

43 Lecture 11CS1Q Computer Systems - Simon Gay 43 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1001...

44 Lecture 11CS1Q Computer Systems - Simon Gay 44 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1001...1 accepted

45 Lecture 11CS1Q Computer Systems - Simon Gay 45 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1001...

46 Lecture 11CS1Q Computer Systems - Simon Gay 46 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1001...

47 Lecture 11CS1Q Computer Systems - Simon Gay 47 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1001...

48 Lecture 11CS1Q Computer Systems - Simon Gay 48 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1001...

49 Lecture 11CS1Q Computer Systems - Simon Gay 49 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1001...

50 Lecture 11CS1Q Computer Systems - Simon Gay 50 Finite State Machines as Accepters A particular kind of FSM accepts or recognises certain input sequences. Transitions are labelled with symbols from an input alphabet. One state is the initial state and some states are final or accepting states. If a sequence of input symbols is fed into the FSM, causing transitions, then the sequence is accepted if the last transition leads to a final state. Example: accepting binary sequences of the form 10101…01. 1 0 01 0,1 initialfinal input: 1001...no escape!

51 Lecture 11CS1Q Computer Systems - Simon Gay 51 Finite State Machines as Accepters This is an important idea in Computing Science. Examples and applications occur in many places: searching for a particular string in a text file recognising programming language keywords, in a compiler studying the power of formal models of computation (which sets of strings can be recognised by a FSM?) For more information, consult any book with “formal languages” or “automata” in the title.

52 Lecture 11CS1Q Computer Systems - Simon Gay 52 The Mathematical Definition Mathematically, an accepting finite state machine of the kind we have just illustrated, is defined by the following. a finite set of states a finite set of symbols, called the input alphabet a function called the transition function a state called the initial state a set of final states (You are not expected to know this for the exam; but it is important to be familiar with the informal idea of a FSM.)


Download ppt "CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay 2 The D FlipFlop The RS flipflop stores one bit of information."

Similar presentations


Ads by Google