-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgates.py
57 lines (42 loc) · 1.01 KB
/
gates.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
from pydantic import BaseModel
class Gate(BaseModel):
def __init__(self, n):
self.label = n
self.output = None
def getLabel(self):
return self.label
def getOutput(self):
self.output = self.performGateLogic()
return self.output
class UnaryGate(Gate):
def __init__(self, n):
super().__init__(n)
self.pin = None
self.label = self.getLabel()
x = UnaryGate(1)
# class Base:
# def __init__(self, a: bool, b: bool = None):
# self.a, self.b = a, b
# class Not(Base):
# def __init__(self):
# if self.a:
# self.out = False
# else:
# self.out = True
# class And(Base):
# def __init__(self):
# return a * b
# class Or(Base):
# def __init__(self):
# return a + b
# class Nand(Base):
# def __init_(self):
# return Not(bool(a + b))
# class Nor:
# def __init_(self):
# pass
# class Xnor:
# pass
# x = Not(True)
# print(x.out)