Skip to content

Instantly share code, notes, and snippets.

@ktemkin
Created April 4, 2020 20:07
Show Gist options
  • Save ktemkin/0333b0772922a83bb6a5b49356822c1b to your computer and use it in GitHub Desktop.
Save ktemkin/0333b0772922a83bb6a5b49356822c1b to your computer and use it in GitHub Desktop.
# Devices would be created by providing a core set of necessary
# information (e.g. PHY connections, clock domains, etc).
device = USBSuperSpeedDevice(pipe_bus=phy_connection, [...])
m.submodules.usb_controller = device
# Create hardware to handle standard requests on ep0. This object
# would provide methods for attaching e.g. class / vendor request handlers.
ep0 = device.create_control_endpoint(descriptors=my_descriptors)
# Endpoints will be added by calling factory methods that will
# create subordinate hardware. Connections between the endpoint hardware
# and the device object would automatically be generated on elaboation.
#
# Endpoint subclasses would allow endpoints to be treated as e.g. simple
# FIFOs, facilitating common use cases.
bulk_in = device.create_bulk_in_fifo(buffer_size=1024)
bulk_out = device.create_bulk_out_fifo(endpoint_number = 3)
# Where possible, simple hardware wrappers would be provided to simplify
# common implementation tasks. For example, if an interrupt endpoint was
# to be used to repeatedly query a given status register, we might
# implement a simple wrapper that reports the value of an nMigen signal,
# or NAKs when the data isn't valid.
status_ep = device.create_simple_interrupt_status_endpoint(
read_data_value=my_signal_valid,
read_value=my_signal,
read_strobe=my_read_strobe
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment