Skip to content

Commit

Permalink
[misc] add test to generate config json
Browse files Browse the repository at this point in the history
  • Loading branch information
OceanS2000 committed Feb 20, 2023
1 parent ce60809 commit 6397d79
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/elaborate/src/TLCrossBarParameterSerializerTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package tests.elaborate

import chisel3.util.experimental.BitSet
import upickle.default._

import org.chipsalliance.tilelink.bundle.TLLinkParameter
import org.chipsalliance.tilelink.xbar._

object TLCrossBarParameterSerializerTest {
def main(args: Array[String]): Unit = {
val linkParameter : TLLinkParameter = TLLinkParameter(
addressWidth = 32,
sourceWidth = 2,
sinkWidth = 2,
dataWidth = 64,
sizeWidth = 4,
hasBCEChannels = true
)

val masterLinkParameter = Seq(TLCrossBarMasterLinkParameter(
linkParameter = linkParameter,
adVisibility = BitSet.fromString("b??"),
bceVisibility = BitSet.fromString("b??"),
srcIdRange = TLIdRange(0, 1)
))

val slaveLinkParameter = Seq(TLCrossBarSlaveLinkParameter(
linkParameter = linkParameter,
adVisibility = BitSet.fromString("b??"),
bceVisibility = BitSet.fromString("b??"),
sinkIdRange = TLIdRange(0, 1),
addressRange = BitSet.fromRange(0x80000000, 0x10000, 32)
),
TLCrossBarSlaveLinkParameter(
linkParameter = linkParameter,
adVisibility = BitSet.fromString("b??"),
bceVisibility = BitSet.fromString("b??"),
sinkIdRange = TLIdRange(2, 3),
addressRange = BitSet.fromRange(0x80010000, 0x10000, 32)
))

val crossBarParameter = TLCrossBarParameter(
TLArbiterPolicy.RoundRobin,
masterLinkParameter,
slaveLinkParameter
)

val serializedConfig = ujson.Obj(
"generator" -> "org.chipsalliance.tilelink.xbar.TLCrossBar",
"parameter" -> upickle.default.writeJs(crossBarParameter),
).render(indent = 2)
os.write(os.pwd / "config.json", serializedConfig)
}
}

0 comments on commit 6397d79

Please sign in to comment.