Exercise 3.1: Basics of Latches

You are not logged in.

Please Log In for full access to this page.

1) Introduction to Sequential Logic

So far, everything you learnt about Logic Gates and the circuits with them, comes under the umbrella of Combinational Logic. This is because the outputs of such circuits are dependent only on the current inputs. There are no memory elements involved.

Let's try to understand this difference with a simple example:

  • Push Button (Combinational): You press it, the light is ON. You let go, the light is OFF. It has no memory of the past.
  • Toggle Switch (Sequential): You press it once, it stays ON. It "remembers" its state until you interact with it again.

To figure out what the next output will be, the current state (previous output) has to be known. In this section, you'll learn how to design circuits that can store bits. Let's begin with the most fundamental block—the Latch.

2) Hardware Setup: The 7400 IC

Before we analyze the theory, let's prepare our breadboard. We will be using the 7400 Quad 2-Input NAND Gate IC.

Pinout of 7400 IC

Components Needed:

  • 1x 7400 IC (NAND Gates)
  • 2x Push Buttons (for Set/Reset)
  • 2x LEDs (Red and Green)
  • Resistors (330Ω for LEDs, 10kΩ for pull-up/down)

Important Wiring Note: The 7400 IC contains four separate NAND gates.

  • Gate 1: Pins 1, 2 (Inputs), 3 (Output)
  • Gate 2: Pins 4, 5 (Inputs), 6 (Output)
  • Gate 3: Pins 9, 10 (Inputs), 8 (Output)
  • Gate 4: Pins 12, 13 (Inputs), 11 (Output)
  • Power: Pin 14 (VCC +5V), Pin 7 (GND)

3) The "Memory" Circuit: SR Latch

We are about to build the most fundamental memory unit in a computer: the Latch. Unlike the circuits you saw before, this one has a superpower: it can remember what you did even after you stop doing it.

If you look closely at the wires in the diagrams below, you'll see a trick. The output of the Top Gate is connected to the input of the Bottom Gate, and vice versa. This is called Feedback.

The Golden Rule for this Circuit:
We are using NAND gates. To understand them without a headache, just remember this one rule:

"If a NAND gate sees a 0 (white wire) at ANY input, it immediately forces its output to 1 (blue wire)."

Phase 1: Turning it ON (The "Set" Action)

Let's say the light is currently OFF. We want to turn it ON and make it stay ON. To do this, we use the Top Switch.

Step 1: Initial Off State 1. Starting State (OFF) The LED is OFF. Both switches are in their normal resting position (sending 1). The circuit is quiet.
Step 2: Pressing Top Switch 2. We Press Top Switch We flip the Top Switch to 0.
Remember the Golden Rule: The Top Gate sees a 0, so it MUST output a 1.
The LED turns ON!
Step 3: Releasing Switch 3. We Release the Switch We let go of the switch (it goes back to 1).
Magic happens here: The LED stays ON. The circuit has "latched" onto the data.

Wait, how did it remember? Look at Step 2 again. When the Top Gate turned ON (Output 1), it sent that "1" down to the Bottom Gate. The Bottom Gate saw two 1s, so it outputted a 0. That 0 traveled back up to the Top Gate. So, even when we released the switch in Step 3, that "feedback 0" from the bottom was still there, holding the Top Gate open.


Phase 2: Turning it OFF (The "Reset" Action)

Now the light is stuck ON. To turn it OFF, we need to break the loop using the Bottom Switch.

Step 1: Currently On 1. Starting State (ON) The LED is currently ON from our previous action. The loop is holding it there.
Step 2: Pressing Bottom Switch 2. We Press Bottom Switch We flip the Bottom Switch to 0.
Golden Rule again: The Bottom Gate sees a 0, so it forces its output to 1.
Step 3: Releasing Switch 3. We Release the Switch This "1" from the bottom travels up. The Top Gate now sees two 1s, which makes it output a 0.
The LED turns OFF and stays OFF.

In the NAND-based SR latch described above, what happens if both inputs (Set and Reset) are kept at '1' (High)?

4) Adding a "Guard": The Enable Pin

Our previous latch was like a light switch that anyone could flip at any time. But in a real computer, we don't want memory changing randomly. We want it to change only when we say "Ready!" To fix this, we add a Guard at the front door. In electronics, we call this the Enable Pin.

Hardware Implementation: We do this by using the remaining two gates on your 7400 IC (Gates 3 and 4) as the "Guard" gates. Their outputs will feed into the inputs of your previous SR Latch.

A Happy Side Effect: The Logic Flipped!
Remember how the previous latch was "backwards" (Active Low)? Because we added another layer of NAND gates, the logic got inverted again (Not(Not(A)) = A).

Now, everything is intuitive:
  • To turn it ON, you send a 1 to the Set pin.
  • To turn it OFF, you send a 1 to the Reset pin.

5) Scenario 1: The Guard is Awake (Enable is ON)

Let's look at how this works when the middle switch (Enable) is turned ON (set to 1). This opens the gate, allowing our Set and Reset buttons to work.

Setting the Latch 1. Turning it ON (Set) Enable is 1. We flip Top Switch to 1.
The first Top NAND gate sees two 1s, so it outputs a 0. This 0 goes to the inner latch, forcing the LED ON.
Holding the State 2. Memory Mode We turn off the Top Switch.
The inner latch does its job and remembers the "ON" state. The LED stays lit even though we stopped pushing the button.
Resetting the Latch 3. Turning it OFF (Reset) Enable is 1. We flip Bottom Switch to 1.
The first Bottom NAND gate sees two 1s, so it outputs a 0. This 0 hits the inner latch, forcing the LED OFF.

6) Scenario 2: The Guard is Asleep (Enable is OFF)

Now, let's see exactly why this "Guard" (Enable Pin) is so powerful. We are going to try to change the memory while the Guard is asleep (Enable = 0).

Locked in ON state 1. The "Shield" is Up Start Point: The Memory is ON.
The Guard (Enable) is 0.
The guard blocks the door. The inner circuit holds the light ON safely.
Inputs Changing but Ignored 2. Attempting a Reset (Ignored) We flip the bottom switch to Reset (1) to try and turn the light off.
Result: NOTHING!
Since Enable is 0, the signal is blocked. The memory ignores us and stays ON.

If the Enable pin is set to 0 (LOW), what effect does pressing the Set button have on the output?


7) Scenario 3: Waking the Guard (The Pulse)

So, our Reset button didn't work because the door was locked. To make the change happen, we need to quickly open the door. This is called a Pulse.

Enable is ON, Reset happens 3. The Guard Wakes Up We flip the Enable switch to 1.
Instantly, the logic flows through.
The Reset signal (1) is finally allowed in. The inner latch flips, and the LED turns OFF.
Locked in OFF state 4. Locked Safely Again We flip Enable back to 0.
The gate closes. The memory is now protected again, but this time it remembers the new "OFF" state.

8) The Heartbeat: Connecting the Clock

Manually flipping an Enable switch every time we want to save data is tedious. In real computers, we don't want a human operating the guard. We want it to happen automatically.

Recall the Clock Signal from Counters. It is a steady, repeating beat of HIGH (1) and LOW (0).

If we connect this Clock Signal directly to our Enable Pin, we get a Synchronous Latch.

  • Tick (Clock High): The Guard wakes up. The Latch is transparent—it accepts new inputs.
  • Tock (Clock Low): The Guard sleeps. The Latch is locked—it holds the last value safely.

9) The Problem: "The Open Door"

Connecting a Clock to a Latch creates a hidden danger called Transparency. When the Clock is HIGH, the guard leaves the door wide open. If the clock speed is slow, that door stays open for a long time.

The Open Door Scenario

Imagine you are trying to take a group photo (saving data).
  • The Latch Way (Level Triggered): You leave the camera shutter open for a full second. If people move around during that second, your photo becomes a blurry mess. The output keeps changing as long as the shutter (Clock) is open.

10) The Solution: The Flip-Flop

To fix this chaos, we need a device that takes a snapshot the exact instant the clock ticks. This brings us to the distinction between Latches and Flip-Flops.

Feature Latch (What we built so far) Flip-Flop (The next step)
Trigger Level Triggered
Responds as long as Clock is HIGH.
Edge Triggered
Responds only at the instant the Clock goes from Low → High.
Analogy Like Video Recording. Like a Camera Snapshot.
Symbol Usually a plain rectangle. Rectangle with a small Triangle on the Clock pin.

Learn and make your own D-Flip-Flop in Next section

What is the primary difference between a Latch and a Flip-Flop?

11) Final Project: Build a Gated Latch

For your final submission in this section, you will wire up the Gated SR Latch using your 7400 IC on the breadboard.

Instructions:

  1. Wire the 4 NAND gates as shown in the logic diagrams above.
  2. Use a Push Button for the Enable pin.
  3. Connect an LED (Red) to the main output (let's call it Q).
  4. Connect a second LED (Green) to the other output of the inner latch (let's call it Q' or Q-bar).

Experiment: Set the Latch to ON. Then Set it to OFF. Watch both LEDs.

Observe the two LEDs (Q and Q'). What is the relationship between them?

Upload a short video (15-20s) showing your Gated Latch working. Show that the Set/Reset buttons ONLY work when you hold down the Enable button!
 No file selected

In the next section, we will take this circuit and transform it into a D-Flip Flop, the building block of modern counters!