1. Home
  2. Explore
  3. Computer Science
  4. Logic Gates and Circuits

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Logic Gates and Circuits

Speaker 1Speaker 2

Logic Gates and Circuits

5:28
0:00-5:28
  1. Anna

    Today we’re looking at four basic logic gates—AND, OR, XOR, and NOT—and then we’ll combine them into a circuit. Each gate takes one or more input bits, applies a simple rule, and produces an output bit.

  2. Michael

    A bit can be zero or one, so the key is to learn the rule for each gate. Once you know those rules, you can work through a bigger circuit one step at a time.

  3. Anna

    Let’s begin with AND. It takes two inputs, and its output is one only when both inputs are one. In the input order zero-zero, zero-one, one-zero, and one-one, the outputs are zero, zero, zero, and one.

  4. Michael

    So if either input is zero, AND gives us zero. That’s a useful way to remember it: both inputs have to meet the condition for the output to turn on.

  5. Anna

    OR is less strict. It outputs one if at least one input is one. For those same four input pairs—zero-zero, zero-one, one-zero, and one-one—the outputs are zero, one, one, and one.

  6. Michael

    The only time OR gives zero is when both inputs are zero. And notice that when both inputs are one, OR still gives one.

  7. Anna

    XOR means exclusive OR. It gives one when exactly one input is one, but gives zero when the inputs match. Its outputs for zero-zero, zero-one, one-zero, and one-one are zero, one, one, and zero.

  8. Michael

    That last case is the important difference from ordinary OR. OR accepts one or both inputs being one; XOR accepts exactly one.

  9. Anna

    NOT is different because it takes just one input. It flips the bit: zero becomes one, and one becomes zero. You may see it drawn as a triangle with a small circle at its output; that circle marks the inversion.

  10. Michael

    The other gates have their own diagram shapes, and drawing styles can vary. In the style we’re using, AND has a flatter input side and a curved output side; OR has a more curved, crescent-like outline. XOR resembles OR, with an extra curved line by the inputs.

  11. Anna

    Now let’s put gates together. A gate’s output is itself a bit, so it can become the input to another gate. That lets us build a circuit in layers: calculate the first gates, feed their results into the next gates, and keep going until we reach one final output.

  12. Michael

    Here’s the example circuit from the lesson. It starts with eight input bits and four bottom-level gates: an AND, an XOR, an OR, and another AND. The outputs of the first pair go into another AND, while the outputs of the second pair go into an OR.

  13. Anna

    Those two results then feed an XOR. Finally, that XOR’s output goes into a NOT gate. So the whole circuit produces one final bit, but we can find it by evaluating each layer in order.

  14. Michael

    Let’s test all zeros. Each bottom gate receives zero and zero, so each produces zero—including the XOR, which gives zero when its inputs match. The next AND receives zero and zero and gives zero; the next OR also receives zero and zero and gives zero.

  15. Anna

    Then the upper XOR gets zero and zero, so it outputs zero. The final NOT flips that zero to one. So, for this circuit, eight zero inputs produce a final output of one.

  16. Michael

    Now try all ones. The bottom AND outputs one, the bottom XOR outputs zero, the OR outputs one, and the other AND outputs one. That gives the next-level AND inputs of one and zero, so it outputs zero; the next-level OR receives one and one, so it outputs one.

  17. Anna

    The upper XOR now receives zero and one, so it outputs one. The final NOT flips that to zero. All ones therefore produce a final output of zero.

  18. Michael

    That step-by-step approach is the main skill: don’t try to evaluate the whole drawing at once. Write the output beside each gate, then use those results as inputs to the next layer.

  19. Anna

    A truth table can help when you’d rather calculate on paper. For any gate with two inputs, list every possible pair in a consistent order: zero-zero, zero-one, one-zero, and one-one. Then write the gate’s output beside each pair.

  20. Michael

    For example, an AND truth table has outputs zero, zero, zero, one in that order. An OR table has zero, one, one, one, and an XOR table has zero, one, one, zero. For NOT, there’s just one input, so the two rows are zero mapping to one and one mapping to zero.

  21. Anna

    For a larger circuit, organize the work hierarchically. Start with the gates closest to the original inputs, record their outputs, and then use those values to evaluate the next level. You can add columns for each gate’s result so you don’t have to redo earlier steps.

  22. Michael

    A complete truth table for the whole example would need every possible combination of its eight input bits. That’s 256 rows, which is why it can be more practical to work through particular inputs or build the calculation up in stages.

  23. Anna

    And whatever method you use, keep the gate rules straight: AND requires both ones, OR requires at least one, XOR requires exactly one, and NOT flips its input. With those rules and a bottom-up process, even a chain of gates becomes manageable.

  24. Michael

    That’s the foundation: understand each gate, connect outputs to later inputs, and evaluate the circuit one layer at a time. A truth table gives you a structured way to check the possibilities, while a diagram makes the flow of the computation easy to follow.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent