Skip to content

Commit

Permalink
Remove TLHelper, directly use tilelink node constructors
Browse files Browse the repository at this point in the history
TLHelper 1) obfuscates the underlying node architecture and
2) results in otherwise unnecessary dependencies on testchipip
  • Loading branch information
jerryz123 committed Feb 22, 2023
1 parent cdfb630 commit 27b0dd8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/Customization/DMA-Devices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ that writes zeros to the memory at a configured address.
:start-after: DOC include start: DigitalTop
:end-before: DOC include end: DigitalTop

We use ``TLHelper.makeClientNode`` to create a TileLink client node for us.
We use ``TLClientNode`` to create a TileLink client node for us.
We then connect the client node to the memory system through the front bus (fbus).
For more info on creating TileLink client nodes, take a look at :ref:`TileLink-Diplomacy-Reference/NodeTypes:Client Node`.

Expand Down
9 changes: 3 additions & 6 deletions docs/TileLink-Diplomacy-Reference/NodeTypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ on the C channel, and send grant acknowledgements on the E channel.

The L1 caches and DMA devices in RocketChip/Chipyard have client nodes.

You can add a TileLink client node to your LazyModule using the TLHelper
object from testchipip like so:
You can add a TileLink client node to your LazyModule like so:

.. literalinclude:: ../../generators/chipyard/src/main/scala/example/NodeTypes.scala
:language: scala
Expand Down Expand Up @@ -48,8 +47,7 @@ generators optimize the hardware by not arbitrating the client to managers with
address ranges that don't overlap with its visibility.

Inside your lazy module implementation, you can call ``node.out`` to get a
list of bundle/edge pairs. If you used the TLHelper, you only specified a
single client edge, so this list will only have one pair.
list of bundle/edge pairs.

The ``tl`` bundle is a Chisel hardware bundle that connects to the IO of this
module. It contains two (in the case of TL-UL and TL-UH) or five (in the case
Expand All @@ -65,8 +63,7 @@ Manager Node
------------

TileLink managers take requests from clients on the A channel and send
responses back on the D channel. You can create a manager node using the
TLHelper like so:
responses back on the D channel. You can create a manager like so:

.. literalinclude:: ../../generators/chipyard/src/main/scala/example/NodeTypes.scala
:language: scala
Expand Down
6 changes: 3 additions & 3 deletions generators/chipyard/src/main/scala/example/InitZero.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import chisel3.util._
import freechips.rocketchip.subsystem.{BaseSubsystem, CacheBlockBytes}
import freechips.rocketchip.config.{Parameters, Field, Config}
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp, IdRange}
import testchipip.TLHelper
import freechips.rocketchip.tilelink._

case class InitZeroConfig(base: BigInt, size: BigInt)
case object InitZeroKey extends Field[Option[InitZeroConfig]](None)

class InitZero(implicit p: Parameters) extends LazyModule {
val node = TLHelper.makeClientNode(
name = "init-zero", sourceId = IdRange(0, 1))
val node = TLClientNode(Seq(TLMasterPortParameters.v1(Seq(TLClientParameters(
name = "init-zero", sourceId = IdRange(0, 1))))))

lazy val module = new InitZeroModuleImp(this)
}
Expand Down
23 changes: 12 additions & 11 deletions generators/chipyard/src/main/scala/example/NodeTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ package chipyard.example
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.tilelink._
import testchipip.TLHelper

// These modules are not meant to be synthesized.
// They are used as examples in the documentation and are only here
// to check that they compile.

// DOC include start: MyClient
class MyClient(implicit p: Parameters) extends LazyModule {
val node = TLHelper.makeClientNode(TLMasterParameters.v1(
val node = TLClientNode(Seq(TLMasterPortParameters.v1(Seq(TLClientParameters(
name = "my-client",
sourceId = IdRange(0, 4),
requestFifo = true,
visibility = Seq(AddressSet(0x10000, 0xffff))))
visibility = Seq(AddressSet(0x10000, 0xffff)))))))

lazy val module = new LazyModuleImp(this) {
val (tl, edge) = node.out(0)
Expand All @@ -29,7 +28,7 @@ class MyClient(implicit p: Parameters) extends LazyModule {
class MyManager(implicit p: Parameters) extends LazyModule {
val device = new SimpleDevice("my-device", Seq("tutorial,my-device0"))
val beatBytes = 8
val node = TLHelper.makeManagerNode(beatBytes, TLSlaveParameters.v1(
val node = TLManagerNode(Seq(TLSlavePortParameters.v1(Seq(TLManagerParameters(
address = Seq(AddressSet(0x20000, 0xfff)),
resources = device.reg,
regionType = RegionType.UNCACHED,
Expand All @@ -40,7 +39,7 @@ class MyManager(implicit p: Parameters) extends LazyModule {
supportsPutFull = TransferSizes(1, beatBytes),
supportsPutPartial = TransferSizes(1, beatBytes),
supportsHint = TransferSizes(1, beatBytes),
fifoId = Some(0)))
fifoId = Some(0))), beatBytes)))

lazy val module = new LazyModuleImp(this) {
val (tl, edge) = node.in(0)
Expand All @@ -50,15 +49,17 @@ class MyManager(implicit p: Parameters) extends LazyModule {

// DOC include start: MyClient1+MyClient2
class MyClient1(implicit p: Parameters) extends LazyModule {
val node = TLHelper.makeClientNode("my-client1", IdRange(0, 1))
val node = TLClientNode(Seq(TLMasterPortParameters.v1(Seq(TLClientParameters(
"my-client1", IdRange(0, 1))))))

lazy val module = new LazyModuleImp(this) {
// ...
}
}

class MyClient2(implicit p: Parameters) extends LazyModule {
val node = TLHelper.makeClientNode("my-client2", IdRange(0, 1))
val node = TLClientNode(Seq(TLMasterPortParameters.v1(Seq(TLClientParameters(
"my-client2", IdRange(0, 1))))))

lazy val module = new LazyModuleImp(this) {
// ...
Expand All @@ -83,17 +84,17 @@ class MyClientGroup(implicit p: Parameters) extends LazyModule {

// DOC include start: MyManagerGroup
class MyManager1(beatBytes: Int)(implicit p: Parameters) extends LazyModule {
val node = TLHelper.makeManagerNode(beatBytes, TLSlaveParameters.v1(
address = Seq(AddressSet(0x0, 0xfff))))
val node = TLManagerNode(Seq(TLSlavePortParameters.v1(Seq(TLManagerParameters(
address = Seq(AddressSet(0x0, 0xfff)))), beatBytes)))

lazy val module = new LazyModuleImp(this) {
// ...
}
}

class MyManager2(beatBytes: Int)(implicit p: Parameters) extends LazyModule {
val node = TLHelper.makeManagerNode(beatBytes, TLSlaveParameters.v1(
address = Seq(AddressSet(0x1000, 0xfff))))
val node = TLManagerNode(Seq(TLSlavePortParameters.v1(Seq(TLManagerParameters(
address = Seq(AddressSet(0x1000, 0xfff)))), beatBytes)))

lazy val module = new LazyModuleImp(this) {
// ...
Expand Down
2 changes: 1 addition & 1 deletion generators/testchipip

0 comments on commit 27b0dd8

Please sign in to comment.