LogicBlocks Experiment Guide

Pages
Contributors: jimblom
Favorited Favorite 2

Introduction

So you've read through the LogicBlocks introductory tutorial (or the kit's included documentation), and are ready for some experiments!? Time to put those LogicBlocks to use!

XNOR circuit

You'll be building big ol' LogicBlock circuits like this XNOR in no time!

Table of Contents

Here's a breakdown of the experiments we'll be exploring in this guide:

  1. 2-Input AND Gate
  2. 3-Input AND Gate
  3. NANDs, NORs, and De Morgan's Laws
  4. Combinational Logic
  5. Ring Oscillator
  6. SR Latch
  7. 2-to-1 Multiplexer
  8. 1-to-2 Decoder (De-multiplexer)
  9. XOR Gate
  10. Beyond LogicBlocks...

Each experiment includes a schematics, and matching LogicBlock layouts for the circuit under test.

alt text

alt text

There are also smatterings of truth tables, state diagrams, and boolean equations throughout each experiment. And they're all capped off with challenges, questions, and sub-experiments. To get the most out of each experiment, make sure you check out the sub-experiments!

1. 2-Input AND Gate

The first experiment starts off as simple as possible: a dual-input, single output AND gate.

What You'll Need

  • 1x AND Block
  • 2x Input Blocks
  • 1x Power Block

Circuit Diagram

AND Gate Circuit

LogicBlock Layout

Nothing too fancy here. An Input Block should be inserted into each of the AND Block's inputs. Then plug the Power Block into the output of the AND Block.

2-Input AND Gate LogicBlocks

The blue LED on the AND Block will indicate the output status of the circuit.

The Experiment

Try all four possible input combinations: 0/0, 0/1, 1/0, and 1/1. Remember, this is what the AND gate's truth table should look like:

Input AInput BOutput
000
010
100
111


  • Does the blue AND block LED light up as you'd expect?

Sub-Experiments

While we're here, let's discuss the other two fundamental gates. A two-input OR and a single-input NOT.

Two-Input OR Gate

2-input OR

Can you lay out the fundamental, two-input OR gate with LogicBlocks? It'll require a similar set of blocks to the AND:

OR gate LogicBlocks

After experimenting with that, can you complete this truth table for the OR?:

Input AInput BOutput
00
01
10
11


Two-Input NOT Gate

Now do the same thing with the NOT gate.

Not gate circuit symbol

This time you'll only need one Input Block:

NOT gate LogicBlocks

Can you complete the NOT truth table?

Input AOutput
01
10



Now that you've got a handle of the three, fundamental logic gates, let's add some inputs! Onto the next experiment...

2. 3-Input AND Gate

Sometimes you need to AND more than two inputs together. In fact, 3- and 4-input AND gates are just as common as the dual-input variety. Let’s make a 3-input AND gate out of two two-input AND gates.

What You'll Need

  • 3x Input Blocks
  • 2x AND Blocks
  • 1x Power Block

Circuit diagram

Three-input AND Circuit

LogicBlock layout

Start by building the 2-input AND block from the last experiment, but plug the output of that into the input of another AND. Then add an Input Block to the second AND's second input.

3-Input AND

Complete the circuit by adding a Power Block to the output of the second AND.

The blue LED on the second AND gate represents the output of this circuit.

The Experiment

With three total inputs, how many different input combinations can you make? 8! This number grows exponentially at 2n, where n is the number of inputs. So, a 4-input AND gate has 16 possible combinations, 5 inputs would be 32 outputs, and so on.

Try all possible input combinations and fill out the truth table below:

Input AInput BInput COutput Y
000
001
010
011
100
101
110
111


  • Can you think of a situation in real life where three requirements must be met before an outcome becomes true?
  • If you had more AND blocks, can you imagine what a 4-input AND block might look like?

Sub-Experiments

Try using two OR gates and three Input Blocks to create a 3-input OR gate.

3-input OR

  • Draw a schematic diagram for this circuit.
  • Write out a truth table for this circuit. Like the 3-input AND circuit, this circuit will have 8 possible sets of input. But there should be a lot more 1's on the output column!

3. NANDs, NORs, and DeMorgan's Laws

NAND -- in other words NOT AND or negated AND -- is what you get when you place an inverter at the output of an AND gate. NAND gates are very popular in the world of digital logic. They’ve even got their very own circuit symbol, an AND gate with a “bubble” at the output:

NAND gate

Let's make one with LogicBlocks!

What You'll Need

  • 1x AND Block
  • 1x NOT Block
  • 2x Input Blocks
  • 1x Power Block

LogicBlocks Layout

This layout is similar to the setup from experiment 1, with the addition of a NOT gate between the AND Block output and the Power Block.

NAND LogicBlocks

The output of this circuit is represented by the red LED on the NOT gate.

The Experiment

Two inputs means four possible input combinations. Try them all and fill out the 2-input NAND gate's truth table:

Input AInput BOutput
000
010
100
111


  • How does that compare to the truth table of the AND gate?

Sub-Experiments

You can also negate an OR gate to create a NOR:

NOR LogicBlock

Which also has its own "bubbled" circuit symbol:

NOR gate

  • What does the 2-input NOR gate's truth table look like?

DeMorgan's Law

All of this NAND and NOR discussion has me itching to discuss De Morgan's Law! De Morgan's Law allows us to convert NANDs to OR, and NORs to ANDs. There are two parts to De Morgan's Law:

  1. A 2-input NAND is equivalent to OR-ing two inverted inputs. In boolean equation terms:

  2. A 2-input NOR is equal to AND-ing two inverted inputs. Or, in boolean terms:

Prove it yourself! Build the circuit below with your LogicBlocks, and compare the truth table you filled out for the NAND gate with the truth table for this circuit -- two inverted inputs running into an OR gate.

Two inverters running into an OR

Are the truth tables the same? You've just verified the first part of DeMorgan's law!

Now, you might be asking: "what's the point?" Well, a big part of digital logic is simplifying the circuit, and using a few gates as possible. Thanks to De Morgan's Law, we can use a NAND gate to stand in for all of the other gates.

For example, a NOT can be made out of a NAND by simply tying one the inputs permanently high:

Making a not out of NAND

Or use three NAND gates to make an OR:

Making an OR out of NANDs

Or use two NANDs to make an AND:

Making an AND out of NANDs

The versatility of NAND gates makes them truly magical!

4. Combinational Logic

The circuits in the previous experiments have all been examples of combinational logic circuits. In combinational circuits the output depends exclusively on the current state of the inputs. The circuit flows in one direction, from the inputs (traditionally) on the left, to the outputs on the right.

The opposite of combinational logic is sequential, in which a circuit's current output will affect its future outputs. But we'll get to that in later experiments.

Here's an example of a combinational logic circuit we can build with LogicBlocks:

example combinational circuit

Given the input names shown in the circuit diagram (A and B feeding into the AND gate, C goes through the first NOT gate), we can form a boolean equation like this:

equivalent boolean equation

The output is the negation of ((A and B) or not C) (not the order of operations!). Let's build the above circuit with LogicBlocks!

What You'll Need

  • 1x AND Block
  • 1x OR Block
  • 2x NOT Blocks
  • 3x Input Blocks
  • 1x Power Block

LogicBlock Layout

The output of an AND Block with two Input Blocks should be connected to one input of an OR Block. The other input of the OR Block should be connected to a NOT Block, which has an Input Block feeding into it. Finally, the output of the OR Block should feed into another NOT block, which is connected to a Power Block.

combinational logicblock circuit

The output of this combinational logic circuit is represented by the red LED on the final NOT Block.

The Experiment

Try all eight possible input combinations and fill out this circuit's truth table:

Input AInput BInput COutput Y
000
001
010
011
100
101
110
111


  • Does that jive with the equation from above?
  • Have another look at that equation, or even the schematic. Recognizing the NANDs and NORs, could the equation be simplified by using De Morgan's Laws? Yes! First, push that inverter into the OR gate to turn it into a NOR:

simplifying with demorgan part 1

Then apply De Morgan's law: push the bubble through the NOR gate - turning that gate into an AND - and through to create NOT gates on both inputs:

simplifying with demorgan's part 2

The two NOT gates on the C input would cancel each other out, so just get rid of them both. The NOT gate on the first AND's output can be pushed onto the gate to create a NAND gate:

simplifying with demorgan's part 3

We've completely eliminated the OR gate! Would you believe that this circuit produces the same truth table as the circuit at the beginning of this experiment? Try it out for yourself:

simplified circuit

Sub-Experiments

  • The next experiment takes a pretty giant leap from combinational to sequential logic. At this point, we'd really encourage you to just play around with the LogicBlocks, create your own circuits. Then try to draw out a circuit diagram, and a truth table.
  • Are there any real-life scenarios you could imagine solving with digital logic?

5. Ring Oscillator

An oscillator is a circuit whose output periodically and repetitively fluctuates. Oscillators are a critical part of most electronic circuits; they're used to create anything from a clock to radio waves. There are a variety of circuits that can create oscillation, you can use op amps, crystals, 555 timers, and, of course, logic gates!

By stringing an odd number of NOT gates together, and introducing feedback -- looping the output of the last inverter back to the input of the first -- we can create a ring oscillator. Let's LogicBlock it!

What You'll Need

  • 3x NOT Blocks
  • 1x Splitter Block
  • 1x Feedback Cable
  • 1x Power Block

Circuit Diagram

This circuit introduces a concept we've only briefly mentioned so far: sequential circuits. Unlike combinational circuits, the output of a sequential circuit depends on previous output states.

Here is the circuit for a ring oscillator:

ring oscillator circuit

See how the output of third and final NOT gate splits into two directions? The first goes straight out to the output, like we're used to, but it also loops back into the input of the the first NOT gate. This is called feedback -- a term almost synonymous with sequential circuits. The current state of the output depends on what it was doing in the past.

LogicBlock Layout

First link up three NOT gates and plug the third into a Splitter Block. Use the Feedback Cable to connect one of the Splitter Block outputs to the input of the first NOT gate. Finally, plug the Power Block into the second output of the Splitter Block.

ring oscillator LogicBlock

The output of this circuit is represented by the red LED on the third and final NOT block.

The Experiment

What does the truth table look like for this circuit? Wait. Does it even have a truth table? There aren't any inputs! Instead of a standard truth table, we can create a state table that defines the value of the current output as dependent on the previous output:

Previous OutputCurrent Output
01
10


  • Does the number of inverters have to be odd? What happens if there are an even number of inverters? Try removing one of them.
  • Can you calculate how fast the LED on the final NOT Block is blinking? Each block has a delay of about 1 second. What effect would increasing the number of inverters to 5 have on the blinking rate of the output?

Sub-Experiments

In some cases it may be handy to have an enable input on your oscillator. Enable inputs -- commonly found in many digital logic circuits -- control the overall operation of the circuit. When the enable input is set to 1, the circuit operates as normal, but when its set to 0 the circuit's operation is halted.

We can add an enable input to the ring oscillator by introducing an AND gate. Have a look at this circuit diagram:

ring oscillator with enable

Build it by plugging an AND Block into the first NOT gate (removing the feedback cable). Then plug the male end of the feedback cable into one of the AND Block's inputs, and an Input Block (our enable) into the other input.

Now flip the switch on the enable input to see how it affects the output of the oscillator.

What would the state table look like now?

EnablePrevious OutputCurrent Output
00
01
10
11


6. SR Latch

A latch (also called a flip-flop) is a fundamental component of data storage. A single latch can hold 1-bit of data, increase that number by many orders of magnitude and you can create kilo-, mega-, giga-, even tera-bytes of memory. Of course, like most digital circuits, latches are made out of digital logic gates!

There are many different kinds of latches, all with somewhat cryptic names like SR, D, JK, and T. The SR-latch we'll be experimenting with is one of the most fundamental forms of a latch.

There are a few ways to make an SR latch. Here’s an example of a NOR SR latch:

SR latch circuit

Notice the feedback? This is another sequential logic circuit. The two NOR gates each have their output flow into the input of the other. There are two controllable inputs: reset (R) and set (S), which produce the two outputs: Q and Q ("Q-not"). That's where the SR latch get's its name -- it's a set/reset latch.

The SR latch comes with a rule, which cannot ever be broken: Q must always be the opposite of Q. These outputs are called complements. In our application Q is the only output we really care about -- that's where the latch's data is usually stored and retreived -- but it's important to observe that the two outputs are opposites.

An SR latch is so important it even gets its very own circuit symbol:

SR latch symbol

Here is the state table, which is a bit wonky. Because the circuit is sequential, the current value of Q depends on its previous state:

SRPrevious QCurrent QCurrent Q
0000 (no change)1
0011 (no change)0
0100 (no change)1
01101
10010
1011 (no change)0
1100 (Restricted, Q and Q would not be complements)0
1110 (Restricted, Q and Q would not be complements)0


Put into words, the output, Q, can be in any of the following states:

  • Steady: When S and R are both 0, then Q remains steady. It keeps the value it had before. If it was 0 it'll remain 0, if it was 1 it will still be 1.
  • Set: Changing S to 1 has the potential to "set" the output of Q. If Q was 0, changing S to 1 will change Q to 1 as well. If Q was already 1, making S=1 will have no effect.
  • Reset: Moving the R input from 0 to 1 can "reset" Q. As long as Q was 1, setting R to 1 will change Q to 0. If Q was already 0, though, R won't have any effect on it.
  • Restricted: When both S and R are 1, we enter restricted territory: our rule that Q and Q must be complements is broken, as they both go to 0. So we call S=1/R=1 a restricted combination. In most latch circuits precautions are taken to keep those inputs from both being 1. Our LogicBlock circuit isn't quite that smart, so you'll need to take the "circuit safety" precautions into your own hands to make sure they're never both 1 (don't worry, the universe should survive the contradiction if you set both inputs high).

We can also use a state diagram to document the possible states of Q:

SR latch state diagram

Enough conceptual stuff. Let's lay out the SR latch with LogicBlocks!

What You'll Need

  • 2x OR Blocks
  • 2x NOT Blocks
  • 2x Input Blocks
  • 1x Splitter Block
  • 1x Feedback Cable
  • 1x Power Block

LogicBlock Layout

Construct the LogicBlock circuit like below:

SR latch LogicBlock

In our mind, we need to assign names to both inputs. One should be R (reset) the other should be S (set). Because the circuit is symmetric, it doesn't matter which input we call which, but the name of the input will affect which output is which.

There are two outputs to keep an eye on in this circuit; both are indicated by the red LEDs on the NOT gates. The NOT gate coming out of the OR gate with S as its direct input indicates the Q output. Our Q output is indicated by the red LED on the NOT gate fed by the OR gate with R as its input.

The Experiment

Give this series of steps a try, and observe both Q and Q outputs.

  1. We need an initial state to start us off. Begin by setting both S=0 and R=0.
  2. Now, set R=1. Q should "reset", if it wasn't already 0, it will become 0. If Q already was 0, it will stay there. Obeying our rule, Q should be 1.
  3. Set R=0. Nothing should change on Q or Q. They hold steady.
  4. Set S=1. Now Q should 'set' and go high, while Q goes low.
  5. Set S=0. There shouldn't be any effect on Q or its complement.
  • Can you see how this might work as a piece of memory? Imagine a single bit of data being stored in the Q output!
  • Try entering the restricted state by setting both S and R to 1. Q and Q should both be 0; our complement rule has been broken! To avoid this from happening safeguards will usually be placed on the inputs (in the form of more logic gates!), which will convert the restricted combination to an allowed input value.

Sub-Experiments

You can also make a latch out of NAND gates. Just swap the ORs with ANDs. Too keep the names of the inputs in line with the outcome they produce, we also swap the S and R inputs (or Q and Q, depending on how you look at it).

NAND SR latch circuit

And lay it out with Logic Blocks like this (just replace the OR blocks with AND blocks):

NAND SR Latch logicblock

You still have two stable states, but the truth table changes. Write out the state table for the NAND SR latch, and compare it with the NOR SR latch above. Which combination of inputs creates a restricted output in this case?

SRPrevious QCurrent QCurrent Q
000
001
010
011
100
101
110
111


  • Latches are the building blocks of many types of memory, including SRAM (static random access memory). As we've seen, a single latch can store one bit of data. How many latches do you think a piece of 1 Mb (1 million bits) SRAM has? How many NOR gates is that? Zounds!

7. 2-to-1 Multiplexer

A multiplexer (or mux) is a common digital circuit used to mix a lot of signals into just one. If you want multiple sources of data to share a single, common data line, you’d use a multiplexer to run them into that line. Multiplexers come in all sorts of shapes and sizes, but they’re all made out of logic gates.

Every multiplexer has at least one select line, which is used to select which input signal gets relayed to the output. In a 2-to-1 multiplexer, there’s just one select line. More inputs means more select lines: a 4-to-1 multiplexer would have 2 select lines, an 8-to-1 has 3, and so on (2n inputs requires n select lines).

Think of a mux as a "digital switch". The select line is the throw on the switch, it chooses which of the many inputs get to be the output.

Here’s how you might make a 2-to-1 multiplexer out of logic gates. A and B are the two inputs, X is the select input, and Y is the output.

multiplexer schematic

Here's what a truth table would look like for such a circuit:

Select Input (X)Input AInput BOutput Y
0000
0010
0101
0111
1000
1011
1100
1111


LogicBlock time!

What You'll Need

  • 2x AND Blocks
  • 1x OR Block
  • 1x Inverter Block
  • 1x Splitter Block
  • 3x Input Blocks
  • 1x Feedback Cable
  • 1x Power Block

LogicBlocks Layout

Follow the layout below to create a 2-to-1 multiplexer (Hint: pay more attention than we did to matching up the + and − labels!):

multiplexer logicblock layout

We'll need to internally label each of the inputs. The selector input (X) is the lonely input running into the NOT gate. The remaining two inputs are our A and B, which you can arbitrarily name as you wish.

The output of this multiplexer is indicated by the yellow LED on the OR gate.

The Experiment

Give this order of operations a try:

  1. Initial state: set all three inputs to 0. The output should be 0.
  2. Flip A to 1. Nothing should happen to the output, since, with the selector switch set to 0, the B input is being fed into the output.
  3. Toggle the B input to 1. Observe the output, and set B back to 0. The output should follow your toggling on B!
  4. Switch the selct to 1. The output should now follow the A input, and it won't care what B is set to.
  • Is this circuit combinational or sequential? (Don't let the "Feedback" cable fool you!)
  • Can you imagine what a 4-to-1 multiplexer might look like? It'd require double the inputs lines -- two selectors and four possible inputs. Here's a (color-coded) schematic for a 4-to-1 multiplexer:

A 4-to-1 demux requires four 3-input ANDs, four NOTs, and one 4-input OR. This circuit allows us to choose to send either A, B, C, or D into the X output. X0 and X1 do the selecting.

  • How many gates do you think a 8-to-1 multiplexer might require?

8. 1-to-2 Decoder (De-Multiplexer)

The opposite of a multiplexer is a de-multiplexer, also called a demux or decoder. A demux allows a single input line to be passed through to multiple output lines, again using a select line to choose which output the input goes to.

The schematic for a 2-to-1 demultiplexer looks like this:

2-to-1 demux schematic

There are two inputs (X and A) and two outputs Y1 and Y2. X is our selector input, it decides which of the two outputs the A input is routed to. When X is 0, the output at Y2 mirrors A (while Y1 will always be 0). When X is 1, the A input is routed to Y1.

The demultiplexer becomes really handy when we have limited outputs available in our system and we need to interface with many many input devices.

What You'll Need

  • 2x AND Blocks
  • 2x NOT Blocks
  • 2x Input Blocks
  • 2x Splitter Blocks
  • 1x Power Block
  • 1x Feedback Cable

LogicBlocks Layout

Construct the LogicBlocks circuit as shown below. Use the feedback cable to simply extend the output of one splitter (you'll need to fuss with it a bit to fit it into both blocks).

DeMux LogicBlocks

In this LogicBlock circuit, our selector input (X) is represented by the Input Block that runs into the NOT Block. The only remaining input is our A input.

The two outputs are each represented by the blue LEDs on each of the AND gates. Y1 is the AND Block without the Power Block attached.

The Experiment

Give this order of operations a try:

  1. Flip the selector input (X) to 0. Then try toggling the A input both high and low. Only one of the AND Blocks should change, and it should be the same value as the input.
  2. Flip the X input to 1. Again toggle A a few times. Now the other AND gate should be keeping pace with A.
  • Can you imagine what a larger demux might look like? Here's an example circuit for a 2-to-4 decoder:

This circuit has two selector inputs (X0 and X1) which route our input (A) to one of the four outputs.

  • Compare the 2-to-4 decoder to a 4-to-1 multiplexer (from the last experiment). How do they differe?
  • Can you imagine what a circuit for a 3-to-8 decoder might look like?

9. XOR Gate

Up till now, you've been happily living in a world with just three fundamental logic gates. It's time to shatter that perception! Prepare for the revelation that is...the exclusive OR.

An exclusive OR, shortened to XOR, is similar to an OR gate with one major difference. Can you tell from the truth table?:

Input AInput BOutput
000
011
101
110


When we say exclusive, we mean it. An XOR only produces a 1 when a lone input is also 1. If two or more inputs are 1, the XOR gate outputs a 0.

It turns out the XOR gate is an incredibly useful function in digital logic. So useful, in fact, that it gets its own circuit symbol -- kind of a modified OR gate, with a concave line preceding the gate we're used to:

XOR Gate

Like all of the previous experiments, the XOR gate can be implemented with the three fundamental digital logic gates. A mix of NOTs, ANDs, and an OR:

XOR circuit

Let's LogicBlock it!

What You'll Need

  • 2x AND Blocks
  • 1x OR Block
  • 2x NOT Blocks
  • 2x Input Blocks
  • 2x Splitter Blocks
  • 1x Power Block
  • 1x Feedback cable

LogicBlocks Layout

Construct the XOR as shown below:

XOR Logicblocks

The output of the XOR LogicBlocks circuit is represented by the yellow LED on the final OR gate.

The Experiment

Prove the XOR truth table true by toggling both inputs. The LED on the OR block should only light up when you have one or the other of the inputs on.

  • Is the XOR a combinational or sequential circuit?
  • Can you think of a real life example where a statement is true if only one of the inputs is also true?

Sub-Experiments

Remember NAND and NOR? Well XOR has it's own complement...XNOR. Like the other two negative gates, XNOR has its own bubbled circuit diagram:

XNOR symbol

The truth table for the 2-input XNOR looks like this:

Input AInput BOutput
001
010
100
111


What's really neat about the XNOR is it only proves true when both inputs are the same. That's why we call this operator the logical equality. You could even use the equals sign (=) as the XNOR operator. The equality operator is used all over electronics and programming. If you ever need to check if two statements are equal, an XNOR will be involved.

Hey we've got another NOT Block lying around, let's make an XNOR LogicBlocks circuit! Replace the Power Block with a NOT Block, and plug the Power Block into the end of that.

XNOR logicblocks

The output of this circuit is represented by the red LED on the final NOT Block.

  • Try toggling both Input Blocks. Does the output LED only illuminate when they're both equal?

Logic Beyond LogicBlocks...

These experiments have barely covered the tip of the proverbial iceberg. We've discovered a lot of fundamental electronics building blocks, but there are many left to uncover. Unfortunately, with the standard kit we've run out of blocks. Here are a few of the foundational circuits and concepts we'd be remiss if we didn't discuss:

Adders

Adders are actual circuits (as opposed to the snakes) that add numbers, and they're built with logic gates! A half-adder is the most simple adder circuit there is. It adds two bits together and has two outputs: the sum (S) and a carry (C). As you can see, the circuit isn't all that complicated:

adder circuit

The sum of the two bits is just their XOR, and if both A and B are 1 we generate a carry output.

More complete adders, called full-adders, also have a carry input. These circuits can be strung together in long chains to create a multi-bit binary adder.

Most processors have a block of circuitry within them called an arithmetic logic unit (ALU), where all of the addition, subtraction, multiplication, and division operations are performed. The ALU houses hundreds of adder circuits (among others), and links them to create enormous 32- or 64-bit adders.

Flip-Flops (Latches)

We talked about flip-flops in the SR Latch experiment, but we only glossed over the importance of these circuits. The SR latch we made is one of the more simple latches in electronics. We can modify the SR latch to create a D latch:

D latch circuit

Notice the SR latch in there? The D latch has two inputs -- data (D) and enable (E). As long as the enable input is 1, the Q output will be whatever D is. If enable goes low, Q will retain its set value regardless of what the data input does.

Another popular latch is the JK latch. This latch is also based on the SR latch, but it modifies that "illegal" set of inputs (the one where Q and Q were equal) to instead toggle the current output. Here's how the JK latch is built:

JK latch circuit

The truth table for a JK latch looks something like this:

JKPrevious QCurrent Q
0000 (hold state)
0011 (hold state)
01X (don't care)0 (reset)
10X1 (set)
1101 (toggle)
1110 (toggle)


Now, let's turn that JK latch into a JK flip-flop. Flip-flops are usually created by adding a clock input to a latch. A flip-flop with a clock input will usually only perform an operation on the rising edge of a clock signal. The clock input can be used in many ways, for instance multiple flip flops can be synchronized by sharing a clock input. By replacing those 2-input AND gates with a 3-input variety, we can add a clock input to the JK flip-flop:

JK flip-flop circuit

Now, the JK flop-flop will only produce a new output when the clock input is high. This gives us a bit more control over the operation of the flip-flop.

The JK flip-flop will come in handy in the next section...counters.

Counters

Adders add and counters count. Counters are a key element in most processors, especially in timing applications. Your digital clock has to count seconds somehow, right?

A really simple counter can be created by linking together numerous JK flip-flops. If multiple JK flip-flops are all set to constantly toggle (J=K=1), and we link the output of one flip-flop to the input of the next, we can create an asynchronous ripple counter. Here's how we might make a 3-bit ripple counter out of JK flip-flops:

Ripple counter

Q0, Q1, and Q2 are our three outputs; Q0 the least-significant bit, Q2 most. With three bits, this circuit can count all the way from 0 to 7 in binary. We can apply a periodic clock to the initial clock input, and begin the counting. Every rising edge on the clock leads to an increment on the counter. Since we've hooked up the complemented output from one JK to the clock input of the next, the Q outputs will toggle whenever the previous one falls.

Counter timing diagram

This 3-bit counter will overflow at 7, but adding more flip-flops will increase the upper limit by powers of 2 (n flip-flops count to 2n-1), so we'd need 20 flip-flops to count above 1 million.

There are other types of counters, but this is a good example built with logic circuits that aren't actually all that far-stretched from what we've learned so far.

7400 Series Logic Chips

If you're looking for somewhere to go after LogicBlocks, we'd recommend looking into 7400 series logic chips. The 7400s are a huge range of integrated circuits (ICs) that implement all sorts of digital logic functions. You can find quad-NAND gates, along with a variety of other standard digital logic gates. In fact, the chips on the LogicBlock Gate blocks are 7400-series parts -- little single-circuit SMD versions.

7400N Chip

Flip flops, counters, multiplexers, decoders, all sorts of other circuits we've covered in this tutorial are implemented in a 7400 series chip. Even more complicated circuits like entire 4-bit ALUs, memories, comparators...seriously, it's a pretty long list, check this out.

Most 7400 series chips come in a breadboard-friendly DIP package, like the 3-to-8 decoder below (74238). So you can experiment and explore without having to actually solder anything.

74328 Guts

If you still can't get enough digital logic, CPLDs (compact programmable logic devices) or even FPGAs (field programmable gate array) would be the next step. They represent a giant leap in complexity from even the 7400 series chips, but those ICs can pack thousands of configurable digital logic circuits into a tiny space. There's a lot of digital logic out there for you to explore, but I hope the LogicBlocks have been a good introduction.

Resources and Going Further

Congratulations on making it all the way through the Experiments Guide! Hopefully, by now, you're much more comfortable with your knowledge of digital logic, ANDs, ORs, NOTs, XORs, multiplexers, oscillators, and then some. If you ever need a refresher on digital logic, you can always check out our digital logic tutorial.

If you're not sure where to go from here, here are some more SparkFun tutorials we'd encourage you to check out!

  • Resistors, Capacitors, Diodes, and Switches are just a handful of component-specific tutorials we have. If you're eager to learn about other fundamental electronics components, these tutorials are a good place to start!
  • What is an Arduino? -- Arduino is a hyper-popular microcontroller development platform driven to be as easy-to-use as possible. The heart of the Arduino is a microcontroller -- a tiny computer -- that has millions of logic gates inside.
  • Shift Registers -- Shift registers are incredibly useful IC's that can switch a wide array of inputs or outputs, with just a few control lines. Plus, they're completely built out of digital logic!
  • Hexadecimal -- If you're on a math kick, and comfortable with binary, take some time to learn about hex.