-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sim: add support for passive generators
1 parent
598638b
commit e50df16
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from migen.sim.core import Simulator, run_simulation | ||
from migen.sim.core import Simulator, run_simulation, passive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import unittest | ||
|
||
from migen import * | ||
|
||
|
||
class PassiveCase(unittest.TestCase): | ||
def test_terminates_correctly(self): | ||
n = 5 | ||
|
||
count = 0 | ||
@passive | ||
def counter(): | ||
nonlocal count | ||
while True: | ||
yield | ||
count += 1 | ||
|
||
def terminator(): | ||
for i in range(n): | ||
yield | ||
|
||
run_simulation(Module(), [counter(), terminator()]) | ||
self.assertEqual(count, n) |