ハードウェア記述言語ChiselはScalaのプラットフォームの上に構築されている。大きく分けて2つのリポジトリから構成されている。
chisel3: https://github.com/freechipsproject/chisel3firrtl: https://github.com/freechipsproject/firrtl
chisel3のリポジトリは、ChiselのコードをFIRへ変換する。firrtlのリポジトリは、FIRのコードをVerilogに変換する。
Chiselの開発・デバッグ用にChisel3のリポジトリをダウンロードしてみる。
git clone https://github.com/freechipsproject/chisel3.git
このときにいくつかのChisel3コンパイラの実装を変更してローカルでテストするためには、sbt publishLocalを使えば良いようだった。
sbt publishLocal
${HOME}/.ivyにローカル用のディレクトリが作られる。${HOME}/.ivy2/local/edu.berkeley.cs/chisel3_2.12/3.2-SNAPSHOTである。
このリポジトリの名前は、chisel3リポジトリのホームディレクトリに位置されているbuild.sbtで決定されている。
build.sbt
lazy val commonSettings = Seq ( resolvers ++= Seq( Resolver.sonatypeRepo("snapshots"), Resolver.sonatypeRepo("releases") ), organization := "edu.berkeley.cs", version := "3.2-SNAPSHOT", autoAPIMappings := true, scalaVersion := "2.12.6", crossScalaVersions := Seq("2.12.6", "2.11.12"),
改造を加えたchiselを別ディレクトリとしてコンパイルしたい場合、上記の設定情報を書き換える。
diff --git a/build.sbt b/build.sbt index 2cffb8b7..4b5fb36f 100644 --- a/build.sbt +++ b/build.sbt @@ -35,8 +35,8 @@ lazy val commonSettings = Seq ( Resolver.sonatypeRepo("snapshots"), Resolver.sonatypeRepo("releases") ), - organization := "edu.berkeley.cs", - version := "3.2-SNAPSHOT", + organization := "local.berkeley.cs", + version := "msyksphinz-SNAPSHOT", autoAPIMappings := true, scalaVersion := "2.12.6", crossScalaVersions := Seq("2.12.6", "2.11.12"),
これでsbt publishLocalを実行すると、以下のようにローカルディレクトリに独自のディレクトリが出来上がる。
local
└── local.berkeley.cs
└── chisel3_2.12
└── msyksphinz-SNAPSHOT
├── docs
│ ├── chisel3_2.12-javadoc.jar
│ ├── chisel3_2.12-javadoc.jar.md5
│ └── chisel3_2.12-javadoc.jar.sha1
├── ivys
│ ├── ivy.xml
│ ├── ivy.xml.md5
│ └── ivy.xml.sha1
├── jars
│ ├── chisel3_2.12.jar
│ ├── chisel3_2.12.jar.md5
│ └── chisel3_2.12.jar.sha1
├── poms
│ ├── chisel3_2.12.pom
│ ├── chisel3_2.12.pom.md5
│ └── chisel3_2.12.pom.sha1
└── srcs
├── chisel3_2.12-sources.jar
├── chisel3_2.12-sources.jar.md5
└── chisel3_2.12-sources.jar.sha1
8 directories, 15 files
例えば以下のようにChisel3のリポジトリに改造を加えてみる。emitVerilog()を実行時にprintf()を実行する。
diff --git a/src/main/scala/chisel3/Driver.scala b/src/main/scala/chisel3/Driver.scala index a78cc92f..3629affd 100644 --- a/src/main/scala/chisel3/Driver.scala +++ b/src/main/scala/chisel3/Driver.scala @@ -122,6 +122,7 @@ object Driver extends BackendCompilationUtilities { * @return A String containing the design in Verilog. */ def emitVerilog[T <: RawModule](gen: => T): String = { + print("MYSKSPHINZ : emitVerilog is called\n") execute(Array[String](), { () => gen }) match { case ChiselExecutionSuccess(_, _, Some(firrtl.FirrtlExecutionSuccess(_, verilog))) => verilog case _ => sys.error("Cannot get Verilog!")
Chisel3のリポジトリ内で再度sbt publishLocalを実行してローカルディレクトリにデプロイする。
今度は、Chiselのハードウェアを設計しているディレクトリのbuild.sbtを変更する。
build.sbt
libraryDependencies ++= (Seq("local.berkeley.cs" %% "chisel3" % "msyksphinz-SNAPSHOT"))
[info] Done packaging. [info] Running map_test.map_test MYSKSPHINZ : emitVerilog is called [info] [0.002] Elaborating design... [info] [8.166] Done elaborating. Total FIRRTL Compile Time: 1019.6 ms [success] Total time: 48 s, completed 2019/08/25 14:04:55
