diff --git a/rtl/axis_baser_tx_64.v b/rtl/axis_baser_tx_64.v index d79bfe8f3..3a2523655 100644 --- a/rtl/axis_baser_tx_64.v +++ b/rtl/axis_baser_tx_64.v @@ -43,9 +43,10 @@ module axis_baser_tx_64 # parameter PTP_PERIOD_FNS = 16'h6666, parameter PTP_TS_ENABLE = 0, parameter PTP_TS_WIDTH = 96, + parameter PTP_TS_CTRL_IN_TUSER = 0, parameter PTP_TAG_ENABLE = PTP_TS_ENABLE, parameter PTP_TAG_WIDTH = 16, - parameter USER_WIDTH = (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + 1 + parameter USER_WIDTH = (PTP_TS_ENABLE ? (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + (PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1 ) ( input wire clk, @@ -400,31 +401,44 @@ always @* begin // XGMII start and preamble if (swap_lanes_reg) begin // lanes swapped - if (PTP_TS_WIDTH == 96) begin - m_axis_ptp_ts_next[45:0] = ptp_ts[45:0] + (((PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS) * 3) >> 1); - m_axis_ptp_ts_next[95:48] = ptp_ts[95:48]; - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_int_next = 1'b1; - end else begin - m_axis_ptp_ts_next = ptp_ts + (((PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS) * 3) >> 1); - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_next = 1'b1; + if (PTP_TS_ENABLE) begin + if (PTP_TS_WIDTH == 96) begin + m_axis_ptp_ts_next[45:0] = ptp_ts[45:0] + (((PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS) * 3) >> 1); + m_axis_ptp_ts_next[95:48] = ptp_ts[95:48]; + end else begin + m_axis_ptp_ts_next = ptp_ts + (((PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS) * 3) >> 1); + end end start_packet_next = 2'b10; end else begin // lanes not swapped - if (PTP_TS_WIDTH == 96) begin - m_axis_ptp_ts_next[45:0] = ptp_ts[45:0] + (PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS); - m_axis_ptp_ts_next[95:48] = ptp_ts[95:48]; - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_int_next = 1'b1; - end else begin - m_axis_ptp_ts_next = ptp_ts + (PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS); - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_next = 1'b1; + if (PTP_TS_ENABLE) begin + if (PTP_TS_WIDTH == 96) begin + m_axis_ptp_ts_next[45:0] = ptp_ts[45:0] + (PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS); + m_axis_ptp_ts_next[95:48] = ptp_ts[95:48]; + end else begin + m_axis_ptp_ts_next = ptp_ts + (PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS); + end end start_packet_next = 2'b01; end + if (PTP_TS_ENABLE) begin + if (PTP_TS_CTRL_IN_TUSER) begin + m_axis_ptp_ts_tag_next = s_axis_tuser >> 2; + if (PTP_TS_WIDTH == 96) begin + m_axis_ptp_ts_valid_int_next = s_axis_tuser[1]; + end else begin + m_axis_ptp_ts_valid_next = s_axis_tuser[1]; + end + end else begin + m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; + if (PTP_TS_WIDTH == 96) begin + m_axis_ptp_ts_valid_int_next = 1'b1; + end else begin + m_axis_ptp_ts_valid_next = 1'b1; + end + end + end output_data_next = {ETH_SFD, {7{ETH_PRE}}}; output_type_next = OUTPUT_TYPE_START_0; s_axis_tready_next = 1'b1; diff --git a/rtl/axis_gmii_tx.v b/rtl/axis_gmii_tx.v index d887536e9..36c4c210c 100644 --- a/rtl/axis_gmii_tx.v +++ b/rtl/axis_gmii_tx.v @@ -38,9 +38,10 @@ module axis_gmii_tx # parameter MIN_FRAME_LENGTH = 64, parameter PTP_TS_ENABLE = 0, parameter PTP_TS_WIDTH = 96, + parameter PTP_TS_CTRL_IN_TUSER = 0, parameter PTP_TAG_ENABLE = PTP_TS_ENABLE, parameter PTP_TAG_WIDTH = 16, - parameter USER_WIDTH = (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + 1 + parameter USER_WIDTH = (PTP_TS_ENABLE ? (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + (PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1 ) ( input wire clk, @@ -196,10 +197,15 @@ always @* begin gmii_tx_en_next = 1'b0; gmii_tx_er_next = 1'b0; - if (start_packet_reg) begin + if (start_packet_reg && PTP_TS_ENABLE) begin m_axis_ptp_ts_next = ptp_ts; - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_next = 1'b1; + if (PTP_TS_CTRL_IN_TUSER) begin + m_axis_ptp_ts_tag_next = s_axis_tuser >> 2; + m_axis_ptp_ts_valid_next = s_axis_tuser[1]; + end else begin + m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; + m_axis_ptp_ts_valid_next = 1'b1; + end end start_packet_int_next = start_packet_int_reg; diff --git a/rtl/axis_xgmii_tx_32.v b/rtl/axis_xgmii_tx_32.v index 1f87cef24..673438662 100644 --- a/rtl/axis_xgmii_tx_32.v +++ b/rtl/axis_xgmii_tx_32.v @@ -41,9 +41,10 @@ module axis_xgmii_tx_32 # parameter MIN_FRAME_LENGTH = 64, parameter PTP_TS_ENABLE = 0, parameter PTP_TS_WIDTH = 96, + parameter PTP_TS_CTRL_IN_TUSER = 0, parameter PTP_TAG_ENABLE = PTP_TS_ENABLE, parameter PTP_TAG_WIDTH = 16, - parameter USER_WIDTH = (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + 1 + parameter USER_WIDTH = (PTP_TS_ENABLE ? (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + (PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1 ) ( input wire clk, @@ -276,10 +277,15 @@ always @* begin m_axis_ptp_ts_tag_next = m_axis_ptp_ts_tag_reg; m_axis_ptp_ts_valid_next = 1'b0; - if (start_packet_reg) begin + if (start_packet_reg && PTP_TS_ENABLE) begin m_axis_ptp_ts_next = ptp_ts; - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_next = 1'b1; + if (PTP_TS_CTRL_IN_TUSER) begin + m_axis_ptp_ts_tag_next = s_axis_tuser >> 2; + m_axis_ptp_ts_valid_next = s_axis_tuser[1]; + end else begin + m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; + m_axis_ptp_ts_valid_next = 1'b1; + end end // XGMII idle diff --git a/rtl/axis_xgmii_tx_64.v b/rtl/axis_xgmii_tx_64.v index 4372c75c8..060ec412d 100644 --- a/rtl/axis_xgmii_tx_64.v +++ b/rtl/axis_xgmii_tx_64.v @@ -43,9 +43,10 @@ module axis_xgmii_tx_64 # parameter PTP_PERIOD_FNS = 16'h6666, parameter PTP_TS_ENABLE = 0, parameter PTP_TS_WIDTH = 96, + parameter PTP_TS_CTRL_IN_TUSER = 0, parameter PTP_TAG_ENABLE = PTP_TS_ENABLE, parameter PTP_TAG_WIDTH = 16, - parameter USER_WIDTH = (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + 1 + parameter USER_WIDTH = (PTP_TS_ENABLE ? (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + (PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1 ) ( input wire clk, @@ -347,31 +348,44 @@ always @* begin // XGMII start and preamble if (swap_lanes_reg) begin // lanes swapped - if (PTP_TS_WIDTH == 96) begin - m_axis_ptp_ts_next[45:0] = ptp_ts[45:0] + (((PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS) * 3) >> 1); - m_axis_ptp_ts_next[95:48] = ptp_ts[95:48]; - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_int_next = 1'b1; - end else begin - m_axis_ptp_ts_next = ptp_ts + (((PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS) * 3) >> 1); - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_next = 1'b1; + if (PTP_TS_ENABLE) begin + if (PTP_TS_WIDTH == 96) begin + m_axis_ptp_ts_next[45:0] = ptp_ts[45:0] + (((PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS) * 3) >> 1); + m_axis_ptp_ts_next[95:48] = ptp_ts[95:48]; + end else begin + m_axis_ptp_ts_next = ptp_ts + (((PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS) * 3) >> 1); + end end start_packet_next = 2'b10; end else begin // lanes not swapped - if (PTP_TS_WIDTH == 96) begin - m_axis_ptp_ts_next[45:0] = ptp_ts[45:0] + (PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS); - m_axis_ptp_ts_next[95:48] = ptp_ts[95:48]; - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_int_next = 1'b1; - end else begin - m_axis_ptp_ts_next = ptp_ts + (PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS); - m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; - m_axis_ptp_ts_valid_next = 1'b1; + if (PTP_TS_ENABLE) begin + if (PTP_TS_WIDTH == 96) begin + m_axis_ptp_ts_next[45:0] = ptp_ts[45:0] + (PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS); + m_axis_ptp_ts_next[95:48] = ptp_ts[95:48]; + end else begin + m_axis_ptp_ts_next = ptp_ts + (PTP_PERIOD_NS * 2**16 + PTP_PERIOD_FNS); + end end start_packet_next = 2'b01; end + if (PTP_TS_ENABLE) begin + if (PTP_TS_CTRL_IN_TUSER) begin + m_axis_ptp_ts_tag_next = s_axis_tuser >> 2; + if (PTP_TS_WIDTH == 96) begin + m_axis_ptp_ts_valid_int_next = s_axis_tuser[1]; + end else begin + m_axis_ptp_ts_valid_next = s_axis_tuser[1]; + end + end else begin + m_axis_ptp_ts_tag_next = s_axis_tuser >> 1; + if (PTP_TS_WIDTH == 96) begin + m_axis_ptp_ts_valid_int_next = 1'b1; + end else begin + m_axis_ptp_ts_valid_next = 1'b1; + end + end + end xgmii_txd_next = {ETH_SFD, {6{ETH_PRE}}, XGMII_START}; xgmii_txc_next = 8'b00000001; s_axis_tready_next = 1'b1; diff --git a/rtl/eth_mac_10g.v b/rtl/eth_mac_10g.v index 7346c0248..b9e89c9af 100644 --- a/rtl/eth_mac_10g.v +++ b/rtl/eth_mac_10g.v @@ -43,11 +43,12 @@ module eth_mac_10g # parameter PTP_PERIOD_FNS = 16'h6666, parameter TX_PTP_TS_ENABLE = 0, parameter TX_PTP_TS_WIDTH = 96, + parameter TX_PTP_TS_CTRL_IN_TUSER = 0, parameter TX_PTP_TAG_ENABLE = TX_PTP_TS_ENABLE, parameter TX_PTP_TAG_WIDTH = 16, parameter RX_PTP_TS_ENABLE = TX_PTP_TS_ENABLE, parameter RX_PTP_TS_WIDTH = 96, - parameter TX_USER_WIDTH = (TX_PTP_TS_ENABLE && TX_PTP_TAG_ENABLE ? TX_PTP_TAG_WIDTH : 0) + 1, + parameter TX_USER_WIDTH = (TX_PTP_TS_ENABLE ? (TX_PTP_TAG_ENABLE ? TX_PTP_TAG_WIDTH : 0) + (TX_PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1, parameter RX_USER_WIDTH = (RX_PTP_TS_ENABLE ? RX_PTP_TS_WIDTH : 0) + 1 ) ( @@ -161,6 +162,7 @@ axis_xgmii_tx_64 #( .PTP_PERIOD_FNS(PTP_PERIOD_FNS), .PTP_TS_ENABLE(TX_PTP_TS_ENABLE), .PTP_TS_WIDTH(TX_PTP_TS_WIDTH), + .PTP_TS_CTRL_IN_TUSER(TX_PTP_TS_CTRL_IN_TUSER), .PTP_TAG_ENABLE(TX_PTP_TAG_ENABLE), .PTP_TAG_WIDTH(TX_PTP_TAG_WIDTH), .USER_WIDTH(TX_USER_WIDTH) @@ -222,6 +224,7 @@ axis_xgmii_tx_32 #( .MIN_FRAME_LENGTH(MIN_FRAME_LENGTH), .PTP_TS_ENABLE(TX_PTP_TS_ENABLE), .PTP_TS_WIDTH(TX_PTP_TS_WIDTH), + .PTP_TS_CTRL_IN_TUSER(TX_PTP_TS_CTRL_IN_TUSER), .PTP_TAG_ENABLE(TX_PTP_TAG_ENABLE), .PTP_TAG_WIDTH(TX_PTP_TAG_WIDTH), .USER_WIDTH(TX_USER_WIDTH) diff --git a/rtl/eth_mac_10g_fifo.v b/rtl/eth_mac_10g_fifo.v index 396827964..a99b968b8 100644 --- a/rtl/eth_mac_10g_fifo.v +++ b/rtl/eth_mac_10g_fifo.v @@ -58,11 +58,12 @@ module eth_mac_10g_fifo # parameter PTP_USE_SAMPLE_CLOCK = 0, parameter TX_PTP_TS_ENABLE = 0, parameter RX_PTP_TS_ENABLE = TX_PTP_TS_ENABLE, + parameter TX_PTP_TS_CTRL_IN_TUSER = 0, parameter TX_PTP_TS_FIFO_DEPTH = 64, parameter PTP_TS_WIDTH = 96, parameter TX_PTP_TAG_ENABLE = TX_PTP_TS_ENABLE, parameter PTP_TAG_WIDTH = 16, - parameter TX_USER_WIDTH = (TX_PTP_TS_ENABLE && TX_PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + 1, + parameter TX_USER_WIDTH = (TX_PTP_TS_ENABLE ? (TX_PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + (TX_PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1, parameter RX_USER_WIDTH = (RX_PTP_TS_ENABLE ? PTP_TS_WIDTH : 0) + 1 ) ( @@ -339,6 +340,7 @@ eth_mac_10g #( .PTP_PERIOD_FNS(PTP_PERIOD_FNS), .TX_PTP_TS_ENABLE(TX_PTP_TS_ENABLE), .TX_PTP_TS_WIDTH(PTP_TS_WIDTH), + .TX_PTP_TS_CTRL_IN_TUSER(TX_PTP_TS_CTRL_IN_TUSER), .TX_PTP_TAG_ENABLE(TX_PTP_TAG_ENABLE), .TX_PTP_TAG_WIDTH(PTP_TAG_WIDTH), .RX_PTP_TS_ENABLE(RX_PTP_TS_ENABLE), diff --git a/rtl/eth_mac_1g.v b/rtl/eth_mac_1g.v index 9fed39ee0..27cd40b36 100644 --- a/rtl/eth_mac_1g.v +++ b/rtl/eth_mac_1g.v @@ -38,11 +38,12 @@ module eth_mac_1g # parameter MIN_FRAME_LENGTH = 64, parameter TX_PTP_TS_ENABLE = 0, parameter TX_PTP_TS_WIDTH = 96, + parameter TX_PTP_TS_CTRL_IN_TUSER = 0, parameter TX_PTP_TAG_ENABLE = TX_PTP_TS_ENABLE, parameter TX_PTP_TAG_WIDTH = 16, parameter RX_PTP_TS_ENABLE = TX_PTP_TS_ENABLE, parameter RX_PTP_TS_WIDTH = 96, - parameter TX_USER_WIDTH = (TX_PTP_TAG_ENABLE ? TX_PTP_TAG_WIDTH : 0) + 1, + parameter TX_USER_WIDTH = (TX_PTP_TS_ENABLE ? (TX_PTP_TAG_ENABLE ? TX_PTP_TAG_WIDTH : 0) + (TX_PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1, parameter RX_USER_WIDTH = (RX_PTP_TS_ENABLE ? RX_PTP_TS_WIDTH : 0) + 1 ) ( @@ -140,6 +141,7 @@ axis_gmii_tx #( .MIN_FRAME_LENGTH(MIN_FRAME_LENGTH), .PTP_TS_ENABLE(TX_PTP_TS_ENABLE), .PTP_TS_WIDTH(TX_PTP_TS_WIDTH), + .PTP_TS_CTRL_IN_TUSER(TX_PTP_TS_CTRL_IN_TUSER), .PTP_TAG_ENABLE(TX_PTP_TAG_ENABLE), .PTP_TAG_WIDTH(TX_PTP_TAG_WIDTH), .USER_WIDTH(TX_USER_WIDTH) diff --git a/rtl/eth_mac_phy_10g.v b/rtl/eth_mac_phy_10g.v index 7e85b5755..46267b7f6 100644 --- a/rtl/eth_mac_phy_10g.v +++ b/rtl/eth_mac_phy_10g.v @@ -43,11 +43,12 @@ module eth_mac_phy_10g # parameter PTP_PERIOD_FNS = 16'h6666, parameter TX_PTP_TS_ENABLE = 0, parameter TX_PTP_TS_WIDTH = 96, + parameter TX_PTP_TS_CTRL_IN_TUSER = 0, parameter TX_PTP_TAG_ENABLE = TX_PTP_TS_ENABLE, parameter TX_PTP_TAG_WIDTH = 16, parameter RX_PTP_TS_ENABLE = TX_PTP_TS_ENABLE, parameter RX_PTP_TS_WIDTH = 96, - parameter TX_USER_WIDTH = (TX_PTP_TAG_ENABLE ? TX_PTP_TAG_WIDTH : 0) + 1, + parameter TX_USER_WIDTH = (TX_PTP_TS_ENABLE ? (TX_PTP_TAG_ENABLE ? TX_PTP_TAG_WIDTH : 0) + (TX_PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1, parameter RX_USER_WIDTH = (RX_PTP_TS_ENABLE ? RX_PTP_TS_WIDTH : 0) + 1, parameter BIT_REVERSE = 0, parameter SCRAMBLER_DISABLE = 0, @@ -176,6 +177,7 @@ eth_mac_phy_10g_tx #( .PTP_PERIOD_FNS(PTP_PERIOD_FNS), .PTP_TS_ENABLE(TX_PTP_TS_ENABLE), .PTP_TS_WIDTH(TX_PTP_TS_WIDTH), + .PTP_TS_CTRL_IN_TUSER(TX_PTP_TS_CTRL_IN_TUSER), .PTP_TAG_ENABLE(TX_PTP_TAG_ENABLE), .PTP_TAG_WIDTH(TX_PTP_TAG_WIDTH), .USER_WIDTH(TX_USER_WIDTH), diff --git a/rtl/eth_mac_phy_10g_fifo.v b/rtl/eth_mac_phy_10g_fifo.v index 6b1b71e20..6205cdca1 100644 --- a/rtl/eth_mac_phy_10g_fifo.v +++ b/rtl/eth_mac_phy_10g_fifo.v @@ -66,11 +66,12 @@ module eth_mac_phy_10g_fifo # parameter PTP_USE_SAMPLE_CLOCK = 0, parameter TX_PTP_TS_ENABLE = 0, parameter RX_PTP_TS_ENABLE = TX_PTP_TS_ENABLE, + parameter TX_PTP_TS_CTRL_IN_TUSER = 0, parameter TX_PTP_TS_FIFO_DEPTH = 64, parameter PTP_TS_WIDTH = 96, parameter TX_PTP_TAG_ENABLE = TX_PTP_TS_ENABLE, parameter PTP_TAG_WIDTH = 16, - parameter TX_USER_WIDTH = (TX_PTP_TS_ENABLE && TX_PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + 1, + parameter TX_USER_WIDTH = (TX_PTP_TS_ENABLE ? (TX_PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + (TX_PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1, parameter RX_USER_WIDTH = (RX_PTP_TS_ENABLE ? PTP_TS_WIDTH : 0) + 1 ) ( @@ -368,6 +369,7 @@ eth_mac_phy_10g #( .PTP_PERIOD_FNS(PTP_PERIOD_FNS), .TX_PTP_TS_ENABLE(TX_PTP_TS_ENABLE), .TX_PTP_TS_WIDTH(PTP_TS_WIDTH), + .TX_PTP_TS_CTRL_IN_TUSER(TX_PTP_TS_CTRL_IN_TUSER), .TX_PTP_TAG_ENABLE(TX_PTP_TAG_ENABLE), .TX_PTP_TAG_WIDTH(PTP_TAG_WIDTH), .RX_PTP_TS_ENABLE(RX_PTP_TS_ENABLE), diff --git a/rtl/eth_mac_phy_10g_tx.v b/rtl/eth_mac_phy_10g_tx.v index 4e6f55710..38d39c3db 100644 --- a/rtl/eth_mac_phy_10g_tx.v +++ b/rtl/eth_mac_phy_10g_tx.v @@ -43,9 +43,10 @@ module eth_mac_phy_10g_tx # parameter PTP_PERIOD_FNS = 16'h6666, parameter PTP_TS_ENABLE = 0, parameter PTP_TS_WIDTH = 96, + parameter PTP_TS_CTRL_IN_TUSER = 0, parameter PTP_TAG_ENABLE = PTP_TS_ENABLE, parameter PTP_TAG_WIDTH = 16, - parameter USER_WIDTH = (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + 1, + parameter USER_WIDTH = (PTP_TS_ENABLE ? (PTP_TAG_ENABLE ? PTP_TAG_WIDTH : 0) + (PTP_TS_CTRL_IN_TUSER ? 1 : 0) : 0) + 1, parameter BIT_REVERSE = 0, parameter SCRAMBLER_DISABLE = 0, parameter PRBS31_ENABLE = 0, @@ -124,6 +125,7 @@ axis_baser_tx_64 #( .PTP_PERIOD_FNS(PTP_PERIOD_FNS), .PTP_TS_ENABLE(PTP_TS_ENABLE), .PTP_TS_WIDTH(PTP_TS_WIDTH), + .PTP_TS_CTRL_IN_TUSER(PTP_TS_CTRL_IN_TUSER), .PTP_TAG_ENABLE(PTP_TAG_ENABLE), .PTP_TAG_WIDTH(PTP_TAG_WIDTH), .USER_WIDTH(USER_WIDTH) diff --git a/tb/axis_baser_tx_64/Makefile b/tb/axis_baser_tx_64/Makefile index 26b54659c..a5d23facd 100644 --- a/tb/axis_baser_tx_64/Makefile +++ b/tb/axis_baser_tx_64/Makefile @@ -41,9 +41,10 @@ export PARAM_ENABLE_DIC := 1 export PARAM_MIN_FRAME_LENGTH := 64 export PARAM_PTP_TS_ENABLE := 1 export PARAM_PTP_TS_WIDTH := 96 +export PARAM_PTP_TS_CTRL_IN_TUSER := $(PARAM_PTP_TS_ENABLE) export PARAM_PTP_TAG_ENABLE := $(PARAM_PTP_TS_ENABLE) export PARAM_PTP_TAG_WIDTH := 16 -export PARAM_USER_WIDTH := $(if $(filter-out 1,$(PARAM_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_PTP_TAG_WIDTH) + 1 )) +export PARAM_USER_WIDTH := $(if $(filter-out 1,$(PARAM_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_PTP_TAG_ENABLE)),0,$(PARAM_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) ifeq ($(SIM), icarus) PLUSARGS += -fst diff --git a/tb/axis_baser_tx_64/test_axis_baser_tx_64.py b/tb/axis_baser_tx_64/test_axis_baser_tx_64.py index e8b6b77f0..1f522429b 100644 --- a/tb/axis_baser_tx_64/test_axis_baser_tx_64.py +++ b/tb/axis_baser_tx_64/test_axis_baser_tx_64.py @@ -38,7 +38,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamFrame from cocotbext.axi.stream import define_stream try: @@ -98,7 +98,7 @@ async def run_test(dut, payload_lengths=None, payload_data=None, ifg=12): test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.source.send(test_data) + await tb.source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.sink.recv() @@ -144,7 +144,7 @@ async def run_test_alignment(dut, payload_data=None, ifg=12): start_lane = [] for test_data in test_frames: - await tb.source.send(test_data) + await tb.source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.sink.recv() @@ -263,9 +263,10 @@ def test_axis_baser_tx_64(request, enable_dic): parameters['MIN_FRAME_LENGTH'] = 64 parameters['PTP_TS_ENABLE'] = 1 parameters['PTP_TS_WIDTH'] = 96 + parameters['PTP_TS_CTRL_IN_TUSER'] = parameters['PTP_TS_ENABLE'] parameters['PTP_TAG_ENABLE'] = parameters['PTP_TS_ENABLE'] parameters['PTP_TAG_WIDTH'] = 16 - parameters['USER_WIDTH'] = (parameters['PTP_TAG_WIDTH'] if parameters['PTP_TAG_ENABLE'] else 0) + 1 + parameters['USER_WIDTH'] = ((parameters['PTP_TAG_WIDTH'] if parameters['PTP_TAG_ENABLE'] else 0) + (1 if parameters['PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['PTP_TS_ENABLE'] else 0) + 1 extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} diff --git a/tb/axis_gmii_tx/Makefile b/tb/axis_gmii_tx/Makefile index 5015e1b46..8686c13d3 100644 --- a/tb/axis_gmii_tx/Makefile +++ b/tb/axis_gmii_tx/Makefile @@ -38,9 +38,10 @@ export PARAM_ENABLE_PADDING := 1 export PARAM_MIN_FRAME_LENGTH := 64 export PARAM_PTP_TS_ENABLE := 1 export PARAM_PTP_TS_WIDTH := 96 +export PARAM_PTP_TS_CTRL_IN_TUSER := $(PARAM_PTP_TS_ENABLE) export PARAM_PTP_TAG_ENABLE := $(PARAM_PTP_TS_ENABLE) export PARAM_PTP_TAG_WIDTH := 16 -export PARAM_USER_WIDTH := $(if $(filter-out 1,$(PARAM_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_PTP_TAG_WIDTH) + 1 )) +export PARAM_USER_WIDTH := $(if $(filter-out 1,$(PARAM_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_PTP_TAG_ENABLE)),0,$(PARAM_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) ifeq ($(SIM), icarus) PLUSARGS += -fst diff --git a/tb/axis_gmii_tx/test_axis_gmii_tx.py b/tb/axis_gmii_tx/test_axis_gmii_tx.py index 246598f6a..75cd31bc0 100644 --- a/tb/axis_gmii_tx/test_axis_gmii_tx.py +++ b/tb/axis_gmii_tx/test_axis_gmii_tx.py @@ -36,7 +36,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import GmiiSink, PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamFrame from cocotbext.axi.stream import define_stream @@ -114,7 +114,7 @@ async def run_test(dut, payload_lengths=None, payload_data=None, ifg=12, enable_ test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.source.send(test_data) + await tb.source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.sink.recv() @@ -186,9 +186,10 @@ def test_axis_gmii_tx(request): parameters['MIN_FRAME_LENGTH'] = 64 parameters['PTP_TS_ENABLE'] = 1 parameters['PTP_TS_WIDTH'] = 96 + parameters['PTP_TS_CTRL_IN_TUSER'] = parameters['PTP_TS_ENABLE'] parameters['PTP_TAG_ENABLE'] = parameters['PTP_TS_ENABLE'] parameters['PTP_TAG_WIDTH'] = 16 - parameters['USER_WIDTH'] = (parameters['PTP_TS_WIDTH'] if parameters['PTP_TS_ENABLE'] else 0) + 1 + parameters['USER_WIDTH'] = ((parameters['PTP_TAG_WIDTH'] if parameters['PTP_TAG_ENABLE'] else 0) + (1 if parameters['PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['PTP_TS_ENABLE'] else 0) + 1 extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} diff --git a/tb/axis_xgmii_tx_32/Makefile b/tb/axis_xgmii_tx_32/Makefile index e24b2f9a1..ceef12de3 100644 --- a/tb/axis_xgmii_tx_32/Makefile +++ b/tb/axis_xgmii_tx_32/Makefile @@ -41,9 +41,10 @@ export PARAM_ENABLE_DIC := 1 export PARAM_MIN_FRAME_LENGTH := 64 export PARAM_PTP_TS_ENABLE := 1 export PARAM_PTP_TS_WIDTH := 96 +export PARAM_PTP_TS_CTRL_IN_TUSER := $(PARAM_PTP_TS_ENABLE) export PARAM_PTP_TAG_ENABLE := $(PARAM_PTP_TS_ENABLE) export PARAM_PTP_TAG_WIDTH := 16 -export PARAM_USER_WIDTH := $(if $(filter-out 1,$(PARAM_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_PTP_TAG_WIDTH) + 1 )) +export PARAM_USER_WIDTH := $(if $(filter-out 1,$(PARAM_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_PTP_TAG_ENABLE)),0,$(PARAM_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) ifeq ($(SIM), icarus) PLUSARGS += -fst diff --git a/tb/axis_xgmii_tx_32/test_axis_xgmii_tx_32.py b/tb/axis_xgmii_tx_32/test_axis_xgmii_tx_32.py index b6b3ab900..460043805 100644 --- a/tb/axis_xgmii_tx_32/test_axis_xgmii_tx_32.py +++ b/tb/axis_xgmii_tx_32/test_axis_xgmii_tx_32.py @@ -37,7 +37,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import XgmiiSink, PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamFrame from cocotbext.axi.stream import define_stream @@ -87,7 +87,7 @@ async def run_test(dut, payload_lengths=None, payload_data=None, ifg=12): test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.source.send(test_data) + await tb.source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.sink.recv() @@ -129,7 +129,7 @@ async def run_test_alignment(dut, payload_data=None, ifg=12): start_lane = [] for test_data in test_frames: - await tb.source.send(test_data) + await tb.source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.sink.recv() @@ -244,9 +244,10 @@ def test_axis_xgmii_tx_32(request, enable_dic): parameters['MIN_FRAME_LENGTH'] = 64 parameters['PTP_TS_ENABLE'] = 1 parameters['PTP_TS_WIDTH'] = 96 + parameters['PTP_TS_CTRL_IN_TUSER'] = parameters['PTP_TS_ENABLE'] parameters['PTP_TAG_ENABLE'] = parameters['PTP_TS_ENABLE'] parameters['PTP_TAG_WIDTH'] = 16 - parameters['USER_WIDTH'] = (parameters['PTP_TAG_WIDTH'] if parameters['PTP_TAG_ENABLE'] else 0) + 1 + parameters['USER_WIDTH'] = ((parameters['PTP_TAG_WIDTH'] if parameters['PTP_TAG_ENABLE'] else 0) + (1 if parameters['PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['PTP_TS_ENABLE'] else 0) + 1 extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} diff --git a/tb/axis_xgmii_tx_64/Makefile b/tb/axis_xgmii_tx_64/Makefile index 7743dd38b..0ade45058 100644 --- a/tb/axis_xgmii_tx_64/Makefile +++ b/tb/axis_xgmii_tx_64/Makefile @@ -41,9 +41,10 @@ export PARAM_ENABLE_DIC := 1 export PARAM_MIN_FRAME_LENGTH := 64 export PARAM_PTP_TS_ENABLE := 1 export PARAM_PTP_TS_WIDTH := 96 +export PARAM_PTP_TS_CTRL_IN_TUSER := $(PARAM_PTP_TS_ENABLE) export PARAM_PTP_TAG_ENABLE := $(PARAM_PTP_TS_ENABLE) export PARAM_PTP_TAG_WIDTH := 16 -export PARAM_USER_WIDTH := $(if $(filter-out 1,$(PARAM_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_PTP_TAG_WIDTH) + 1 )) +export PARAM_USER_WIDTH := $(if $(filter-out 1,$(PARAM_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_PTP_TAG_ENABLE)),0,$(PARAM_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) ifeq ($(SIM), icarus) PLUSARGS += -fst diff --git a/tb/axis_xgmii_tx_64/test_axis_xgmii_tx_64.py b/tb/axis_xgmii_tx_64/test_axis_xgmii_tx_64.py index cdc18de49..10d8fa837 100644 --- a/tb/axis_xgmii_tx_64/test_axis_xgmii_tx_64.py +++ b/tb/axis_xgmii_tx_64/test_axis_xgmii_tx_64.py @@ -37,7 +37,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import XgmiiSink, PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamFrame from cocotbext.axi.stream import define_stream @@ -87,7 +87,7 @@ async def run_test(dut, payload_lengths=None, payload_data=None, ifg=12): test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.source.send(test_data) + await tb.source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.sink.recv() @@ -133,7 +133,7 @@ async def run_test_alignment(dut, payload_data=None, ifg=12): start_lane = [] for test_data in test_frames: - await tb.source.send(test_data) + await tb.source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.sink.recv() @@ -252,9 +252,10 @@ def test_axis_xgmii_tx_64(request, enable_dic): parameters['MIN_FRAME_LENGTH'] = 64 parameters['PTP_TS_ENABLE'] = 1 parameters['PTP_TS_WIDTH'] = 96 + parameters['PTP_TS_CTRL_IN_TUSER'] = parameters['PTP_TS_ENABLE'] parameters['PTP_TAG_ENABLE'] = parameters['PTP_TS_ENABLE'] parameters['PTP_TAG_WIDTH'] = 16 - parameters['USER_WIDTH'] = (parameters['PTP_TAG_WIDTH'] if parameters['PTP_TAG_ENABLE'] else 0) + 1 + parameters['USER_WIDTH'] = ((parameters['PTP_TAG_WIDTH'] if parameters['PTP_TAG_ENABLE'] else 0) + (1 if parameters['PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['PTP_TS_ENABLE'] else 0) + 1 extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} diff --git a/tb/eth_mac_10g/Makefile b/tb/eth_mac_10g/Makefile index 7b0098fb2..1b22b8e9e 100644 --- a/tb/eth_mac_10g/Makefile +++ b/tb/eth_mac_10g/Makefile @@ -51,7 +51,7 @@ export PARAM_TX_PTP_TAG_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_TX_PTP_TAG_WIDTH := 16 export PARAM_RX_PTP_TS_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_RX_PTP_TS_WIDTH := 96 -export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),1,$(shell expr $(PARAM_TX_PTP_TAG_WIDTH) + 1 )) +export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),0,$(PARAM_TX_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(TX_PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) export PARAM_RX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_RX_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_RX_PTP_TS_WIDTH) + 1 )) ifeq ($(SIM), icarus) diff --git a/tb/eth_mac_10g/test_eth_mac_10g.py b/tb/eth_mac_10g/test_eth_mac_10g.py index 8261d44c7..8cfe70d9f 100644 --- a/tb/eth_mac_10g/test_eth_mac_10g.py +++ b/tb/eth_mac_10g/test_eth_mac_10g.py @@ -37,7 +37,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import XgmiiFrame, XgmiiSource, XgmiiSink, PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink, AxiStreamFrame from cocotbext.axi.stream import define_stream @@ -142,7 +142,7 @@ async def run_test_tx(dut, payload_lengths=None, payload_data=None, ifg=12): test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.xgmii_sink.recv() @@ -189,7 +189,7 @@ async def run_test_tx_alignment(dut, payload_data=None, ifg=12): start_lane = [] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.xgmii_sink.recv() @@ -304,11 +304,12 @@ def test_eth_mac_10g(request, data_width, enable_dic): parameters['PTP_PERIOD_FNS'] = 0x6666 if parameters['DATA_WIDTH'] == 64 else 0x3333 parameters['TX_PTP_TS_ENABLE'] = 1 parameters['TX_PTP_TS_WIDTH'] = 96 + parameters['TX_PTP_TS_CTRL_IN_TUSER'] = parameters['TX_PTP_TS_ENABLE'] parameters['TX_PTP_TAG_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] parameters['TX_PTP_TAG_WIDTH'] = 16 parameters['RX_PTP_TS_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] parameters['RX_PTP_TS_WIDTH'] = 96 - parameters['TX_USER_WIDTH'] = (parameters['TX_PTP_TAG_WIDTH'] if parameters['TX_PTP_TS_ENABLE'] and parameters['TX_PTP_TAG_ENABLE'] else 0) + 1 + parameters['TX_USER_WIDTH'] = ((parameters['TX_PTP_TAG_WIDTH'] if parameters['TX_PTP_TAG_ENABLE'] else 0) + (1 if parameters['TX_PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['TX_PTP_TS_ENABLE'] else 0) + 1 parameters['RX_USER_WIDTH'] = (parameters['RX_PTP_TS_WIDTH'] if parameters['RX_PTP_TS_ENABLE'] else 0) + 1 extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} diff --git a/tb/eth_mac_10g_fifo/Makefile b/tb/eth_mac_10g_fifo/Makefile index 2086f187d..ae8109a08 100644 --- a/tb/eth_mac_10g_fifo/Makefile +++ b/tb/eth_mac_10g_fifo/Makefile @@ -67,11 +67,12 @@ export PARAM_PTP_PERIOD_FNS := 26214 export PARAM_PTP_USE_SAMPLE_CLOCK := 0 export PARAM_TX_PTP_TS_ENABLE := 1 export PARAM_RX_PTP_TS_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) +export PARAM_TX_PTP_TS_CTRL_IN_TUSER := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_TX_PTP_TS_FIFO_DEPTH := 64 export PARAM_PTP_TS_WIDTH := 96 export PARAM_TX_PTP_TAG_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_PTP_TAG_WIDTH := 16 -export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),1,$(shell expr $(PARAM_PTP_TAG_WIDTH) + 1 )) +export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),0,$(PARAM_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(TX_PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) export PARAM_RX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_RX_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_PTP_TS_WIDTH) + 1 )) ifeq ($(SIM), icarus) diff --git a/tb/eth_mac_10g_fifo/test_eth_mac_10g_fifo.py b/tb/eth_mac_10g_fifo/test_eth_mac_10g_fifo.py index 04bfbf46e..09e1150c7 100644 --- a/tb/eth_mac_10g_fifo/test_eth_mac_10g_fifo.py +++ b/tb/eth_mac_10g_fifo/test_eth_mac_10g_fifo.py @@ -37,7 +37,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import XgmiiFrame, XgmiiSource, XgmiiSink, PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink, AxiStreamFrame from cocotbext.axi.stream import define_stream @@ -156,7 +156,7 @@ async def run_test_tx(dut, payload_lengths=None, payload_data=None, ifg=12): test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.xgmii_sink.recv() @@ -203,7 +203,7 @@ async def run_test_tx_alignment(dut, payload_data=None, ifg=12): start_lane = [] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.xgmii_sink.recv() @@ -338,11 +338,12 @@ def test_eth_mac_10g_fifo(request, data_width, enable_dic): parameters['PTP_USE_SAMPLE_CLOCK'] = 0 parameters['TX_PTP_TS_ENABLE'] = 1 parameters['RX_PTP_TS_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] + parameters['TX_PTP_TS_CTRL_IN_TUSER'] = parameters['TX_PTP_TS_ENABLE'] parameters['TX_PTP_TS_FIFO_DEPTH'] = 64 parameters['PTP_TS_WIDTH'] = 96 parameters['TX_PTP_TAG_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] parameters['PTP_TAG_WIDTH'] = 16 - parameters['TX_USER_WIDTH'] = (parameters['PTP_TAG_WIDTH'] if parameters['TX_PTP_TS_ENABLE'] and parameters['TX_PTP_TAG_ENABLE'] else 0) + 1 + parameters['TX_USER_WIDTH'] = ((parameters['PTP_TAG_WIDTH'] if parameters['TX_PTP_TAG_ENABLE'] else 0) + (1 if parameters['TX_PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['TX_PTP_TS_ENABLE'] else 0) + 1 parameters['RX_USER_WIDTH'] = (parameters['PTP_TS_WIDTH'] if parameters['RX_PTP_TS_ENABLE'] else 0) + 1 extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} diff --git a/tb/eth_mac_1g/Makefile b/tb/eth_mac_1g/Makefile index 351e0c02f..cf7a54693 100644 --- a/tb/eth_mac_1g/Makefile +++ b/tb/eth_mac_1g/Makefile @@ -40,11 +40,12 @@ export PARAM_ENABLE_PADDING := 1 export PARAM_MIN_FRAME_LENGTH := 64 export PARAM_TX_PTP_TS_ENABLE := 1 export PARAM_TX_PTP_TS_WIDTH := 96 +export PARAM_TX_PTP_TS_CTRL_IN_TUSER := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_TX_PTP_TAG_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_TX_PTP_TAG_WIDTH := 16 export PARAM_RX_PTP_TS_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_RX_PTP_TS_WIDTH := 96 -export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),1,$(shell expr $(PARAM_TX_PTP_TAG_WIDTH) + 1 )) +export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),0,$(PARAM_TX_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(TX_PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) export PARAM_RX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_RX_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_TX_PTP_TS_WIDTH) + 1 )) ifeq ($(SIM), icarus) diff --git a/tb/eth_mac_1g/test_eth_mac_1g.py b/tb/eth_mac_1g/test_eth_mac_1g.py index 06fffe442..9cc24913f 100644 --- a/tb/eth_mac_1g/test_eth_mac_1g.py +++ b/tb/eth_mac_1g/test_eth_mac_1g.py @@ -36,7 +36,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import GmiiFrame, GmiiSource, GmiiSink, PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink, AxiStreamFrame from cocotbext.axi.stream import define_stream @@ -193,7 +193,7 @@ async def run_test_tx(dut, payload_lengths=None, payload_data=None, ifg=12, enab test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.gmii_sink.recv() @@ -269,11 +269,12 @@ def test_eth_mac_1g(request): parameters['MIN_FRAME_LENGTH'] = 64 parameters['TX_PTP_TS_ENABLE'] = 1 parameters['TX_PTP_TS_WIDTH'] = 96 + parameters['TX_PTP_TS_CTRL_IN_TUSER'] = parameters['TX_PTP_TS_ENABLE'] parameters['TX_PTP_TAG_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] parameters['TX_PTP_TAG_WIDTH'] = 16 parameters['RX_PTP_TS_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] parameters['RX_PTP_TS_WIDTH'] = 96 - parameters['TX_USER_WIDTH'] = (parameters['TX_PTP_TAG_WIDTH'] if parameters['TX_PTP_TAG_ENABLE'] else 0) + 1 + parameters['TX_USER_WIDTH'] = ((parameters['TX_PTP_TAG_WIDTH'] if parameters['TX_PTP_TAG_ENABLE'] else 0) + (1 if parameters['TX_PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['TX_PTP_TS_ENABLE'] else 0) + 1 parameters['RX_USER_WIDTH'] = (parameters['RX_PTP_TS_WIDTH'] if parameters['RX_PTP_TS_ENABLE'] else 0) + 1 extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()} diff --git a/tb/eth_mac_phy_10g/Makefile b/tb/eth_mac_phy_10g/Makefile index b3da313bc..e5dec6fd2 100644 --- a/tb/eth_mac_phy_10g/Makefile +++ b/tb/eth_mac_phy_10g/Makefile @@ -52,11 +52,12 @@ export PARAM_PTP_PERIOD_NS := 6 export PARAM_PTP_PERIOD_FNS := 26214 export PARAM_TX_PTP_TS_ENABLE := 1 export PARAM_TX_PTP_TS_WIDTH := 96 +export PARAM_TX_PTP_TS_CTRL_IN_TUSER := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_TX_PTP_TAG_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_TX_PTP_TAG_WIDTH := 16 export PARAM_RX_PTP_TS_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_RX_PTP_TS_WIDTH := 96 -export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),1,$(shell expr $(PARAM_TX_PTP_TAG_WIDTH) + 1 )) +export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),0,$(PARAM_TX_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(TX_PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) export PARAM_RX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_RX_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_RX_PTP_TS_WIDTH) + 1 )) export PARAM_BIT_REVERSE := 0 export PARAM_SCRAMBLER_DISABLE := 0 diff --git a/tb/eth_mac_phy_10g/test_eth_mac_phy_10g.py b/tb/eth_mac_phy_10g/test_eth_mac_phy_10g.py index 32b6512e3..769de6fae 100644 --- a/tb/eth_mac_phy_10g/test_eth_mac_phy_10g.py +++ b/tb/eth_mac_phy_10g/test_eth_mac_phy_10g.py @@ -38,7 +38,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import XgmiiFrame, PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink, AxiStreamFrame from cocotbext.axi.stream import define_stream try: @@ -165,7 +165,7 @@ async def run_test_tx(dut, payload_lengths=None, payload_data=None, ifg=12): test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.serdes_sink.recv() @@ -212,7 +212,7 @@ async def run_test_tx_alignment(dut, payload_data=None, ifg=12): start_lane = [] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.serdes_sink.recv() @@ -373,11 +373,12 @@ def test_eth_mac_phy_10g(request, data_width, enable_dic): parameters['PTP_PERIOD_FNS'] = 0x6666 if parameters['DATA_WIDTH'] == 64 else 0x3333 parameters['TX_PTP_TS_ENABLE'] = 1 parameters['TX_PTP_TS_WIDTH'] = 96 + parameters['TX_PTP_TS_CTRL_IN_TUSER'] = parameters['TX_PTP_TS_ENABLE'] parameters['TX_PTP_TAG_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] parameters['TX_PTP_TAG_WIDTH'] = 16 parameters['RX_PTP_TS_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] parameters['RX_PTP_TS_WIDTH'] = 96 - parameters['TX_USER_WIDTH'] = (parameters['TX_PTP_TAG_WIDTH'] if parameters['TX_PTP_TS_ENABLE'] and parameters['TX_PTP_TAG_ENABLE'] else 0) + 1 + parameters['TX_USER_WIDTH'] = ((parameters['TX_PTP_TAG_WIDTH'] if parameters['TX_PTP_TAG_ENABLE'] else 0) + (1 if parameters['TX_PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['TX_PTP_TS_ENABLE'] else 0) + 1 parameters['RX_USER_WIDTH'] = (parameters['RX_PTP_TS_WIDTH'] if parameters['RX_PTP_TS_ENABLE'] else 0) + 1 parameters['BIT_REVERSE'] = 0 parameters['SCRAMBLER_DISABLE'] = 0 diff --git a/tb/eth_mac_phy_10g_fifo/Makefile b/tb/eth_mac_phy_10g_fifo/Makefile index d2d3486eb..c44570970 100644 --- a/tb/eth_mac_phy_10g_fifo/Makefile +++ b/tb/eth_mac_phy_10g_fifo/Makefile @@ -72,11 +72,12 @@ export PARAM_PTP_PERIOD_FNS := 26214 export PARAM_PTP_USE_SAMPLE_CLOCK := 0 export PARAM_TX_PTP_TS_ENABLE := 1 export PARAM_RX_PTP_TS_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) +export PARAM_TX_PTP_TS_CTRL_IN_TUSER := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_TX_PTP_TS_FIFO_DEPTH := 64 export PARAM_PTP_TS_WIDTH := 96 export PARAM_TX_PTP_TAG_ENABLE := $(PARAM_TX_PTP_TS_ENABLE) export PARAM_PTP_TAG_WIDTH := 16 -export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),1,$(shell expr $(PARAM_PTP_TAG_WIDTH) + 1 )) +export PARAM_TX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_TX_PTP_TS_ENABLE)),1,$(shell expr $(if $(filter-out 1,$(PARAM_TX_PTP_TAG_ENABLE)),0,$(PARAM_PTP_TAG_WIDTH)) + $(if $(filter-out 1,$(TX_PTP_TS_CTRL_IN_TUSER)),0,1) + 1 )) export PARAM_RX_USER_WIDTH := $(if $(filter-out 1,$(PARAM_RX_PTP_TS_ENABLE)),1,$(shell expr $(PARAM_PTP_TS_WIDTH) + 1 )) export PARAM_BIT_REVERSE := 0 export PARAM_SCRAMBLER_DISABLE := 0 diff --git a/tb/eth_mac_phy_10g_fifo/test_eth_mac_phy_10g_fifo.py b/tb/eth_mac_phy_10g_fifo/test_eth_mac_phy_10g_fifo.py index a22886665..aa6d8220c 100644 --- a/tb/eth_mac_phy_10g_fifo/test_eth_mac_phy_10g_fifo.py +++ b/tb/eth_mac_phy_10g_fifo/test_eth_mac_phy_10g_fifo.py @@ -38,7 +38,7 @@ from cocotb.utils import get_time_from_sim_steps from cocotb.regression import TestFactory from cocotbext.eth import XgmiiFrame, PtpClockSimTime -from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink +from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink, AxiStreamFrame from cocotbext.axi.stream import define_stream try: @@ -177,7 +177,7 @@ async def run_test_tx(dut, payload_lengths=None, payload_data=None, ifg=12): test_frames = [payload_data(x) for x in payload_lengths()] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.serdes_sink.recv() @@ -224,7 +224,7 @@ async def run_test_tx_alignment(dut, payload_data=None, ifg=12): start_lane = [] for test_data in test_frames: - await tb.axis_source.send(test_data) + await tb.axis_source.send(AxiStreamFrame(test_data, tuser=2)) for test_data in test_frames: rx_frame = await tb.serdes_sink.recv() @@ -405,11 +405,12 @@ def test_eth_mac_phy_10g_fifo(request, data_width, enable_dic): parameters['PTP_USE_SAMPLE_CLOCK'] = 0 parameters['TX_PTP_TS_ENABLE'] = 1 parameters['RX_PTP_TS_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] + parameters['TX_PTP_TS_CTRL_IN_TUSER'] = parameters['TX_PTP_TS_ENABLE'] parameters['TX_PTP_TS_FIFO_DEPTH'] = 64 parameters['PTP_TS_WIDTH'] = 96 parameters['TX_PTP_TAG_ENABLE'] = parameters['TX_PTP_TS_ENABLE'] parameters['PTP_TAG_WIDTH'] = 16 - parameters['TX_USER_WIDTH'] = (parameters['PTP_TAG_WIDTH'] if parameters['TX_PTP_TS_ENABLE'] and parameters['TX_PTP_TAG_ENABLE'] else 0) + 1 + parameters['TX_USER_WIDTH'] = ((parameters['PTP_TAG_WIDTH'] if parameters['TX_PTP_TAG_ENABLE'] else 0) + (1 if parameters['TX_PTP_TS_CTRL_IN_TUSER'] else 0) if parameters['TX_PTP_TS_ENABLE'] else 0) + 1 parameters['RX_USER_WIDTH'] = (parameters['PTP_TS_WIDTH'] if parameters['RX_PTP_TS_ENABLE'] else 0) + 1 parameters['BIT_REVERSE'] = 0 parameters['SCRAMBLER_DISABLE'] = 0