FPGA開発日記

カテゴリ別記事インデックス https://msyksphinz.github.io/github_pages , English Version https://fpgadevdiary.hatenadiary.com/

TileLinkのDiplomacyを使った実際のデザインを試してみる (3. Diplomacyを使ってバスシステムのカスタマイズにトライ)

TileLinkの生成フローについて調査を進めている。まずはTileLinkを使った独自のデザインを生成する環境を整えていく。

class TLOriginalRAMSimple(ramBeatBytes: Int, txns: Int)(implicit p: Parameters) extends LazyModule {
  val fuzz = LazyModule(new TLFuzzer(txns))
  val model = LazyModule(new TLRAMModel("SRAMSimple"))
  val ram  = LazyModule(new TLRAM(AddressSet(0x0, 0x3ff), beatBytes = ramBeatBytes))

  ram.node := TLDelayer(0.25) := model.node := fuzz.node

  lazy val module = new LazyModuleImp(this) with UnitTestModule {
    io.finished := fuzz.module.io.finished
  }
}

class TLOriginalRAMSimpleTest(ramBeatBytes: Int, txns: Int = 5000, timeout: Int = 500000)(implicit p: Parameters) extends UnitTest(timeout) {
  val dut = Module(LazyModule(new TLOriginalRAMSimple(ramBeatBytes, txns)).module)
  io.finished := dut.io.finished
}


class WithTLOriginalUnitTest extends Config((site, here, up) => {
  case UnitTests => (q: Parameters) => {
    implicit val p = q
    val txns = 1 * site(TestDurationMultiplier)
    val timeout = 50000 * site(TestDurationMultiplier)
    Seq(
      Module(new TLOriginalRAMSimpleTest(4, txns=15*txns, timeout=timeout))
    )}
})

class TLOriginalUnitTestConfig extends Config(new WithTLOriginalUnitTest ++ new WithTestDuration(1) ++ new BaseSubsystemConfig)

バス幅は以下のようになった。

  • TLFuzzer
信号 ビット数 説明
a_bits_opcode 3 Operation code. Identifies the type of message carried by the channel.
a_bits_size 1 Logarithm of the operation size: 2n bytes.
a_bits_source 5 Unique, per-link master source identifier.
a_bits_address 10 Target byte address of the operation. Must be aligned to a size.
a_bits_mask 1 Byte lane select for messages with data.
a_bits_data 8 Data payload for messages with data.
d_bits_source 5 Unique, per-link master source identifier.
  • TLRAM
信号 ビット数 説明
a_bits_opcode 3 Operation code. Identifies the type of message carried by the channel.
a_bits_param 3 Parameter code. Meaning depends on a opcode; specifies a transfer of caching permissions or a sub-opcode.
a_bits_size 1 Logarithm of the operation size: 2n bytes.
a_bits_source 5 Unique, per-link master source identifier.
a_bits_address 10 Target byte address of the operation. Must be aligned to a size.
a_bits_mask 1 Byte lane select for messages with data.
a_bits_data 8 Data payload for messages with data.
d_bits_opcode 3 Operation code. Identifies the type of message carried by the channel.
d_bits_size 1 Logarithm of the operation size: 2n bytes.
d_bits_source 5 Unique, per-link master source identifier.
d_bits_data 8 Data payload for messages with data.

次に、バス幅を32ビットに変更したときにどのようにVerilogが変化するか確認する。

diff --git a/chisel-hw/src/main/scala/TLUnitTest/TLUnitTest.scala b/chisel-hw/src/main/scala/TLUnitTest/TLUnitTest.scala
index b6e09a9..77fefb9 100644
--- a/chisel-hw/src/main/scala/TLUnitTest/TLUnitTest.scala
+++ b/chisel-hw/src/main/scala/TLUnitTest/TLUnitTest.scala
@@ -40,7 +40,7 @@ class WithTLOriginalUnitTest extends Config((site, here, up) => {
     val txns = 1 * site(TestDurationMultiplier)
     val timeout = 50000 * site(TestDurationMultiplier)
     Seq(
-      Module(new TLOriginalRAMSimpleTest(1, txns=15*txns, timeout=timeout))
+      Module(new TLOriginalRAMSimpleTest(4, txns=15*txns, timeout=timeout))
     )}
 })

そのままバイトサイズと様々な信号のビット幅に影響が出た。32ビットだと以下のように影響が出る。

信号 ビット数(8-bit) ビット数(32-bit) 説明
a_bits_opcode 3 3 Operation code. Identifies the type of message carried by the channel.
a_bits_param 3 3 Parameter code. Meaning depends on a opcode; specifies a transfer of caching permissions or a sub-opcode.
a_bits_size 1 2 Logarithm of the operation size: 2n bytes.
a_bits_source 5 5 Unique, per-link master source identifier.
a_bits_address 10 10 Target byte address of the operation. Must be aligned to a size.
a_bits_mask 1 4 Byte lane select for messages with data.
a_bits_data 8 32 Data payload for messages with data.
d_bits_opcode 3 3 Operation code. Identifies the type of message carried by the channel.
d_bits_size 1 2 Logarithm of the operation size: 2n bytes.
d_bits_source 5 5 Unique, per-link master source identifier.
d_bits_data 8 32 Data payload for messages with data.

Diplomacyの構築状況をGraphMLで確認する

Diplomacyの構成状況は、GraphMLにより出力することができる。GrapMLの出力方法について確認する。

まずはTLOriginalRAMSimpleTestの構成を変更する。

class TLOriginalRAMSimpleTest(ramBeatBytes: Int, txns: Int = 5000, timeout: Int = 500000)(implicit p: Parameters) extends UnitTest(timeout) {
  val lazy_dut = LazyModule(new TLOriginalRAMSimple(ramBeatBytes, txns)
  val dut = Module(lazy_dut).module)
  ElaborationArtefacts.add("graphml", lazy_dut.graphML)
  io.finished := dut.io.finished
}

lazy_dutによりLazyModuleを生成し、lazy_dutに対してgraphmlを生成する。それがElaborationArtefacts.add("graphml", lazy_dut.graphML)である。これでChiselのコンパイラを走らせると、GraphMLファイルが生成される。

sbt 'runMain freechips.rocketchip.unittest.Generator . freechips.rocketchip.unittest TestHarness freechips.rocketchip.unittest TLOriginalUnitTestConfig'
$ ls -1 | grep TLSimpleUnitTestConfig
freechips.rocketchip.unittest.TLSimpleUnitTestConfig.0x400.0.regmap.json
freechips.rocketchip.unittest.TLSimpleUnitTestConfig.0x400.1.regmap.json
freechips.rocketchip.unittest.TLSimpleUnitTestConfig.0x400.2.regmap.json
freechips.rocketchip.unittest.TLSimpleUnitTestConfig.anno.json
freechips.rocketchip.unittest.TLSimpleUnitTestConfig.d
freechips.rocketchip.unittest.TLSimpleUnitTestConfig.fir
freechips.rocketchip.unittest.TLSimpleUnitTestConfig.plusArgs

これをWindows上に持ってきて、yzEditorというツールで開いた。

www.yworks.com

f:id:msyksphinz:20191230011042p:plain
GraphMLで生成したファイルを開く。

デフォルトだと何が何だか分からないので、Flowchartの形式に変換してみよう。

f:id:msyksphinz:20191230011151p:plain
GraphMLでFlowの並べ替えを行う。
f:id:msyksphinz:20191230011516p:plain
GraphMLでフローチャートに並べ替えた後の状態。