side bar imageside bar imageside bar image navigation navigation navigation navigation navigation

Logic and Latches

Now throughout this you were probably wondering how the processor worked in the first place. Well it as simple as 1 and 0. Yes, it runs off of either on or off. But for this to happen, there needs to be what are called logic gates. They manipulate the 1s and 0s in different ways. Below i'll explain each type, starting with regular gates.

OR

These are the very simple gates. They have 2 inputs and one output. If both inputs are 0, the output is zero, if both inputs are 1, the output is 1. If either input is 1, the output is 1. The chart below each gate I define shows what you call a truth table.

AND

AND gates are essential the opposite of or gates. They only output 1 if both inputs are 1. If you were to put it into code, it would look like:

            if(a == 1 && b==1){
               output = 1;
            }else{
               output = 0;
            }
            


NOT

A not gate is the most simple gate there is. All it does is invert the current. This means if the input is 1, it will output 0. More commonly it is called an inverter due to the fact all it does is invert the current.



Negated and X Gates

These gates are variants on the gates I previously told about. When they are negated, it usually means that they are flipped around, or inverted.



NAND (negated AND)

This is the negated version of an AND gate. It has 2 inputs and one output. It will only output 0 if both inputs are 1. So if both input are 0, it will output 1. If one output is 1 and the other is 0, it will output 1.



NOR (negated OR)

This is the negated version of the OR gate. As an OR, it has 2 inputs and one output. It is pretty much just the opposite of a NAND gate. If both inputs are 0, it will output 1. Anything else and it will output 0.



XOR

The XOR gate is a variant of an OR gate. If the inputs are the same, it outputs 0, if the inputs are different, it outputs 1. So if both inputs are 1, it will output 0. If one input is one while the other is 0, it will output 1.



XNOR

XNOR gates are the opposite of a XOR gate. When both inputs are the same, it outputs 1. If the inputs are different, it will output 0. So if both inputs are 0, 1 will be outputted. If the inputs are 1 and 0, the output will be 0.










INPUTOutput
AB
000
011
101
111

INPUTOutput
AB
000
010
100
111





INPUTOutput
ANOT A
01
10










INPUTOutput
AB
001
011
101
110

INPUTOutput
AB
001
010
100
110

INPUTOutput
AB
000
011
101
110

INPUTOutput
AB
001
010
100
111