Download presentation
Presentation is loading. Please wait.
Published byMyra Bishop Modified over 9 years ago
1
CS1Q Computer Systems Lecture 11 Simon Gay
2
Lecture 11CS1Q Computer Systems - Simon Gay2 The D FlipFlop A 1-bit register is called a D flipflop. When considering the D flipflop as an individual component, it is common to make both the output Q and its inverse Q available. Here it is (without the Reset input, which we do not need for the next few examples).
3
Lecture 11CS1Q Computer Systems - Simon Gay3 The D FlipFlop A register can be viewed as a collection of D flipflops. Here is a 4 bit register (without the Reset input). Note that all 4 flipflops are connected to the same clock input.
4
Lecture 11CS1Q Computer Systems - Simon Gay4 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. There is one bit of memory, and at each clock cycle, the memory is updated by storing the negated output from the previous cycle.
5
Lecture 11CS1Q Computer Systems - Simon Gay5 A Binary Counter When counting in binary, each bit changes its value when the bit to its right changes from 1 to 0 (i.e. at a negative edge). 0000 0001 0010 0011 0100 a negative edge causes the bit on the left to change
6
Lecture 11CS1Q Computer Systems - Simon Gay6 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
7
Lecture 11CS1Q Computer Systems - Simon Gay7 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.
8
Lecture 11CS1Q Computer Systems - Simon Gay8 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?
9
Lecture 11CS1Q Computer Systems - Simon Gay9 The Prime Number Machine Again Recall our design of the circuit which outputs the sequence 2, 3, 5, 7, 11, 13 as 4 bit binary numbers. The design works but has a couple of undesirable features: a 4 bit register is used, but there are only 6 states and therefore only 3 bits of storage should be necessary it seems to be a fluke that the “Reset problem” can be solved so easily; this technique might be hard to generalise The idea for an alternative design is to assume that we have a 3 bit counter as a standard component. It has a clock input and an asynchronous reset input. Q2Q1Q0 Reset Clock
10
Lecture 11CS1Q Computer Systems - Simon Gay10 PNM Second Design Assuming that we make use of states 0 to 5 (i.e. 000 to 101) of the counter, we need a circuit to calculate the outputs P3,P2,P1,P0 according to this truth table: Q2Q1Q0P3P2P1P0 0000010 0010011 0100101 011 100 1011101 110 111XXXX XXXX 1011 0111 Easy to design the circuit for P3,P2,P1,P0 (exercise).
11
Lecture 11CS1Q Computer Systems - Simon Gay11 PNM Second Design States 110 and 111 are not needed. We would like the counter to advance from state 101 to state 000. This can be achieved by connecting the Reset input to a small circuit which will activate Reset when the state reaches 110. If Reset is active high, then we can use If Reset is active low, then we need
12
Lecture 11CS1Q Computer Systems - Simon Gay12 PNM Second Design reset circuit Q2Q1Q0 Reset Clock output circuit P0P1P2 Exercise: complete the circuit.
13
Lecture 11CS1Q Computer Systems - Simon Gay13 Implementing Memory/Registers With current integrated circuit technology, memory can be implemented by taking advantage of capacitance - the tendency for electric charge to persist in part of a circuit. The electric current representing a 1 input to a register causes a tiny electric charge to build up in the circuit, and this charge will remain for a short time. If the contents of the register are only needed for the next clock cycle, and the clock speed is sufficiently high, then nothing more needs to be done. Registers (known as latches) which are used for temporary storage, have this property. In the case of a CPU’s general registers, and the RAM of a computer, the contents must be refreshed in order to preserve them for longer periods.
14
Lecture 11CS1Q Computer Systems - Simon Gay14 Implementing Memory/Registers It is also interesting that memory can be built from the purely logical properties of the basic gates that we are familiar with. We will now look at the step-by-step development of the D flipflop from a circuit called the RS flipflop, which just consists of two NOR gates.
15
Lecture 11CS1Q Computer Systems - Simon Gay15 The RS FlipFlop Using two NOR gates we can build a circuit which is able to store one bit of information: either 0 or 1. nor2 R S Q Q Note the essential use of feedback (connections from outputs to inputs), which takes us beyond combinational circuits.
16
Lecture 11CS1Q Computer Systems - Simon Gay16 The RS FlipFlop: Summary The RS flipflop has two stable states: Q = 0, Q = 1 Q = 1, Q = 0 If R (reset) becomes 1 then Q becomes 0 and Q becomes 1, and this state is maintained when R returns to 0. If S (set) becomes 1 then Q becomes 1 and Q becomes 0, and this state is maintained when S returns to 0. If R and S become 1 simultaneously then the behaviour of the circuit is not defined (in practice, one of R and S would remain at 1 for slightly longer than the other, and the last one to change would determine the subsequent state of the flipflop).
17
Lecture 11CS1Q Computer Systems - Simon Gay17 The RS FlipFlop The RS flipflop is a basic unit of memory: it can store one bit, and the stored bit can be changed by means of the R and S inputs. Some refinements are needed before the RS flipflop becomes a useful component for digital circuits. The first issue is that it is an asynchronous component: the R and S inputs can be used at any time. As we are interested in synchronous circuits, we need to introduce a clock, in such a way that setting R or S causes the state to change at the next clock cycle, rather than immediately. The first step is to introduce an enable input.
18
Lecture 11CS1Q Computer Systems - Simon Gay18 The Gated RS FlipFlop A gated or enabled RS flipflop only responds to its inputs when the Enable input is 1. This is done by passing the inputs through AND gates. Diagrammatically:
19
Lecture 11CS1Q Computer Systems - Simon Gay19 The Clocked RS FlipFlop If the clock is connected to the Enable input of a gated RS flipflop, the result is a flipflop which responds to its inputs when the clock is high (has value 1) and ignores its inputs when the clock is low (has value 0). A sequential circuit built in this way can only change state while the clock is high. This is a good start, but there are a number of engineering reasons why it is preferable for state changes to occur at a clock edge. A circuit can be designed to use either the positive edge (the transition from 0 to 1) or the negative edge (the transition from 1 to 0). negative edgepositive edge clock high clock low
20
Lecture 11CS1Q Computer Systems - Simon Gay20 The Master-Slave Circuit Two gated RS flipflops connected together: R S Q QE R S Q QE R SQ Q Clock MASTERSLAVE
21
Lecture 11CS1Q Computer Systems - Simon Gay21 The Master-Slave Circuit: Summary When the clock is 1, the master flipflop is enabled and responds to its inputs. It can therefore be set or reset by the S and R inputs. The slave flipflop is not enabled, because it receives the inverted clock, which is 0. Therefore the outputs of the circuit, corresponding to the value stored in the slave flipflop and are not affected by the S and R inputs. When the clock changes to 0, the master flipflop is no longer enabled, so its stored value is fixed according to whether the S or R input was the last one to have value 1. The slave flipflop is now enabled, so the outputs of the master flipflop set or reset the value stored in the slave. Therefore as the clock changes from 1 to 0, the value represented by the inputs to the master flipflop is transferred to the slave flipflop. Once the slave has received this value, its outputs are fixed until the next time the clock changes from 1 to 0. This circuit is a negative edge-triggered RS flipflop.
22
Lecture 11CS1Q Computer Systems - Simon Gay22 RS FlipFlop with Clear It is useful to be able to reset a flipflop to 0 at any time, even when it is not enabled. (For example, because an electronic flipflop enters a random state when power is first applied, and needs to be initialised.) A Clear input can be added to the basic gated RS flipflop circuit like this: A master-slave circuit built from two flipflops with Clear, by connecting the Clear inputs together, gives a clocked flipflop with an asynchronous Clear input.
23
Lecture 11CS1Q Computer Systems - Simon Gay23 Positive or Negative? We will use the following diagram for a clocked RS flipflop. When studying synchronous circuits, we don’t care whether components are triggered by the positive or negative clock edge; actually, we can even forget about whether they are edge-triggered or level-triggered. All we need to know is that the clock “ticks” regularly, and a state change is possible at each tick.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.