Skip to content

Commit

Permalink
fix binding transformer grabbing first stage of pipeline even if that…
Browse files Browse the repository at this point in the history
… one has a stream dependency
  • Loading branch information
mattfel1 committed Aug 23, 2020
1 parent 922a761 commit bf6e4bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/spatial/transform/BindingTransformer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ case class BindingTransformer(IR: State) extends MutateTransformer with AccelTra
val activeWrMems = c.nestedWrittenMems ++ c.nestedWrittenDRAMs
val nextShouldNotBind = (Seq(c.toCtrl) ++ c.nestedChildren).exists(_.s.get.shouldNotBind) | (c.isSwitch && c.op.exists(_.R.isBits))
val prevShouldNotBind = (Seq(lhs.children.apply(i)) ++ lhs.children.apply(i).nestedChildren).exists(_.s.get.shouldNotBind) | (lhs.children.apply(i).s.get.isSwitch && lhs.children.apply(i).s.get.op.exists(_.R.isBits))
val prevStreamShouldNotBind = if (i == 0)
lhs.hasStreamAncestor && (lhs.children.apply(i).nestedWrittenMems ++ lhs.children.apply(i).nestedReadMems).exists{mem => mem.isStreamOut || mem.isFIFO || mem.isMergeBuffer || mem.isFIFOReg || mem.isStreamIn}
else false
val streamShouldNotBind = lhs.hasStreamAncestor && activeMems.exists{mem => mem.isStreamOut || mem.isFIFO || mem.isMergeBuffer || mem.isFIFOReg || mem.isStreamIn}
val breakWhenShouldNotBind = activeMems.exists{m => (Seq(lhs.toCtrl) ++ lhs.ancestors).map(_.breaker).contains(Some(m))}
if (prevMems.intersect(activeMems).intersect(activeWrMems ++ prevWrMems ++ addressableMems).nonEmpty || nextShouldNotBind || prevShouldNotBind || streamShouldNotBind || breakWhenShouldNotBind) {
if (prevMems.intersect(activeMems).intersect(activeWrMems ++ prevWrMems ++ addressableMems).nonEmpty || nextShouldNotBind || prevStreamShouldNotBind || prevShouldNotBind || streamShouldNotBind || breakWhenShouldNotBind) {
dbgs(s"Conflict between:")
dbgs(s" - Prev rd/wr: $prevMems")
dbgs(s" - Next rd/wr: $activeMems")
dbgs(s" - Next wr + Prev wr + addressable: ${prevWrMems ++ activeWrMems ++ addressableMems}")
dbgs(s" - Stream dependency: $streamShouldNotBind")
dbgs(s" - Prev Stream dependency (child #1 only): $prevStreamShouldNotBind")
dbgs(s" - BreakWhen dependency: $breakWhenShouldNotBind")
dbgs(s" - (or someone should not bind next: $nextShouldNotBind prev: $prevShouldNotBind)!")
dbgs(s"Placing $c in group ${bundling.toList.size}")
Expand Down

0 comments on commit bf6e4bc

Please sign in to comment.