When we work with computers, we deal with digital rather than analog circuits. They are electrical circuits that operate with two values: true and false, or yes and no.
Computers only work with those two values, usually referred to as bits. A bit is a single value that is either true or false.
We combine 8 bits into bytes and create combinations to solve a variety of problems. But how does that work?
First we need to rephrase the problem in a way that a digital circuit (e.g. a computer) can work with it. For example we can rephrase the problem “Can I play computer games today?” to “Do I have nothing else on my schedule?”
That is a “yes/no” question, so a digital circuit can answer it . Now we need to think of how we would represent a “yes” and a “no” answer.
Let’s say we use a single light - if it turns on, we can play and if it doesn’t, we can’t play.
The digital circuit to answer our question could be a battery, the light and a switch. It might need a resistor, too so that the voltage through the light isn’t too high.
We can use the switch to input the answer to our question and the circuit will show us if we can play:
|Schedule free?||Switch||LED||Can we play computer games?|
Here is a working version of our digital circuit:
We were thinking about batteries, resistors and so on, instead of the logic. To focus on the logic we can leave all those out and focus on the logic only.
Here is the same circuit in the logical circuit schematic:
The previous digital circuit was not very interesting, but pretty simple. Let’s think of a circuit solving a more complex problem.
We want to build a circuit that can answer if somebody can take the company car or not. Let’s rephrase it as a few yes/no questions:
We can see that question number four only matters, if the answer to question number 3 was “no”. We could rephrase this as “The answer to question three OR four needs to be yes”.
Now that we broke the problem down into yes/no questions, we can design our digital circuit.
We can represent all questions with switches. When answers one, two and five and at at least one of the questions three and four are yes we can turn the light on. In any other case the light will be off. Our circuit will look like this:
To explain the circuit, we can look at the questions again:
|Old enough?||Drivers licence?||Employee?||alternative: Permission?||Car free?||Result|
|no||doesn’t matter||doesn’t matter||doesn’t matter||doesn’t matter||No|
Looking at the table, we can formulate it this way: If Q3 OR Q4 are answered “yes” AND all other questions are answered “yes”, we can take the company car.
The logical circuit is a lot less cluttered and represents the logic well:
In the logic circuit above, you see an input that is either “1” (“yes”, on) or “0” (“no”, off) for each question. This is where we put our answers in.
The answers for Q3 and Q4 go into a kind of switch that only outputs true (“yes”), if at least one of the inputs is true. Then, this output and all the other questions go into a switch that only outputs true (“yes”), if all inputs are true.
These two switches are so-called gates, in this case they are an OR and AND gate.
Transistors or combinations of transistors represent logical gates in an electric circuit. That’s why the amount of transistors that fit into a processor matters.
More transistors = more gates = more things done in a single step.
Now we know how real digital circuits and digital logical circuits work. We have also seen that they behave identical and we can express a digital circuit as a logical one and vice versa.
Logical circuits and real circuits are useful for different situations:
When programming, we care less about the electrical circuits.
In the next section we will discuss logic and operators on our values
false. So read on to learn about boolean logic in the next section.