ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is...

26
FLIP FLOP A flip flop is an electronic circuit with two stable states that can be used to store binary data. The stored data can be changed by applying varying inputs. Flip-flops and latches are fundamental building blocks of digital electronics systems used in computers, communications, and many other types of systems. Flip- flops and latches are used as data storage elements. It is the basic storage element in sequential logic. But first, let’s clarify the difference between a latch and a flip-flop. Flip flop v/s Latch The basic difference between a latch and a flip-flop is a gating or clocking mechanism. For example, let us talk about SR latch and SR flip- flops. In this circuit when you Set S as active the output Q would be high and Q’ will be low. This is irrespective of anything else. (This is an active-low circuit so active here means low, but for an active high circuit active would mean high)

Transcript of ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is...

Page 1: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

FLIP FLOP

A flip flop is an electronic circuit with two stable states that can be used to store binary data. The stored data can be changed by applying varying inputs. Flip-flops and latches are fundamental building blocks of digital electronics systems used in computers, communications, and many other types of systems. Flip-flops and latches are used as data storage elements. It is the basic storage element in sequential logic. But first, let’s clarify the difference between a latch and a flip-flop.

Flip flop v/s Latch

The basic difference between a latch and a flip-flop is a gating or clocking mechanism.

For example, let us talk about SR latch and SR flip-flops. In this circuit when you Set S as active the output Q would be high and Q’ will be low. This is irrespective of anything else. (This is an active-low circuit so active here means low, but for an active high circuit active would mean high)

SR LatchA flip flop, on the other hand, is synchronous and is also known as gated or clocked SR latch.

Page 2: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

SR Flip-FlopIn this circuit diagram, the output is changed (i.e. the stored data is changed) only when you give an active clock signal. Otherwise, even if the S or R is active the data will not change. Let’s look at the types of flip-flops to understand better.

SR Flip Flop

There are majorly 4 types of flip flops, with the most common one being SR flip flop. This simple flip flop circuit has a set input (S) and a reset input (R). In this circuit when you Set “S” as active the output “Q” would be high and “Q‘‘” will be low. Once the outputs are established, the wiring of the circuit is maintained until “S” or “R” go high, or power is turned off. As shown above, it is the simplest and easiest to understand. The two outputs, as shown above, are the inverse of each other. The truth table of SR Flip Flop is highlighted below.

S R Q Q’

0 0 0 1

0 1 0 1

1 0 1 0

1 1 ∞ ∞

JK Flip-flop

Page 3: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Due to the undefined state in the SR flip flop, another flip flop is required in electronics. The JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem.

JK Flip-FlopThe input condition of J=K=1, gives an output inverting the output state. However, the outputs are the same when one tests the circuit practically.

In simple words, If J and K data input are different (i.e. high and low) then the output Q takes the value of J at the next clock edge. If J and K are both low then no change occurs. If J and K are both high at the clock edge then the output will toggle from one state to the other. JK Flip Flop can function as Set or Reset Flip flop

J K Q Q’

0 0 0 0

0 1 0 0

1 0 0 1

1 1 0 1

0 0 1 1

Page 4: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

0 1 1 0

1 0 1 1

1 1 1 0

D Flip Flop

D flip flop is a better alternative that is very popular with digital electronics. They are commonly used for counters and shift-registers and input synchronisation.

D Flip-FlopIn a D flip flop, the output can be only changed at the clock edge, and if the input changes at other times, the output will be unaffected.

Clock D Q Q’

↓ » 0 0 0 1

↑ » 1 0 0 1

↓ » 0 1 0 1

↑ » 1 1 1 0

 

The change of state of the output is dependent on the rising edge of the clock. The output (Q) is same as the input and can only change at the rising edge of the clock.

Page 5: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

T Flip Flop

A T flip flop is like JK flip-flop. These are basically a single input version of JK flip flop. This modified form of JK flip-flop is obtained by connecting both inputs J and K together. This flip-flop has only one input along with the clock input.

These flip-flops are called T flip-flops because of their ability to complement its state (i.e.) Toggle, hence the name Toggle flip-flop.

T Q Q (t+1)

0 0 0

1 0 1

0 1 1

1 1 0

Applications of Flip-Flops

These are the various types of flip-flops being used in digital electronic circuits and the applications of Flip-flops are as specified below.

Page 6: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

CountersFrequency DividersShift RegistersStorage Registers

Register

Flip-flop is a 1 bit memory cell which can be used for storing the digital data. To increase the storage capacity in terms of number of bits, we have to use a group of flip-flop. Such a group of flip-flop is known as a Register. The n-bit register will consist of n number of flip-flop and it is capable of storing an n-bit word.

The binary data in a register can be moved within the register from one flip-flop to another. The registers that allow such data transfers are called as shift registers. There are four mode of operations of a shift register.

Serial Input Serial Output Serial Input Parallel Output Parallel Input Serial Output Parallel Input Parallel Output

Serial Input Serial Output

Let all the flip-flop be initially in the reset condition i.e. Q3 = Q2 = Q1 = Q0 = 0. If an entry of a four bit binary number 1 1 1 1 is made into the register, this number should be applied to Din bit with the LSB bit applied first. The D input of FF-3 i.e. D3 is connected to serial data input Din. Output of FF-3 i.e. Q3 is connected to the input of the next flip-flop i.e. D2 and so on.

Page 7: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Block Diagram

Operation

Before application of clock signal, let Q3 Q2 Q1 Q0 = 0000 and apply LSB bit of the number to be entered to Din. So Din = D3 = 1. Apply the clock. On the first falling edge of clock, the FF-3 is set, and stored word in the register is Q3 Q2 Q1 Q0 = 1000.

Apply the next bit to Din. So Din = 1. As soon as the next negative edge of the clock hits, FF-2 will set and the stored word change to Q3 Q2 Q1 Q0 = 1100.

Apply the next bit to be stored i.e. 1 to D in. Apply the clock pulse. As soon as the third negative clock edge hits, FF-1 will be set and output will be modified to Q3 Q2 Q1 Q0 = 1110.

Page 8: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Similarly with Din = 1 and with the fourth negative clock edge arriving, the stored word in the register is Q3 Q2 Q1 Q0 = 1111.

Truth Table

Page 9: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Waveforms

Serial Input Parallel Output

In such types of operations, the data is entered serially and taken out in parallel fashion.

Data is loaded bit by bit. The outputs are disabled as long as the data is loading.

As soon as the data loading gets completed, all the flip-flops contain their required data, the outputs are enabled so that all the loaded data is made available over all the output lines at the same time.

4 clock cycles are required to load a four bit word. Hence the speed of operation of SIPO mode is same as that of SISO mode.

Page 10: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Block Diagram

Parallel Input Serial Output (PISO)

Data bits are entered in parallel fashion. The circuit shown below is a four bit parallel input serial output register. Output of previous Flip Flop is connected to the input of the next one via a

combinational circuit. The binary input word B0, B1, B2, B3 is applied though the same

combinational circuit. There are two modes in which this circuit can work namely - shift mode or

load mode.

Load mode

When the shift/load bar line is low (0), the AND gate 2, 4 and 6 become active they will pass B1, B2, B3 bits to the corresponding flip-flops. On the low going edge of clock, the binary input B0, B1, B2, B3 will get loaded into the corresponding flip-flops. Thus parallel loading takes place.

Shift mode

When the shift/load bar line is low (1), the AND gate 2, 4 and 6 become inactive. Hence the parallel loading of the data becomes impossible. But the AND gate 1,3 and 5 become active. Therefore the shifting of data from left to right bit by bit on application of clock pulses. Thus the parallel in serial out operation takes place.

Page 11: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Block Diagram

Parallel Input Parallel Output (PIPO)

In this mode, the 4 bit binary input B0, B1, B2, B3 is applied to the data inputs D0, D1, D2, D3 respectively of the four flip-flops. As soon as a negative clock edge is applied, the input binary bits will be loaded into the flip-flops simultaneously. The loaded bits will appear simultaneously to the output side. Only clock pulse is essential to load all the bits.

Page 12: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Block Diagram

Bidirectional Shift Register

If a binary number is shifted left by one position then it is equivalent to multiplying the original number by 2. Similarly if a binary number is shifted right by one position then it is equivalent to dividing the original number by 2.

Hence if we want to use the shift register to multiply and divide the given binary number, then we should be able to move the data in either left or right direction.

Such a register is called bi-directional register. A four bit bi-directional shift register is shown in fig.

There are two serial inputs namely the serial right shift data input DR, and the serial left shift data input DL along with a mode select input (M).

Page 13: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Block Diagram

Operation

S.N.

Condition Operation

1 With M = 1 − Shift right operation If M = 1, then the AND gates 1, 3, 5 and 7 are enabled whereas the remaining AND gates 2, 4, 6 and 8 will be disabled.

The data at DR is shifted to right bit by bit from FF-3 to FF-0 on the application of clock pulses. Thus with M = 1 we get the serial right shift operation.

2 With M = 0 − Shift left operation When the mode control M is connected to 0 then the AND gates 2, 4, 6 and 8 are enabled while 1, 3, 5 and 7

Page 14: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

are disabled.

The data at DL is shifted left bit by bit from FF-0 to FF-3 on the application of clock pulses. Thus with M = 0 we get the serial right shift operation.

Universal Shift Register

A shift register which can shift the data in only one direction is called a uni-directional shift register. A shift register which can shift the data in both directions is called a bi-directional shift register. Applying the same logic, a shift register which can shift the data in both directions as well as load it parallely, is known as a universal shift register. The shift register is capable of performing the following operation −

Parallel loading Left Shifting Right shifting

The mode control input is connected to logic 1 for parallel loading operation whereas it is connected to 0 for serial shifting. With mode control pin connected to ground, the universal shift register acts as a bi-directional register. For serial left operation, the input is applied to the serial input which goes to AND gate-1 shown in figure. Whereas for the shift right operation, the serial input is applied to D input.

Block Diagram

Page 15: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Counter

In digital logic and computing, a counter is a device which stores (and sometimes displays) the number of times a particular event or process has occurred, often in relationship to a clock. The most common type is a sequential digital logic circuit with an input line called the clock and multiple output lines. The values on the output lines represent a number in the binary or BCD number system. Each pulse applied to the clock input increments or decrements the number in the counter.

A counter circuit is usually constructed of a number of flip-flops connected in cascade. Counters are a very widely used component in digital circuits, and are manufactured as separate integrated circuits and also incorporated as parts of larger integrated circuits.

Electronic counters

In electronics, counters can be implemented quite easily using register-type circuits such as the flip-flop, and a wide variety of classified into:

Page 16: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Asynchronous (ripple) counter – changing state bits are used as clocks to subsequent state flip-flops

Synchronous counter – all state bits change under control of a single clock Decade counter – counts through ten states per stage Up/down counter – counts both up and down, under command of a control

input Ring counter – formed by a shift register with feedback connection in a ring Johnson counter – a twisted ring counter Cascaded counter Modulus counter.

Each is useful for different applications. Usually, counter circuits are digital in nature, and count in natural binary. Many types of counter circuits are available as digital building blocks, for example a number of chips in the 4000 and 4500 series implement different counters.

Occasionally there are advantages to using a counting sequence other than the natural binary sequence—such as the binary coded decimal counter, a linear-feedback shift register counter, or a Gray-code counter.

Counters are useful for digital clocks and timers, and in oven timers, VCR clocks, etc.[1]

Asynchronous (ripple) counter

Asynchronous counter created from two JK flip-flops

An asynchronous (ripple) counter is a single d-type flip-flop, with its J (data) input fed from its own inverted output. This circuit can store one bit, and hence can count from zero to one before it overflows (starts over from 0). This counter will increment once for every clock cycle and takes two clock cycles to overflow, so every cycle it will alternate between a transition from 0 to 1 and a transition from 1

Page 17: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

to 0. Notice that this creates a new clock with a 50% duty cycle at exactly half the frequency of the input clock. If this output is then used as the clock signal for a similarly arranged D flip-flop (remembering to invert the output to the input), one will get another 1 bit counter that counts half as fast. Putting them together yields a two-bit counter:

Cycle

Q1 Q0 (Q1:Q0)dec

0 0 0 0

1 0 1 1

2 1 0 2

3 1 1 3

4 0 0 0

You can continue to add additional flip-flops, always inverting the output to its own input, and using the output from the previous flip-flop as the clock signal. The result is called a ripple counter, which can count to 2n - 1 where n is the number of bits (flip-flop stages) in the counter. Ripple counters suffer from unstable outputs as the overflows "ripple" from stage to stage, but they do find frequent application as dividers for clock signals, where the instantaneous count is unimportant, but the division ratio overall is (to clarify this, a 1-bit counter is exactly equivalent to a divide by two circuit; the output frequency is exactly half that of the input when fed with a regular train of clock pulses).

The use of flip-flop outputs as clocks leads to timing skew between the count data bits, making this ripple technique incompatible with normal synchronous circuit design styles.

Page 18: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Synchronous counter

A 4-bit synchronous counter using JK flip-flops

In synchronous counters, the clock inputs of all the flip-flops are connected together and are triggered by the input pulses. Thus, all the flip-flops change state simultaneously (in parallel). The circuit below is a 4-bit synchronous counter. The J and K inputs of FF0 are connected to HIGH. FF1 has its J and K inputs connected to the output of FF0, and the J and K inputs of FF2 are connected to the output of an AND gate that is fed by the outputs of FF0 and FF1. A simple way of implementing the logic for each bit of an ascending counter (which is what is depicted in the adjacent image) is for each bit to toggle when all of the less significant bits are at a logic high state. For example, bit 1 toggles when bit 0 is logic high; bit 2 toggles when both bit 1 and bit 0 are logic high; bit 3 toggles when bit 2, bit 1 and bit 0 are all high; and so on.

Synchronous counters can also be implemented with hardware finite-state machines, which are more complex but allow for smoother, more stable transitions.

Decade counter

A circuit decade counter using JK Flip-flops (74LS112D)

A decade counter is one that counts in decimal digits, rather than binary. A decade counter may have each (that is, it may count in binary-coded decimal, as

Page 19: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

the 7490 integrated circuit did) or other binary encodings. "A decade counter is a binary counter that is designed to count to 1010 (decimal 10). An ordinary four-stage counter can be easily modified to a decade counter by adding a NAND gate as in the schematic to the right. Notice that FF2 and FF4 provide the inputs to the NAND gate. The NAND gate outputs are connected to the CLR input of each of the FFs."[2] A decade counter is one that counts in decimal digits, rather than binary. It counts from 0 to 9 and then resets to zero. The counter output can be set to zero by pulsing the reset line low. The count then increments on each clock pulse until it reaches 1001 (decimal 9). When it increments to 1010 (decimal 10) both inputs of the NAND gate go high. The result is that the NAND output goes low, and resets the counter to zero. D going low can be a CARRY OUT signal, indicating that there has been a count of ten.

Ring counter

A ring counter is a circular shift register which is initiated such that only one of its flip-flops is the state one while others are in their zero states.

A ring counter is a shift register (a cascade connection of flip-flops) with the output of the last one connected to the input of the first, that is, in a ring. Typically, a pattern consisting of a single bit is circulated so the state repeats every n clock cycles if n flip-flops are used.

Johnson counter

A Johnson counter (or switch-tail ring counter, twisted ring counter, walking ring counter, or Möbius counter) is a modified ring counter, where the output from the last stage is inverted and fed back as input to the first stage.[3][4][5] The register cycles through a sequence of bit-patterns, whose length is equal to twice the length of the shift register, continuing indefinitely. These counters find specialist applications, including those similar to the decade counter, digital-to-analog conversion, etc. They can be implemented easily using D- or JK-type flip-flops.

Computer science counters

In computability theory, a counter is considered a type of memory. A counter stores a single natural number (initially zero) and can be arbitrarily long. A counter is usually considered in conjunction with a finite-state machine (FSM), which can perform the following operations on the counter:

Page 20: ccs.iamr.ac.in  · Web viewThe JK flip flop is an improvement on the SR flip flop where S=R=1 is not a problem. JK Flip-Flop. The input condition of J=K=1, gives an output inverting

Check whether the counter is zero Increment the counter by one. Decrement the counter by one (if it's already zero, this leaves it unchanged).

The following machines are listed in order of power, with each one being strictly more powerful than the one below it:

1. Deterministic or non-deterministic FSM plus two counters2. Non-deterministic FSM plus one stack3. Non-deterministic FSM plus one counter4. Deterministic FSM plus one counter5. Deterministic or non-deterministic FSM.

For the first and last, it doesn't matter whether the FSM is a deterministic finite automaton or a nondeterministic finite automaton. They have the same power. The first two and the last one are levels of the Chomsky hierarchy.

The first machine, an FSM plus two counters, is equivalent in power to a Turing machine. See the article on counter machines for a proof.