Latches and Flip-Flops 1 - The SR Latch

Computer Science
29 Jul 201612:14

Summary

TLDRThis video script delves into the world of computer memory, focusing on the SR latch, a fundamental building block that acts as a one-bit memory unit. It explores the latch's operation using NOR and NAND gates, detailing how it can store a state triggered by input pulses and maintain it until changed. The script also discusses the latch's truth tables, the concept of 'active high' and 'active low' configurations, and its practical applications, such as debouncing mechanical switches to prevent signal interference in digital circuits.

Takeaways

  • 🌟 Latches and flip-flops are fundamental to computer memory, with the SR latch being a basic building block.
  • πŸ”„ The SR latch functions as a one-bit memory, capable of holding one of two stable states until changed by an input pulse or power removal.
  • πŸ”© The SR latch is constructed using fundamental logic gates, such as the OR, AND, NOR, and NAND gates, which have specific behaviors defined by their truth tables.
  • πŸ”„ The SR latch has two inputs, S (Set) and R (Reset), and can be built using either NOR or NAND gates, resulting in different control mechanisms.
  • ↔️ In a NOR-based SR latch, the output is influenced by high logic levels, making it an active-high SR latch, whereas a NAND-based latch is controlled by low logic levels, making it active-low.
  • πŸ”„ The SR latch can be in one of two states: Set (storing a '1') or Reset (storing a '0'), and it transitions between these states based on the input pulses applied to S and R.
  • 🚫 Both S and R should not be high at the same time in an SR latch, as this would create an illegal state where the latch's next state cannot be determined.
  • πŸ”„ The SR latch can be used to debounce mechanical switch signals, ensuring that only one signal is recognized despite multiple electrical signals generated during switch press.
  • πŸ› οΈ SR latches are used in control applications to monitor and react to changing conditions, such as in a burglar alarm system where the state of a door or window can trigger an alarm.
  • πŸ”Œ The SR latch is also the foundation for more complex memory circuits, highlighting its importance in the design of digital systems.
  • πŸ”„ Understanding the behavior of SR latches, including their truth tables and forbidden states, is crucial for designing reliable digital circuits.

Q & A

  • What are latches and flip-flops in the context of computer memory?

    -Latches and flip-flops are fundamental building blocks of computer memory. They are used to store and manipulate binary data, with latches being simpler and flip-flops being more complex and versatile.

  • What is an SR latch and what does it represent?

    -An SR latch, also known as a Set-Reset latch, is a type of latch that can be thought of as a one-bit memory. It has two stable output states and is triggered by input pulses to set or reset its state.

  • How does the SR latch remember its state?

    -The SR latch remembers its state through positive feedback within the circuit. It maintains the state until it is changed again by another input pulse or until power is removed.

  • What are the basic logic gates used in constructing an SR latch?

    -The basic logic gates used in constructing an SR latch are NOR gates and NAND gates. These gates are combined in a specific way to create the latch's functionality.

  • What is the purpose of the NOR gate in an SR latch?

    -In an SR latch constructed with NOR gates, the NOR gate is used to create a form of positive feedback through cross-coupling, which allows the latch to maintain its state until a new input pulse is received.

  • How does the output of an AND gate become the input for a NOT gate?

    -By inverting the output of a regular AND gate with a NOT gate, the zeros in the output column of the truth table are swapped for ones, and the ones are swapped for zeros.

  • What is the significance of the 'Q' and 'not Q' outputs in an SR latch?

    -The 'Q' output represents the current state of the latch, while 'not Q' is the inverse of 'Q'. These outputs are crucial for the latch to function as a memory element, storing and providing the state information.

  • Why is it important that S and R inputs of an SR latch are never left high?

    -It is important that S and R inputs are never left high because the latch is controlled by pulses. Continuously setting either input high could lead to an invalid state, causing the latch to malfunction.

  • What is a race condition in the context of an SR latch?

    -A race condition in an SR latch occurs when both inputs S and R are set high simultaneously, causing both outputs to be indeterminate. This is an illegal state for the latch and should be avoided.

  • How does an SR latch help in debouncing a mechanical switch?

    -An SR latch helps in debouncing a mechanical switch by providing a stable single signal output even when the switch generates multiple electrical signals due to bounce. The latch ignores further set signals after it has been set, ensuring a clean signal for the controlling circuit.

  • What are the two types of SR latches based on the logic used for setting and resetting?

    -There are two types of SR latches: the active-high SR latch, which is built from NOR gates and uses high logic levels for setting and resetting, and the active-low SR latch, which is built from NAND gates and uses low logic levels for the same purpose.

Outlines

00:00

πŸ“¦ Building Blocks of Memory: SR Latch Basics

This paragraph introduces the concept of latches and flip-flops as fundamental components of computer memory. It specifically focuses on the Set-Reset (SR) latch, which acts as a one-bit memory capable of holding a stable output state triggered by input pulses. The SR latch is explained as a 'bistable' latch, maintaining its state until changed by another input or power removal. The paragraph also reviews basic logic gates like OR, AND, NOR, and NAND, which are essential for understanding the construction of SR latches. The NOR gate-based SR latch is described in detail, including its inputs (R and S), outputs (Q and not Q), and the positive feedback mechanism that enables its latching behavior. The explanation includes how the latch operates with different input pulses to set or reset its state.

05:01

πŸ”„ SR Latch Operation and Truth Tables

This paragraph delves deeper into the operation of the SR latch, emphasizing the importance of input pulses to control the latch's state. It clarifies that inputs S and R should not be left high continuously, as the latch is designed to be triggered by pulses. The paragraph presents the truth table for the SR latch, illustrating the possible states of the latch depending on the inputs. It also discusses the forbidden state when both inputs are high simultaneously, which leads to an indeterminate state. Additionally, the paragraph compares the active-high SR latch built from NOR gates with the active-low SR latch built from NAND gates, highlighting the differences in their behavior and control logic.

10:01

πŸ›  Applications and Debouncing with SR Latches

The final paragraph discusses practical applications of the SR latch, particularly in scenarios where a single, clean signal is required from a mechanical switch that may generate multiple signals due to 'switch bounce.' It describes how an integrated circuit with an SR latch can be used to debounce such signals, ensuring that only one signal is processed even if the switch is pressed multiple times in quick succession. The paragraph also touches on other potential uses of SR latches, such as in control systems that need to monitor and react to changing conditions. Furthermore, it emphasizes the SR latch's role as a foundational element in the development of more complex memory circuits.

Mindmap

Keywords

πŸ’‘Latches

Latches are fundamental building blocks in digital circuits, used to store binary data. In the context of the video, latches are essential for creating memory units. The script mentions SR latches, which can be considered as one-bit memory elements that hold their state until changed by an input pulse, illustrating the basic concept of data retention in digital systems.

πŸ’‘Flip-Flops

Flip-flops are a type of latch that can be clocked to change state. They are used in various digital systems for data storage and are more predictable in their operation than SR latches due to their synchronization with a clock signal. The video does not directly mention flip-flops, but they are closely related to the theme of memory storage.

πŸ’‘SR Latch

The SR latch, or Set-Reset latch, is a specific type of latch that can be set to store a '1' or reset to store a '0'. The script describes it as a one-bit memory with two stable output states, controlled by input pulses. It is a central concept in the video, illustrating how digital memory can be implemented using basic logic gates.

πŸ’‘Stable Output States

Stable output states refer to the condition where a circuit maintains its output until a new input changes it. In the script, this concept is used to explain how the SR latch retains its state, emphasizing the reliability of latches in memory storage applications.

πŸ’‘Input Pulse

An input pulse is a brief change in voltage that triggers a change in the state of a circuit, such as a latch. The script explains that the SR latch can be set or reset by an input pulse, demonstrating how latches can be controlled to store or change data.

πŸ’‘Logic Gates

Logic gates are the basic components used to construct digital circuits. The script mentions OR, AND, NOR, and NAND gates, which are fundamental to building more complex circuits like the SR latch. The video uses these gates to explain the construction and function of latches.

πŸ’‘Truth Table

A truth table is a tool used in digital logic to describe the output of a gate or circuit for all possible input combinations. The script provides truth tables for various gates, which are essential for understanding the behavior of the SR latch and other digital circuits.

πŸ’‘Positive Feedback

Positive feedback in a circuit is a situation where the output is fed back to the input in a way that reinforces the output signal. The script describes how the cross-coupling of NOR gates in an SR latch creates positive feedback, which is crucial for the latch's ability to maintain its state.

πŸ’‘Debounce

Debounce refers to the process of filtering out noise or multiple signals to ensure that only one signal is recognized. The script explains how an SR latch can be used to debounce a mechanical switch, providing a practical application of latches in controlling digital circuits.

πŸ’‘Active High

Active high refers to a signal or condition that is active or true when at a high voltage level. In the script, the SR latch is described as active high because it requires a high pulse at the set or reset input to change its state, which is a key aspect of its operation.

πŸ’‘Active Low

Active low is the opposite of active high, where a signal or condition is active when at a low voltage level. The script contrasts the active high SR latch with an active low version built from NAND gates, showing the different ways latches can be controlled.

πŸ’‘Race Condition

A race condition occurs when two or more processes attempt to reach a shared resource at the same time, and the outcome is uncertain. The script warns against setting both S and R inputs of an SR latch high simultaneously, as it leads to an indeterminate state, illustrating the importance of proper circuit design.

Highlights

Latches and flip-flops are fundamental building blocks of computer memory.

The SR latch acts as a one-bit memory with stable output states triggered by input pulses.

An SR latch remembers its state until changed by another input pulse or power removal.

Fundamental logic gates such as OR, AND, NOR, and NAND are essential for constructing SR latches.

The NOR gate version of an SR latch uses crosscoupling to create positive feedback.

SR latches require power to function, though power connections are not shown in diagrams.

The SR latch has two inputs, R and S, and provides an output Q and its inverse.

Applying a pulse to input R resets the latch, changing the output state.

A set pulse at input S forces the latch into a set state, storing a one.

The latch's state is latched and remains until another valid input pulse is applied.

An SR latch has a unique truth table reflecting its behavior with S and R inputs.

Simultaneously setting both S and R inputs creates an invalid state for the SR latch.

The SR latch is controlled by pulses, not continuous high or low signals.

An SR latch built from NAND gates is known as an active low SR latch.

NAND gate-based SR latches have a different truth table and behavior compared to NOR gate versions.

An SR latch can be used to debounce mechanical switch signals in digital circuits.

The SR latch serves in control applications and as a building block for more complex memory circuits.

Transcripts

play00:01

latches and flip-flops are the building

play00:03

blocks of computer memory in this

play00:06

particular video we'll focus on the

play00:08

so-called Sr latch later we'll see how

play00:12

this circuit can be

play00:14

enhanced the set reset latch or Sr latch

play00:17

for short can be thought of as a one bit

play00:21

memory it can be put into one of two

play00:23

stable output States triggered by an

play00:26

input

play00:27

pulse the circuit remembers the this

play00:30

state until it's changed Again by

play00:32

another input pulse or until the power's

play00:34

removed for this reason the circuit is

play00:37

known as a bable

play00:42

latch before we consider the

play00:44

construction of Sr latches let's remind

play00:46

ourselves of some fundamental logic

play00:48

gates this is an or gate and this is the

play00:52

truth table that describes Its Behavior

play00:55

any combination of inputs A and B

play00:57

results in a one at output p except when

play01:01

both inputs are zero in which case the

play01:03

output is

play01:05

zero this is an and gate and this is the

play01:09

truth table that describes Its Behavior

play01:11

any combination of inputs A and B

play01:14

results in a zero at output P except

play01:17

when both inputs are one in which case

play01:19

the output is

play01:22

one if we modify the output of a regular

play01:26

or gate by inverting it with a not gate

play01:30

then we can swap the zero for a one and

play01:33

the ones for zeros in the output column

play01:35

of the truth

play01:38

table in a similar fashion we can invert

play01:42

the output of a regular and gate then we

play01:45

can swap the zeros for ones and the one

play01:47

for a zero in the output column of this

play01:50

tooth

play01:53

table each of these gate combinations

play01:56

has its own name and its own symbol they

play01:59

are are known as the Norgate and the

play02:02

nand

play02:04

gate the Norgate only produces an output

play02:07

of one if both of the inputs are zero

play02:11

the nand gate only produces an output of

play02:14

zero if both of the inputs are

play02:17

one the SR latch can be built using one

play02:20

of these two basic building

play02:26

blocks let's start by considering an Sr

play02:28

latch built from nor

play02:32

gates in this Norgate version of an Sr

play02:35

latch two nor gates are connected

play02:37

together in such a way as the output of

play02:39

each nor gate is one of the inputs of

play02:42

the other this crosscoupling of two

play02:45

gates results in a form of positive

play02:49

feedback Sr latches like all electronic

play02:52

circuits require power to work the power

play02:55

connections aren't shown on this

play02:57

diagram the SR lat has two inputs R and

play03:02

S and the output Q the SR latch also

play03:06

makes the inverse of the output

play03:08

available on this diagram you can see

play03:10

not q a q with a bar above

play03:14

it the starting State here is that S and

play03:17

R are both low that is both inputs are

play03:21

zero Q is high that is the output is one

play03:25

and not Q the inverse of this is

play03:28

zero both of the inputs of the top n

play03:31

gate are zero so the output of the top

play03:35

gate is one this is exactly what you

play03:38

would expect from a

play03:39

Norgate the inputs of the lower Norgate

play03:42

are one and zero so the output of the

play03:45

Lower Gate is

play03:47

zero because Q is one the latch is

play03:50

currently storing

play03:52

one now we apply a pulse to input R to

play03:56

reset the

play03:57

latch this changes the the output of the

play04:00

top gate and then this is fed back into

play04:02

the Lower Gate the lower Gate's output

play04:05

also changes and this is fed back into

play04:07

the top gate the pulse that was applied

play04:10

to reset the SR latch is then removed

play04:13

and R is zero

play04:15

again but the output at Q is now zero so

play04:19

the latch is now storing a

play04:23

zero in order to store a one again a

play04:26

pulse must be applied to input s which

play04:28

will set the lat

play04:31

again notice how the various changes are

play04:34

propagated around the

play04:40

circuit the set pulse is then

play04:44

removed and the circuit is now latched

play04:47

into a set State it's storing a one

play04:50

again notice that if another set pulse

play04:52

is applied it has no

play04:55

effect applying a set pulse at s will

play04:59

always for Force the latch into a set

play05:00

State regardless of the previous state

play05:02

of the latch similarly applying a reset

play05:06

pulse will always Force the latch into a

play05:08

reset state it should be noted that S

play05:11

and R are never left high that is

play05:15

neither is ever set continuously to the

play05:17

value one the latch is controlled by

play05:21

pulses

play05:26

only this gives us an unusual looking

play05:28

truth table

play05:30

when both S and R are set to zero Q may

play05:34

be one or it may be zero depending on

play05:37

the previous state of the circuit let's

play05:40

examine the truth table as this Sr latch

play05:43

is reset

play05:44

again the reset pulse is applied s is

play05:49

zero R is one output Q is zero and its

play05:53

inverse not Q is one the SR latch is

play05:56

storing a

play05:58

zero the reset pulse is removed both S

play06:02

and R are zero again output Q remains at

play06:06

zero and its inverse remains at one the

play06:09

SR latch is still storing a

play06:13

zero a set pulse is applied s is one and

play06:17

R is zero the output Q becomes one and

play06:21

its inverse becomes

play06:23

zero the set pulse is removed s is zero

play06:28

and R is zero output Q is still one and

play06:32

not Q is of course

play06:36

zero now the only circumstance we

play06:39

haven't considered is when both inputs S

play06:42

and R are set to one at the same

play06:45

time if this were to occur we'd be

play06:48

telling the SR latch to set the value of

play06:50

Q to both one and zero

play06:53

simultaneously in reality Q would become

play06:56

zero and not Q would also become zero

play07:00

this would sort itself out if one of the

play07:02

inputs fell to zero before the other for

play07:05

example if r fell to zero first with s

play07:08

still at one then Q would become one

play07:10

again if however both inputs were at one

play07:14

and both fell to zero at the same time

play07:17

we'd have what's known as a race

play07:19

condition between the two gates they'd

play07:21

be racing each other to feed back their

play07:23

new output and it's impossible to know

play07:25

which one would win hence if both puts

play07:29

are high the next state of the latch

play07:32

can't be determined this is not a state

play07:36

that the latch should ever be in it's

play07:38

illegal it's

play07:40

invalid most of the time inputs S and R

play07:43

should both be at zero and only

play07:45

momentarily will one or the other input

play07:48

become one and at any time while it's

play07:51

operating the SR latch should either be

play07:53

in a set state or a reset state with q

play07:57

and not Q the opposite of each other

play08:01

one final piece of terminology this type

play08:04

of Sr latch is said to be an active High

play08:07

Sr latch because the normal condition

play08:10

for S andr is low and a high pulse at

play08:13

one of these inputs is required to bring

play08:15

about a

play08:20

change now let's consider an Sr latch

play08:23

built from nand Gates here's a reminder

play08:26

of the nandate truth table only when

play08:29

both inputs are high is the output

play08:33

low the wiring of this SL latch is the

play08:36

same but notice that input s is at the

play08:38

top now and R is at the

play08:41

bottom here's a truth table for this

play08:43

variation of the SR latch it's a little

play08:46

different from the truth table we've

play08:47

just seen because this latch behaves

play08:51

differently the difference is that R and

play08:54

S are kept High most of the time here we

play08:57

can see that output Q is zero so the

play09:00

latch is storing a zero when input s is

play09:03

made low momentarily that is when s

play09:06

becomes zero and R is still one the

play09:09

output at Q becomes one the latch is now

play09:12

storing a one and S can be returned to

play09:16

its normal high

play09:20

State when R is set low momentarily the

play09:23

output at Q is changed to

play09:27

zero R can then return to its normal

play09:29

high value and the latch is now storing

play09:32

a zero

play09:33

again an Sr latch built from nand Gates

play09:37

like this is more explicitly known as an

play09:40

active low Sr

play09:43

latch an Sr latch based on nand Gates

play09:47

also has a forbidden state that is when

play09:49

both S and R are simultaneously

play09:52

zero this would result in an illegal

play09:55

state in which both q and its complement

play09:58

are one

play10:01

to summarize then an Sr latch can be

play10:03

built from nor Gates or from nand Gates

play10:07

both types of latch do the same job but

play10:10

they're just controlled in a slightly

play10:12

different way the Norgate based Sr latch

play10:15

is set or reset with high logic that is

play10:19

it is an active High Sr latch the nand

play10:23

gate Sr latch on the other hand is set

play10:25

or reset with low logic that is it's an

play10:29

active low Sr

play10:31

latch let's consider a particular

play10:34

application of an Sr

play10:36

latch when a mechanical switch is

play10:39

pressed it may actually generate several

play10:41

electrical signals in a tiny fraction of

play10:44

a second when only one signal is

play10:47

required lots of onoff signals like this

play10:50

could then cause problems with the

play10:51

circuit that this switch is supposed to

play10:53

be

play10:54

controlling the effect is known as

play10:56

switch

play10:58

bounce

play10:59

an integrated circuit with an Sr latch

play11:02

on it can be purchased commercially to

play11:04

allow clean interfacing between a

play11:07

mechanical switch and the digital

play11:08

circuit it's

play11:10

controlling here we can see a switch

play11:12

that will connect input s which is

play11:14

currently High to Earth making it low

play11:17

and thereby changing the output of this

play11:19

nand based Sr latch from low to

play11:23

high this Sr latch will ignore any

play11:26

further set signals after it's already

play11:28

been set

play11:29

so it's serving to debounce the signal

play11:32

from the mechanical

play11:35

switch you can imagine other systems

play11:38

which might make good use of this

play11:39

debouncing effect for example a burglar

play11:42

alarm may be triggered when a window or

play11:44

a door is opened but we don't want the

play11:47

alarm Bell to stop ringing if the

play11:48

burglar shuts the

play11:50

door on its own an Sr lch has a few uses

play11:54

mainly in control applications where we

play11:56

need to monitor some condition that

play11:58

might change or change back again and

play12:00

react

play12:01

accordingly but more importantly as

play12:04

you'll see later the simple Sr lch is

play12:07

the building block of sophisticated

play12:10

memory

play12:12

circuits

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
SR LatchDigital MemoryLogic GatesNOR GateNAND GateCircuit DesignSet ResetControl SystemsSignal DebouncingElectronic CircuitsMemory Storage