EE lab track, module 8

Combinational and sequential logic

Graded digital logic labs: find a gate from its truth table, build a half adder and a 2-to-1 multiplexer, divide a clock with a D flip-flop, count to ten.

On the syllabus

  • Truth tables and the six two-input gates
  • The half adder: sum and carry
  • The 2-to-1 multiplexer
  • The D flip-flop and divide-by-two
  • Counters: the CD4017 decade counter

You will be able to

  • Read a truth table off a timing diagram and name the gate.
  • Build a half adder and a multiplexer from gates.
  • Use a D flip-flop to divide a clock, and predict the output frequency.
  • Measure a decade counter’s output period and pulse width.

The first challenge is free. The rest, the viva and the certificate are part of Pro, and everything is here to read.

Graded challenges

Values like 4.7k, 100n or 2.2u are fine. Readings are the number only, in the unit shown. Every check measures the simulation, not a bench: ideal parts within their models, no noise.

1. Name the gate from its truth table

A truth table lists the output for every input combination. Each of the six two-input gates has its own pattern, so four rows are enough to name it.

FormulaCount the rows that give 1, then see which ones they are

Worked exampleA table of 1, 0, 0, 0 for 00, 10, 01, 11 is high only when both inputs are 0: that is NOR. A table of 1, 1, 1, 0 is NAND.

On the scope or meterThe LED lights on the rows that give 1. The check reads each row at a set time in the first 10 ms.

Your task

Two clocks drive gate G1: A at 200 Hz and B at 100 Hz. Both start low, so in the first 10 ms the inputs run through 00, 10, 01 and 11.

Set G1’s function so its output follows this table: 00 gives 0, 10 gives 1, 01 gives 1, 11 gives 0. An LED shows the output.

    Your design

    It is checked for

    • Y is 0 at 1 ms
    • Y is 1 at 3 ms
    • Y is 1 at 6 ms
    • Y is 0 at 8 ms

    2. Build a half adder

    Adding two one-bit numbers gives a two-bit result: a sum bit and a carry bit. 0 + 0 = 00, 0 + 1 = 01, 1 + 0 = 01, 1 + 1 = 10.

    FormulaA + B = (carry, sum)

    Worked exampleIn decimal, 7 + 5 = 12: you write 2 and carry 1. In binary, 1 + 1 works the same way: write 0, carry 1.

    On the scope or meterTwo LEDs read as a binary number. With both inputs high only the carry LED is on.

    Your task

    The same two clocks are the bits A and B. Gate G1 makes the sum bit and gate G2 the carry bit, each with an LED.

    Set both gates so that A + B appears on the two LEDs: carry and sum, as a two-bit binary number.

      Part of Pro. Read it all here. The trial has no card, and module 1 and the first challenge of every module stay free.

      Your design

      It is checked for

      • Sum is 0 at 1 ms
      • Sum is 1 at 3 ms
      • Sum is 1 at 6 ms
      • Sum is 0 at 8 ms
      • Carry is 0 at 1 ms
      • Carry is 0 at 3 ms
      • Carry is 0 at 6 ms
      • Carry is 1 at 8 ms

      3. Finish a 2-to-1 multiplexer

      A multiplexer is a switch made of logic. Each data input gets a gate that only lets it through when its select condition is true; a final gate joins the two paths. Writing it as products added together is called a sum of products.

      FormulaY = (A · S̄) + (B · S)

      Worked exampleWith S = 0, the B path is blocked and the A path passes A, so Y = A. With S = 1 the paths swap and Y = B.

      On the scope or meterThe LED follows the fast clock A for the first 5 ms, while S is low, then the slower clock B for the next 5 ms.

      Your task

      Three clocks: A at 400 Hz, B at 200 Hz and the select line S at 100 Hz, so 10 ms holds all eight rows.

      G1 is wired as NOT S (a NAND with both inputs on S). G2 combines A with NOT S, G3 combines B with S, and G4 combines G2 and G3 into the output Y.

      Set G2, G3 and G4 so Y follows A while S is 0 and B while S is 1.

        Part of Pro. Read it all here. The trial has no card, and module 1 and the first challenge of every module stay free.

        Your design

        It is checked for

        • Y is 0 at 0.6 ms
        • Y is 1 at 1.85 ms
        • Y is 0 at 3.1 ms
        • Y is 1 at 4.35 ms
        • Y is 0 at 5.6 ms
        • Y is 0 at 6.85 ms
        • Y is 1 at 8.1 ms
        • Y is 1 at 9.35 ms

        4. Divide a clock with a D flip-flop

        A D flip-flop copies D to Q on each rising clock edge. Feed QN back to D and every edge flips Q. Q goes through one full cycle every two clock cycles.

        Formulaf(Q) = f(clock) / 2

        Worked exampleAn 800 Hz clock gives Q at 400 Hz. Two flip-flops in a chain give 200 Hz: each stage halves it again.

        On the scope or meterQ is a square wave at half the clock rate, changing only on rising clock edges.

        Your task

        A 74HC74 D flip-flop has its QN output wired back to D, so it toggles on every rising clock edge. An LED shows Q.

        Set the clock so Q runs at 250 Hz: one cycle every 4 ms, within 2%.

          Part of Pro. Read it all here. The trial has no card, and module 1 and the first challenge of every module stay free.

          Your design

          Hz

          It is checked for

          • Q makes one cycle every 4 ms

          5. Read a decade counter

          A CD4017 has ten outputs and moves a single high from one to the next on each clock. Q0 is high for one clock out of every ten.

          FormulaPeriod(Q0) = 10 / f(clock), width = 1 / f(clock)

          Worked exampleAt a 500 Hz clock each clock lasts 2 ms, so Q0 comes back every 20 ms and stays high for 2 ms.

          On the scope or meterShort pulses on Q0 with long gaps between them: one high and nine lows.

          Your task

          A CD4017 decade counter is clocked at 1 kHz. Its outputs Q0 to Q9 go high one at a time, one clock each. An LED shows Q0.

          Put the scope on Q0. Measure the time between its pulses and how long each pulse lasts, both in milliseconds.

            Part of Pro. Read it all here. The trial has no card, and module 1 and the first challenge of every module stay free.

            Your readings

            ms
            ms

            Viva questions

            The questions an examiner asks at the bench. 75% passes; every answer comes with why.

            Part of Pro. Read it all here. The trial has no card, and module 1 and the first challenge of every module stay free.

            1. Which gates are called universal, and why?

            2. What is De Morgan’s theorem for NOT (A AND B)?

            3. What is the difference between combinational and sequential logic?

            4. When does an edge-triggered D flip-flop copy D to Q?

            5. How many flip-flops does a counter need to count from 0 to 99 in binary?

            6. What are setup time and hold time?

            7. What does a ripple counter do that a synchronous counter does not?

            8. Why must unused CMOS inputs never be left floating?