Generator¶
Stream generators.
- class torii_usb.stream.generator.ConstantStreamGenerator(constant_data, domain: str = 'sync', stream_type: type[~torii_usb.stream.generator.T] = <class 'torii.lib.stream.simple.StreamInterface'>, max_length_width: int | None = None, data_width: int | None = None, data_endianness: ~typing.Literal['little', 'big'] = 'little')¶
Gateware that generates stream of constant data.
- Attributes:
start (Signal(), input) – Strobe that indicates when the stream should be started.
done (Signal(), output) – Strobe that pulses high when we’re finishing a transmission.
start_position (Signal(range(len(data)), input) – Specifies the starting position in the constant stream; applied when start() is pulsed.
max_length (Signal(max_length_width), input) – The maximum length to be sent -in bytes-. Defaults to the length of the stream. Only present if the max_length_width parameter is provided on creation.
output_length (Signal(max_length_width), output) – Indicates the actual data length for the stream currently being output. Will always be the lesser of our data length and :attr:
max_length
. Only present if the max_length_width parameter is provided on creation.stream (stream_type(), output stream) – The generated stream interface.
- Parameters:
constant_data (bytes, or equivalent) – The constant data for the stream to be generated. Should be an iterable of integers; or, if data_width is divisible by 8, a bytes-like object.
domain (str) – The clock domain this generator should belong to. (default: ‘sync’) (default:
'sync'
)stream_type (StreamInterface, or subclass) – The type of stream we’ll be multiplexing. (default:
<class 'torii.lib.stream.simple.StreamInterface'>
)data_width (int | None) – The width of the constant payload. If not provided; will be taken from the stream’s payload width. (default: None) (default:
None
)max_length_width (int | None) – If provided, a max_length signal will be present that can limit the total length transmitted. (default: None) (default:
None
)data_endianness ('little' | 'big') – If bytes are provided, and our data width is greater. (default: ‘little’) (default:
'little'
)
- class torii_usb.stream.generator.StreamSerializer(data_length: int, domain: str = 'sync', data_width: int = 8, stream_type: type[~torii_usb.stream.generator.T] = <class 'torii.lib.stream.simple.StreamInterface'>, max_length_width: int | None = None)¶
Gateware that serializes a short Array input onto a stream.
- I/O port:
I: start – Strobe that indicates when the stream should be started. O: done – Strobe that pulses high when we’re finishing a transmission.
I: data[] – The data stream to be sent out. Length is set by the data_length initializer argument. I: max_length[] – The maximum length to be sent. Defaults to the length of the stream.
Only present if the max_length_width parameter is provided on creation.
*: stream – The generated stream interface.