Main content
Course: Computers and the Internet > Unit 2
Lesson 3: Logic gates and circuitsLogic circuits
Computers often chain logic gates together, by taking the output from one gate and using it as the input to another gate. We call that a logic circuit.
Circuits enables computers to do more complex operations than they could accomplish with just a single gate.
The smallest circuit is a chain of 2 logic gates. Consider this circuit:
Inputs A and B first go through an AND gate. Then the output of that gate goes through an OR gate, combined with another input, C.
Now interesting things happen based on which inputs are or .
Let's set everything to on at first - all inputs are or "true":
The output is also or "true", since AND is , and OR is also .
What if we set inputs A and B to off, and keep C on?
In this case, the output is still ! That's because the final step is an OR gate, so it only needs one of the inputs to be on for it to output a .
If you're struggling to figure out what a circuit outputs, try tracing it one gate at a time. Get out a pencil and paper, start on the first gate, write its output over the wire, then look at the next gate. Theoretically, you could figure out the output for a chain of gates that's hundreds of gates long! You probably have more exciting things to do though, so it's a good thing that we typically have computers to do that for us.
🙋🏽🙋🏻♀️🙋🏿♂️Do you have any questions about this topic? We'd love to answer— just ask in the questions area below!
Want to join the conversation?
- What would happen with more complex chains with changing variables? Like an "if" statement changes A variable into what B variable is at that moment. Wouldn't that change an entire logic chain?(11 votes)
- From the author:A circuit that relies on variables is known as a "sequential circuit". Sequential circuits must have a way maintain "state"; to retrieve and updates values in memory.
The diagram in this article shows how a sequential circuit involves both a combinational circuit (what we've learned here) and memory elements:
https://www.tutorialspoint.com/digital_circuits/digital_circuits_sequential_circuits.htm
Just like combinational logic circuits, memory is also often implemented as an electronic circuit (https://en.wikipedia.org/wiki/Memory_cell_(computing)).(7 votes)
- OoOooOooOOooooOOOOooOooooOooooOOOOOO(7 votes)
- How come when A is 1 and B is 0 when it goes through the "and" gate it is 0 and not 1(3 votes)
- The AND gate only outputs 1 when both of its inputs equal 1.(4 votes)
- I understood all of this, but can you make a video or article about doing computation with these logic gates? Like multiplication or division with these?(4 votes)
- AND is a logic operator that outputs a true if both of the values that it inputs are true, and false if both of the values are false. If one input is true and the other is false, the output of the AND (&&) operator is false.(3 votes)
- How can I understand logic gates better?(2 votes)
- In what ways are these chips used? How do programmers recognize and remember all of them?(2 votes)
- Programmers don't actually have to remember what all of the logic circuits and chips do, just that they work reliably to do what they need them to do.
Put more simply, they don't need to know how exactly it works, just that it does work.
Hope this helps! (:(2 votes)
- Hi there, can I ask if I put numeric value of AND like 1 and another one is 0. When reached OR value, I put 1, does it will become 1 or 0?(2 votes)
- an AND gate will only turn on when both inputs are 1
which means the AND output is 0. an OR will be on unless it's inputs are both on, so the output will be 1(1 vote)
- an AND gate leads to an OR gate. The circuit has three inputs (A, B, C) and a single output and the output is 0
and input C is 0
what could be the possible states of inputs A and B?(1 vote) - What's the purpose of having a logic circuit? Wouldn't the outcome always just be the final gate's outcome? So basically you could just input whatever you need for the last gate and that's it... Or am I missing something?(1 vote)