You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.1 KiB
Python

import pin
# 一个指令周期
FETCH = [
# 把 pc(当前是0) 的值 输出到偏移地址寄存器中,
pin.PC_OUT | pin.MAR_IN,
# 内存根据上方修改后的偏移地址寄存器找到数据输出到总线上, IR 写入, 给PC 增加1
pin.RAM_OUT | pin.IR_IN | pin.PC_INC,
pin.PC_OUT | pin.MAR_IN,
pin.RAM_OUT | pin.DST_IN | pin.PC_INC,
pin.PC_OUT | pin.MAR_IN,
pin.RAM_OUT | pin.SRC_IN | pin.PC_INC,
pin.SRC_R | pin.DST_IN,
]
MOV = 0 << pin.ADDR_2_SHIFT | pin.ADDR_2
ADD = 1 << pin.ADDR_2_SHIFT | pin.ADDR_2
NOP = 0b0
HLT = 0b11_1111
INSTRUCTIONS = {
2: {
MOV: {
# mov X, 5
(pin.AM_REG, pin.AM_INS): [
# 目的任意寄存器的控制线的编号X, 保存在了DST寄存器中中, 输出到读写控制器控制使X寄存器打开写
pin.DST_W | pin.SRC_OUT,
]
}
},
1: {
},
0: {
NOP: [
pin.CYC,
],
HLT: [
pin.HLT,
]
}
}
if __name__ == "__main__":
print(FETCH)