1
0

tilelink2 SourceShrinker: handle degenerate cases for free

This commit is contained in:
Wesley W. Terpstra 2016-11-22 22:01:43 -08:00
parent 1e7d597fd3
commit 1d3cad3671

View File

@ -9,6 +9,8 @@ import scala.math.{min,max}
class TLSourceShrinker(maxInFlight: Int) extends LazyModule class TLSourceShrinker(maxInFlight: Int) extends LazyModule
{ {
require (maxInFlight > 0)
private val client = TLClientParameters(sourceId = IdRange(0, maxInFlight)) private val client = TLClientParameters(sourceId = IdRange(0, maxInFlight))
val node = TLAdapterNode( val node = TLAdapterNode(
// We erase all client information since we crush the source Ids // We erase all client information since we crush the source Ids
@ -37,6 +39,10 @@ class TLSourceShrinker(maxInFlight: Int) extends LazyModule
in.c.ready := Bool(true) in.c.ready := Bool(true)
in.e.ready := Bool(true) in.e.ready := Bool(true)
if (maxInFlight >= edgeIn.client.endSourceId) {
out.a <> in.a
in.d <> out.d
} else {
// State tracking // State tracking
val sourceIdMap = Mem(maxInFlight, in.a.bits.source) val sourceIdMap = Mem(maxInFlight, in.a.bits.source)
val allocated = RegInit(UInt(0, width = maxInFlight)) val allocated = RegInit(UInt(0, width = maxInFlight))
@ -67,6 +73,7 @@ class TLSourceShrinker(maxInFlight: Int) extends LazyModule
allocated := (allocated | alloc_id) & ~free_id allocated := (allocated | alloc_id) & ~free_id
} }
} }
}
object TLSourceShrinker object TLSourceShrinker
{ {