Number System and BASIC Logic Gates
by mit41301 in Circuits > Electronics
4 Views, 0 Favorites, 0 Comments
Number System and BASIC Logic Gates
Number system is necessary in this universe. When we want to compute, measure, compare anything we need some representation which should be unique in nature. Basically we need to record or represent the magnitude or used to quantify.
There are SEVEN base units in SI. We need some mechanism to measure and quantify those units.
The representation may be sound in nature like Morse Code or Sensing with fingers like Braile Code. Or it may be light form.
Supplies
Any scientific calculator capable of performing Arithmetic and Logical operations using different base like Binary, Octal or Hexa decimal apart from normal Decimal.
To perform real operation on a 8 bit computer we can use MCS-51 based Single Chip Computer
There is a 8 bit Input/Output port available in the Single Chip Computer. We can use it as read hardware for performing Logic Gates using Switches and LEDs interfaced to PORT1 of the Single Chip Computer. We can use any of the pins for Switch and LED.
BINARY, OCTAL, DECIMAL and HEXA DECIMAL
Humans always use decimal system in daily life. There are few exceptions like Time measurement and angle measurement uses different BASE.
For example counting from 0 to 15 in decimal system is like follows:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
For the same above numbers represented in binary in following sequence
0000,0001,0010,0011,0100,0101,0110,0111,1000,1001,1010,1011,1100,1101,1110,1111
The same 0~15 in decimal represented in OCTAL(BASE 8) as
0,1,2,3,4,5,6,7,10,11,12,13,14,15,16,17
The same 0~15 in decimal represented in HEXA(BASE 16) as
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
We need to focus more on Decimal, Binary and Hexadecimal system. Octal systems were famous when Main Frame computer and human interaction is through Octal based.
To perform any Arithmetic operations, we need two numbers along with a operator.
Apart from this the LOGICAL input and output can be represented just as TRUE or FALSE or just 1 or 0
The logical operation can be any of AND, NAND, OR, NOR, XOR, XNOR and NOT.
The world is always filled with complements. Cold or Hot, Happy or Sorrow, Rich or poor, etc.
There are something which we can not quantify or compare which is Human Feelings like Happy, Joy, Pain, Sorrow, etc., So those human feelings falls under Logical rathen than Arithmetic.
BASIC LOGIC Gates
Similar to Rainbow, Music, SI units, etc., Digital Logic circuits built upto fundamental Logic Gates.
- AND Gate
- OR Gate
- NOT Gate
These are primary Logic Gates. We can derive other logic gates
- NAND
- NOR
- XOR
- XNOR
When we design Logic Gates in paper or computer, we will not worry about the Logic Levels and Voltage.
Logic Input and Output can have the following values.
TRUE = 1 = HIGH
FALSE = 0 = LOW
BASIC LOGIC Gates
In this section we will see how the BASIC performs the Logic Operations. BASIC performs all the logic operation in 16 bit.
First we will see the Truth Table for each gate using minimal configuration. That is two bits for AND, OR and single bit for NOT gate.
- AND Gate
- OR Gate
- NOT Gate
Two Input AND GATE:
The inputs are A, B and the output is Y.
All the possible input combination is represented by line 80 as DATA. For each cycle the program loads different values for A and B and performs the .AND. operation in line number 30. The output is printed as Y.
The code and system output is shown above.
Two Input OR GATE:
The program is same as the AND gate program except the line number 30 which performs .OR. operation here.
Program listing and RUN output are as above.
NOT GATE:
The above is the listing of NOT gate. Compared to AND, OR gate which needs two inputs A,B for NOT gate we need only one input. The input bit can be assigned to 0 or 1 which is declared in line 80.
When we RUN the program, we get the results for the NOT gate as shown above. The NOT gate operation is performed in line number 30. As mentioned above BASIC performs all logical operations as 16 bit data. Since we are considering only one BIT, we need to MASK all the unwanted bits by additional AND operation.
NAND, NOR, XOR, XNOR Gate
NAND GATE:
NOR GATE:
XOR GATE:
The Logical XOR operation performed by line number 30 using .XOR. We can see the output.
XNOR GATE:
The Logical XNOR operation performed by line number 30 using .XOR. followed by NOT operation. We can see the output.
Conclusion
We learned the Binary, Octal, Decimal and Hexa Decimal number system along with the BASIC fundamental Logic gates operation by coding in BASIC-52 using a real 8 bit computer.
In the next Instructable we will see how to perform Logical Operations on 16 bit values using Hexa Decimal values.
All the codes used above is available from my Github