Skip to content

Commit

Permalink
Merge pull request #24 from rameloni/fix-issue-12
Browse files Browse the repository at this point in the history
Update to the new tywaves backend, integrated in Chisel-CIRCT compilation
  • Loading branch information
rameloni authored Jun 25, 2024
2 parents d878939 + 3a525a6 commit 05e932d
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ build/

*.anno.json

tmp/
tmp/

*.vcd
*.fst
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ make install-tywaves-chisel-api
Once published locally, you can use it in your project by adding the following line to your `build.sbt` file:

```scala
libraryDependencies += "com.github.rameloni" %% "tywaves-demo-backend" % "your-version-here"
libraryDependencies += "com.github.rameloni" %% "tywaves-chisel-api" % "your-version-here"
```

# Usage in a project through the Tywaves-Chisel-API
Expand Down Expand Up @@ -226,16 +226,27 @@ The following list shows a summary of the features added by the Tywaves project
- [ ] Automatic/custom signal value rendering
- [ ] For loops code generation

# Versioning and tools
# Versioning and tools ([ref](https://github.com/rameloni/tywaves-chisel-demo/wiki/Tywaves-internals#tywaves-software-architecture))

| Name of this scala package | Tywaves-Chisel-API (this repo) | Chisel | Firtool | Tywaves-rs | Surfer |
|------------------------------------------------------------|:-----------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------|
| `com.github.rameloni::tywaves-demo-backend:0.3.1-SNAPSHOT` | 0.3.1-SNAPSHOT (_coming soon_) | [v6.4.2-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.4.2-tywaves-SNAPSHOT) from `rameloni/chisel` (fork of chisel) | [v0.1.1](https://github.com/rameloni/circt/releases/tag/v0.1.1-tywaves-SNAPSHOT) from `rameloni/circt` (fork of circt) | [v0.1.2](https://github.com/rameloni/tywaves-rs/releases/tag/v0.1.2-SNAPSHOT) | [v0.3.1-tywaves-dev-SNAPSHOT]() from `surfer-tywaves-demo` _COMING SOON_ |
| `com.github.rameloni::tywaves-demo-backend:0.3.0-SNAPSHOT` | 0.3.0-SNAPSHOT (_coming soon_) | [v6.4.2-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.4.2-tywaves-SNAPSHOT) from `rameloni/chisel` (fork of chisel) | [v0.1.1](https://github.com/rameloni/circt/releases/tag/v0.1.1-tywaves-SNAPSHOT) from `rameloni/circt` (fork of circt) | [v0.1.1](https://github.com/rameloni/tywaves-rs/releases/tag/v0.1.1-SNAPSHOT) | [v0.3.0-tywaves-dev-SNAPSHOT](https://gitlab.com/rameloni/surfer-tywaves-demo/-/releases/v0.3.0-tywaves-dev-SNAPSHOT) from `surfer-tywaves-demo` |
| `com.github.rameloni::tywaves-demo-backend:0.2.1-SNAPSHOT` | [0.2.1-SNAPSHOT](https://github.com/rameloni/tywaves-chisel-demo/releases/tag/v0.2.1-SNAPSHOT) | [v6.1.0-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.1.0-tywaves-SNAPSHOT) from `rameloni/chisel` (fork of chisel), _needed for the parametric workspace_ | [v1.75.0](https://github.com/llvm/circt/releases/tag/firtool-1.75.0) official repo | [v0.1.0](https://github.com/rameloni/tywaves-rs/releases/tag/v0.1.0-SNAPSHOT) | [v0.2.1-tywaves-dev-SNAPSHOT](https://gitlab.com/rameloni/surfer-tywaves-demo/-/releases/v0.2.1-tywaves-dev-SNAPSHOT) from `surfer-tywaves-demo` |
| `com.github.rameloni::tywaves-demo-backend:0.2.0-SNAPSHOT` | [0.2.0-SNAPSHOT](https://github.com/rameloni/tywaves-chisel-demo/releases/tag/v0.2.0-SNAPSHOT) | [v6.1.0-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.1.0-tywaves-SNAPSHOT) from `rameloni/chisel` (fork of chisel), _needed for the parametric workspace_ | [v1.75.0](https://github.com/llvm/circt/releases/tag/firtool-1.75.0) official repo | - | [v0.2.0-tywaves-dev-SNAPSHOT](https://gitlab.com/rameloni/surfer-tywaves-demo/-/releases/v0.2.0-tywaves-dev-SNAPSHOT) from `surfer-tywaves-demo` |
| `com.github.rameloni::tywaves-demo-backend:0.1.0-SNAPSHOT` | [0.1.1-SNAPSHOT](https://github.com/rameloni/tywaves-chisel-demo/releases/tag/v0.1.1-SNAPSHOT) | [v6.1.0-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.1.0-tywaves-SNAPSHOT) from `rameloni/chisel` (fork of chisel), _needed for the parametric workspace_ | [v1.75.0](https://github.com/llvm/circt/releases/tag/firtool-1.75.0) official repo | - | [v0.1.1-SNAPSHOT]() from `surfer-tywaves-demo` |
| `com.github.rameloni::tywaves-demo-backend:0.1.0-SNAPSHOT` | [0.1.0-SNAPSHOT](https://github.com/rameloni/tywaves-chisel-demo/releases/tag/v0.1.0-SNAPSHOT) | [v6.1.0](https://github.com/chipsalliance/chisel/releases/tag/v6.1.0) official repo | [v1.62.0](https://github.com/llvm/circt/releases/tag/firtool-1.62.0) official repo | - | [v0.1.0-SNAPSHOT]() from `surfer-tywaves-demo` |
Use the new name of the library in your sbt dependencies: `com.github.rameloni::tywaves-chisel-api:<version>`.

| Release | Chisel fork version (from `rameloni/chisel`) | Firtool fork version (from `rameloni/circt`) | Tywaves-rs version | Surfer-tywaves version |
|:-------------------------------|:---------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------|
| 0.3.1-SNAPSHOT (_coming soon_) | [v6.4.2-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.4.2-tywaves-SNAPSHOT) | [v0.1.1](https://github.com/rameloni/circt/releases/tag/v0.1.1-tywaves-SNAPSHOT) | [v0.1.2](https://github.com/rameloni/tywaves-rs/releases/tag/v0.1.2-SNAPSHOT) | [v0.3.1-tywaves-dev-SNAPSHOT]() _COMING SOON_ |
| 0.3.0-SNAPSHOT (_coming soon_) | [v6.4.2-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.4.2-tywaves-SNAPSHOT) | [v0.1.1](https://github.com/rameloni/circt/releases/tag/v0.1.1-tywaves-SNAPSHOT) | [v0.1.1](https://github.com/rameloni/tywaves-rs/releases/tag/v0.1.1-SNAPSHOT) | [v0.3.0-tywaves-dev-SNAPSHOT](https://gitlab.com/rameloni/surfer-tywaves-demo/-/releases/v0.3.0-tywaves-dev-SNAPSHOT) |

## Old backend implementations ([ref](https://github.com/rameloni/tywaves-chisel-demo/wiki/An-alternative-solution-(old-demo-version)))

Use the old name of the library in your sbt dependencies: `com.github.rameloni::tywaves-demo-backend:<version>`.

| Release | Chisel fork version (from `rameloni/chisel`) | Firtool version (official CIRCT repo) | Tywaves-rs version | Surfer-tywaves version |
|:-----------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------|:------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------|
| [0.2.1-SNAPSHOT](https://github.com/rameloni/tywaves-chisel-demo/releases/tag/v0.2.1-SNAPSHOT) | [v6.1.0-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.1.0-tywaves-SNAPSHOT) | [v1.75.0](https://github.com/llvm/circt/releases/tag/firtool-1.75.0) | [v0.1.0](https://github.com/rameloni/tywaves-rs/releases/tag/v0.1.0-SNAPSHOT) | [v0.2.1-tywaves-dev-SNAPSHOT](https://gitlab.com/rameloni/surfer-tywaves-demo/-/releases/v0.2.1-tywaves-dev-SNAPSHOT) |
| [0.2.0-SNAPSHOT](https://github.com/rameloni/tywaves-chisel-demo/releases/tag/v0.2.0-SNAPSHOT) | [v6.1.0-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.1.0-tywaves-SNAPSHOT) | [v1.75.0](https://github.com/llvm/circt/releases/tag/firtool-1.75.0) | - | [v0.2.0-tywaves-dev-SNAPSHOT](https://gitlab.com/rameloni/surfer-tywaves-demo/-/releases/v0.2.0-tywaves-dev-SNAPSHOT) |
| [0.1.1-SNAPSHOT](https://github.com/rameloni/tywaves-chisel-demo/releases/tag/v0.1.1-SNAPSHOT) | [v6.1.0-tywaves-SNAPSHOT](https://github.com/rameloni/chisel/releases/tag/v6.1.0-tywaves-SNAPSHOT) | [v1.75.0](https://github.com/llvm/circt/releases/tag/firtool-1.75.0) | - | [v0.1.1-SNAPSHOT]() |
| [0.1.0-SNAPSHOT](https://github.com/rameloni/tywaves-chisel-demo/releases/tag/v0.1.0-SNAPSHOT) | [v6.1.0](https://github.com/chipsalliance/chisel/releases/tag/v6.1.0) official repo | [v1.62.0](https://github.com/llvm/circt/releases/tag/firtool-1.62.0) | - | [v0.1.0-SNAPSHOT]() |

#

[^1]: While `TywavesSimulator` is a central part of the Tywaves project and its functionalities are not fully supported
yet, the `ParametricSimulator` is able to simulate any Chisel circuit. In case you need to simulate a circuit that is
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ lazy val root = (project in file("."))
buildInfoPackage := "tywaves",
buildInfoUsePackageAsPath := true,
).settings(
name := "TyWaves-demo-backend",
name := "tywaves-chisel-api",
addCompilerPlugin(
"org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full
),
libraryDependencies += "org.chipsalliance" %% "chisel" % chiselVersion,
libraryDependencies += "org.scalatest" %% "scalatest" % scalatestVersion % "test",
libraryDependencies += "org.chipsalliance" %% "chisel" % chiselVersion,
libraryDependencies += "org.scalatest" %% "scalatest" % scalatestVersion % "test",
// libraryDependencies += "io.circe" %% "circe-core" % circeVersion,
// libraryDependencies += "io.circe" %% "circe-generic" % circeVersion,
// libraryDependencies += "io.circe" %% "circe-generic-extras" % "0.14.3",
Expand Down
2 changes: 1 addition & 1 deletion example/gcd.test.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//> using scala "2.13.14"
//> using dep "com.github.rameloni::tywaves-demo-backend:0.3.0-SNAPSHOT"
//> using dep "com.github.rameloni::tywaves-chisel-api:0.3.0-SNAPSHOT"
//> using dep "org.chipsalliance::chisel:6.4.0"
//> using plugin "org.chipsalliance:::chisel-plugin:6.4.0"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
Expand Down
2 changes: 1 addition & 1 deletion example/tydi-example.test.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//> using scala "2.13.14"
//> using dep "com.github.rameloni::tywaves-demo-backend:0.3.0-SNAPSHOT"
//> using dep "com.github.rameloni::tywaves-chisel-api:0.3.0-SNAPSHOT"
//> using dep "nl.tudelft::tydi-chisel::0.1.0"
//> using plugin "org.chipsalliance:::chisel-plugin:6.4.0"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
Expand Down
11 changes: 6 additions & 5 deletions src/main/scala/tywaves/circuitmapper/TypedConverter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ private[tywaves] object TypedConverter {
this.workingDir = Some(workingDir)
hglddWithOptDir = workingDir + "/" + hglddWithOptDir
hglddDebugDir = workingDir + "/" + hglddDebugDir
// hglddDebugDir = workingDir + "/" + "support-artifacts"

// Annotations for ChiselStage
val annotations = Seq(ChiselGeneratorAnnotation(generateModule)) ++ defaultFirtoolOptAnno

// Run without debug mode
chiselStage.execute(
chiselStageBaseArgs ++ Array("--target-dir", hglddWithOptDir),
annotations,
) // execute returns the passThrough annotations in CIRCT transform stage
// Run without debug mode: TODO check it is actually not needed
// chiselStage.execute(
// chiselStageBaseArgs ++ Array("--target-dir", hglddWithOptDir),
// annotations,
// ) // execute returns the passThrough annotations in CIRCT transform stage

// Run with debug mode
val finalAnno = chiselStage.execute(
Expand Down
3 changes: 3 additions & 0 deletions src/main/scala/tywaves/simulator/TywavesSimulator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ object TywavesSimulator extends PeekPokeAPI {
if (containTywaves)
settings ++ Seq(FirtoolArgs(Seq("-O=debug", "-g", "--emit-hgldd", "--split-verilog", "-o=WORK.v")))
else settings

simulator.simulate(module, finalSettings, simName)(body)

if (simulator.finalTracePath.nonEmpty && containTywaves) {
// Get the extra scopes created by ChiselSim backend: TOP, svsimTestbench, dut
val extraScopes = Seq("TOP", Workspace.testbenchModuleName, "dut")

// Create the debug info from the firtool and get the top module name
// TODO: this may not be needed anymore, since the debug info can be generated directly from chiselsim, by giving the right options to firtool
// But the problem is to call chiselstage with debug options
TypedConverter.createDebugInfoHgldd(() => module, simulator.wantedWorkspacePath)

// Run tywaves viewer if the Tywaves waveform generation is enabled by Tywaves(true)
Expand Down
6 changes: 5 additions & 1 deletion src/test/scala/gcd/GCDTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ class GCDTest extends AnyFunSpec with Matchers {
it("runs GCD correctly") {
import TywavesSimulator._

simulate(new GCD(), Seq(VcdTrace, WithTywavesWaveforms(false)), simName = "runs_GCD_correctly") {
simulate(
new GCD(),
Seq(VcdTrace, WithTywavesWaveforms(false), WithFirtoolArgs(Seq("-g", "--emit-hgldd")), SaveWorkdir),
simName = "runs_GCD_correctly",
) {
gcd =>
gcd.io.a.poke(24.U)
gcd.io.b.poke(36.U)
Expand Down

0 comments on commit 05e932d

Please sign in to comment.