punk@1: import RegFile::*; punk@1: import RWire::*; punk@1: import ProcTypes::*; punk@1: punk@1: //----------------------------------------------------------- punk@1: // Register file module punk@1: //----------------------------------------------------------- punk@1: punk@1: interface BRegFile #(type index_t, type data_t); punk@1: method Action upd(index_t addr, data_t data); punk@1: method data_t sub(index_t addr); punk@1: endinterface punk@1: punk@1: module mkBRegFile(RegFile#(index_t, data_t)) punk@1: provisos (Bits#(index_t, size_index), punk@1: Bits#(data_t, size_data), punk@1: Eq#(index_t), punk@1: Bounded#(index_t) ); punk@1: punk@1: RegFile#(index_t, data_t) rf <- mkRegFileWCF(minBound, maxBound); punk@1: RWire#(Tuple2#(index_t, data_t)) rw <-mkRWire(); punk@1: punk@1: method Action upd (index_t r, data_t d); punk@1: rf.upd(r,d); punk@1: rw.wset(tuple2(r,d)); punk@1: endmethod punk@1: punk@1: method data_t sub (index_t r); punk@1: case (rw.wget()) matches punk@1: tagged Valid {.wr, .d} : punk@1: return (wr == r) ? d : rf.sub(r); punk@1: tagged Invalid : return rf.sub(r); punk@1: endcase punk@1: endmethod punk@1: punk@1: endmodule