parent
b93aa5abb5
commit
bb2fae9bb4
@ -1,14 +1,15 @@
|
||||
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'
|
||||
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'
|
||||
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
|
||||
forward_b = '00'
|
||||
return forward_a, forward_b
|
||||
|
@ -1,6 +1,6 @@
|
||||
def hazard_detector(if_id_rs1,if_id_rs2,id_ex_rd,id_ex_memread):
|
||||
if id_ex_memread and (id_ex_rd==if_id_rs1 or id_ex_rd==if_id_rs2):
|
||||
stall=1
|
||||
def hazard_detector(if_id_rs1, if_id_rs2, id_ex_rd, id_ex_memread):
|
||||
if id_ex_memread and (id_ex_rd == if_id_rs1 or id_ex_rd == if_id_rs2):
|
||||
stall = 1
|
||||
else:
|
||||
stall=0
|
||||
return stall
|
||||
stall = 0
|
||||
return stall
|
||||
|
Loading…
Reference in new issue