hwtLib.peripheral.usb.sim package

Submodules

hwtLib.peripheral.usb.sim.agent_base module

class hwtLib.peripheral.usb.sim.agent_base.UsbAgent(rx: Deque[Union[UsbPacketToken, UsbPacketData, UsbPacketHandshake]], tx: Deque[Union[UsbPacketToken, UsbPacketData, UsbPacketHandshake]])[source]

Bases: object

__init__(rx: Deque[Union[UsbPacketToken, UsbPacketData, UsbPacketHandshake]], tx: Deque[Union[UsbPacketToken, UsbPacketData, UsbPacketHandshake]])[source]
deparse_packet(p)[source]

Called to convert the packet from types supported by this class before putting into tx/rx queue

parse_packet(p)[source]

Called to convert the packet from tx/rx queues to types supported by this class

receive(packet_cls)[source]
send(p)[source]

send and wait until other side consumes the data

send_ack()[source]
wait_on_ack()[source]
class hwtLib.peripheral.usb.sim.agent_base.UsbPacketData(pid: int, data: List[int])[source]

Bases: object

__init__(pid: int, data: List[int])[source]
__repr__()[source]

Return repr(self).

crc16()[source]
unpack(t: HdlType)[source]

reinterpret data as specified type

class hwtLib.peripheral.usb.sim.agent_base.UsbPacketHandshake(pid: USB_PID)[source]

Bases: object

__init__(pid: USB_PID)[source]
__repr__()[source]

Return repr(self).

class hwtLib.peripheral.usb.sim.agent_base.UsbPacketToken(pid: USB_PID, addr: int, endp: int)[source]

Bases: object

Note

bits of individual items are sent in LSB first but the items of the packet are sent in the oreder defined by structure of the packet

__init__(pid: USB_PID, addr: int, endp: int)[source]
__repr__()[source]

Return repr(self).

crc5()[source]
classmethod from_pid_and_body_bytes(pid: int, addr_ep_crc_byte_list: Union[BitsVal, List[BitsVal]])[source]

hwtLib.peripheral.usb.sim.usb_agent_device module

class hwtLib.peripheral.usb.sim.usb_agent_device.UsbDevAgent(rx: Deque[Union[UsbPacketToken, UsbPacketData]], tx: Deque[Union[UsbPacketToken, UsbPacketData]], descriptors: UsbDescriptorBundle)[source]

Bases: UsbAgent

This agent uses rx and tx queue to comunicate with a USB device. The agnet implements address assignment and descriptor upload and it is meant to be extended with a specific functionality of USB device.

__init__(rx: Deque[Union[UsbPacketToken, UsbPacketData]], tx: Deque[Union[UsbPacketToken, UsbPacketData]], descriptors: UsbDescriptorBundle)[source]
get_data_pid()[source]
proc()[source]
send_data(endp: int, pid_init: USB_PID, maxPacketLen: int, data_bytes: List[int])[source]
set_data_pid(pid: USB_PID)[source]

hwtLib.peripheral.usb.sim.usb_agent_host module

class hwtLib.peripheral.usb.sim.usb_agent_host.UsbHostAgent(rx: Deque[Union[UsbPacketToken, UsbPacketData, UsbPacketHandshake]], tx: Deque[Union[UsbPacketToken, UsbPacketData, UsbPacketHandshake]])[source]

Bases: UsbAgent

This agent uses rx and tx queue to comunicate with a USB device. It performs bus enumerations, sets address to a device and downloads the descriptors. Note that the agent is written in a way which allows for easy extension to a driver which can parse the specific descriptors and comunicate with devices further.

__init__(rx: Deque[Union[UsbPacketToken, UsbPacketData, UsbPacketHandshake]], tx: Deque[Union[UsbPacketToken, UsbPacketData, UsbPacketHandshake]])[source]
control_read(addr, bmRequestType_type: USB_REQUEST_TYPE_TYPE, bRequest: int, wValue: int, wIndex: int, wLength: int, bmRequestType_recipient: USB_REQUEST_TYPE_RECIPIENT = 0, bmRequestType_data_transfer_direction: USB_REQUEST_TYPE_DIRECTION = 1)[source]
control_write(addr: int, ep: int, bmRequestType_type: USB_REQUEST_TYPE_TYPE, bRequest: int, wValue: int, wIndex: int, buff: List[int], bmRequestType_recipient: USB_REQUEST_TYPE_RECIPIENT = 0, bmRequestType_data_transfer_direction: USB_REQUEST_TYPE_DIRECTION = 0)[source]
download_descriptor(addr: int, descriptor_t: ~typing.Union[~hwt.hdl.types.struct.HStruct, str], index: int, wIndex: int = 0, wLength: ~typing.Optional[int] = <class 'hwt.synthesizer.rtlLevel.constants.NOT_SPECIFIED'>)[source]
get_max_packet_size(addr: int, endp: int, direction: USB_ENDPOINT_DIR)[source]
parse_configuration_descriptor_bundle(data_bytes: List[int])[source]
parse_interface_functional_descriptor(interface_descr: StructValBase, data: BitsVal)[source]
proc()[source]
receive_bulk(addr: int, endp: int, pid_init: ~hwtLib.peripheral.usb.constants.USB_PID, size=<class 'hwt.synthesizer.rtlLevel.constants.NOT_SPECIFIED'>) List[int][source]
transmit_bulk(addr: int, endp: int, pid_init: USB_PID, data_bytes: List[int])[source]