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