Add glitch generator to source and glitch checker to sink#2
Conversation
…to generate glitches in source
| data.value = 1 | ||
| await stop_bit_t | ||
| for _ in range(self.stop_bits): | ||
| await bit_t() |
There was a problem hiding this comment.
This does not work - a valid value for stop_bits is 1.5
|
|
||
| bit_t = Timer(int(1e9/self.baud), 'ns') | ||
| stop_bit_t = Timer(int(1e9/self.baud*stop_bits), 'ns') | ||
| bit_t = lambda: self.wait_bit(data, int(1e9/self.baud), 'ns') |
There was a problem hiding this comment.
The whole point of "caching" the events is to not continuously create and destroy event objects. Presumably you're making this change to support changing the baud rate dynamically? If so, let's make baud and stop_bits properties, store the events as instance parameters, and swap out the events when these properties are changed.
There was a problem hiding this comment.
Also, it might make sense to rework all of the time math in terms of sim steps, which avoids passing units around all over the place.
| assert False, "Unexpected transition" | ||
|
|
||
| async def check_bits(self, period, units, signal, bits): | ||
| window = int(period*0.01) |
There was a problem hiding this comment.
This is probably something to bring out somehow for configuration
Codecov ReportBase: 23.77% // Head: 24.47% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2 +/- ##
==========================================
+ Coverage 23.77% 24.47% +0.70%
==========================================
Files 4 4
Lines 244 286 +42
Branches 22 35 +13
==========================================
+ Hits 58 70 +12
- Misses 186 215 +29
- Partials 0 1 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
848c453 to
390f1d2
Compare
Hi,
I added an assertion to the sink that fails when there is a transition in the middle of a bit and added glitch_generator parameter to source that allows insert glitches during bit transmission.
You can check the run_glitch_test test for usage example.