Skip to content

Commit

Permalink
Emit events for capture stop.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinling committed Jul 10, 2024
1 parent 19fa30f commit da87457
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cynthion/python/src/gateware/analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ def elaborate(self, platform):
# AWAIT_PACKET: capture is enabled, wait for a packet to start.
with m.State("AWAIT_PACKET"):
with m.If(~self.capture_enable):
# Capture is being stopped.
m.next = "AWAIT_START"
# Log a stop event.
m.d.comb += [
write_event .eq(1),
event_code .eq(USBAnalyzerEvent.CAPTURE_STOP),
]
with m.Elif(self.utmi.rx_active):
m.next = "CAPTURE_PACKET"
m.d.usb += [
Expand Down Expand Up @@ -565,6 +571,30 @@ def test_timestamp_wrap(self):
yield from self.expect_data(start_event + rollover_event + packet)


@usb_domain_test_case
def test_stop_event(self):

# Start capture.
yield self.analyzer.capture_enable.eq(1)
yield

# Nothing happens for 0x123 cycles.
yield from self.advance_cycles(0x123)

# Stop capture.
yield self.analyzer.capture_enable.eq(0)
yield

# First we should get a start event with a timestamp of zero.
start_event = [0xFF, 0x04, 0x00, 0x00]

# Then, we should get an stop event with a timestamp of 0x123.
stop_event = [0xFF, 0x01, 0x01, 0x23]

# Validate that we get all of the expected bytes.
yield from self.expect_data(start_event + stop_event)


class USBAnalyzerStackTest(USBAnalyzerTestBase):
""" Test that evaluates a full-stack USB analyzer setup. """

Expand Down

0 comments on commit da87457

Please sign in to comment.