diff --git a/CPU.py b/CPU.py index 8e5ce6e..ca63b20 100644 --- a/CPU.py +++ b/CPU.py @@ -2,6 +2,7 @@ import queue from Memory import Memory from error import * import pathlib +import warnings import program import importlib @@ -27,7 +28,7 @@ class Core: for file in pathlib.Path("ASM").iterdir(): if file.is_dir(): continue - + if str(file).split('.')[-1] not in ['py', 'pyc', 'pyd', 'so']: continue module = "ASM." + file.name.split(".")[0] @@ -37,7 +38,7 @@ class Core: def loadProgram(self, code): # 加载程序至cmdMemroy - self.cmdMemory.write_batch(0,code) + self.cmdMemory.write_batch(0, code) def fetchInstruction(self): # 取指令 @@ -58,7 +59,7 @@ class Core: # 执行指令 if instruction is None: return False # 程序已执行完毕,返回False - + lists = instruction.split(" ") # 解析指令 @@ -74,9 +75,9 @@ class Core: return False else: return True - + else: - + raise InvalidInstruction(instruction) def run(self): @@ -89,6 +90,7 @@ class Core: class MultiCoreCPU: def __init__(self, num_cores, registers, dt_memory, cmd_memory_size=-1): + warnings.warn("该类型CPU有BUG") self.cores = [] self.programs = queue.Queue(maxsize=num_cores)