bne instruction in cpu simulator not working
I am trying to write a cpu simulator. But, it doesnt seem to function as
expected when bne instruction is encountered. bne performs the same as
bqe. bqe seems to be working fine though:
Mux2_32(mbranchAddress, pcPlus4, branchAddress, AND2_1(zero, branch));
Mux2_32(pc, mbranchAddress, jumpAddress, jump);
if(!strcmp(opcode, "000101")&& !strcmp(branch, "1")){ /*bne instruction,
("000101" is the opcode for bne)*/
Mux2_32(mbranchAddress, pcPlus4, branchAddress, AND2_1(NOT_1(zero), branch));
Mux2_32(pc, mbranchAddress, jumpAddress, jump);
}
"branch" is the flag raised when the instruction is a branch instruction.
zero is the single bit alu output
MUX2_32(a, b, c, d) works as follows: a=b if d=0 a=c if d=1
where a, b and c are 32 bits long and d is a single bit.
Could someone please point out why beq instruction works fine but bne
doesn't. Thanks
No comments:
Post a Comment