Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline USB reads #73

Closed
whitequark opened this issue Oct 31, 2018 · 1 comment
Closed

Pipeline USB reads #73

whitequark opened this issue Oct 31, 2018 · 1 comment
Labels
software Component: software

Comments

@whitequark
Copy link
Member

Right now, making very large latency-sensitive USB reads is done by giving interface.read() a hint with the amount of expected data, which causes it to use a buffer that large. Unfortunately, the following sequence still results in a FIFO underflow:

  1. interface.read(512, hint=512*1000) is called
  2. device returns a single 512-byte packet, interface.read returns
  3. processing starts; bus is idle (no IN-BULK-NAK)
  4. device queues 2 (4) more 512-byte packets, filling FX2 FIFO
  5. interface.read(512, hint=512*1000) is called again

Given how small the FX2+device FIFO are (at most a 2+30 KB on UP5K), the maximum fill rate (up to 30 KB per millisecond), and the OS scheduling latency (at best, a few milliseconds), if we get a context switch anywhere between steps 3 and 5, a FIFO underflow is unavoidable at the maximum fill rate, and becomes linearly less likely at fractions of maximum fill rate. This can be easily demonstrated with the shugart-floppy applet at higher read redundancies.

Thus, we have to teach the software to pipeline USB reads. Up to 30 MB/s of reads should definitely be doable in Python if no particular processing is done (shugart-floppy just appends reads to a buffer), and possibly even with processing.

@whitequark whitequark added the software Component: software label Oct 31, 2018
@whitequark
Copy link
Member Author

There is an example of this in the yamaha-opl applet, which only needs to be generalized a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
software Component: software
Projects
None yet
Development

No branches or pull requests

1 participant