You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0027-simulator-testbenches.md
+14-11Lines changed: 14 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,11 @@
4
4
5
5
# Testbench processes for the simulator
6
6
7
+
> **Amendments**
8
+
> This RFC was amended on 2024-02-12 to deprecate `add_sync_process` rather than `add_process`, for two reasons:
9
+
> 1.`add_process` encompasses anything `add_sync_process` can do, but there is functionality that is quite difficult to do with `add_sync_process`, such as behavioral implementation of a DDR flop.
10
+
> 2.`add_sync_process` relies on argument-less `yield`, which has no equivalent with `await ...` syntax that is desired in the future.
11
+
7
12
## Summary
8
13
[summary]: #summary
9
14
@@ -86,10 +91,10 @@ Reusable abstractions can be built by defining generator functions on interfaces
86
91
87
92
### Guidance on simulator modalities
88
93
89
-
There are two main simulator modalities: `add_testbench` and `add_sync_process`. They have completely disjoint purposes:
94
+
There are two main simulator modalities: `add_testbench` and `add_process`. They have completely disjoint purposes:
90
95
91
96
-`add_testbench` is used for testing logic (asynchronous or synchronous). It is not used for behavioral replacement of synchronous logic.
92
-
-`add_sync_process` is used for behavioral replacement of synchronous logic. It is not for testing logic (except for legacy code), and a deprecation warning is shown when `yield Settle()` is executed in such a process.
97
+
-`add_process` is used for behavioral replacement of synchronous logic. It is not for testing logic (except for legacy code), and a deprecation warning is shown when `yield Settle()` is executed in such a process.
93
98
94
99
Example of using `add_testbench` to test combinatorial logic:
95
100
@@ -124,7 +129,7 @@ sim.add_testbench(testbench)
124
129
sim.run()
125
130
```
126
131
127
-
Example of using `add_sync_process` to replace the flop above, and `add_testbench` to test the flop:
132
+
Example of using `add_process` to replace the flop above, and `add_testbench` to test the flop:
128
133
129
134
```python
130
135
m = Module()
@@ -141,12 +146,12 @@ def testbench():
141
146
142
147
sim = Simulator(m)
143
148
sim.add_clock(1e-6)
144
-
sim.add_sync_process(flop)
149
+
sim.add_process(flop)
145
150
sim.add_testbench(testbench)
146
151
sim.run()
147
152
```
148
153
149
-
### Why not replace `add_sync_process` with `add_testbench` entirely?
154
+
### Why not replace `add_process` with `add_testbench` entirely?
150
155
151
156
It is not possible to use `add_testbench` processes that drive signals in a race-free way. Consider this (behaviorally defined) circuit:
152
157
@@ -178,23 +183,21 @@ proc3 x=1 y=0
178
183
proc2 x=1 y=1
179
184
```
180
185
181
-
If they are added using `add_sync_process`, the output is:
186
+
If they are added using `add_process`, the output is:
182
187
183
188
```
184
189
proc2 x=1 y=0
185
190
proc3 x=1 y=0
186
191
```
187
192
188
-
Clearly, if `proc2` and `proc3` are other flops in the circuit, perhaps performing a computation on `x` and `y`, they must be simulated using `add_sync_process`.
193
+
Clearly, if `proc2` and `proc3` are other flops in the circuit, perhaps performing a computation on `x` and `y`, they must be simulated using `add_process`.
A new `Simulator.add_testbench(process)` is added. This function schedules `process` similarly to `add_process`, except that before returning control to the coroutine `process` it performs the equivalent of `yield Settle()`.
194
199
195
-
`add_process` and `Settle` are deprecated and removed in a future version.
196
-
197
-
`yield Tick()` is deprecated within `add_sync_process` and the ability to use it as well as `yield Settle()` is removed in a future version.
200
+
`add_sync_process` and `Settle` are deprecated and removed in a future version.
198
201
199
202
## Drawbacks
200
203
[drawbacks]: #drawbacks
@@ -227,4 +230,4 @@ As it is, every such helper function would have to take a `domain` argument, whi
227
230
228
231
A new `add_comb_process` function could be added, to replace combinatorial logic. This function would have to accept a list of all signals driven by the process, so that combinatorial loops could be detected. (The demand for this has not been high; as of right now, this is not possible anyway.)
229
232
230
-
The existing `add_sync_process` function could accept a list of all signals driven by the process. This could aid in error detection, especially as CXXRTL is integrated into the design, because if a simulator process is driving a signal at the same time as an RTL process, a silent race condition occurs.
233
+
The existing `add_process` function could accept a list of all signals driven by the process. This could aid in error detection, especially as CXXRTL is integrated into the design, because if a simulator process is driving a signal at the same time as an RTL process, a silent race condition occurs.
0 commit comments