IEEE1588v2
The PTP library provides functions for creating and manipulating IEEE1588v2 packets.
Functionality
- Create PTPv2 messages
- Extract PTPv2 messages
More details in nw_ptpv2_pkg
Example use
Include the libraries:
library nw_util;
context nw_util.nw_util_context;
library nw_ptp;
use nw_ptp.nw_ptpv2.all;
library ne_ethernet;
context nw_ethernet.nw_ethernet_context;
In many other NetWiz protocols a packet consists of a header and a payload. The PTP packet (or message) is contained completely in a record.
variable v_msg : t_ptpv2_msg;
variable v_len : natural;
variable v_pkt : t_slv_arr(0 to 127)(7 downto 0);
Example 1: Create a Sync message in an Ethernet packet.
v_msg := C_DEFAULT_PTPV2_MSG;
v_msg.header.message_type := C_MSG_SYNC;
v_msg.header.sequence_id := x"1234";
v_msg.origin_timestamp.seconds := x"0000511003fc";
v_msg.origin_timestamp.nanoseconds := x"0188fa34";
v_eth_header := C_DEFAULT_ETH_HEADER;
v_eth_header.mac_dest := f_eth_mac_2_slv_arr("01:1b:19:00:00:00");
v_eth_header.ethertype := C_ET_PTP;
v_len := f_eth_create_pkt_len(v_eth_header, f_ptpv2_create_pkt(v_msg));
v_pkt(0 to v_len -1) := f_eth_create_pkt(v_eth_header, f_ptpv2_create_pkt(v_msg));
See further examples in the test bench nw_ptp_tb.vhd.