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