Network Wizard for VHDL Test Benches
USB Library

Table of Contents

USB

This library provides functions for creating and extracting USB v1 and v2 packets.

Functionality

  • Create USB packets
  • Extract USB packets
  • Packet types: Token, Start-of-Frame, Data, Handshake, Split Transaction


More details in nw_usb_pkg

Example use

Include the libraries:

library nw_util;
context nw_util.nw_util_context;
library nw_usb;
context nw_usb.nw_usb_context;

In many other NetWiz protocols a packet consists of a header and a payload. The USB packet is contained completely in a record. The CRC5 or CRC16 is added according to packet type.

variable v_usb_pkt : t_usb_packet; -- packet record
variable v_len : natural;
variable v_pkt : t_slv_arr(0 to 127)(7 downto 0); -- data array

Example 1: Create a data packet.

v_usb_pkt := C_DEFAULT_USB_PACKET; -- copy default packet
v_usb_pkt.pkt_type := DATA; -- define the type of packet to create
v_usb_pkt.data_pkt.data(0 to 5) := (x"01", x"02", x"33", x"44", x"50", x"06"); -- set the data packet payload (6 bytes)
v_usb_pkt.data_pkt.data_len := 6; -- set the data length
v_len := f_usb_create_pkt_len(v_usb_pkt); -- get length of USB packet (optional)
v_pkt(0 to v_len - 1) := f_usb_create_pkt(v_usb_pkt); -- v_pkt now holds the USB packet in 8bit format

See further examples in the test bench nw_usb_tb.vhd.