From b26a306cb1455e48737e6056e78dd44e7fc2ee0d Mon Sep 17 00:00:00 2001 From: moyan <1561515308@qq.com> Date: Tue, 7 May 2024 16:50:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPU.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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)