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.
|
|
|
MSR = 1
|
|
|
|
MAR = 2
|
|
|
|
MDR = 3
|
|
|
|
RAM = 4
|
|
|
|
IR = 5
|
|
|
|
DST = 6
|
|
|
|
SRC = 7
|
|
|
|
A = 8
|
|
|
|
B = 9
|
|
|
|
C = 10
|
|
|
|
D = 11
|
|
|
|
DI = 12
|
|
|
|
SI = 13
|
|
|
|
SP = 14
|
|
|
|
BP = 15
|
|
|
|
CS = 16
|
|
|
|
DS = 17
|
|
|
|
SS = 18
|
|
|
|
ES = 19
|
|
|
|
VEC = 20
|
|
|
|
T1 = 21
|
|
|
|
T2 = 22
|
|
|
|
|
|
|
|
MSR_OUT = MSR
|
|
|
|
MAR_OUT = MAR
|
|
|
|
MDR_OUT = MDR
|
|
|
|
RAM_OUT = RAM
|
|
|
|
IR_OUT = IR
|
|
|
|
DST_OUT = DST
|
|
|
|
SRC_OUT = SRC
|
|
|
|
A_OUT = A
|
|
|
|
B_OUT = B
|
|
|
|
C_OUT = C
|
|
|
|
D_OUT = D
|
|
|
|
DI_OUT = DI
|
|
|
|
SI_OUT = SI
|
|
|
|
SP_OUT = SP
|
|
|
|
BP_OUT = BP
|
|
|
|
CS_OUT = CS
|
|
|
|
DS_OUT = DS
|
|
|
|
SS_OUT = SS
|
|
|
|
ES_OUT = ES
|
|
|
|
VEC_OUT = VEC
|
|
|
|
T1_OUT = T1
|
|
|
|
T2_OUT = T2
|
|
|
|
|
|
|
|
|
|
|
|
_DST_SHIFT = 5
|
|
|
|
|
|
|
|
|
|
|
|
MSR_IN = MSR << _DST_SHIFT
|
|
|
|
MAR_IN = MAR << _DST_SHIFT
|
|
|
|
MDR_IN = MDR << _DST_SHIFT
|
|
|
|
RAM_IN = RAM << _DST_SHIFT
|
|
|
|
IR_IN = IR << _DST_SHIFT
|
|
|
|
DST_IN = DST << _DST_SHIFT
|
|
|
|
SRC_IN = SRC << _DST_SHIFT
|
|
|
|
A_IN = A << _DST_SHIFT
|
|
|
|
B_IN = B << _DST_SHIFT
|
|
|
|
C_IN = C << _DST_SHIFT
|
|
|
|
D_IN = D << _DST_SHIFT
|
|
|
|
DI_IN = DI << _DST_SHIFT
|
|
|
|
SI_IN = SI << _DST_SHIFT
|
|
|
|
SP_IN = SP << _DST_SHIFT
|
|
|
|
BP_IN = BP << _DST_SHIFT
|
|
|
|
CS_IN = CS << _DST_SHIFT
|
|
|
|
DS_IN = DS << _DST_SHIFT
|
|
|
|
SS_IN = SS << _DST_SHIFT
|
|
|
|
ES_IN = ES << _DST_SHIFT
|
|
|
|
VEC_IN = VEC << _DST_SHIFT
|
|
|
|
T1_IN = T1 << _DST_SHIFT
|
|
|
|
T2_IN = T2 << _DST_SHIFT
|
|
|
|
|
|
|
|
|
|
|
|
SRC_R = 1 << 10 # 读取 SRC 寄存器中的值, 这个值是寄存器编号
|
|
|
|
SRC_W = 1 << 11
|
|
|
|
DST_R = 1 << 12
|
|
|
|
DST_W = 1 << 13
|
|
|
|
|
|
|
|
PC_WE = 1 << 14
|
|
|
|
PC_CS = 1 << 15
|
|
|
|
PC_EN = 1 << 16
|
|
|
|
|
|
|
|
|
|
|
|
PC_OUT = PC_CS
|
|
|
|
PC_IN = PC_CS | PC_WE
|
|
|
|
PC_INC = PC_CS | PC_WE | PC_EN
|
|
|
|
|
|
|
|
_OP_SHIFT = 17
|
|
|
|
|
|
|
|
OP_ADD = 0 << _OP_SHIFT
|
|
|
|
OP_SUB = 1 << _OP_SHIFT
|
|
|
|
OP_INC = 2 << _OP_SHIFT
|
|
|
|
OP_DEC = 3 << _OP_SHIFT
|
|
|
|
OP_AND = 4 << _OP_SHIFT
|
|
|
|
OP_OR = 5 << _OP_SHIFT
|
|
|
|
OP_XOR = 6 << _OP_SHIFT
|
|
|
|
OP_NOT = 7 << _OP_SHIFT
|
|
|
|
|
|
|
|
ALU_OUT = 1 << 20
|
|
|
|
ALU_PSW = 1 << 21
|
|
|
|
|
|
|
|
|
|
|
|
CYC = 1 << 30 # 当前指令周期 清零, 执行下一个指令周期
|
|
|
|
HLT = 1 << 31 # 停止
|
|
|
|
|
|
|
|
ADDR_2 = 1 << 7 # 2指令标志 1xxx[aa][bb]
|
|
|
|
ADDR_1 = 1 << 6 # 1指令标志 01xxxx[aa]
|
|
|
|
|
|
|
|
ADDR_2_SHIFT = 4 # 指令需要左移4位 留出来操作数位
|
|
|
|
ADDR_1_SHIFT = 2
|
|
|
|
|
|
|
|
AM_INS = 0b00 # 立即数 0x5
|
|
|
|
AM_REG = 0b01 # 寄存器 a
|
|
|
|
AM_DIR = 0b10 # 立即数寻址 [0x5]
|
|
|
|
AM_RAM = 0b11 # 寄存器间接寻址 [a]
|
|
|
|
|
|
|
|
|