mirror of
https://github.com/fpganinja/taxi.git
synced 2025-12-09 00:48:40 -08:00
eth: Add GMII Ethernet MAC module and testbench
Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
3
rtl/eth/taxi_eth_mac_1g_gmii.f
Normal file
3
rtl/eth/taxi_eth_mac_1g_gmii.f
Normal file
@@ -0,0 +1,3 @@
|
||||
taxi_eth_mac_1g_gmii.sv
|
||||
taxi_eth_mac_1g.f
|
||||
taxi_gmii_phy_if.f
|
||||
423
rtl/eth/taxi_eth_mac_1g_gmii.sv
Normal file
423
rtl/eth/taxi_eth_mac_1g_gmii.sv
Normal file
@@ -0,0 +1,423 @@
|
||||
// SPDX-License-Identifier: CERN-OHL-S-2.0
|
||||
/*
|
||||
|
||||
Copyright (c) 2015-2025 FPGA Ninja, LLC
|
||||
|
||||
Authors:
|
||||
- Alex Forencich
|
||||
|
||||
*/
|
||||
|
||||
`resetall
|
||||
`timescale 1ns / 1ps
|
||||
`default_nettype none
|
||||
|
||||
/*
|
||||
* 1G Ethernet MAC with GMII interface
|
||||
*/
|
||||
module taxi_eth_mac_1g_gmii #
|
||||
(
|
||||
parameter logic SIM = 1'b0,
|
||||
parameter VENDOR = "XILINX",
|
||||
parameter FAMILY = "virtex7",
|
||||
parameter logic PADDING_EN = 1'b1,
|
||||
parameter MIN_FRAME_LEN = 64,
|
||||
parameter logic PTP_TS_EN = 1'b0,
|
||||
parameter PTP_TS_W = 96,
|
||||
parameter logic PFC_EN = 1'b0,
|
||||
parameter logic PAUSE_EN = PFC_EN
|
||||
)
|
||||
(
|
||||
input wire logic gtx_clk,
|
||||
input wire logic gtx_rst,
|
||||
output wire logic rx_clk,
|
||||
output wire logic rx_rst,
|
||||
output wire logic tx_clk,
|
||||
output wire logic tx_rst,
|
||||
|
||||
/*
|
||||
* Transmit interface (AXI stream)
|
||||
*/
|
||||
taxi_axis_if.snk s_axis_tx,
|
||||
taxi_axis_if.src m_axis_tx_cpl,
|
||||
|
||||
/*
|
||||
* Receive interface (AXI stream)
|
||||
*/
|
||||
taxi_axis_if.src m_axis_rx,
|
||||
|
||||
/*
|
||||
* GMII interface
|
||||
*/
|
||||
input wire logic gmii_rx_clk,
|
||||
input wire logic [7:0] gmii_rxd,
|
||||
input wire logic gmii_rx_dv,
|
||||
input wire logic gmii_rx_er,
|
||||
input wire logic mii_tx_clk,
|
||||
output wire logic gmii_tx_clk,
|
||||
output wire logic [7:0] gmii_txd,
|
||||
output wire logic gmii_tx_en,
|
||||
output wire logic gmii_tx_er,
|
||||
|
||||
/*
|
||||
* PTP
|
||||
*/
|
||||
input wire logic [PTP_TS_W-1:0] tx_ptp_ts = '0,
|
||||
input wire logic [PTP_TS_W-1:0] rx_ptp_ts = '0,
|
||||
|
||||
/*
|
||||
* Link-level Flow Control (LFC) (IEEE 802.3 annex 31B PAUSE)
|
||||
*/
|
||||
input wire logic tx_lfc_req = 1'b0,
|
||||
input wire logic tx_lfc_resend = 1'b0,
|
||||
input wire logic rx_lfc_en = 1'b0,
|
||||
output wire logic rx_lfc_req,
|
||||
input wire logic rx_lfc_ack = 1'b0,
|
||||
|
||||
/*
|
||||
* Priority Flow Control (PFC) (IEEE 802.3 annex 31D PFC)
|
||||
*/
|
||||
input wire logic [7:0] tx_pfc_req = '0,
|
||||
input wire logic tx_pfc_resend = 1'b0,
|
||||
input wire logic [7:0] rx_pfc_en = '0,
|
||||
output wire logic [7:0] rx_pfc_req,
|
||||
input wire logic [7:0] rx_pfc_ack = '0,
|
||||
|
||||
/*
|
||||
* Pause interface
|
||||
*/
|
||||
input wire logic tx_lfc_pause_en = 1'b0,
|
||||
input wire logic tx_pause_req = 1'b0,
|
||||
output wire logic tx_pause_ack,
|
||||
|
||||
/*
|
||||
* Status
|
||||
*/
|
||||
output wire logic tx_start_packet,
|
||||
output wire logic tx_error_underflow,
|
||||
output wire logic rx_start_packet,
|
||||
output wire logic rx_error_bad_frame,
|
||||
output wire logic rx_error_bad_fcs,
|
||||
output wire logic [1:0] link_speed,
|
||||
output wire logic stat_tx_mcf,
|
||||
output wire logic stat_rx_mcf,
|
||||
output wire logic stat_tx_lfc_pkt,
|
||||
output wire logic stat_tx_lfc_xon,
|
||||
output wire logic stat_tx_lfc_xoff,
|
||||
output wire logic stat_tx_lfc_paused,
|
||||
output wire logic stat_tx_pfc_pkt,
|
||||
output wire logic [7:0] stat_tx_pfc_xon,
|
||||
output wire logic [7:0] stat_tx_pfc_xoff,
|
||||
output wire logic [7:0] stat_tx_pfc_paused,
|
||||
output wire logic stat_rx_lfc_pkt,
|
||||
output wire logic stat_rx_lfc_xon,
|
||||
output wire logic stat_rx_lfc_xoff,
|
||||
output wire logic stat_rx_lfc_paused,
|
||||
output wire logic stat_rx_pfc_pkt,
|
||||
output wire logic [7:0] stat_rx_pfc_xon,
|
||||
output wire logic [7:0] stat_rx_pfc_xoff,
|
||||
output wire logic [7:0] stat_rx_pfc_paused,
|
||||
|
||||
/*
|
||||
* Configuration
|
||||
*/
|
||||
input wire logic [7:0] cfg_ifg = 8'd12,
|
||||
input wire logic cfg_tx_enable = 1'b1,
|
||||
input wire logic cfg_rx_enable = 1'b1,
|
||||
input wire logic [47:0] cfg_mcf_rx_eth_dst_mcast = 48'h01_80_C2_00_00_01,
|
||||
input wire logic cfg_mcf_rx_check_eth_dst_mcast = 1'b1,
|
||||
input wire logic [47:0] cfg_mcf_rx_eth_dst_ucast = 48'd0,
|
||||
input wire logic cfg_mcf_rx_check_eth_dst_ucast = 1'b0,
|
||||
input wire logic [47:0] cfg_mcf_rx_eth_src = 48'd0,
|
||||
input wire logic cfg_mcf_rx_check_eth_src = 1'b0,
|
||||
input wire logic [15:0] cfg_mcf_rx_eth_type = 16'h8808,
|
||||
input wire logic [15:0] cfg_mcf_rx_opcode_lfc = 16'h0001,
|
||||
input wire logic cfg_mcf_rx_check_opcode_lfc = 1'b1,
|
||||
input wire logic [15:0] cfg_mcf_rx_opcode_pfc = 16'h0101,
|
||||
input wire logic cfg_mcf_rx_check_opcode_pfc = 1'b1,
|
||||
input wire logic cfg_mcf_rx_forward = 1'b0,
|
||||
input wire logic cfg_mcf_rx_enable = 1'b0,
|
||||
input wire logic [47:0] cfg_tx_lfc_eth_dst = 48'h01_80_C2_00_00_01,
|
||||
input wire logic [47:0] cfg_tx_lfc_eth_src = 48'h80_23_31_43_54_4C,
|
||||
input wire logic [15:0] cfg_tx_lfc_eth_type = 16'h8808,
|
||||
input wire logic [15:0] cfg_tx_lfc_opcode = 16'h0001,
|
||||
input wire logic cfg_tx_lfc_en = 1'b0,
|
||||
input wire logic [15:0] cfg_tx_lfc_quanta = 16'hffff,
|
||||
input wire logic [15:0] cfg_tx_lfc_refresh = 16'h7fff,
|
||||
input wire logic [47:0] cfg_tx_pfc_eth_dst = 48'h01_80_C2_00_00_01,
|
||||
input wire logic [47:0] cfg_tx_pfc_eth_src = 48'h80_23_31_43_54_4C,
|
||||
input wire logic [15:0] cfg_tx_pfc_eth_type = 16'h8808,
|
||||
input wire logic [15:0] cfg_tx_pfc_opcode = 16'h0101,
|
||||
input wire logic cfg_tx_pfc_en = 1'b0,
|
||||
input wire logic [8*16-1:0] cfg_tx_pfc_quanta = {8{16'hffff}},
|
||||
input wire logic [8*16-1:0] cfg_tx_pfc_refresh = {8{16'h7fff}},
|
||||
input wire logic [15:0] cfg_rx_lfc_opcode = 16'h0001,
|
||||
input wire logic cfg_rx_lfc_en = 1'b0,
|
||||
input wire logic [15:0] cfg_rx_pfc_opcode = 16'h0101,
|
||||
input wire logic cfg_rx_pfc_en = 1'b0
|
||||
);
|
||||
|
||||
reg [1:0] link_speed_reg = 2'b10;
|
||||
reg mii_select_reg = 1'b0;
|
||||
|
||||
(* srl_style = "register" *)
|
||||
reg [1:0] tx_mii_select_sync = 2'd0;
|
||||
|
||||
always_ff @(posedge tx_clk) begin
|
||||
tx_mii_select_sync <= {tx_mii_select_sync[0], mii_select_reg};
|
||||
end
|
||||
|
||||
(* srl_style = "register" *)
|
||||
reg [1:0] rx_mii_select_sync = 2'd0;
|
||||
|
||||
always_ff @(posedge rx_clk) begin
|
||||
rx_mii_select_sync <= {rx_mii_select_sync[0], mii_select_reg};
|
||||
end
|
||||
|
||||
// PHY speed detection
|
||||
reg [2:0] rx_prescale = 3'd0;
|
||||
|
||||
always_ff @(posedge rx_clk) begin
|
||||
rx_prescale <= rx_prescale + 3'd1;
|
||||
end
|
||||
|
||||
(* srl_style = "register" *)
|
||||
reg [2:0] rx_prescale_sync = 3'd0;
|
||||
|
||||
always_ff @(posedge gtx_clk) begin
|
||||
rx_prescale_sync <= {rx_prescale_sync[1:0], rx_prescale[2]};
|
||||
end
|
||||
|
||||
reg [6:0] rx_speed_count_1 = 0;
|
||||
reg [1:0] rx_speed_count_2 = 0;
|
||||
|
||||
always_ff @(posedge gtx_clk) begin
|
||||
if (gtx_rst) begin
|
||||
rx_speed_count_1 <= 0;
|
||||
rx_speed_count_2 <= 0;
|
||||
link_speed_reg <= 2'b10;
|
||||
mii_select_reg <= 1'b0;
|
||||
end else begin
|
||||
rx_speed_count_1 <= rx_speed_count_1 + 1;
|
||||
|
||||
if (rx_prescale_sync[1] ^ rx_prescale_sync[2]) begin
|
||||
rx_speed_count_2 <= rx_speed_count_2 + 1;
|
||||
end
|
||||
|
||||
if (&rx_speed_count_1) begin
|
||||
// reference count overflow - 10M
|
||||
rx_speed_count_1 <= 0;
|
||||
rx_speed_count_2 <= 0;
|
||||
link_speed_reg <= 2'b00;
|
||||
mii_select_reg <= 1'b1;
|
||||
end
|
||||
|
||||
if (&rx_speed_count_2) begin
|
||||
// prescaled count overflow - 100M or 1000M
|
||||
rx_speed_count_1 <= 0;
|
||||
rx_speed_count_2 <= 0;
|
||||
if (rx_speed_count_1[6:5] != 0) begin
|
||||
// large reference count - 100M
|
||||
link_speed_reg <= 2'b01;
|
||||
mii_select_reg <= 1'b1;
|
||||
end else begin
|
||||
// small reference count - 1000M
|
||||
link_speed_reg <= 2'b10;
|
||||
mii_select_reg <= 1'b0;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assign link_speed = link_speed_reg;
|
||||
|
||||
wire [7:0] mac_gmii_rxd;
|
||||
wire mac_gmii_rx_dv;
|
||||
wire mac_gmii_rx_er;
|
||||
wire [7:0] mac_gmii_txd;
|
||||
wire mac_gmii_tx_en;
|
||||
wire mac_gmii_tx_er;
|
||||
|
||||
taxi_gmii_phy_if #(
|
||||
.SIM(SIM),
|
||||
.VENDOR(VENDOR),
|
||||
.FAMILY(FAMILY)
|
||||
)
|
||||
gmii_phy_if_inst (
|
||||
.gtx_clk(gtx_clk),
|
||||
.gtx_rst(gtx_rst),
|
||||
|
||||
/*
|
||||
* GMII interface to MAC
|
||||
*/
|
||||
.mac_gmii_rx_clk(rx_clk),
|
||||
.mac_gmii_rx_rst(rx_rst),
|
||||
.mac_gmii_rxd(mac_gmii_rxd),
|
||||
.mac_gmii_rx_dv(mac_gmii_rx_dv),
|
||||
.mac_gmii_rx_er(mac_gmii_rx_er),
|
||||
.mac_gmii_tx_clk(tx_clk),
|
||||
.mac_gmii_tx_rst(tx_rst),
|
||||
.mac_gmii_txd(mac_gmii_txd),
|
||||
.mac_gmii_tx_en(mac_gmii_tx_en),
|
||||
.mac_gmii_tx_er(mac_gmii_tx_er),
|
||||
|
||||
/*
|
||||
* GMII interface to PHY
|
||||
*/
|
||||
.phy_gmii_rx_clk(gmii_rx_clk),
|
||||
.phy_gmii_rxd(gmii_rxd),
|
||||
.phy_gmii_rx_dv(gmii_rx_dv),
|
||||
.phy_gmii_rx_er(gmii_rx_er),
|
||||
.phy_mii_tx_clk(mii_tx_clk),
|
||||
.phy_gmii_tx_clk(gmii_tx_clk),
|
||||
.phy_gmii_txd(gmii_txd),
|
||||
.phy_gmii_tx_en(gmii_tx_en),
|
||||
.phy_gmii_tx_er(gmii_tx_er),
|
||||
|
||||
.mii_select(mii_select_reg)
|
||||
);
|
||||
|
||||
taxi_eth_mac_1g #(
|
||||
.DATA_W(8),
|
||||
.PADDING_EN(PADDING_EN),
|
||||
.MIN_FRAME_LEN(MIN_FRAME_LEN),
|
||||
.PTP_TS_EN(PTP_TS_EN),
|
||||
.PTP_TS_W(PTP_TS_W),
|
||||
.PFC_EN(PFC_EN),
|
||||
.PAUSE_EN(PAUSE_EN)
|
||||
)
|
||||
eth_mac_1g_inst (
|
||||
.tx_clk(tx_clk),
|
||||
.tx_rst(tx_rst),
|
||||
.rx_clk(rx_clk),
|
||||
.rx_rst(rx_rst),
|
||||
|
||||
/*
|
||||
* Transmit interface (AXI stream)
|
||||
*/
|
||||
.s_axis_tx(s_axis_tx),
|
||||
.m_axis_tx_cpl(m_axis_tx_cpl),
|
||||
|
||||
/*
|
||||
* Receive interface (AXI stream)
|
||||
*/
|
||||
.m_axis_rx(m_axis_rx),
|
||||
|
||||
/*
|
||||
* GMII interface
|
||||
*/
|
||||
.gmii_rxd(mac_gmii_rxd),
|
||||
.gmii_rx_dv(mac_gmii_rx_dv),
|
||||
.gmii_rx_er(mac_gmii_rx_er),
|
||||
.gmii_txd(mac_gmii_txd),
|
||||
.gmii_tx_en(mac_gmii_tx_en),
|
||||
.gmii_tx_er(mac_gmii_tx_er),
|
||||
|
||||
/*
|
||||
* PTP
|
||||
*/
|
||||
.tx_ptp_ts(tx_ptp_ts),
|
||||
.rx_ptp_ts(rx_ptp_ts),
|
||||
|
||||
/*
|
||||
* Link-level Flow Control (LFC) (IEEE 802.3 annex 31B PAUSE)
|
||||
*/
|
||||
.tx_lfc_req(tx_lfc_req),
|
||||
.tx_lfc_resend(tx_lfc_resend),
|
||||
.rx_lfc_en(rx_lfc_en),
|
||||
.rx_lfc_req(rx_lfc_req),
|
||||
.rx_lfc_ack(rx_lfc_ack),
|
||||
|
||||
/*
|
||||
* Priority Flow Control (PFC) (IEEE 802.3 annex 31D PFC)
|
||||
*/
|
||||
.tx_pfc_req(tx_pfc_req),
|
||||
.tx_pfc_resend(tx_pfc_resend),
|
||||
.rx_pfc_en(rx_pfc_en),
|
||||
.rx_pfc_req(rx_pfc_req),
|
||||
.rx_pfc_ack(rx_pfc_ack),
|
||||
|
||||
/*
|
||||
* Pause interface
|
||||
*/
|
||||
.tx_lfc_pause_en(tx_lfc_pause_en),
|
||||
.tx_pause_req(tx_pause_req),
|
||||
.tx_pause_ack(tx_pause_ack),
|
||||
|
||||
/*
|
||||
* Control
|
||||
*/
|
||||
.rx_clk_enable(1'b1),
|
||||
.tx_clk_enable(1'b1),
|
||||
.rx_mii_select(rx_mii_select_sync[1]),
|
||||
.tx_mii_select(tx_mii_select_sync[1]),
|
||||
|
||||
/*
|
||||
* Status
|
||||
*/
|
||||
.tx_start_packet(tx_start_packet),
|
||||
.tx_error_underflow(tx_error_underflow),
|
||||
.rx_start_packet(rx_start_packet),
|
||||
.rx_error_bad_frame(rx_error_bad_frame),
|
||||
.rx_error_bad_fcs(rx_error_bad_fcs),
|
||||
.stat_tx_mcf(stat_tx_mcf),
|
||||
.stat_rx_mcf(stat_rx_mcf),
|
||||
.stat_tx_lfc_pkt(stat_tx_lfc_pkt),
|
||||
.stat_tx_lfc_xon(stat_tx_lfc_xon),
|
||||
.stat_tx_lfc_xoff(stat_tx_lfc_xoff),
|
||||
.stat_tx_lfc_paused(stat_tx_lfc_paused),
|
||||
.stat_tx_pfc_pkt(stat_tx_pfc_pkt),
|
||||
.stat_tx_pfc_xon(stat_tx_pfc_xon),
|
||||
.stat_tx_pfc_xoff(stat_tx_pfc_xoff),
|
||||
.stat_tx_pfc_paused(stat_tx_pfc_paused),
|
||||
.stat_rx_lfc_pkt(stat_rx_lfc_pkt),
|
||||
.stat_rx_lfc_xon(stat_rx_lfc_xon),
|
||||
.stat_rx_lfc_xoff(stat_rx_lfc_xoff),
|
||||
.stat_rx_lfc_paused(stat_rx_lfc_paused),
|
||||
.stat_rx_pfc_pkt(stat_rx_pfc_pkt),
|
||||
.stat_rx_pfc_xon(stat_rx_pfc_xon),
|
||||
.stat_rx_pfc_xoff(stat_rx_pfc_xoff),
|
||||
.stat_rx_pfc_paused(stat_rx_pfc_paused),
|
||||
|
||||
/*
|
||||
* Configuration
|
||||
*/
|
||||
.cfg_ifg(cfg_ifg),
|
||||
.cfg_tx_enable(cfg_tx_enable),
|
||||
.cfg_rx_enable(cfg_rx_enable),
|
||||
.cfg_mcf_rx_eth_dst_mcast(cfg_mcf_rx_eth_dst_mcast),
|
||||
.cfg_mcf_rx_check_eth_dst_mcast(cfg_mcf_rx_check_eth_dst_mcast),
|
||||
.cfg_mcf_rx_eth_dst_ucast(cfg_mcf_rx_eth_dst_ucast),
|
||||
.cfg_mcf_rx_check_eth_dst_ucast(cfg_mcf_rx_check_eth_dst_ucast),
|
||||
.cfg_mcf_rx_eth_src(cfg_mcf_rx_eth_src),
|
||||
.cfg_mcf_rx_check_eth_src(cfg_mcf_rx_check_eth_src),
|
||||
.cfg_mcf_rx_eth_type(cfg_mcf_rx_eth_type),
|
||||
.cfg_mcf_rx_opcode_lfc(cfg_mcf_rx_opcode_lfc),
|
||||
.cfg_mcf_rx_check_opcode_lfc(cfg_mcf_rx_check_opcode_lfc),
|
||||
.cfg_mcf_rx_opcode_pfc(cfg_mcf_rx_opcode_pfc),
|
||||
.cfg_mcf_rx_check_opcode_pfc(cfg_mcf_rx_check_opcode_pfc),
|
||||
.cfg_mcf_rx_forward(cfg_mcf_rx_forward),
|
||||
.cfg_mcf_rx_enable(cfg_mcf_rx_enable),
|
||||
.cfg_tx_lfc_eth_dst(cfg_tx_lfc_eth_dst),
|
||||
.cfg_tx_lfc_eth_src(cfg_tx_lfc_eth_src),
|
||||
.cfg_tx_lfc_eth_type(cfg_tx_lfc_eth_type),
|
||||
.cfg_tx_lfc_opcode(cfg_tx_lfc_opcode),
|
||||
.cfg_tx_lfc_en(cfg_tx_lfc_en),
|
||||
.cfg_tx_lfc_quanta(cfg_tx_lfc_quanta),
|
||||
.cfg_tx_lfc_refresh(cfg_tx_lfc_refresh),
|
||||
.cfg_tx_pfc_eth_dst(cfg_tx_pfc_eth_dst),
|
||||
.cfg_tx_pfc_eth_src(cfg_tx_pfc_eth_src),
|
||||
.cfg_tx_pfc_eth_type(cfg_tx_pfc_eth_type),
|
||||
.cfg_tx_pfc_opcode(cfg_tx_pfc_opcode),
|
||||
.cfg_tx_pfc_en(cfg_tx_pfc_en),
|
||||
.cfg_tx_pfc_quanta(cfg_tx_pfc_quanta),
|
||||
.cfg_tx_pfc_refresh(cfg_tx_pfc_refresh),
|
||||
.cfg_rx_lfc_opcode(cfg_rx_lfc_opcode),
|
||||
.cfg_rx_lfc_en(cfg_rx_lfc_en),
|
||||
.cfg_rx_pfc_opcode(cfg_rx_pfc_opcode),
|
||||
.cfg_rx_pfc_en(cfg_rx_pfc_en)
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
||||
`resetall
|
||||
50
syn/vivado/taxi_eth_mac_1g_gmii.tcl
Normal file
50
syn/vivado/taxi_eth_mac_1g_gmii.tcl
Normal file
@@ -0,0 +1,50 @@
|
||||
# SPDX-License-Identifier: CERN-OHL-S-2.0
|
||||
#
|
||||
# Copyright (c) 2019-2025 FPGA Ninja, LLC
|
||||
#
|
||||
# Authors:
|
||||
# - Alex Forencich
|
||||
#
|
||||
|
||||
# GMII Gigabit Ethernet MAC timing constraints
|
||||
|
||||
foreach inst [get_cells -hier -regexp -filter {(ORIG_REF_NAME =~ "taxi_eth_mac_1g_gmii(__\w+__\d+)?" ||
|
||||
REF_NAME =~ "taxi_eth_mac_1g_gmii(__\w+__\d+)?")}] {
|
||||
puts "Inserting timing constraints for taxi_eth_mac_1g_gmii instance $inst"
|
||||
|
||||
set select_ffs [get_cells -hier -regexp ".*/tx_mii_select_sync_reg\\\[\\d\\\]" -filter "PARENT == $inst"]
|
||||
|
||||
if {[llength $select_ffs]} {
|
||||
set_property ASYNC_REG TRUE $select_ffs
|
||||
|
||||
set src_clk [get_clocks -of_objects [get_pins $inst/mii_select_reg_reg/C]]
|
||||
|
||||
set src_clk_period [if {[llength $src_clk]} {get_property -min PERIOD $src_clk} {expr 8.0}]
|
||||
|
||||
set_max_delay -from [get_cells $inst/mii_select_reg_reg] -to [get_cells $inst/tx_mii_select_sync_reg[0]] -datapath_only $src_clk_period
|
||||
}
|
||||
|
||||
set select_ffs [get_cells -hier -regexp ".*/rx_mii_select_sync_reg\\\[\\d\\\]" -filter "PARENT == $inst"]
|
||||
|
||||
if {[llength $select_ffs]} {
|
||||
set_property ASYNC_REG TRUE $select_ffs
|
||||
|
||||
set src_clk [get_clocks -of_objects [get_pins $inst/mii_select_reg_reg/C]]
|
||||
|
||||
set src_clk_period [if {[llength $src_clk]} {get_property -min PERIOD $src_clk} {expr 8.0}]
|
||||
|
||||
set_max_delay -from [get_cells $inst/mii_select_reg_reg] -to [get_cells $inst/rx_mii_select_sync_reg[0]] -datapath_only $src_clk_period
|
||||
}
|
||||
|
||||
set prescale_ffs [get_cells -hier -regexp ".*/rx_prescale_sync_reg\\\[\\d\\\]" -filter "PARENT == $inst"]
|
||||
|
||||
if {[llength $prescale_ffs]} {
|
||||
set_property ASYNC_REG TRUE $prescale_ffs
|
||||
|
||||
set src_clk [get_clocks -of_objects [get_pins $inst/rx_prescale_reg[2]/C]]
|
||||
|
||||
set src_clk_period [if {[llength $src_clk]} {get_property -min PERIOD $src_clk} {expr 8.0}]
|
||||
|
||||
set_max_delay -from [get_cells $inst/rx_prescale_reg[2]] -to [get_cells $inst/rx_prescale_sync_reg[0]] -datapath_only $src_clk_period
|
||||
}
|
||||
}
|
||||
55
tb/eth/taxi_eth_mac_1g_gmii/Makefile
Normal file
55
tb/eth/taxi_eth_mac_1g_gmii/Makefile
Normal file
@@ -0,0 +1,55 @@
|
||||
# SPDX-License-Identifier: CERN-OHL-S-2.0
|
||||
#
|
||||
# Copyright (c) 2020-2025 FPGA Ninja, LLC
|
||||
#
|
||||
# Authors:
|
||||
# - Alex Forencich
|
||||
|
||||
TOPLEVEL_LANG = verilog
|
||||
|
||||
SIM ?= verilator
|
||||
WAVES ?= 0
|
||||
|
||||
COCOTB_HDL_TIMEUNIT = 1ns
|
||||
COCOTB_HDL_TIMEPRECISION = 1ps
|
||||
|
||||
DUT = taxi_eth_mac_1g_gmii
|
||||
COCOTB_TEST_MODULES = test_$(DUT)
|
||||
COCOTB_TOPLEVEL = test_$(DUT)
|
||||
MODULE = $(COCOTB_TEST_MODULES)
|
||||
TOPLEVEL = $(COCOTB_TOPLEVEL)
|
||||
VERILOG_SOURCES += $(COCOTB_TOPLEVEL).sv
|
||||
VERILOG_SOURCES += ../../../rtl/eth/$(DUT).f
|
||||
|
||||
# handle file list files
|
||||
process_f_file = $(call process_f_files,$(addprefix $(dir $1),$(shell cat $1)))
|
||||
process_f_files = $(foreach f,$1,$(if $(filter %.f,$f),$(call process_f_file,$f),$f))
|
||||
uniq_base = $(if $1,$(call uniq_base,$(foreach f,$1,$(if $(filter-out $(notdir $(lastword $1)),$(notdir $f)),$f,))) $(lastword $1))
|
||||
VERILOG_SOURCES := $(call uniq_base,$(call process_f_files,$(VERILOG_SOURCES)))
|
||||
|
||||
# module parameters
|
||||
export PARAM_SIM := 1
|
||||
export PARAM_VENDOR := "\"XILINX\""
|
||||
export PARAM_FAMILY := "\"virtex7\""
|
||||
export PARAM_PADDING_EN := 1
|
||||
export PARAM_MIN_FRAME_LEN := 64
|
||||
export PARAM_PTP_TS_EN := 1
|
||||
export PARAM_PTP_TS_W := 96
|
||||
export PARAM_TX_TAG_W := 16
|
||||
export PARAM_PFC_EN := 1
|
||||
export PARAM_PAUSE_EN := $(PARAM_PFC_EN)
|
||||
|
||||
ifeq ($(SIM), icarus)
|
||||
PLUSARGS += -fst
|
||||
|
||||
COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-P $(COCOTB_TOPLEVEL).$(subst PARAM_,,$(v))=$($(v)))
|
||||
else ifeq ($(SIM), verilator)
|
||||
COMPILE_ARGS += $(foreach v,$(filter PARAM_%,$(.VARIABLES)),-G$(subst PARAM_,,$(v))=$($(v)))
|
||||
|
||||
ifeq ($(WAVES), 1)
|
||||
COMPILE_ARGS += --trace-fst
|
||||
VERILATOR_TRACE = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(shell cocotb-config --makefiles)/Makefile.sim
|
||||
688
tb/eth/taxi_eth_mac_1g_gmii/test_taxi_eth_mac_1g_gmii.py
Normal file
688
tb/eth/taxi_eth_mac_1g_gmii/test_taxi_eth_mac_1g_gmii.py
Normal file
@@ -0,0 +1,688 @@
|
||||
#!/usr/bin/env python
|
||||
# SPDX-License-Identifier: CERN-OHL-S-2.0
|
||||
"""
|
||||
|
||||
Copyright (c) 2020-2025 FPGA Ninja, LLC
|
||||
|
||||
Authors:
|
||||
- Alex Forencich
|
||||
|
||||
"""
|
||||
|
||||
import itertools
|
||||
import logging
|
||||
import struct
|
||||
import os
|
||||
|
||||
from scapy.layers.l2 import Ether
|
||||
|
||||
import pytest
|
||||
import cocotb_test.simulator
|
||||
|
||||
import cocotb
|
||||
from cocotb.clock import Clock
|
||||
from cocotb.triggers import RisingEdge
|
||||
from cocotb.utils import get_time_from_sim_steps
|
||||
from cocotb.regression import TestFactory
|
||||
|
||||
from cocotbext.eth import GmiiFrame, GmiiPhy, PtpClockSimTime
|
||||
from cocotbext.axi import AxiStreamBus, AxiStreamSource, AxiStreamSink, AxiStreamFrame
|
||||
|
||||
|
||||
class TB:
|
||||
def __init__(self, dut, speed=1000e6):
|
||||
self.dut = dut
|
||||
|
||||
self.log = logging.getLogger("cocotb.tb")
|
||||
self.log.setLevel(logging.DEBUG)
|
||||
|
||||
cocotb.start_soon(Clock(dut.gtx_clk, 8, units="ns").start())
|
||||
|
||||
self.gmii_phy = GmiiPhy(dut.gmii_txd, dut.gmii_tx_er, dut.gmii_tx_en, dut.mii_tx_clk, dut.gmii_tx_clk,
|
||||
dut.gmii_rxd, dut.gmii_rx_er, dut.gmii_rx_dv, dut.gmii_rx_clk, speed=speed)
|
||||
|
||||
# the UUT tx_clk/rx_clk, which can cause problems in cocotb
|
||||
if speed == 1000e6:
|
||||
self.axis_source = AxiStreamSource(AxiStreamBus.from_entity(dut.s_axis_tx), dut.gtx_clk, dut.tx_rst)
|
||||
self.tx_cpl_sink = AxiStreamSink(AxiStreamBus.from_entity(dut.m_axis_tx_cpl), dut.gtx_clk, dut.tx_rst)
|
||||
else:
|
||||
self.axis_source = AxiStreamSource(AxiStreamBus.from_entity(dut.s_axis_tx), dut.mii_tx_clk, dut.tx_rst)
|
||||
self.tx_cpl_sink = AxiStreamSink(AxiStreamBus.from_entity(dut.m_axis_tx_cpl), dut.mii_tx_clk, dut.tx_rst)
|
||||
self.axis_sink = AxiStreamSink(AxiStreamBus.from_entity(dut.m_axis_rx), dut.gmii_rx_clk, dut.rx_rst)
|
||||
|
||||
self.rx_ptp_clock = PtpClockSimTime(ts_tod=dut.rx_ptp_ts, clock=dut.rx_clk)
|
||||
self.tx_ptp_clock = PtpClockSimTime(ts_tod=dut.tx_ptp_ts, clock=dut.tx_clk)
|
||||
|
||||
dut.tx_lfc_req.setimmediatevalue(0)
|
||||
dut.tx_lfc_resend.setimmediatevalue(0)
|
||||
dut.rx_lfc_en.setimmediatevalue(0)
|
||||
dut.rx_lfc_ack.setimmediatevalue(0)
|
||||
|
||||
dut.tx_pfc_req.setimmediatevalue(0)
|
||||
dut.tx_pfc_resend.setimmediatevalue(0)
|
||||
dut.rx_pfc_en.setimmediatevalue(0)
|
||||
dut.rx_pfc_ack.setimmediatevalue(0)
|
||||
|
||||
dut.tx_lfc_pause_en.setimmediatevalue(0)
|
||||
dut.tx_pause_req.setimmediatevalue(0)
|
||||
|
||||
dut.cfg_ifg.setimmediatevalue(0)
|
||||
dut.cfg_tx_enable.setimmediatevalue(0)
|
||||
dut.cfg_rx_enable.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_eth_dst_mcast.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_check_eth_dst_mcast.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_eth_dst_ucast.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_check_eth_dst_ucast.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_eth_src.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_check_eth_src.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_eth_type.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_opcode_lfc.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_check_opcode_lfc.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_opcode_pfc.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_check_opcode_pfc.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_forward.setimmediatevalue(0)
|
||||
dut.cfg_mcf_rx_enable.setimmediatevalue(0)
|
||||
dut.cfg_tx_lfc_eth_dst.setimmediatevalue(0)
|
||||
dut.cfg_tx_lfc_eth_src.setimmediatevalue(0)
|
||||
dut.cfg_tx_lfc_eth_type.setimmediatevalue(0)
|
||||
dut.cfg_tx_lfc_opcode.setimmediatevalue(0)
|
||||
dut.cfg_tx_lfc_en.setimmediatevalue(0)
|
||||
dut.cfg_tx_lfc_quanta.setimmediatevalue(0)
|
||||
dut.cfg_tx_lfc_refresh.setimmediatevalue(0)
|
||||
dut.cfg_tx_pfc_eth_dst.setimmediatevalue(0)
|
||||
dut.cfg_tx_pfc_eth_src.setimmediatevalue(0)
|
||||
dut.cfg_tx_pfc_eth_type.setimmediatevalue(0)
|
||||
dut.cfg_tx_pfc_opcode.setimmediatevalue(0)
|
||||
dut.cfg_tx_pfc_en.setimmediatevalue(0)
|
||||
dut.cfg_tx_pfc_quanta.setimmediatevalue(0)
|
||||
dut.cfg_tx_pfc_refresh.setimmediatevalue(0)
|
||||
dut.cfg_rx_lfc_opcode.setimmediatevalue(0)
|
||||
dut.cfg_rx_lfc_en.setimmediatevalue(0)
|
||||
dut.cfg_rx_pfc_opcode.setimmediatevalue(0)
|
||||
dut.cfg_rx_pfc_en.setimmediatevalue(0)
|
||||
|
||||
async def reset(self):
|
||||
self.dut.gtx_rst.setimmediatevalue(0)
|
||||
await RisingEdge(self.dut.tx_clk)
|
||||
await RisingEdge(self.dut.tx_clk)
|
||||
self.dut.gtx_rst.value = 1
|
||||
await RisingEdge(self.dut.tx_clk)
|
||||
await RisingEdge(self.dut.tx_clk)
|
||||
self.dut.gtx_rst.value = 0
|
||||
await RisingEdge(self.dut.tx_clk)
|
||||
await RisingEdge(self.dut.tx_clk)
|
||||
|
||||
|
||||
async def run_test_rx(dut, payload_lengths=None, payload_data=None, ifg=12, speed=1000e6):
|
||||
|
||||
tb = TB(dut, speed)
|
||||
|
||||
tb.gmii_phy.rx.ifg = ifg
|
||||
tb.dut.cfg_ifg.value = ifg
|
||||
tb.dut.cfg_rx_enable.value = 1
|
||||
|
||||
await tb.reset()
|
||||
|
||||
for k in range(100):
|
||||
await RisingEdge(dut.rx_clk)
|
||||
|
||||
if speed == 10e6:
|
||||
assert dut.link_speed == 0
|
||||
elif speed == 100e6:
|
||||
assert dut.link_speed == 1
|
||||
else:
|
||||
assert dut.link_speed == 2
|
||||
|
||||
test_frames = [payload_data(x) for x in payload_lengths()]
|
||||
tx_frames = []
|
||||
|
||||
for test_data in test_frames:
|
||||
test_frame = GmiiFrame.from_payload(test_data, tx_complete=tx_frames.append)
|
||||
await tb.gmii_phy.rx.send(test_frame)
|
||||
|
||||
for test_data in test_frames:
|
||||
rx_frame = await tb.axis_sink.recv()
|
||||
tx_frame = tx_frames.pop(0)
|
||||
|
||||
frame_error = rx_frame.tuser & 1
|
||||
ptp_ts = rx_frame.tuser >> 1
|
||||
ptp_ts_ns = ptp_ts / 2**16
|
||||
|
||||
tx_frame_sfd_ns = get_time_from_sim_steps(tx_frame.sim_time_sfd, "ns")
|
||||
|
||||
tb.log.info("RX frame PTP TS: %f ns", ptp_ts_ns)
|
||||
tb.log.info("TX frame SFD sim time: %f ns", tx_frame_sfd_ns)
|
||||
tb.log.info("Difference: %f ns", abs(ptp_ts_ns - tx_frame_sfd_ns))
|
||||
|
||||
assert rx_frame.tdata == test_data
|
||||
assert frame_error == 0
|
||||
if speed == 10e6:
|
||||
assert abs(ptp_ts_ns - tx_frame_sfd_ns - 800) < 0.01
|
||||
elif speed == 100e6:
|
||||
assert abs(ptp_ts_ns - tx_frame_sfd_ns - 80) < 0.01
|
||||
else:
|
||||
assert abs(ptp_ts_ns - tx_frame_sfd_ns - 16) < 0.01
|
||||
|
||||
assert tb.axis_sink.empty()
|
||||
|
||||
await RisingEdge(dut.rx_clk)
|
||||
await RisingEdge(dut.rx_clk)
|
||||
|
||||
|
||||
async def run_test_tx(dut, payload_lengths=None, payload_data=None, ifg=12, speed=1000e6):
|
||||
|
||||
tb = TB(dut, speed)
|
||||
|
||||
tb.gmii_phy.rx.ifg = ifg
|
||||
tb.dut.cfg_ifg.value = ifg
|
||||
tb.dut.cfg_tx_enable.value = 1
|
||||
|
||||
await tb.reset()
|
||||
|
||||
for k in range(100):
|
||||
await RisingEdge(dut.rx_clk)
|
||||
|
||||
if speed == 10e6:
|
||||
assert dut.link_speed == 0
|
||||
elif speed == 100e6:
|
||||
assert dut.link_speed == 1
|
||||
else:
|
||||
assert dut.link_speed == 2
|
||||
|
||||
test_frames = [payload_data(x) for x in payload_lengths()]
|
||||
|
||||
for test_data in test_frames:
|
||||
await tb.axis_source.send(test_data)
|
||||
|
||||
for test_data in test_frames:
|
||||
rx_frame = await tb.gmii_phy.tx.recv()
|
||||
tx_cpl = await tb.tx_cpl_sink.recv()
|
||||
|
||||
ptp_ts_ns = int(tx_cpl.tdata[0]) / 2**16
|
||||
|
||||
rx_frame_sfd_ns = get_time_from_sim_steps(rx_frame.sim_time_sfd, "ns")
|
||||
|
||||
tb.log.info("TX frame PTP TS: %f ns", ptp_ts_ns)
|
||||
tb.log.info("RX frame SFD sim time: %f ns", rx_frame_sfd_ns)
|
||||
tb.log.info("Difference: %f ns", abs(rx_frame_sfd_ns - ptp_ts_ns))
|
||||
|
||||
assert rx_frame.get_payload() == test_data
|
||||
assert rx_frame.check_fcs()
|
||||
assert rx_frame.error is None
|
||||
if speed == 10e6:
|
||||
assert abs(rx_frame_sfd_ns - ptp_ts_ns - 800) < 0.01
|
||||
elif speed == 100e6:
|
||||
assert abs(rx_frame_sfd_ns - ptp_ts_ns - 80) < 0.01
|
||||
else:
|
||||
assert abs(rx_frame_sfd_ns - ptp_ts_ns - 12) < 0.01
|
||||
|
||||
assert tb.gmii_phy.tx.empty()
|
||||
|
||||
await RisingEdge(dut.tx_clk)
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
|
||||
async def run_test_tx_underrun(dut, ifg=12, speed=1000e6):
|
||||
|
||||
tb = TB(dut, speed)
|
||||
|
||||
tb.gmii_phy.rx.ifg = ifg
|
||||
tb.dut.cfg_ifg.value = ifg
|
||||
tb.dut.cfg_tx_enable.value = 1
|
||||
|
||||
await tb.reset()
|
||||
|
||||
for k in range(100):
|
||||
await RisingEdge(dut.rx_clk)
|
||||
|
||||
test_data = bytes(x for x in range(60))
|
||||
|
||||
for k in range(3):
|
||||
test_frame = AxiStreamFrame(test_data)
|
||||
await tb.axis_source.send(test_frame)
|
||||
|
||||
for k in range(200 if speed != 1000e6 else 100):
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
tb.axis_source.pause = True
|
||||
|
||||
for k in range(10):
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
tb.axis_source.pause = False
|
||||
|
||||
for k in range(3):
|
||||
rx_frame = await tb.gmii_phy.tx.recv()
|
||||
|
||||
if k == 1:
|
||||
assert rx_frame.error[-1] == 1
|
||||
else:
|
||||
assert rx_frame.get_payload() == test_data
|
||||
assert rx_frame.check_fcs()
|
||||
assert rx_frame.error is None
|
||||
|
||||
assert tb.gmii_phy.tx.empty()
|
||||
|
||||
await RisingEdge(dut.tx_clk)
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
|
||||
async def run_test_tx_error(dut, ifg=12, speed=1000e6):
|
||||
|
||||
tb = TB(dut, speed)
|
||||
|
||||
tb.gmii_phy.rx.ifg = ifg
|
||||
tb.dut.cfg_ifg.value = ifg
|
||||
tb.dut.cfg_tx_enable.value = 1
|
||||
|
||||
await tb.reset()
|
||||
|
||||
for k in range(100):
|
||||
await RisingEdge(dut.rx_clk)
|
||||
|
||||
test_data = bytes(x for x in range(60))
|
||||
|
||||
for k in range(3):
|
||||
test_frame = AxiStreamFrame(test_data)
|
||||
if k == 1:
|
||||
test_frame.tuser = 1
|
||||
await tb.axis_source.send(test_frame)
|
||||
|
||||
for k in range(3):
|
||||
rx_frame = await tb.gmii_phy.tx.recv()
|
||||
|
||||
if k == 1:
|
||||
assert rx_frame.error[-1] == 1
|
||||
else:
|
||||
assert rx_frame.get_payload() == test_data
|
||||
assert rx_frame.check_fcs()
|
||||
assert rx_frame.error is None
|
||||
|
||||
assert tb.gmii_phy.tx.empty()
|
||||
|
||||
await RisingEdge(dut.tx_clk)
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
|
||||
async def run_test_lfc(dut, ifg=12, speed=1000e6):
|
||||
|
||||
tb = TB(dut, speed)
|
||||
|
||||
tb.gmii_phy.rx.ifg = ifg
|
||||
tb.dut.cfg_ifg.value = ifg
|
||||
tb.dut.cfg_rx_enable.value = 1
|
||||
tb.dut.cfg_tx_enable.value = 1
|
||||
|
||||
await tb.reset()
|
||||
|
||||
for k in range(100):
|
||||
await RisingEdge(dut.rx_clk)
|
||||
|
||||
dut.tx_lfc_req.value = 0
|
||||
dut.tx_lfc_resend.value = 0
|
||||
dut.rx_lfc_en.value = 1
|
||||
dut.rx_lfc_ack.value = 0
|
||||
|
||||
dut.tx_lfc_pause_en.value = 1
|
||||
dut.tx_pause_req.value = 0
|
||||
|
||||
dut.cfg_mcf_rx_eth_dst_mcast.value = 0x0180C2000001
|
||||
dut.cfg_mcf_rx_check_eth_dst_mcast.value = 1
|
||||
dut.cfg_mcf_rx_eth_dst_ucast.value = 0xDAD1D2D3D4D5
|
||||
dut.cfg_mcf_rx_check_eth_dst_ucast.value = 0
|
||||
dut.cfg_mcf_rx_eth_src.value = 0x5A5152535455
|
||||
dut.cfg_mcf_rx_check_eth_src.value = 0
|
||||
dut.cfg_mcf_rx_eth_type.value = 0x8808
|
||||
dut.cfg_mcf_rx_opcode_lfc.value = 0x0001
|
||||
dut.cfg_mcf_rx_check_opcode_lfc.value = 1
|
||||
dut.cfg_mcf_rx_opcode_pfc.value = 0x0101
|
||||
dut.cfg_mcf_rx_check_opcode_pfc.value = 1
|
||||
|
||||
dut.cfg_mcf_rx_forward.value = 0
|
||||
dut.cfg_mcf_rx_enable.value = 1
|
||||
|
||||
dut.cfg_tx_lfc_eth_dst.value = 0x0180C2000001
|
||||
dut.cfg_tx_lfc_eth_src.value = 0x5A5152535455
|
||||
dut.cfg_tx_lfc_eth_type.value = 0x8808
|
||||
dut.cfg_tx_lfc_opcode.value = 0x0001
|
||||
dut.cfg_tx_lfc_en.value = 1
|
||||
dut.cfg_tx_lfc_quanta.value = 0xFFFF
|
||||
dut.cfg_tx_lfc_refresh.value = 0x7F00
|
||||
|
||||
dut.cfg_rx_lfc_opcode.value = 0x0001
|
||||
dut.cfg_rx_lfc_en.value = 1
|
||||
|
||||
test_tx_pkts = []
|
||||
test_rx_pkts = []
|
||||
|
||||
for k in range(32):
|
||||
length = 128
|
||||
payload = bytearray(itertools.islice(itertools.cycle(range(256)), length))
|
||||
|
||||
eth = Ether(src='5A:51:52:53:54:55', dst='DA:D1:D2:D3:D4:D5', type=0x8000)
|
||||
test_pkt = eth / payload
|
||||
test_tx_pkts.append(test_pkt.copy())
|
||||
|
||||
await tb.axis_source.send(bytes(test_pkt))
|
||||
|
||||
eth = Ether(src='DA:D1:D2:D3:D4:D5', dst='5A:51:52:53:54:55', type=0x8000)
|
||||
test_pkt = eth / payload
|
||||
test_rx_pkts.append(test_pkt.copy())
|
||||
|
||||
test_frame = GmiiFrame.from_payload(bytes(test_pkt))
|
||||
await tb.gmii_phy.rx.send(test_frame)
|
||||
|
||||
if k == 16:
|
||||
eth = Ether(src='DA:D1:D2:D3:D4:D5', dst='01:80:C2:00:00:01', type=0x8808)
|
||||
test_pkt = eth / struct.pack('!HH', 0x0001, 100)
|
||||
test_rx_pkts.append(test_pkt.copy())
|
||||
|
||||
test_frame = GmiiFrame.from_payload(bytes(test_pkt))
|
||||
await tb.gmii_phy.rx.send(test_frame)
|
||||
|
||||
for k in range(1000):
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
dut.tx_lfc_req.value = 1
|
||||
|
||||
for k in range(1000):
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
dut.tx_lfc_req.value = 0
|
||||
|
||||
while not dut.rx_lfc_req.value.integer:
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
for k in range(1000):
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
dut.tx_lfc_req.value = 1
|
||||
|
||||
for k in range(1000):
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
dut.tx_lfc_req.value = 0
|
||||
|
||||
while test_rx_pkts:
|
||||
rx_frame = await tb.axis_sink.recv()
|
||||
|
||||
rx_pkt = Ether(bytes(rx_frame))
|
||||
|
||||
tb.log.info("RX packet: %s", repr(rx_pkt))
|
||||
|
||||
if rx_pkt.type == 0x8808:
|
||||
test_pkt = test_rx_pkts.pop(0)
|
||||
# check prefix as frame gets zero-padded
|
||||
assert bytes(rx_pkt).find(bytes(test_pkt)) == 0
|
||||
if isinstance(rx_frame.tuser, list):
|
||||
assert rx_frame.tuser[-1] & 1
|
||||
else:
|
||||
assert rx_frame.tuser & 1
|
||||
else:
|
||||
test_pkt = test_rx_pkts.pop(0)
|
||||
# check prefix as frame gets zero-padded
|
||||
assert bytes(rx_pkt).find(bytes(test_pkt)) == 0
|
||||
if isinstance(rx_frame.tuser, list):
|
||||
assert not rx_frame.tuser[-1] & 1
|
||||
else:
|
||||
assert not rx_frame.tuser & 1
|
||||
|
||||
tx_lfc_cnt = 0
|
||||
|
||||
while test_tx_pkts:
|
||||
tx_frame = await tb.gmii_phy.tx.recv()
|
||||
|
||||
tx_pkt = Ether(bytes(tx_frame.get_payload()))
|
||||
|
||||
tb.log.info("TX packet: %s", repr(tx_pkt))
|
||||
|
||||
if tx_pkt.type == 0x8808:
|
||||
tx_lfc_cnt += 1
|
||||
else:
|
||||
test_pkt = test_tx_pkts.pop(0)
|
||||
# check prefix as frame gets zero-padded
|
||||
assert bytes(tx_pkt).find(bytes(test_pkt)) == 0
|
||||
|
||||
assert tx_lfc_cnt == 4
|
||||
|
||||
assert tb.axis_sink.empty()
|
||||
assert tb.gmii_phy.tx.empty()
|
||||
|
||||
await RisingEdge(dut.tx_clk)
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
|
||||
async def run_test_pfc(dut, ifg=12, speed=1000e6):
|
||||
|
||||
tb = TB(dut, speed)
|
||||
|
||||
tb.gmii_phy.rx.ifg = ifg
|
||||
tb.dut.cfg_ifg.value = ifg
|
||||
tb.dut.cfg_rx_enable.value = 1
|
||||
tb.dut.cfg_tx_enable.value = 1
|
||||
|
||||
await tb.reset()
|
||||
|
||||
for k in range(100):
|
||||
await RisingEdge(dut.rx_clk)
|
||||
|
||||
dut.tx_pfc_req.value = 0x00
|
||||
dut.tx_pfc_resend.value = 0
|
||||
dut.rx_pfc_en.value = 0xff
|
||||
dut.rx_pfc_ack.value = 0
|
||||
|
||||
dut.tx_lfc_pause_en.value = 0
|
||||
dut.tx_pause_req.value = 0
|
||||
|
||||
dut.cfg_mcf_rx_eth_dst_mcast.value = 0x0180C2000001
|
||||
dut.cfg_mcf_rx_check_eth_dst_mcast.value = 1
|
||||
dut.cfg_mcf_rx_eth_dst_ucast.value = 0xDAD1D2D3D4D5
|
||||
dut.cfg_mcf_rx_check_eth_dst_ucast.value = 0
|
||||
dut.cfg_mcf_rx_eth_src.value = 0x5A5152535455
|
||||
dut.cfg_mcf_rx_check_eth_src.value = 0
|
||||
dut.cfg_mcf_rx_eth_type.value = 0x8808
|
||||
dut.cfg_mcf_rx_opcode_lfc.value = 0x0001
|
||||
dut.cfg_mcf_rx_check_opcode_lfc.value = 1
|
||||
dut.cfg_mcf_rx_opcode_pfc.value = 0x0101
|
||||
dut.cfg_mcf_rx_check_opcode_pfc.value = 1
|
||||
|
||||
dut.cfg_mcf_rx_forward.value = 0
|
||||
dut.cfg_mcf_rx_enable.value = 1
|
||||
|
||||
dut.cfg_tx_pfc_eth_dst.value = 0x0180C2000001
|
||||
dut.cfg_tx_pfc_eth_src.value = 0x5A5152535455
|
||||
dut.cfg_tx_pfc_eth_type.value = 0x8808
|
||||
dut.cfg_tx_pfc_opcode.value = 0x0101
|
||||
dut.cfg_tx_pfc_en.value = 1
|
||||
dut.cfg_tx_pfc_quanta.value = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
dut.cfg_tx_pfc_refresh.value = 0x7F007F007F007F007F007F007F007F00
|
||||
|
||||
dut.cfg_rx_pfc_opcode.value = 0x0101
|
||||
dut.cfg_rx_pfc_en.value = 1
|
||||
|
||||
test_tx_pkts = []
|
||||
test_rx_pkts = []
|
||||
|
||||
for k in range(32):
|
||||
length = 128
|
||||
payload = bytearray(itertools.islice(itertools.cycle(range(256)), length))
|
||||
|
||||
eth = Ether(src='5A:51:52:53:54:55', dst='DA:D1:D2:D3:D4:D5', type=0x8000)
|
||||
test_pkt = eth / payload
|
||||
test_tx_pkts.append(test_pkt.copy())
|
||||
|
||||
await tb.axis_source.send(bytes(test_pkt))
|
||||
|
||||
eth = Ether(src='DA:D1:D2:D3:D4:D5', dst='5A:51:52:53:54:55', type=0x8000)
|
||||
test_pkt = eth / payload
|
||||
test_rx_pkts.append(test_pkt.copy())
|
||||
|
||||
test_frame = GmiiFrame.from_payload(bytes(test_pkt))
|
||||
await tb.gmii_phy.rx.send(test_frame)
|
||||
|
||||
if k == 16:
|
||||
eth = Ether(src='DA:D1:D2:D3:D4:D5', dst='01:80:C2:00:00:01', type=0x8808)
|
||||
test_pkt = eth / struct.pack('!HH8H', 0x0101, 0x00FF, 10, 20, 30, 40, 50, 60, 70, 80)
|
||||
test_rx_pkts.append(test_pkt.copy())
|
||||
|
||||
test_frame = GmiiFrame.from_payload(bytes(test_pkt))
|
||||
await tb.gmii_phy.rx.send(test_frame)
|
||||
|
||||
for i in range(8):
|
||||
for k in range(500):
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
dut.tx_pfc_req.value = 0xff >> (7-i)
|
||||
|
||||
for k in range(500):
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
dut.tx_pfc_req.value = 0x00
|
||||
|
||||
while test_rx_pkts:
|
||||
rx_frame = await tb.axis_sink.recv()
|
||||
|
||||
rx_pkt = Ether(bytes(rx_frame))
|
||||
|
||||
tb.log.info("RX packet: %s", repr(rx_pkt))
|
||||
|
||||
if rx_pkt.type == 0x8808:
|
||||
test_pkt = test_rx_pkts.pop(0)
|
||||
# check prefix as frame gets zero-padded
|
||||
assert bytes(rx_pkt).find(bytes(test_pkt)) == 0
|
||||
if isinstance(rx_frame.tuser, list):
|
||||
assert rx_frame.tuser[-1] & 1
|
||||
else:
|
||||
assert rx_frame.tuser & 1
|
||||
else:
|
||||
test_pkt = test_rx_pkts.pop(0)
|
||||
# check prefix as frame gets zero-padded
|
||||
assert bytes(rx_pkt).find(bytes(test_pkt)) == 0
|
||||
if isinstance(rx_frame.tuser, list):
|
||||
assert not rx_frame.tuser[-1] & 1
|
||||
else:
|
||||
assert not rx_frame.tuser & 1
|
||||
|
||||
tx_pfc_cnt = 0
|
||||
|
||||
while test_tx_pkts:
|
||||
tx_frame = await tb.gmii_phy.tx.recv()
|
||||
|
||||
tx_pkt = Ether(bytes(tx_frame.get_payload()))
|
||||
|
||||
tb.log.info("TX packet: %s", repr(tx_pkt))
|
||||
|
||||
if tx_pkt.type == 0x8808:
|
||||
tx_pfc_cnt += 1
|
||||
else:
|
||||
test_pkt = test_tx_pkts.pop(0)
|
||||
# check prefix as frame gets zero-padded
|
||||
assert bytes(tx_pkt).find(bytes(test_pkt)) == 0
|
||||
|
||||
assert tx_pfc_cnt > 2 and tx_pfc_cnt <= 9
|
||||
|
||||
assert tb.axis_sink.empty()
|
||||
assert tb.gmii_phy.tx.empty()
|
||||
|
||||
await RisingEdge(dut.tx_clk)
|
||||
await RisingEdge(dut.tx_clk)
|
||||
|
||||
|
||||
def size_list():
|
||||
return list(range(60, 128)) + [512, 1514] + [60]*10
|
||||
|
||||
|
||||
def incrementing_payload(length):
|
||||
return bytearray(itertools.islice(itertools.cycle(range(256)), length))
|
||||
|
||||
|
||||
def cycle_en():
|
||||
return itertools.cycle([0, 0, 0, 1])
|
||||
|
||||
|
||||
if cocotb.SIM_NAME:
|
||||
|
||||
for test in [run_test_rx, run_test_tx]:
|
||||
|
||||
factory = TestFactory(test)
|
||||
factory.add_option("payload_lengths", [size_list])
|
||||
factory.add_option("payload_data", [incrementing_payload])
|
||||
factory.add_option("ifg", [12])
|
||||
factory.add_option("speed", [1000e6, 100e6, 10e6])
|
||||
factory.generate_tests()
|
||||
|
||||
for test in [run_test_tx_underrun, run_test_tx_error]:
|
||||
|
||||
factory = TestFactory(test)
|
||||
factory.add_option("ifg", [12])
|
||||
factory.add_option("speed", [1000e6, 100e6, 10e6])
|
||||
factory.generate_tests()
|
||||
|
||||
if cocotb.top.PFC_EN.value:
|
||||
for test in [run_test_lfc, run_test_pfc]:
|
||||
factory = TestFactory(test)
|
||||
factory.add_option("ifg", [12])
|
||||
factory.add_option("speed", [1000e6, 100e6, 10e6])
|
||||
factory.generate_tests()
|
||||
|
||||
|
||||
# cocotb-test
|
||||
|
||||
tests_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', '..', 'rtl'))
|
||||
|
||||
|
||||
def process_f_files(files):
|
||||
lst = {}
|
||||
for f in files:
|
||||
if f[-2:].lower() == '.f':
|
||||
with open(f, 'r') as fp:
|
||||
l = fp.read().split()
|
||||
for f in process_f_files([os.path.join(os.path.dirname(f), x) for x in l]):
|
||||
lst[os.path.basename(f)] = f
|
||||
else:
|
||||
lst[os.path.basename(f)] = f
|
||||
return list(lst.values())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pfc_en", [1, 0])
|
||||
def test_taxi_eth_mac_1g_gmii(request, pfc_en):
|
||||
dut = "taxi_eth_mac_1g_gmii"
|
||||
module = os.path.splitext(os.path.basename(__file__))[0]
|
||||
toplevel = module
|
||||
|
||||
verilog_sources = [
|
||||
os.path.join(tests_dir, f"{toplevel}.sv"),
|
||||
os.path.join(rtl_dir, "eth", f"{dut}.f"),
|
||||
]
|
||||
|
||||
verilog_sources = process_f_files(verilog_sources)
|
||||
|
||||
parameters = {}
|
||||
|
||||
parameters['SIM'] = 1
|
||||
parameters['VENDOR'] = "\"XILINX\""
|
||||
parameters['FAMILY'] = "\"virtex7\""
|
||||
parameters['PADDING_EN'] = 1
|
||||
parameters['MIN_FRAME_LEN'] = 64
|
||||
parameters['PTP_TS_EN'] = 1
|
||||
parameters['PTP_TS_W'] = 96
|
||||
parameters['TX_TAG_W'] = 16
|
||||
parameters['PFC_EN'] = pfc_en
|
||||
parameters['PAUSE_EN'] = parameters['PFC_EN']
|
||||
|
||||
extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()}
|
||||
|
||||
sim_build = os.path.join(tests_dir, "sim_build",
|
||||
request.node.name.replace('[', '-').replace(']', ''))
|
||||
|
||||
cocotb_test.simulator.run(
|
||||
simulator="verilator",
|
||||
python_search=[tests_dir],
|
||||
verilog_sources=verilog_sources,
|
||||
toplevel=toplevel,
|
||||
module=module,
|
||||
parameters=parameters,
|
||||
sim_build=sim_build,
|
||||
extra_env=extra_env,
|
||||
)
|
||||
282
tb/eth/taxi_eth_mac_1g_gmii/test_taxi_eth_mac_1g_gmii.sv
Normal file
282
tb/eth/taxi_eth_mac_1g_gmii/test_taxi_eth_mac_1g_gmii.sv
Normal file
@@ -0,0 +1,282 @@
|
||||
// SPDX-License-Identifier: CERN-OHL-S-2.0
|
||||
/*
|
||||
|
||||
Copyright (c) 2025 FPGA Ninja, LLC
|
||||
|
||||
Authors:
|
||||
- Alex Forencich
|
||||
|
||||
*/
|
||||
|
||||
`resetall
|
||||
`timescale 1ns / 1ps
|
||||
`default_nettype none
|
||||
|
||||
/*
|
||||
* 1G Ethernet MAC with GMII interface testbench
|
||||
*/
|
||||
module test_taxi_eth_mac_1g_gmii #
|
||||
(
|
||||
/* verilator lint_off WIDTHTRUNC */
|
||||
parameter logic SIM = 1'b1,
|
||||
parameter VENDOR = "XILINX",
|
||||
parameter FAMILY = "virtex7",
|
||||
parameter logic PADDING_EN = 1'b1,
|
||||
parameter MIN_FRAME_LEN = 64,
|
||||
parameter logic PTP_TS_EN = 1'b0,
|
||||
parameter PTP_TS_W = 96,
|
||||
parameter TX_TAG_W = 16,
|
||||
parameter logic PFC_EN = 1'b0,
|
||||
parameter logic PAUSE_EN = PFC_EN
|
||||
/* verilator lint_on WIDTHTRUNC */
|
||||
)
|
||||
();
|
||||
|
||||
localparam DATA_W = 8;
|
||||
localparam TX_USER_W = 1;
|
||||
localparam RX_USER_W = (PTP_TS_EN ? PTP_TS_W : 0) + 1;
|
||||
|
||||
logic gtx_clk;
|
||||
logic gtx_rst;
|
||||
logic rx_clk;
|
||||
logic rx_rst;
|
||||
logic tx_clk;
|
||||
logic tx_rst;
|
||||
|
||||
taxi_axis_if #(.DATA_W(DATA_W), .USER_EN(1), .USER_W(TX_USER_W), .ID_EN(1), .ID_W(TX_TAG_W)) s_axis_tx();
|
||||
taxi_axis_if #(.DATA_W(PTP_TS_W), .KEEP_W(1), .ID_EN(1), .ID_W(TX_TAG_W)) m_axis_tx_cpl();
|
||||
taxi_axis_if #(.DATA_W(DATA_W), .USER_EN(1), .USER_W(RX_USER_W)) m_axis_rx();
|
||||
|
||||
logic gmii_rx_clk;
|
||||
logic [7:0] gmii_rxd;
|
||||
logic gmii_rx_dv;
|
||||
logic gmii_rx_er;
|
||||
logic mii_tx_clk;
|
||||
logic gmii_tx_clk;
|
||||
logic [7:0] gmii_txd;
|
||||
logic gmii_tx_en;
|
||||
logic gmii_tx_er;
|
||||
|
||||
logic [PTP_TS_W-1:0] tx_ptp_ts;
|
||||
logic [PTP_TS_W-1:0] rx_ptp_ts;
|
||||
|
||||
logic tx_lfc_req;
|
||||
logic tx_lfc_resend;
|
||||
logic rx_lfc_en;
|
||||
logic rx_lfc_req;
|
||||
logic rx_lfc_ack;
|
||||
|
||||
logic [7:0] tx_pfc_req;
|
||||
logic tx_pfc_resend;
|
||||
logic [7:0] rx_pfc_en;
|
||||
logic [7:0] rx_pfc_req;
|
||||
logic [7:0] rx_pfc_ack;
|
||||
|
||||
logic tx_lfc_pause_en;
|
||||
logic tx_pause_req;
|
||||
logic tx_pause_ack;
|
||||
|
||||
logic tx_start_packet;
|
||||
logic tx_error_underflow;
|
||||
logic rx_start_packet;
|
||||
logic rx_error_bad_frame;
|
||||
logic rx_error_bad_fcs;
|
||||
logic [1:0] link_speed;
|
||||
logic stat_tx_mcf;
|
||||
logic stat_rx_mcf;
|
||||
logic stat_tx_lfc_pkt;
|
||||
logic stat_tx_lfc_xon;
|
||||
logic stat_tx_lfc_xoff;
|
||||
logic stat_tx_lfc_paused;
|
||||
logic stat_tx_pfc_pkt;
|
||||
logic [7:0] stat_tx_pfc_xon;
|
||||
logic [7:0] stat_tx_pfc_xoff;
|
||||
logic [7:0] stat_tx_pfc_paused;
|
||||
logic stat_rx_lfc_pkt;
|
||||
logic stat_rx_lfc_xon;
|
||||
logic stat_rx_lfc_xoff;
|
||||
logic stat_rx_lfc_paused;
|
||||
logic stat_rx_pfc_pkt;
|
||||
logic [7:0] stat_rx_pfc_xon;
|
||||
logic [7:0] stat_rx_pfc_xoff;
|
||||
logic [7:0] stat_rx_pfc_paused;
|
||||
|
||||
logic [7:0] cfg_ifg;
|
||||
logic cfg_tx_enable;
|
||||
logic cfg_rx_enable;
|
||||
logic [47:0] cfg_mcf_rx_eth_dst_mcast;
|
||||
logic cfg_mcf_rx_check_eth_dst_mcast;
|
||||
logic [47:0] cfg_mcf_rx_eth_dst_ucast;
|
||||
logic cfg_mcf_rx_check_eth_dst_ucast;
|
||||
logic [47:0] cfg_mcf_rx_eth_src;
|
||||
logic cfg_mcf_rx_check_eth_src;
|
||||
logic [15:0] cfg_mcf_rx_eth_type;
|
||||
logic [15:0] cfg_mcf_rx_opcode_lfc;
|
||||
logic cfg_mcf_rx_check_opcode_lfc;
|
||||
logic [15:0] cfg_mcf_rx_opcode_pfc;
|
||||
logic cfg_mcf_rx_check_opcode_pfc;
|
||||
logic cfg_mcf_rx_forward;
|
||||
logic cfg_mcf_rx_enable;
|
||||
logic [47:0] cfg_tx_lfc_eth_dst;
|
||||
logic [47:0] cfg_tx_lfc_eth_src;
|
||||
logic [15:0] cfg_tx_lfc_eth_type;
|
||||
logic [15:0] cfg_tx_lfc_opcode;
|
||||
logic cfg_tx_lfc_en;
|
||||
logic [15:0] cfg_tx_lfc_quanta;
|
||||
logic [15:0] cfg_tx_lfc_refresh;
|
||||
logic [47:0] cfg_tx_pfc_eth_dst;
|
||||
logic [47:0] cfg_tx_pfc_eth_src;
|
||||
logic [15:0] cfg_tx_pfc_eth_type;
|
||||
logic [15:0] cfg_tx_pfc_opcode;
|
||||
logic cfg_tx_pfc_en;
|
||||
logic [8*16-1:0] cfg_tx_pfc_quanta;
|
||||
logic [8*16-1:0] cfg_tx_pfc_refresh;
|
||||
logic [15:0] cfg_rx_lfc_opcode;
|
||||
logic cfg_rx_lfc_en;
|
||||
logic [15:0] cfg_rx_pfc_opcode;
|
||||
logic cfg_rx_pfc_en;
|
||||
|
||||
taxi_eth_mac_1g_gmii #(
|
||||
.SIM(SIM),
|
||||
.VENDOR(VENDOR),
|
||||
.FAMILY(FAMILY),
|
||||
.PADDING_EN(PADDING_EN),
|
||||
.MIN_FRAME_LEN(MIN_FRAME_LEN),
|
||||
.PTP_TS_EN(PTP_TS_EN),
|
||||
.PTP_TS_W(PTP_TS_W),
|
||||
.PFC_EN(PFC_EN),
|
||||
.PAUSE_EN(PAUSE_EN)
|
||||
)
|
||||
uut (
|
||||
.gtx_clk(gtx_clk),
|
||||
.gtx_rst(gtx_rst),
|
||||
.rx_clk(rx_clk),
|
||||
.rx_rst(rx_rst),
|
||||
.tx_clk(tx_clk),
|
||||
.tx_rst(tx_rst),
|
||||
|
||||
/*
|
||||
* Transmit interface (AXI stream)
|
||||
*/
|
||||
.s_axis_tx(s_axis_tx),
|
||||
.m_axis_tx_cpl(m_axis_tx_cpl),
|
||||
|
||||
/*
|
||||
* Receive interface (AXI stream)
|
||||
*/
|
||||
.m_axis_rx(m_axis_rx),
|
||||
|
||||
/*
|
||||
* GMII interface
|
||||
*/
|
||||
.gmii_rx_clk(gmii_rx_clk),
|
||||
.gmii_rxd(gmii_rxd),
|
||||
.gmii_rx_dv(gmii_rx_dv),
|
||||
.gmii_rx_er(gmii_rx_er),
|
||||
.mii_tx_clk(mii_tx_clk),
|
||||
.gmii_tx_clk(gmii_tx_clk),
|
||||
.gmii_txd(gmii_txd),
|
||||
.gmii_tx_en(gmii_tx_en),
|
||||
.gmii_tx_er(gmii_tx_er),
|
||||
|
||||
/*
|
||||
* PTP
|
||||
*/
|
||||
.tx_ptp_ts(tx_ptp_ts),
|
||||
.rx_ptp_ts(rx_ptp_ts),
|
||||
|
||||
/*
|
||||
* Link-level Flow Control (LFC) (IEEE 802.3 annex 31B PAUSE)
|
||||
*/
|
||||
.tx_lfc_req(tx_lfc_req),
|
||||
.tx_lfc_resend(tx_lfc_resend),
|
||||
.rx_lfc_en(rx_lfc_en),
|
||||
.rx_lfc_req(rx_lfc_req),
|
||||
.rx_lfc_ack(rx_lfc_ack),
|
||||
|
||||
/*
|
||||
* Priority Flow Control (PFC) (IEEE 802.3 annex 31D PFC)
|
||||
*/
|
||||
.tx_pfc_req(tx_pfc_req),
|
||||
.tx_pfc_resend(tx_pfc_resend),
|
||||
.rx_pfc_en(rx_pfc_en),
|
||||
.rx_pfc_req(rx_pfc_req),
|
||||
.rx_pfc_ack(rx_pfc_ack),
|
||||
|
||||
/*
|
||||
* Pause interface
|
||||
*/
|
||||
.tx_lfc_pause_en(tx_lfc_pause_en),
|
||||
.tx_pause_req(tx_pause_req),
|
||||
.tx_pause_ack(tx_pause_ack),
|
||||
|
||||
/*
|
||||
* Status
|
||||
*/
|
||||
.tx_start_packet(tx_start_packet),
|
||||
.tx_error_underflow(tx_error_underflow),
|
||||
.rx_start_packet(rx_start_packet),
|
||||
.rx_error_bad_frame(rx_error_bad_frame),
|
||||
.rx_error_bad_fcs(rx_error_bad_fcs),
|
||||
.link_speed(link_speed),
|
||||
.stat_tx_mcf(stat_tx_mcf),
|
||||
.stat_rx_mcf(stat_rx_mcf),
|
||||
.stat_tx_lfc_pkt(stat_tx_lfc_pkt),
|
||||
.stat_tx_lfc_xon(stat_tx_lfc_xon),
|
||||
.stat_tx_lfc_xoff(stat_tx_lfc_xoff),
|
||||
.stat_tx_lfc_paused(stat_tx_lfc_paused),
|
||||
.stat_tx_pfc_pkt(stat_tx_pfc_pkt),
|
||||
.stat_tx_pfc_xon(stat_tx_pfc_xon),
|
||||
.stat_tx_pfc_xoff(stat_tx_pfc_xoff),
|
||||
.stat_tx_pfc_paused(stat_tx_pfc_paused),
|
||||
.stat_rx_lfc_pkt(stat_rx_lfc_pkt),
|
||||
.stat_rx_lfc_xon(stat_rx_lfc_xon),
|
||||
.stat_rx_lfc_xoff(stat_rx_lfc_xoff),
|
||||
.stat_rx_lfc_paused(stat_rx_lfc_paused),
|
||||
.stat_rx_pfc_pkt(stat_rx_pfc_pkt),
|
||||
.stat_rx_pfc_xon(stat_rx_pfc_xon),
|
||||
.stat_rx_pfc_xoff(stat_rx_pfc_xoff),
|
||||
.stat_rx_pfc_paused(stat_rx_pfc_paused),
|
||||
|
||||
/*
|
||||
* Configuration
|
||||
*/
|
||||
.cfg_ifg(cfg_ifg),
|
||||
.cfg_tx_enable(cfg_tx_enable),
|
||||
.cfg_rx_enable(cfg_rx_enable),
|
||||
.cfg_mcf_rx_eth_dst_mcast(cfg_mcf_rx_eth_dst_mcast),
|
||||
.cfg_mcf_rx_check_eth_dst_mcast(cfg_mcf_rx_check_eth_dst_mcast),
|
||||
.cfg_mcf_rx_eth_dst_ucast(cfg_mcf_rx_eth_dst_ucast),
|
||||
.cfg_mcf_rx_check_eth_dst_ucast(cfg_mcf_rx_check_eth_dst_ucast),
|
||||
.cfg_mcf_rx_eth_src(cfg_mcf_rx_eth_src),
|
||||
.cfg_mcf_rx_check_eth_src(cfg_mcf_rx_check_eth_src),
|
||||
.cfg_mcf_rx_eth_type(cfg_mcf_rx_eth_type),
|
||||
.cfg_mcf_rx_opcode_lfc(cfg_mcf_rx_opcode_lfc),
|
||||
.cfg_mcf_rx_check_opcode_lfc(cfg_mcf_rx_check_opcode_lfc),
|
||||
.cfg_mcf_rx_opcode_pfc(cfg_mcf_rx_opcode_pfc),
|
||||
.cfg_mcf_rx_check_opcode_pfc(cfg_mcf_rx_check_opcode_pfc),
|
||||
.cfg_mcf_rx_forward(cfg_mcf_rx_forward),
|
||||
.cfg_mcf_rx_enable(cfg_mcf_rx_enable),
|
||||
.cfg_tx_lfc_eth_dst(cfg_tx_lfc_eth_dst),
|
||||
.cfg_tx_lfc_eth_src(cfg_tx_lfc_eth_src),
|
||||
.cfg_tx_lfc_eth_type(cfg_tx_lfc_eth_type),
|
||||
.cfg_tx_lfc_opcode(cfg_tx_lfc_opcode),
|
||||
.cfg_tx_lfc_en(cfg_tx_lfc_en),
|
||||
.cfg_tx_lfc_quanta(cfg_tx_lfc_quanta),
|
||||
.cfg_tx_lfc_refresh(cfg_tx_lfc_refresh),
|
||||
.cfg_tx_pfc_eth_dst(cfg_tx_pfc_eth_dst),
|
||||
.cfg_tx_pfc_eth_src(cfg_tx_pfc_eth_src),
|
||||
.cfg_tx_pfc_eth_type(cfg_tx_pfc_eth_type),
|
||||
.cfg_tx_pfc_opcode(cfg_tx_pfc_opcode),
|
||||
.cfg_tx_pfc_en(cfg_tx_pfc_en),
|
||||
.cfg_tx_pfc_quanta(cfg_tx_pfc_quanta),
|
||||
.cfg_tx_pfc_refresh(cfg_tx_pfc_refresh),
|
||||
.cfg_rx_lfc_opcode(cfg_rx_lfc_opcode),
|
||||
.cfg_rx_lfc_en(cfg_rx_lfc_en),
|
||||
.cfg_rx_pfc_opcode(cfg_rx_pfc_opcode),
|
||||
.cfg_rx_pfc_en(cfg_rx_pfc_en)
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
||||
`resetall
|
||||
Reference in New Issue
Block a user