家庭作业第四章
4.48
取指阶段
icode:ifun = M1[PC] = C:0
rA:rB <= M1[PC+1]
valC <= M4[PC+2]
valP <= PC + 6
译码阶段
valB <= R[rB]
执行阶段
valE <= valB + valC
SetCC
访存阶段
写回阶段
R[rB] <= valE
4.50
取指
bool need_regids =
icode in { IRRMOVL, IOPL, IPUSHL, IPOPL,
IIRMOVL, IRMMOVL, IMRMOVL, IADDL
};
bool need_valC =
icode in { IIRMOVL, IRMMOVL, IMRMOVL, IJXX, ICALL, IADDL
};
译码和写回
int srcA = [
icode in { IRRMOVL, IRMMOVL, IOPL, IPUSHL } : rA;
icode in { IPOPL,IRET } : RESP;
1 : RNONE; # Don’t need register
];
int srcB = [
icode in { IOPL, IRMMOVL, IMRMOVL, IADDL } : rB;
icode in { IPUSHL, IPOPL, ICALL, IRET } : RESP;
icode in { ILEAVE } : REBP;
1 : RNONE; # Don’t need register
];
int dstE = [
icode in { IRRMOVL} && Cnd: rB;
icode in { IIRMOVL, IOPL, IADDL } : rB;
icode in { IPUSHL, IPOPL, ICALL, IRET, ILEAVE } : RESP;
1 : RNONE; # Don’t write any register
];
int dstM = [
icode in { IMRMOVL, IPOPL}:rA;
icode in { ILEAVE }: REBP;
1 : RNONE; # Don’t write any register
];
执行
int aluA = [
icode in { IRRMOVL, IOPL } : valA;
icode in { IIRMOVL, IRMMOVL, IMRMOVL, IADDL} : valC;
icode in { ICALL, IPUSHL}:-4;
icode in { IRET, IPOPL, ILEAVE}:4;
# Other instructions don’t need ALU
];
int aluB = [
icode in { IRMMOVL, IMRMOVL, IOPL, ICALL,IPUSHL, IRET, IPOPL, ILEAVE, IADDL} : valB;
icode in { IRRMOVL, IIRMOVL}:0;
# Other instructions don’t need ALU
];
bool set_cc = icode in { IOPL, IADDL };
访存
int mem_addr = [
icode in { IRMMOVL, IPUSHL, ICALL, IMRMOVL } : valE;
icode in { IPOPL, IRET } : valA;
icode in { ILEAVE } : valB;
# Other instructions don’t need address
];
bool mem_read = icode in { IMRMOVL, IPOPL, IRET, ILEAVE};