Files
Python-Computer/Source/Components/Boolean_Arithmetic/HalfAdder.py
T
2022-03-26 11:21:46 +02:00

15 lines
446 B
Python

from Source.Pre_Built_Gates.And import And
from Source.Logic_Gates.Xor import Xor
from Source.Pre_Built_Gates.Power import Power
class HalfAdder:
def __init__(self,a,b) -> None:
self.a=a
self.b=b
self.out=[Power(False),Power(False)]
self()
def __call__(self) -> None:
bit_sum=Xor(self.a,self.b)
carry=And(self.a,self.b)
self.out[0].out=bit_sum.out
self.out[1].out=carry.out