enjoy-digital / litescope

Small footprint and configurable embedded FPGA logic analyzer
Other
160 stars 38 forks source link

Allow a trigger pattern (rather than just a single trigger value) #6

Closed mithro closed 6 years ago

mithro commented 6 years ago

It would be good if litescope support a trigger pattern rather that just a single trigger value.

I think a good solution is to change FrontendTrigger module to make the value / mask CSRs into FIFOs. Then a hit only occurs when the whole sequence in the FIFO matches.

This would allow triggering on the falling edge of the first signal if you loaded the FIFO with the sequence (value=0x1, mask=0x1), (value=0x0, mask=0x1) (IE match the value 1 followed by the value=0).

enjoy-digital commented 6 years ago

Thanks, that seems indeed a good solution and as you said covers rising/falling edge triggering as a specific trigger pattern. Do you want to contribute it? (I'll be happy to do it if not, or fix eventual issues if you want to do it)

mithro commented 6 years ago

FYI - There is a bunch of info on how the Open Bench Logic Sniffer does it at http://dangerousprototypes.com/docs/Logic_Sniffer_102#Complex_parallel_triggers

bunnie commented 6 years ago

I've got a branch going on my fork that adds multi-trigger and edges:

https://github.com/bunnie/litescope/tree/add_edges

It's janky as it's code written to help me debug something else I really want to debug, rather than develop a logic analyzer, but I think the edge trigger API is at least palatable.

N triggers is a bit tricky from a system config standpoint, probably a larger refactor is needed to make it scalable. At the moment it's either 1 or 2 triggers, but a few framework improvements are needed to go from 2 to N without making the analyzer driver scripts unruly.

Still, two triggers each with 2^N hit counts (N=0 means ignore trigger) and arbitrary combination of edge+level in each trigger module is enough to do some reasonably fancy introspection on video, e.g. I can now home in on the very first pixel by triggering on vsync and then on DE, and then I can zoom in on the first pixel of the last line by counting DE edges after a vsync, and so forth.

enjoy-digital commented 6 years ago

This has been added with https://github.com/enjoy-digital/litescope/commit/c0bab06765bb1126935254f5b84a26fbac22fc72 and demonstrated in the following commits. The code should allow most of the useful triggering patterns but you can create specific issue if some are not supported.