@@ -37,9 +37,9 @@ discovered [here](https://github.com/rameloni/Tydi-Chisel-testing-frameworks-ana
37
37
38
38
# Installation
39
39
40
- You can run ` make all ` to install all the pre-requisites.
40
+ You can run ` make all ` to install all the pre-requisites and ** this library ** .
41
41
42
- ## Install [ surfer-tywaves-demo] ( https://gitlab.com/rameloni/surfer-tywaves-demo/-/tree/tywaves )
42
+ ## Prerequisite: Install [ surfer-tywaves-demo] ( https://gitlab.com/rameloni/surfer-tywaves-demo/-/tree/tywaves )
43
43
44
44
The makefile contains a rule to clone the frontend repository, build and install it.
45
45
@@ -50,62 +50,102 @@ make clean # To remove the cloned repository
50
50
51
51
The frontend will be installed as ` surfer-tywaves ` executable.
52
52
53
- ## Publish locally this scala project
53
+ ## Install and publish locally this library
54
54
55
55
``` bash
56
- make install-chisel-fork
56
+ make install-chisel-fork # TEMPORARY NEEDED: Install the chisel fork with the needed changes in the development branch
57
57
make install-tywaves-backend
58
58
```
59
59
60
60
Once published locally, the ` tywaves-demo-backend ` can be used by adding the following line to the ` build.sbt ` file:
61
61
62
62
``` scala
63
- libraryDependencies += " com.github.rameloni" %% " tywaves-backend" % " 0.1.0-SNAPSHOT"
63
+ libraryDependencies += " com.github.rameloni" %% " tywaves-demo- backend" % " 0.1.0-SNAPSHOT"
64
64
```
65
65
66
66
# Use it on your project
67
67
68
- The ` TywavesBackend ` provides a [ simulator] ( ./src/main/tywaves/simulator/BetterEphemeralSimulator.scala ) with
69
- functionalities to simulate a circuit through [ svsim] ( https://github.com/chipsalliance/chisel/tree/main/svsim ) , emit VCD
70
- traces and of course generate the symbol table for the waveform viewer itself automatically.
68
+ The ` TywavesBackend ` provides 2 simulators with functionalities to simulate a circuit
69
+ through [ svsim] ( https://github.com/chipsalliance/chisel/tree/main/svsim ) , emit VCD
70
+ traces and of course generate the symbol table for the waveform viewer itself automatically:
71
+
72
+ - [ ParametricSimulator] ( ./src/main/scala/tywaves/simulator/ParametricSimulator.scala ) : provides some generic features
73
+ such as VCD trace emission, name the trace file, pass additional arguments to firtool before simulation, save the
74
+ workspace of svsim
75
+ - [ TywavesSimulator] ( ./src/main/scala/tywaves/simulator/TywavesSimulator.scala ) : it extends the parametric simulator in
76
+ order to generate the symbol table for Tywaves waveform viewer and provides an option to launch the waveform viewer
77
+ after the simulation
78
+
79
+ > While ` TywavesSimulator ` is central part of the Tywaves project and its functionalities are not fully supported
80
+ > yet, ` ParametricSimulator ` is
81
+ > should be able to simulate any Chisel circuit. In case you need to simulate a circuit that is not supported
82
+ > by ` TywavesSimulator ` , you can use ` ParametricSimulator ` .
83
+ >
84
+ > If you want to try the functionalities of ` Tywaves ` then ` TywavesSimulator ` is the right choice.
85
+ > But, if you want to visualize waveforms of any chisel circuit without issues related to features not supported yet,
86
+ > you should make use of ` ParametricSimulator ` .
71
87
72
88
The following example shows how it is possible also to:
73
89
74
90
- Enable the trace of the simulation
75
- - Launch the waveform viewer after the simulation
76
91
- Set the name of the simulation (it will be used to create a folder with a user defined name for the traces and
77
92
workspace of svsim)
93
+ - Launch the waveform viewer after the simulation
78
94
- Use tywaves and expect API to test the circuit
95
+ ### Use TywavesSimulator
96
+
97
+ ``` scala
98
+ import tywaves .simulator .TywavesSimulator ._
99
+ import tywaves .simulator .simulatorSettings ._
100
+ import org .scalatest .flatspec .AnyFlatSpec
101
+
102
+ class GCDTest extends AnyFunSpec with Matchers {
103
+ describe(" TywavesSimulator" ) {
104
+ it(" runs GCD correctly" ) {
105
+ simulate(new GCD (), Seq (VcdTrace , WithTywavesWaveforms (true )), simName = " runs_GCD_correctly_launch_tywaves" ) {
106
+ gcd =>
107
+ gcd.io.a.poke(24 .U )
108
+ gcd.io.b.poke(36 .U )
109
+ gcd.io.loadValues.poke(1 .B )
110
+ gcd.clock.step()
111
+ gcd.io.loadValues.poke(0 .B )
112
+ gcd.clock.stepUntil(sentinelPort = gcd.io.resultIsValid, sentinelValue = 1 , maxCycles = 10 )
113
+ gcd.io.resultIsValid.expect(true .B )
114
+ gcd.io.result.expect(12 )
115
+ }
116
+ }
117
+ }
118
+ }
119
+ ```
79
120
121
+ ### Use ParametricSimulator
80
122
``` scala
81
- import tywaves .simulator .BetterEphemeralSimulator ._
82
- import tywaves .simulator .simSettings
123
+ import tywaves .simulator .ParametricSimulator ._
124
+ import tywaves .simulator .simulatorSettings . _
83
125
import org .scalatest .flatspec .AnyFlatSpec
84
126
85
- class BarTest extends AnyFlatSpec {
86
- behavior of " BarTest"
87
- it should " trace simple bar" in {
88
- simulate(
89
- new Bar ,
90
- Seq (simSettings.EnableTraceWithUnderscore , simSettings.LaunchTywavesWaveforms ),
91
- simName = " trace_simple_bar" ,
92
- ) { c =>
93
- c.io.a.poke(true )
94
- c.io.b.poke(false )
95
- c.io.out.expect(false .B )
96
- c.clock.step()
97
- c.io.a.poke(true )
98
- c.io.b.poke(true )
99
- c.io.out.expect(true .B )
100
- c.clock.step()
127
+ class GCDTest extends AnyFunSpec with Matchers {
128
+ describe(" ParametricSimulator" ) {
129
+ it(" runs GCD correctly" ) {
130
+ simulate(new GCD (), Seq (VcdTrace , SaveWorkdirFile (" GCD_parametricSimulator_workdir" )), simName = " runs_GCD_correctly" ) {
131
+ gcd =>
132
+ gcd.io.a.poke(24 .U )
133
+ gcd.io.b.poke(36 .U )
134
+ gcd.io.loadValues.poke(1 .B )
135
+ gcd.clock.step()
136
+ gcd.io.loadValues.poke(0 .B )
137
+ gcd.clock.stepUntil(sentinelPort = gcd.io.resultIsValid, sentinelValue = 1 , maxCycles = 10 )
138
+ gcd.io.resultIsValid.expect(true .B )
139
+ gcd.io.result.expect(12 )
140
+ }
101
141
}
102
142
}
103
143
}
104
144
```
105
145
106
146
# Example output
107
147
108
- The following images show the classic and tywaves waveform visualization of the [ GCD] ( ./src/test/gcd/GCD.scala ) module.
148
+ The following images show the classic and tywaves waveform visualization of the [ GCD] ( ./src/test/scala/ gcd/GCD.scala ) module.
109
149
It is possible to see that the left picture does not provide any information about Chisel level types and hierarchy.
110
150
111
151
``` scala
@@ -123,7 +163,7 @@ class GCD extends Module {
123
163
124
164
when(x > y)(x := x -% y).otherwise(y := y -% x)
125
165
when(io.loadValues) {
126
- x := io.a;
166
+ x := io.a
127
167
y := io.b
128
168
}
129
169
io.result := x
@@ -139,7 +179,6 @@ class GCD extends Module {
139
179
140
180
- [x] Parse and map Chisel/FIRRTL/Verilog circuits
141
181
- [x] Emit VCD traces from the simulator (both with and without underscores in the signal names)
142
- - [x]
143
182
- [x] Automatically generate the symbol table for the waveform viewer
144
183
- [x] Dump Chisel types in the final symbol table
145
184
- [x] Represent hierarchical structures of bundles
0 commit comments