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

15 lines
489 B

def fowardingunit(rs1,rs2,ex_mem_rd,mem_wb_rd,ex_mem_regwrite,mem_wb_regwrite):
if rs1!=0 and rs1==ex_mem_rd and ex_mem_regwrite:
forward_a='01'
elif rs1!=0 and rs1==mem_wb_rd and mem_wb_regwrite:
forward_a='10'
else:
forward_a='00'
if rs2!=0 and rs2==ex_mem_rd and ex_mem_regwrite:
forward_b='01'
elif rs2!=0 and rs2==mem_wb_rd and mem_wb_regwrite:
forward_b='10'
else:
forward_b='00'
return forward_a,forward_b