@@ -16,23 +16,34 @@ import freechips.rocketchip.rocket
1616 a wider AMOALU then replace every output of the old, narrow AMOALU with this wide AMOALU.
1717*/
1818
19+ /* the rocket NBDcache does not really support mask input from the coreside; in stage 2,
20+ * it tries to regenerate the request mask based on the input address and size. this works
21+ * but not for us; the reasons are twofold. first, tilelink requires active byte lanes, so
22+ * the address field is bus-width-aligned, instead of byte-aligned. second, coalescer outputs
23+ * may leave holes in the mask or write a non-power-of-2 number of bytes, so we cannot
24+ * "recover" the rocket-style inputs from the given address/size/mask. thus, we must override
25+ * the mask generation by flopping the input. this presents a challenge with MSHRs when
26+ * requests are replayed. in the original design, the mask for the replayed request is simply
27+ * set to 0, since it will be regenerated on use. we however must store the mask alongside
28+ * the data, which is the purpose of the MaskMSHRFile, and all the additional logic. */
29+
1930class MaskMSHRFile (implicit edge : TLEdgeOut , p : Parameters ) extends MSHRFile {
20- val sdqMask_ = Mem (cfg.nSDQ, UInt (coreDataBytes.W ))
31+ val sdqMask = Mem (cfg.nSDQ, UInt (coreDataBytes.W ))
2132 when (sdq_enq) {
22- sdqMask_ (sdq_alloc_id) := io.req.bits.mask
33+ sdqMask (sdq_alloc_id) := io.req.bits.mask
2334 }
2435
2536 val replay_sdq_addr = RegEnable (replay_arb.io.out.bits.sdq_id, free_sdq)
2637 io.replay.bits.data := sdq(replay_sdq_addr)
27- io.replay.bits.mask := sdqMask_ (replay_sdq_addr)
38+ io.replay.bits.mask := sdqMask (replay_sdq_addr)
2839}
2940
3041class WideNonBlockingDCache (staticIdForMetadataUseOnly : Int )(implicit p : Parameters ) extends NonBlockingDCache (staticIdForMetadataUseOnly) {
3142 override lazy val module = new WideNonBlockingDCacheModule (this )
3243}
3344
3445class WideNonBlockingDCacheModule (outer : NonBlockingDCache ) extends NonBlockingDCacheModule (outer) {
35- // val maskMshrs = Module(new MaskMSHRFile)
46+ val maskMshrs = Module (new MaskMSHRFile )
3647 val wideAmoalu = Module (new AMOALU (wordBits))
3748
3849 when ((s2_valid || s2_replay) && (rocket.isWrite(s2_req.cmd) || s2_data_correctable)) {
@@ -53,8 +64,8 @@ class WideNonBlockingDCacheModule(outer: NonBlockingDCache) extends NonBlockingD
5364
5465 when (s1_clk_en) {
5566 when (s1_write) {
56- s2_req.mask := Mux (s1_replay, mshrs .io.replay.bits.mask, io.cpu.s1_data.mask)
57- s2_req.data := Mux (s1_replay, mshrs .io.replay.bits.data, io.cpu.s1_data.data)
67+ s2_req.mask := Mux (s1_replay, maskMshrs .io.replay.bits.mask, io.cpu.s1_data.mask)
68+ s2_req.data := Mux (s1_replay, maskMshrs .io.replay.bits.data, io.cpu.s1_data.data)
5869 }
5970 when (s1_recycled) {
6071 s2_req.mask := s1_req.mask
@@ -67,40 +78,44 @@ class WideNonBlockingDCacheModule(outer: NonBlockingDCache) extends NonBlockingD
6778 wideAmoalu.io.rhs := s2_req.data
6879
6980 // mshr overrides
70- /* when (maskMshrs.io.replay.valid) {
81+ when (maskMshrs.io.replay.valid) {
7182 s1_req := maskMshrs.io.replay.bits
7283 }
73- mshrs.io.req.valid := s2_valid_masked && !s2_hit && (isPrefetch(s2_req.cmd) || isRead(s2_req.cmd) || isWrite(s2_req.cmd))
74- mshrs.io.req.bits.viewAsSupertype(new Replay) := s2_req.viewAsSupertype(new HellaCacheReq)
75- mshrs.io.req.bits.tag_match := s2_tag_match
76- mshrs.io.req.bits.old_meta := Mux(s2_tag_match, L1Metadata(s2_repl_meta.tag, s2_hit_state), s2_repl_meta)
77- mshrs.io.req.bits.way_en := Mux(s2_tag_match, s2_tag_match_way, s2_replaced_way_en)
78- mshrs.io.req.bits.data := s2_req.data
79- when (mshrs.io.req.fire) { replacer.miss }
80- tl_out.a <> mshrs.io.mem_acquire
81- readArb.io.in(1).valid := mshrs.io.replay.valid
82- readArb.io.in(1).bits.addr := mshrs.io.replay.bits.addr
83- readArb.io.in(1).bits.way_en := ~0.U(nWays.W)
84- mshrs.io.replay.ready := readArb.io.in(1).ready
85- s1_replay := mshrs.io.replay.valid && readArb.io.in(1).ready
86- metaReadArb.io.in(1) <> mshrs.io.meta_read
87- metaWriteArb.io.in(0) <> mshrs.io.meta_write
88- prober.io.mshr_rdy := mshrs.io.probe_rdy
89- mshrs.io.mem_grant.valid := tl_out.d.fire
90- mshrs.io.mem_grant.bits := tl_out.d.bits
91- writeArb.io.in(1).valid := tl_out.d.valid && grant_has_data &&
92- tl_out.d.bits.source < cfg.nMSHRs.U
93- writeArb.io.in(1).bits.addr := mshrs.io.refill.addr
94- writeArb.io.in(1).bits.way_en := mshrs.io.refill.way_en
95- wbArb.io.in(1) <> mshrs.io.wb_req
96- when (s2_nack_hit) { mshrs.io.req.valid := false.B }
97- val s2_nack_victim = s2_hit && mshrs.io.secondary_miss
98- val s2_nack_miss = !s2_hit && !mshrs.io.req.ready
99- uncache_resp.bits := mshrs.io.resp.bits
100- uncache_resp.valid := mshrs.io.resp.valid
101- mshrs.io.resp.ready := RegNext(!(s1_valid || s1_replay))
102- io.cpu.resp := Mux(mshrs.io.resp.ready, uncache_resp, cache_resp)
103- io.cpu.ordered := mshrs.io.fence_rdy && !s1_valid && !s2_valid
104- io.cpu.store_pending := mshrs.io.store_pending
105- io.cpu.replay_next := (s1_replay && s1_read) || mshrs.io.replay_next */
84+ maskMshrs.io.req.valid := s2_valid_masked && ! s2_hit && (isPrefetch(s2_req.cmd) || isRead(s2_req.cmd) || isWrite(s2_req.cmd))
85+ maskMshrs.io.req.bits.viewAsSupertype(new Replay ) := s2_req.viewAsSupertype(new HellaCacheReq )
86+ maskMshrs.io.req.bits.tag_match := s2_tag_match
87+ maskMshrs.io.req.bits.old_meta := Mux (s2_tag_match, L1Metadata (s2_repl_meta.tag, s2_hit_state), s2_repl_meta)
88+ maskMshrs.io.req.bits.way_en := Mux (s2_tag_match, s2_tag_match_way, s2_replaced_way_en)
89+ maskMshrs.io.req.bits.data := s2_req.data
90+ when (maskMshrs.io.req.fire) { replacer.miss }
91+ tl_out.a <> maskMshrs.io.mem_acquire
92+ readArb.io.in(1 ).valid := maskMshrs.io.replay.valid
93+ readArb.io.in(1 ).bits.addr := maskMshrs.io.replay.bits.addr
94+ maskMshrs.io.replay.ready := readArb.io.in(1 ).ready
95+ s1_replay := maskMshrs.io.replay.valid && readArb.io.in(1 ).ready
96+ metaReadArb.io.in(1 ) <> maskMshrs.io.meta_read
97+ metaWriteArb.io.in(0 ) <> maskMshrs.io.meta_write
98+ prober.io.mshr_rdy := maskMshrs.io.probe_rdy
99+ maskMshrs.io.mem_grant.valid := tl_out.d.fire
100+ maskMshrs.io.mem_grant.bits := tl_out.d.bits
101+ writeArb.io.in(1 ).bits.addr := maskMshrs.io.refill.addr
102+ writeArb.io.in(1 ).bits.way_en := maskMshrs.io.refill.way_en
103+ tl_out.e <> maskMshrs.io.mem_finish
104+ wbArb.io.in(1 ) <> maskMshrs.io.wb_req
105+ when (s2_nack_hit) { maskMshrs.io.req.valid := false .B }
106+
107+ val s2_nack_victim_ = s2_hit && maskMshrs.io.secondary_miss
108+ val s2_nack_miss_ = ! s2_hit && ! maskMshrs.io.req.ready
109+ val s2_nack_ = s2_nack_hit || s2_nack_victim_ || s2_nack_miss_
110+ s2_valid_masked := s2_valid && ! s2_nack_ && ! io.cpu.s2_kill
111+ block_miss := (s2_valid || block_miss) && s2_nack_miss_
112+ io.cpu.s2_nack := s2_valid && s2_nack_
113+
114+ uncache_resp.bits := maskMshrs.io.resp.bits
115+ uncache_resp.valid := maskMshrs.io.resp.valid
116+ maskMshrs.io.resp.ready := RegNext (! (s1_valid || s1_replay))
117+ io.cpu.resp := Mux (maskMshrs.io.resp.ready, uncache_resp, cache_resp)
118+ io.cpu.ordered := maskMshrs.io.fence_rdy && ! s1_valid && ! s2_valid
119+ io.cpu.store_pending := maskMshrs.io.store_pending
120+ io.cpu.replay_next := (s1_replay && s1_read) || maskMshrs.io.replay_next
106121}
0 commit comments