# How does computer chip know what a 0 and a 1 is at base level? [closed]

I know there are some questions answered like this, and I have read them. I still have the same question though.

So from my understanding is that machine code is basically 0's and 1's. There are many switches that basically get turned on and off by when electricity is running through, its on (or is 1) and when no electricity it is off (or is 0).

We upload machine code so that the metal or what ever the chip on the board is comprised off, understands this and 0's and 1's. My question is how does this chip once it is built know to even recognize that we're saying 0's and 1's? How does the chip even know what a 0 or 1 is? How does it know that when switch is on to be assigning 1 to it and vise versa?

I know I cant just take a piece of metal(or what ever the chip is made of) and upload machine code it thinking that it will understand that I am trying to tell it that when switch is on to be assigned 1. How does this work?

This is one site I looked at:

How does a computer recognize 0s and 1s?

The problem is when the explanation gets to "The transistor can be turned on to enable access to the capacitor, either to charge it up and store a 1". So basically electricity goes through and the transistor is on and is charged and then stores a 1. But how does it know what a 1 is? How does it know how to interpret that 1 is associated with electricity charging the capacitor up?

As you can see, these are the questions I have. Any help would be great.

• 'It' doesn't know anything. We define electrical specifications that say (for example) a voltage <0.8V means logic 0, >2.8V means logic 1 and we build circuits that stick to those specifications. I think the term you're looking for is logic levels. Oct 5, 2017 at 3:46
• Ok so logic gates and lets say its >2.8v is 1, how does it get a 1 assigned? It doesn't know anything, I know that, but how does 1 get assigned just because an operator is true or false? I am being very specific. My question is how it 1 being assigned? Electricity goes through and fills up the capacitor and then magically a 1 appears? How is it getting 2.8v? Oct 5, 2017 at 3:52
• I think your question is actually quite vague. What does an operator mean? What are you 'assigning'? Are you talking about DRAM? Oct 5, 2017 at 3:55
• What in the world does "assigned" mean? Who is doing all of this assigning? Oct 5, 2017 at 3:57
• Did you read How is binary converted to electrical signals? Oct 5, 2017 at 4:07

The core of basic computer is comprised of "binary" elements, or flip-flops. Or FF for short. The element has two states, "flip-left", and "flip-right". When the FF flops, "electricity flows" from one side to another in a fast, avalanche-like process, one side assumes high potential (voltage), the other assumes "low" voltage. Either side of FF can be considered as "right output", and all FFs are following this arbitrary convention.

As result, an information gets represented as "low voltage", and "high voltage", both somewhere in between the ground and supplying voltage. It is important to note that these two levels are fairly distinct, they don't have a continuous "analogish" spread of values. That determines the fundamental difference between analog and digital electronics. And the FF can stay in this state as long as the supply voltage is there, unless a special kick is applied so the FF can flip. These "storage elements" can be implemented in several different ways, but the principle is the same - their output assumes either a distinctive "high" level, or "low", with a noticeable gap between these two levels.

Once the levels are defined and distinct, there are elements that can discriminate between these two levels, just like a normal comparator. If a signal is above some threshold between "low" and "high", the result is amplified to "strong high". This would be a simple logical buffer. One can say that the output has "assigned" high level, or "1". Since the power supply usually is limited to certain level, 1.8V, 3.3V, or older 5V, the actual output voltage doesn't go too far, and stays within the same voltage "bin" as in the original flip-flop. So we have a consistency in voltage levels representing "low" and "high", or "0s" and "1s".

If the output gets amplified in opposite direction, it will be called "inverter". The next in complexity is a "gate" that receives two input signals, so a certain combination of them results in "strong output". Look up NOR gate as a fundamental example.

So, a computer logic "knows" which is "0" and which is "1" by sensing the difference between two levels (say, with "buffers" as described above), and flipping other internal FFs into corresponding states if needed/instructed. The actual FFs are a bit more complicated than the one shown at the beginning of Wikipedia article, scroll down to more useful FFs called D-flops. They have "reset" signal allowing to put every FF into (known) initial state, and have "enable" inputs that allow to distribute/latch common signals with discretion.

The rest of a computer is simple - FFs are grouped into registers that are wired to buses of buffers, some functions (a bit more complex than NOR) are designed, clock is ticking, and when instruction codes are fetched from memory (similar kind of flip-flop arrays), sequences of logic operations lead to desired results.

• Actually yes, this makes more sense than the other answers. The flip-flops based on electricity flow is what sold this answer. Thanks so much. Oct 5, 2017 at 19:39
• +1 despite it being a very specific/narrow answer to a very broad question because it seems to address the spirit of the original question. Oct 5, 2017 at 23:01

It doesn't "know" anything, it just does what it does. An "on" transistor conducts, an "off" transistor doesn't. We build patterns out of the electrical components, in such a way that a certain pattern of high and low voltages here results in a different pattern of high and low voltages there a moment later. We call the low voltages 0 and the high voltages 1, but the components don't care what we call them.

We choose a representation of numbers as 0s and 1s, and then we build a circuit so that if we put the representation of a number A here and the representation of another number B here, then the representation of A+B comes out there, and we say that the component is doing addition, but all the electrons know is that they're following a potential gradient.

We hook things up so that when the user presses a button with the picture "7" on it, a collection of wires get high and low voltages forced on them in the pattern that we decided corresponds to the number 7. We hook other things up so that the voltages on another collection of wires light and extinguish small lamps in just the right pattern to make a picture of the number those wires represent. Now we've got ourselves... well, a calculator really, but we're on our way to a computer.

• @BobG. it doesn't. Whatever you're imagining that that sentence means, it doesn't happen anywhere. Oct 5, 2017 at 4:04
• @BobG., You can google and find NAND gate circuit designs for TTL or CMOS very easily. If you want a NAND gate for my backwards logic design, just use the circuit that's normally called a NOR gate. If you want to know how one of these circuits works, you can ask a question about that, but please do some research first. It's very basic information that is found in numerous textbooks and online resources, and we generally don't take answers that rehash extremely well-known material. Oct 5, 2017 at 4:16
• @BobG. Suggested reading: Petzold's Code. :) Oct 5, 2017 at 4:19
• There's no interpretation. The transistors are simply wired in a way that has the behaviour where if you have 5V on both the inputs, the output is connected to GND else, the output is connected to 5V. Look up a diagram of a CMOS/PMOS/NMOS NAND gate if you want to see how the transistors can be wired up to exhibit this behavior. Oct 5, 2017 at 4:38
• @BobG. I think you're almost there. First step is to accept that a a computer can be made out of logic gates. Your next step is to understand how a logic gate works. Research "transistor NAND" gate and you'll see that. Afterwards research how a transistor works and you'll be done. Oct 5, 2017 at 7:18