Skip to content

Commit 4147443

Browse files
committed
Update version from v0.2.0 to v0.2.1
- Bump surfer-tywaves from v0.2.0-tywaves-dev-SNAPSHOT to v0.2.1-tywaves-dev-SNAPSHOT - Add Chisel fork versioning to Makefile - Add scala-cli running example
1 parent 39d4f06 commit 4147443

File tree

7 files changed

+93
-12
lines changed

7 files changed

+93
-12
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
.PHONY: all download-surfer clean
22

33
TYWAVES_SURFER_REPO=https://gitlab.com/rameloni/surfer-tywaves-demo.git
4-
TYWAVES_BRANCH=tywaves
4+
TYWAVES_BRANCH=v0.2.1-tywaves-dev-SNAPSHOT
55
TYWAVES_NAME=surfer-tywaves-demo
66

77
CHISEL_FORK_REPO=https://github.com/rameloni/chisel.git
8+
CHISEL_FORK_BRANCH=v6.1.0-tywaves-SNAPSHOT
89

910
all: install-surfer-tywaves install-chisel-fork clean install-tywaves-backend
1011

@@ -19,7 +20,7 @@ clean:
1920
@rm -rf tmp/
2021

2122
install-chisel-fork: create-tmp
22-
@cd tmp/ && git clone $(CHISEL_FORK_REPO)
23+
@cd tmp/ && git clone $(CHISEL_FORK_REPO) && cd chisel && git checkout $(CHISEL_FORK_BRANCH)
2324
@cd tmp/chisel && sbt "unipublish / publishLocal"
2425

2526
install-tywaves-backend:

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Compile / scalaSource := baseDirectory.value / "src/main/scala"
77
Test / scalaSource := baseDirectory.value / "src/test/scala"
88

99
ThisBuild / organization := "com.github.rameloni"
10-
ThisBuild / version := "0.2.0-SNAPSHOT"
10+
ThisBuild / version := "0.2.1-SNAPSHOT"
1111
ThisBuild / scalaVersion := "2.13.12"
1212

1313
enablePlugins(ScalafmtPlugin)

example/gcd.test.scala

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//> using scala "2.13.12"
2+
//> using dep "com.github.rameloni::tywaves-demo-backend:0.2.1-SNAPSHOT"
3+
//> using dep "org.chipsalliance::chisel:6.3.0"
4+
//> using plugin "org.chipsalliance:::chisel-plugin:6.3.0"
5+
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
6+
//> using dep "org.scalatest::scalatest:3.2.18"
7+
8+
// DO NOT EDIT THE ORTHER OF THESE IMPORTS (it will be solved in future versions)
9+
import tywaves.simulator._
10+
import tywaves.simulator.ParametricSimulator._
11+
import tywaves.simulator.simulatorSettings._
12+
import chisel3._
13+
14+
15+
// _root_ disambiguates from package chisel3.util.circt if user imports chisel3.util._
16+
//import _root_.circt.stage.ChiselStage
17+
import org.scalatest.funspec.AnyFunSpec
18+
import org.scalatest.matchers.should.Matchers
19+
20+
/** A simple module useful for testing Chisel generation and testing */
21+
class GCD extends Module {
22+
val io = IO(new Bundle {
23+
val a = Input(UInt(32.W))
24+
val b = Input(UInt(32.W))
25+
val loadValues = Input(Bool())
26+
val result = Output(UInt(32.W))
27+
val resultIsValid = Output(Bool())
28+
})
29+
30+
val x = Reg(UInt(32.W))
31+
val y = Reg(UInt(32.W))
32+
33+
when(x > y)(x := x -% y).otherwise(y := y -% x)
34+
35+
when(io.loadValues) { x := io.a; y := io.b }
36+
37+
io.result := x
38+
io.resultIsValid := y === 0.U
39+
}
40+
41+
class GCDTest extends AnyFunSpec with Matchers {
42+
describe("ParametricSimulator") {
43+
it("runs GCD correctly") {
44+
simulate(new GCD(), Seq(VcdTrace, SaveWorkdirFile("aaa"))) { gcd =>
45+
gcd.io.a.poke(24.U)
46+
gcd.io.b.poke(36.U)
47+
gcd.io.loadValues.poke(1.B)
48+
gcd.clock.step()
49+
gcd.io.loadValues.poke(0.B)
50+
gcd.clock.stepUntil(sentinelPort = gcd.io.resultIsValid, sentinelValue = 1, maxCycles = 10)
51+
gcd.io.resultIsValid.expect(true.B)
52+
gcd.io.result.expect(12)
53+
}
54+
}
55+
}
56+
57+
describe("TywavesSimulator") {
58+
it("runs GCD correctly") {
59+
import TywavesSimulator._
60+
61+
simulate(new GCD(), Seq(VcdTrace, WithTywavesWaveforms(true)), simName = "runs_GCD_correctly_launch_tywaves") {
62+
gcd =>
63+
gcd.io.a.poke(24.U)
64+
gcd.io.b.poke(36.U)
65+
gcd.io.loadValues.poke(1.B)
66+
gcd.clock.step()
67+
gcd.io.loadValues.poke(0.B)
68+
gcd.clock.stepUntil(sentinelPort = gcd.io.resultIsValid, sentinelValue = 1, maxCycles = 10)
69+
gcd.io.resultIsValid.expect(true.B)
70+
gcd.io.result.expect(12)
71+
}
72+
}
73+
}
74+
75+
}

src/test/scala/bar/Bar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Bar extends Module {
2828

2929
val cable =
3030
Wire(Bool()) // do not use reserved verilog words as val names (val wire) -> tywaves-demo does not work for them yet
31-
cable := io.a & io.b
31+
cable := io.a & io.b
3232

3333
io.out := cable
3434
}

src/test/scala/foo/FooTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.scalatest.flatspec.AnyFlatSpec
66
import tywaves.simulator.simulatorSettings._
77

88
object RunFoo {
9+
910
/** Run multiple times */
1011
def apply(c: => Foo): Unit = {
1112
// Inputs and expected results

src/test/scala/hierarchicalmodules/Blink.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Blink(period: Int) extends Module {
77
assert(period > 0, "limit must be greater than 0")
88
val io = IO(new Bundle {
99
val enable: Bool = Input(Bool())
10-
val led : Bool = Output(Bool())
10+
val led: Bool = Output(Bool())
1111
})
1212

1313
val cnt: Counter = Counter(period)

src/test/scala/tywaves/simulator/TywavesSimulatorSpec.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class TywavesSimulatorSpec extends AnyFunSpec with Matchers {
2626
resetBeforeEachRun()
2727

2828
it("runs GCD with waveform generation") {
29-
simulate(new GCD(), Seq(VcdTrace, WithTywavesWaveforms(false)), simName = "runs_gcd_with_waveform_generation") { gcd =>
30-
gcdTb(gcd)
29+
simulate(new GCD(), Seq(VcdTrace, WithTywavesWaveforms(false)), simName = "runs_gcd_with_waveform_generation") {
30+
gcd =>
31+
gcdTb(gcd)
3132
}
3233

3334
assert(Files.exists(Paths.get("test_run_dir/GCD/TywavesSimulator/runs_gcd_with_waveform_generation/trace.vcd")))
@@ -39,7 +40,11 @@ class TywavesSimulatorSpec extends AnyFunSpec with Matchers {
3940
}
4041

4142
it("runs GCD with waveform generation and custom name trace") {
42-
simulate(new GCD(), Seq(VcdTrace, NameTrace("gcdTest"), WithTywavesWaveforms(false)), simName = "runs_gcd_with_waveform_generation") { gcd =>
43+
simulate(
44+
new GCD(),
45+
Seq(VcdTrace, NameTrace("gcdTest"), WithTywavesWaveforms(false)),
46+
simName = "runs_gcd_with_waveform_generation",
47+
) { gcd =>
4348
gcdTb(gcd)
4449
}
4550

@@ -52,12 +57,11 @@ class TywavesSimulatorSpec extends AnyFunSpec with Matchers {
5257
}
5358

5459
it("raises an exception when Tywaves is used without VcdTrace") {
55-
intercept[Exception] {
56-
simulate(new GCD(), Seq(WithTywavesWaveforms(false)))(_ => gcdTb _)
57-
}
60+
intercept[Exception] {
61+
simulate(new GCD(), Seq(WithTywavesWaveforms(false)))(_ => gcdTb _)
62+
}
5863
}
5964

60-
6165
}
6266

6367
describe("Tywaves with ParametricSimulator Functionalities") {

0 commit comments

Comments
 (0)