Skip to content

Add glitch generator to source and glitch checker to sink#2

Open
diegob94 wants to merge 4 commits into
alexforencich:masterfrom
diegob94:check_glitches
Open

Add glitch generator to source and glitch checker to sink#2
diegob94 wants to merge 4 commits into
alexforencich:masterfrom
diegob94:check_glitches

Conversation

@diegob94

@diegob94 diegob94 commented Oct 6, 2022

Copy link
Copy Markdown

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.

Comment thread cocotbext/uart/uart.py
data.value = 1
await stop_bit_t
for _ in range(self.stop_bits):
await bit_t()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work - a valid value for stop_bits is 1.5

Comment thread cocotbext/uart/uart.py

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')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cocotbext/uart/uart.py Outdated
assert False, "Unexpected transition"

async def check_bits(self, period, units, signal, bits):
window = int(period*0.01)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably something to bring out somehow for configuration

@codecov-commenter

codecov-commenter commented Oct 7, 2022

Copy link
Copy Markdown

Codecov Report

Base: 23.77% // Head: 24.47% // Increases project coverage by +0.70% 🎉

Coverage data is based on head (ca9fe1a) compared to base (aad6c49).
Patch coverage: 32.72% of modified lines in pull request are covered.

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     
Impacted Files Coverage Δ
cocotbext/uart/uart.py 0.00% <0.00%> (-1.09%) ⬇️
tests/uart/test_uart.py 100.00% <100.00%> (ø)

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants