BASIC Logic Gates - 16 Bit

by mit41301 in Circuits > Electronics

54 Views, 0 Favorites, 0 Comments

BASIC Logic Gates - 16 Bit

SCC.png
14995488.jpg

AND, OR, NOT, NAND, NOR, XOR and XNOR are Basic Logic Gates. We will see how we can easily implement 16 bit array of logic gates in very simple manner.

Supplies

Any calculator(HW or SW) capable of performing 16 bits of logical operations.

Any Intel MCS-51 Single Board Computer running BASIC-52

Input and Output Format

The system can take 16 bit data in either DECIMAL or HEXADECIMAL format. In decimal the number ranges from 0 to 65535 both included. We can just enter the number.

For Hexadecimal numbers the number always ends with "h" or "H" to denote the entry is Hexadecimal. Apart from this we need to enter a "0" if the hexadecimal starts with any of a Alphabet between A~F.

The program prints the output value of the resulted logic operation in hexadecimal. The user can easily change the output format using PH0. to suppress the trailing zero in hexadecimal format or just add or change to "PRINT" for default decimal format.

It is much easier to enter in hexadecimal and get the output in hexadecimal. This will be easy to understand.

AND Gate

10 REM AND GATE
20 PRINT "AND GATE"
40 INPUT "A INPUT = ",A
50 INPUT "B INPUT = ",B
60 Y=A.AND.B
70 PRINT "AND GATE I/O"
80 PRINT " A B Y"
90 PH1. A,B,Y
100 END

The system prompts the user to enter the input A and B. The output is Y.

User can enter Decimal number between 0 to 65535 for both input A and input B. The system computes the ANDed output and print in hexadecimal format.

OR Gate

10 REM OR GATE
20 PRINT "OR GATE"
30 PRINT
40 INPUT "A INPUT = ",A
50 INPUT "B INPUT = ",B
60 Y=A.OR.B
70 PRINT
80 PRINT "OR GATE I/O"
90 PRINT " A B Y"
100 PH1. A,B,Y
110 END

NOT Gate

10 REM NOT GATE
20 PRINT "NOT GATE"
30 PRINT
40 INPUT "A INPUT = ",A
50 REM INPUT "B INPUT = ",B
60 Y=NOT(A)
70 PRINT
80 PRINT "NOT GATE I/O"
90 PRINT " A Y"
100 PH1. A,Y
110 END

NAND Gate

10 REM NAND GATE
20 PRINT "NAND GATE"
40 INPUT "A INPUT = ",A
50 INPUT "B INPUT = ",B
60 Y=NOT(A.AND.B)
70 PRINT "NAND GATE I/O"
80 PRINT " A B Y"
90 PH1. A,B,Y
100 END

NOR Gate

10 REM NOR GATE
20 PRINT "NOR GATE"
40 INPUT "A INPUT = ",A
50 INPUT "B INPUT = ",B
60 Y=NOT(A.OR.B)
70 PRINT "NOR GATE I/O"
80 PRINT " A B Y"
90 PH1. A,B,Y
100 END

XOR Gate

10 REM XOR GATE
20 PRINT "XOR GATE"
40 INPUT "A INPUT = ",A
50 INPUT "B INPUT = ",B
60 Y=A.XOR.B
70 PRINT "XOR GATE I/O"
80 PRINT " A B Y"
90 PH1. A,B,Y
100 END

XNOR Gate

10 REM XNOR GATE
20 PRINT "XNOR GATE"
40 INPUT "A INPUT = ",A
50 INPUT "B INPUT = ",B
60 Y=NOT(A.XOR.B)
70 PRINT "XNOR GATE I/O"
80 PRINT " A B Y"
90 PH1. A,B,Y
100 END