Initial Commit

This commit is contained in:
2022-03-26 11:21:46 +02:00
commit da7b8cb1ed
124 changed files with 66228 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
from Source.Pre_Built_Gates.Power import Power
class ROM32K:
def __init__(self,a,file_path) -> None:
self.a=a
self.file_path=file_path
self.out=[Power(False) for _ in range(16)]
self.memory=[]
self.loadROM(self.file_path)
self()
def __call__(self) -> None:
instuction=self.memory[self.bool_to_int(self.a)]
for i in range(16):
self.out[i].out=instuction[i]
def loadROM(self,file_path):
f=open(file_path,"r")
for _ in range(32768):
line=f.readline()
self.memory.append([line[j]=="1" for j in range(16)])
f.close()
def bool_to_int(self,a):
x=0
for i in range(14,-1,-1):
x+=a.out[i].out*(2**(14-i))
return x