-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitOperation.py
25 lines (15 loc) · 968 Bytes
/
bitOperation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Module to do all the bit operations"""
from Input import Input #Importing class Input from Input.py
i = Input() #Creating an instane of class Input
i.userInput() #Calling the userInput() function of class Input
class bitOperation:
def operate(self): #The function operate() takes a parameter self so that when an instance is created of a class, the variables can be called by the instance
self.carry = 1
self.xorGate = i.a ^ i.b
self.andGate1 = i.a & i.b
self.andGate2 = self.carry & self.xorGate
self.nandGate = ~self.andGate2
self.orGate = self.carry | self.xorGate
self.ansAndGate = self.orGate & self.nandGate
self.norGate = ~(self.andGate1 | self.andGate2)
self.carry = ~self.norGate