-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CreditedIO to support register-register interfacing for AXI4 and TL #2555
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9f070be
CreditedIO: credit/debit-based flow control primitive
terpstra 473bed8
tilelink: add CreditedIO support for TL parameters, bundles, and nodes
terpstra eb3cd5a
tilelink: add adapter hardware for CreditedIO-enabled TileLink
terpstra 83bc01d
axi4: add CreditedIO support for TL parameters, bundles, and nodes
terpstra 375957f
axi4: add Credited adapter hardware
terpstra 07b5c21
diplomacy: add CreditedCrossing as a new crossing type
terpstra 5851fc3
tilelink: add CreditedIO unit tests
terpstra 30a410f
AXI4: add CreditedIO unit tests
terpstra c640b6f
CreditedIO: fix bug when source.valid is high during reset
terpstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// See LICENSE.SiFive for license details. | ||
|
||
package freechips.rocketchip.amba.axi4 | ||
|
||
import chisel3._ | ||
import freechips.rocketchip.config.Parameters | ||
import freechips.rocketchip.diplomacy._ | ||
import freechips.rocketchip.tilelink._ | ||
import freechips.rocketchip.subsystem.CrossingWrapper | ||
import freechips.rocketchip.util._ | ||
|
||
class AXI4CreditedBuffer(delay: AXI4CreditedDelay)(implicit p: Parameters) extends LazyModule | ||
{ | ||
val node = AXI4CreditedAdapterNode( | ||
masterFn = p => p.copy(delay = delay + p.delay), | ||
slaveFn = p => p.copy(delay = delay + p.delay)) | ||
|
||
lazy val module = new LazyModuleImp(this) { | ||
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) => | ||
out.aw :<> in.aw.pipeline(delay.aw) | ||
out.w :<> in.w.pipeline(delay.w) | ||
in.b :<> out.b.pipeline(delay.b) | ||
out.ar :<> in.ar.pipeline(delay.ar) | ||
in.r :<> out.r.pipeline(delay.r) | ||
} | ||
} | ||
} | ||
|
||
object AXI4CreditedBuffer { | ||
def apply(delay: AXI4CreditedDelay)(implicit p: Parameters): AXI4CreditedAdapterNode = { | ||
val buffer = LazyModule(new AXI4CreditedBuffer(delay)) | ||
buffer.node | ||
} | ||
def apply(delay: CreditedDelay)(implicit p: Parameters): AXI4CreditedAdapterNode = apply(AXI4CreditedDelay(delay)) | ||
def apply()(implicit p: Parameters): AXI4CreditedAdapterNode = apply(CreditedDelay(1, 1)) | ||
} | ||
|
||
class AXI4CreditedSource(delay: AXI4CreditedDelay)(implicit p: Parameters) extends LazyModule | ||
{ | ||
val node = AXI4CreditedSourceNode(delay) | ||
lazy val module = new LazyModuleImp(this) { | ||
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) => | ||
val tld = edgeOut.delay | ||
out.aw :<> CreditedIO.fromSender(in.aw, tld.aw.total).pipeline(delay.aw) | ||
out.w :<> CreditedIO.fromSender(in.w, tld.w.total).pipeline(delay.w) | ||
in.b :<> out.b.pipeline(delay.b).toReceiver(tld.b.total) | ||
out.ar :<> CreditedIO.fromSender(in.ar, tld.ar.total).pipeline(delay.ar) | ||
in.r :<> out.r.pipeline(delay.r).toReceiver(tld.r.total) | ||
} | ||
} | ||
} | ||
|
||
object AXI4CreditedSource { | ||
def apply(delay: AXI4CreditedDelay)(implicit p: Parameters): AXI4CreditedSourceNode = { | ||
val source = LazyModule(new AXI4CreditedSource(delay)) | ||
source.node | ||
} | ||
def apply(delay: CreditedDelay)(implicit p: Parameters): AXI4CreditedSourceNode = apply(AXI4CreditedDelay(delay)) | ||
def apply()(implicit p: Parameters): AXI4CreditedSourceNode = apply(CreditedDelay(1, 1)) | ||
} | ||
|
||
class AXI4CreditedSink(delay: AXI4CreditedDelay)(implicit p: Parameters) extends LazyModule | ||
{ | ||
val node = AXI4CreditedSinkNode(delay) | ||
lazy val module = new LazyModuleImp(this) { | ||
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) => | ||
val tld = edgeIn.delay | ||
out.aw :<> in.aw.pipeline(delay.aw).toReceiver(tld.aw.total) | ||
out.w :<> in.w.pipeline(delay.w).toReceiver(tld.w.total) | ||
in.b :<> CreditedIO.fromSender(out.b, tld.b.total).pipeline(delay.b) | ||
out.ar :<> in.ar.pipeline(delay.ar).toReceiver(tld.ar.total) | ||
in.r :<> CreditedIO.fromSender(out.r, tld.r.total).pipeline(delay.r) | ||
} | ||
} | ||
} | ||
|
||
object AXI4CreditedSink { | ||
def apply(delay: AXI4CreditedDelay)(implicit p: Parameters): AXI4CreditedSinkNode = { | ||
val sink = LazyModule(new AXI4CreditedSink(delay)) | ||
sink.node | ||
} | ||
def apply(delay: CreditedDelay)(implicit p: Parameters): AXI4CreditedSinkNode = apply(AXI4CreditedDelay(delay)) | ||
def apply()(implicit p: Parameters): AXI4CreditedSinkNode = apply(CreditedDelay(1, 1)) | ||
} | ||
|
||
/** Synthesizeable unit tests */ | ||
import freechips.rocketchip.unittest._ | ||
|
||
class AXI4RAMCreditedCrossing(txns: Int, params: CreditedCrossing)(implicit p: Parameters) extends LazyModule { | ||
val model = LazyModule(new TLRAMModel("AXI4CreditedCrossing")) | ||
val fuzz = LazyModule(new TLFuzzer(txns)) | ||
val toaxi = LazyModule(new TLToAXI4) | ||
val island = LazyModule(new CrossingWrapper(params)) | ||
val ram = island { LazyModule(new AXI4RAM(AddressSet(0x0, 0x3ff))) } | ||
|
||
island.crossAXI4In(ram.node) := toaxi.node := TLDelayer(0.1) := model.node := fuzz.node | ||
|
||
lazy val module = new LazyModuleImp(this) with UnitTestModule { | ||
io.finished := fuzz.module.io.finished | ||
} | ||
} | ||
|
||
class AXI4RAMCreditedCrossingTest(txns: Int = 5000, timeout: Int = 500000)(implicit p: Parameters) extends UnitTest(timeout) { | ||
val dut_1000 = Module(LazyModule(new AXI4RAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(1, 0), CreditedDelay(0, 0)))).module) | ||
val dut_0100 = Module(LazyModule(new AXI4RAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(0, 1), CreditedDelay(0, 0)))).module) | ||
val dut_0010 = Module(LazyModule(new AXI4RAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(0, 0), CreditedDelay(1, 0)))).module) | ||
val dut_0001 = Module(LazyModule(new AXI4RAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(0, 0), CreditedDelay(0, 1)))).module) | ||
val dut_1111 = Module(LazyModule(new AXI4RAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(1, 1), CreditedDelay(1, 1)))).module) | ||
|
||
val duts = Seq(dut_1000, dut_0100, dut_0010, dut_0001, dut_1111) | ||
duts.foreach { _.io.start := true.B } | ||
io.finished := duts.map(_.io.finished).reduce(_ && _) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// See LICENSE.SiFive for license details. | ||
|
||
package freechips.rocketchip.tilelink | ||
|
||
import chisel3._ | ||
import chisel3.util.Decoupled | ||
import freechips.rocketchip.config.Parameters | ||
import freechips.rocketchip.diplomacy._ | ||
import freechips.rocketchip.subsystem.CrossingWrapper | ||
import freechips.rocketchip.util._ | ||
|
||
class TLCreditedBuffer(delay: TLCreditedDelay)(implicit p: Parameters) extends LazyModule | ||
{ | ||
val node = TLCreditedAdapterNode( | ||
clientFn = p => p.copy(delay = delay + p.delay), | ||
managerFn = p => p.copy(delay = delay + p.delay)) | ||
|
||
lazy val module = new LazyModuleImp(this) { | ||
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) => | ||
out.a :<> in.a.pipeline(delay.a) | ||
in.b :<> out.b.pipeline(delay.b) | ||
out.c :<> in.c.pipeline(delay.c) | ||
in.d :<> out.d.pipeline(delay.d) | ||
out.e :<> in.e.pipeline(delay.e) | ||
} | ||
} | ||
} | ||
|
||
object TLCreditedBuffer { | ||
def apply(delay: TLCreditedDelay)(implicit p: Parameters): TLCreditedAdapterNode = { | ||
val buffer = LazyModule(new TLCreditedBuffer(delay)) | ||
buffer.node | ||
} | ||
def apply(delay: CreditedDelay)(implicit p: Parameters): TLCreditedAdapterNode = apply(TLCreditedDelay(delay)) | ||
def apply()(implicit p: Parameters): TLCreditedAdapterNode = apply(CreditedDelay(1, 1)) | ||
} | ||
|
||
class TLCreditedSource(delay: TLCreditedDelay)(implicit p: Parameters) extends LazyModule | ||
{ | ||
val node = TLCreditedSourceNode(delay) | ||
lazy val module = new LazyModuleImp(this) { | ||
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) => | ||
val tld = edgeOut.delay | ||
out.a :<> CreditedIO.fromSender(in.a, tld.a.total).pipeline(delay.a) | ||
in.b :<> Decoupled(out.b.pipeline(delay.b).toReceiver(tld.b.total)) | ||
out.c :<> CreditedIO.fromSender(in.c, tld.c.total).pipeline(delay.c) | ||
in.d :<> Decoupled(out.d.pipeline(delay.d).toReceiver(tld.d.total)) | ||
out.e :<> CreditedIO.fromSender(in.e, tld.e.total).pipeline(delay.e) | ||
} | ||
} | ||
} | ||
|
||
object TLCreditedSource { | ||
def apply(delay: TLCreditedDelay)(implicit p: Parameters): TLCreditedSourceNode = { | ||
val source = LazyModule(new TLCreditedSource(delay)) | ||
source.node | ||
} | ||
def apply(delay: CreditedDelay)(implicit p: Parameters): TLCreditedSourceNode = apply(TLCreditedDelay(delay)) | ||
def apply()(implicit p: Parameters): TLCreditedSourceNode = apply(CreditedDelay(1, 1)) | ||
} | ||
|
||
class TLCreditedSink(delay: TLCreditedDelay)(implicit p: Parameters) extends LazyModule | ||
{ | ||
val node = TLCreditedSinkNode(delay) | ||
lazy val module = new LazyModuleImp(this) { | ||
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) => | ||
val tld = edgeIn.delay | ||
out.a :<> Decoupled(in.a.pipeline(delay.a).toReceiver(tld.a.total)) | ||
in.b :<> CreditedIO.fromSender(out.b, tld.b.total).pipeline(delay.b) | ||
out.c :<> Decoupled(in.c.pipeline(delay.c).toReceiver(tld.c.total)) | ||
in.d :<> CreditedIO.fromSender(out.d, tld.d.total).pipeline(delay.d) | ||
out.e :<> Decoupled(in.e.pipeline(delay.e).toReceiver(tld.e.total)) | ||
} | ||
} | ||
} | ||
|
||
object TLCreditedSink { | ||
def apply(delay: TLCreditedDelay)(implicit p: Parameters): TLCreditedSinkNode = { | ||
val sink = LazyModule(new TLCreditedSink(delay)) | ||
sink.node | ||
} | ||
def apply(delay: CreditedDelay)(implicit p: Parameters): TLCreditedSinkNode = apply(TLCreditedDelay(delay)) | ||
def apply()(implicit p: Parameters): TLCreditedSinkNode = apply(CreditedDelay(1, 1)) | ||
} | ||
|
||
/** Synthesizeable unit tests */ | ||
import freechips.rocketchip.unittest._ | ||
|
||
class TLRAMCreditedCrossing(txns: Int, params: CreditedCrossing)(implicit p: Parameters) extends LazyModule { | ||
val model = LazyModule(new TLRAMModel("CreditedCrossing")) | ||
val fuzz = LazyModule(new TLFuzzer(txns)) | ||
val island = LazyModule(new CrossingWrapper(params)) | ||
val ram = island { LazyModule(new TLRAM(AddressSet(0x0, 0x3ff))) } | ||
|
||
island.crossTLIn(ram.node) := TLFragmenter(4, 256) := TLDelayer(0.1) := model.node := fuzz.node | ||
|
||
lazy val module = new LazyModuleImp(this) with UnitTestModule { | ||
io.finished := fuzz.module.io.finished | ||
} | ||
} | ||
|
||
class TLRAMCreditedCrossingTest(txns: Int = 5000, timeout: Int = 500000)(implicit p: Parameters) extends UnitTest(timeout) { | ||
val dut_1000 = Module(LazyModule(new TLRAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(1, 0), CreditedDelay(0, 0)))).module) | ||
val dut_0100 = Module(LazyModule(new TLRAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(0, 1), CreditedDelay(0, 0)))).module) | ||
val dut_0010 = Module(LazyModule(new TLRAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(0, 0), CreditedDelay(1, 0)))).module) | ||
val dut_0001 = Module(LazyModule(new TLRAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(0, 0), CreditedDelay(0, 1)))).module) | ||
val dut_1111 = Module(LazyModule(new TLRAMCreditedCrossing(txns, CreditedCrossing(CreditedDelay(1, 1), CreditedDelay(1, 1)))).module) | ||
|
||
val duts = Seq(dut_1000, dut_0100, dut_0010, dut_0001, dut_1111) | ||
duts.foreach { _.io.start := true.B } | ||
io.finished := duts.map(_.io.finished).reduce(_ && _) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is sinkDebit ignored here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IntSyncCrossingSink does not support a register stage. I could change that. Should I?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I guess I would just leave it, though I confess I don't really understand the semantics of IntSync are as it relates to what circuits outcomes represent "safe" crossings. Would a user explicitly controlling
sinkDebit
be surprised to not get a buffer?