Skip to content

Commit 88bd8b9

Browse files
authored
#47: Amend RFC #27 to deprecate add_sync_process rather than add_process
2 parents d7337b1 + 14fade5 commit 88bd8b9

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

text/0027-simulator-testbenches.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
# Testbench processes for the simulator
66

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+
712
## Summary
813
[summary]: #summary
914

@@ -86,10 +91,10 @@ Reusable abstractions can be built by defining generator functions on interfaces
8691

8792
### Guidance on simulator modalities
8893

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:
9095

9196
- `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.
9398

9499
Example of using `add_testbench` to test combinatorial logic:
95100

@@ -124,7 +129,7 @@ sim.add_testbench(testbench)
124129
sim.run()
125130
```
126131

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:
128133

129134
```python
130135
m = Module()
@@ -141,12 +146,12 @@ def testbench():
141146

142147
sim = Simulator(m)
143148
sim.add_clock(1e-6)
144-
sim.add_sync_process(flop)
149+
sim.add_process(flop)
145150
sim.add_testbench(testbench)
146151
sim.run()
147152
```
148153

149-
### Why not replace `add_sync_process` with `add_testbench` entirely?
154+
### Why not replace `add_process` with `add_testbench` entirely?
150155

151156
It is not possible to use `add_testbench` processes that drive signals in a race-free way. Consider this (behaviorally defined) circuit:
152157

@@ -178,23 +183,21 @@ proc3 x=1 y=0
178183
proc2 x=1 y=1
179184
```
180185

181-
If they are added using `add_sync_process`, the output is:
186+
If they are added using `add_process`, the output is:
182187

183188
```
184189
proc2 x=1 y=0
185190
proc3 x=1 y=0
186191
```
187192

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`.
189194

190195
## Reference-level explanation
191196
[reference-level-explanation]: #reference-level-explanation
192197

193198
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()`.
194199

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.
198201

199202
## Drawbacks
200203
[drawbacks]: #drawbacks
@@ -227,4 +230,4 @@ As it is, every such helper function would have to take a `domain` argument, whi
227230

228231
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.)
229232

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

Comments
 (0)