📄 tb_ethernet.v
字号:
////////////////////////////////////////////////////////////////////////// //////// tb_ethernet.v //////// //////// This file is part of the Ethernet IP core project //////// http://www.opencores.org/projects/ethmac/ //////// //////// Author(s): //////// - Igor Mohor (igorM@opencores.org) //////// //////// All additional information is avaliable in the Readme.txt //////// file. //////// ////////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2001, 2002 Authors //////// //////// This source file may be used and distributed without //////// restriction provided that this copyright statement is not //////// removed from the file and that any derivative work contains //////// the original copyright notice and the associated disclaimer. //////// //////// This source file is free software; you can redistribute it //////// and/or modify it under the terms of the GNU Lesser General //////// Public License as published by the Free Software Foundation; //////// either version 2.1 of the License, or (at your option) any //////// later version. //////// //////// This source is distributed in the hope that it will be //////// useful, but WITHOUT ANY WARRANTY; without even the implied //////// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //////// PURPOSE. See the GNU Lesser General Public License for more //////// details. //////// //////// You should have received a copy of the GNU Lesser General //////// Public License along with this source; if not, download it //////// from http://www.opencores.org/lgpl.shtml //////// ////////////////////////////////////////////////////////////////////////////// CVS Revision History//// $Log: tb_ethernet.v,v $// Revision 1.3 2002/07/23 16:34:31 mohor// gsr added for use when ETH_XILINX_RAMB4 define is set.//// Revision 1.2 2002/07/19 14:02:47 mohor// Clock mrx_clk set to 2.5 MHz.//// Revision 1.1 2002/07/19 13:57:53 mohor// Testing environment also includes traffic cop, memory interface and host// interface.//////////`include "tb_eth_defines.v"`include "eth_defines.v"`include "timescale.v"module tb_ethernet();parameter Tp = 1;reg wb_clk_o;reg wb_rst_o;reg mtx_clk;reg mrx_clk;wire [3:0] MTxD;wire MTxEn;wire MTxErr;reg [3:0] MRxD; // This goes to PHYreg MRxDV; // This goes to PHYreg MRxErr; // This goes to PHYreg MColl; // This goes to PHYreg MCrs; // This goes to PHYwire Mdi_I;wire Mdo_O;wire Mdo_OE;wire Mdc_O;integer tx_log;integer rx_log;reg StartTB;`ifdef ETH_XILINX_RAMB4 reg gsr;`endifinteger packet_ready_cnt, send_packet_cnt;// Ethernet Slave Interface signalswire [31:0] eth_sl_wb_adr_i, eth_sl_wb_dat_o, eth_sl_wb_dat_i;wire [3:0] eth_sl_wb_sel_i;wire eth_sl_wb_we_i, eth_sl_wb_cyc_i, eth_sl_wb_stb_i, eth_sl_wb_ack_o, eth_sl_wb_err_o;// Memory Slave Interface signalswire [31:0] mem_sl_wb_adr_i, mem_sl_wb_dat_o, mem_sl_wb_dat_i;wire [3:0] mem_sl_wb_sel_i;wire mem_sl_wb_we_i, mem_sl_wb_cyc_i, mem_sl_wb_stb_i, mem_sl_wb_ack_o, mem_sl_wb_err_o;// Ethernet Master Interface signalswire [31:0] eth_ma_wb_adr_o, eth_ma_wb_dat_i, eth_ma_wb_dat_o;wire [3:0] eth_ma_wb_sel_o;wire eth_ma_wb_we_o, eth_ma_wb_cyc_o, eth_ma_wb_stb_o, eth_ma_wb_ack_i, eth_ma_wb_err_i;// Host Master Interface signalswire [31:0] host_ma_wb_adr_o, host_ma_wb_dat_i, host_ma_wb_dat_o;wire [3:0] host_ma_wb_sel_o;wire host_ma_wb_we_o, host_ma_wb_cyc_o, host_ma_wb_stb_o, host_ma_wb_ack_i, host_ma_wb_err_i;eth_cop i_eth_cop( // WISHBONE common .wb_clk_i(wb_clk_o), .wb_rst_i(wb_rst_o), // WISHBONE MASTER 1 Ethernet Master Interface is connected here .m1_wb_adr_i(eth_ma_wb_adr_o), .m1_wb_sel_i(eth_ma_wb_sel_o), .m1_wb_we_i (eth_ma_wb_we_o), .m1_wb_dat_o(eth_ma_wb_dat_i), .m1_wb_dat_i(eth_ma_wb_dat_o), .m1_wb_cyc_i(eth_ma_wb_cyc_o), .m1_wb_stb_i(eth_ma_wb_stb_o), .m1_wb_ack_o(eth_ma_wb_ack_i), .m1_wb_err_o(eth_ma_wb_err_i), // WISHBONE MASTER 2 Host Interface is connected here .m2_wb_adr_i(host_ma_wb_adr_o), .m2_wb_sel_i(host_ma_wb_sel_o), .m2_wb_we_i (host_ma_wb_we_o), .m2_wb_dat_o(host_ma_wb_dat_i), .m2_wb_dat_i(host_ma_wb_dat_o), .m2_wb_cyc_i(host_ma_wb_cyc_o), .m2_wb_stb_i(host_ma_wb_stb_o), .m2_wb_ack_o(host_ma_wb_ack_i), .m2_wb_err_o(host_ma_wb_err_i), // WISHBONE slave 1 Ethernet Slave Interface is connected here .s1_wb_adr_o(eth_sl_wb_adr_i), .s1_wb_sel_o(eth_sl_wb_sel_i), .s1_wb_we_o (eth_sl_wb_we_i), .s1_wb_cyc_o(eth_sl_wb_cyc_i), .s1_wb_stb_o(eth_sl_wb_stb_i), .s1_wb_ack_i(eth_sl_wb_ack_o), .s1_wb_err_i(eth_sl_wb_err_o), .s1_wb_dat_i(eth_sl_wb_dat_o), .s1_wb_dat_o(eth_sl_wb_dat_i), // WISHBONE slave 2 Memory Interface is connected here .s2_wb_adr_o(mem_sl_wb_adr_i), .s2_wb_sel_o(mem_sl_wb_sel_i), .s2_wb_we_o (mem_sl_wb_we_i), .s2_wb_cyc_o(mem_sl_wb_cyc_i), .s2_wb_stb_o(mem_sl_wb_stb_i), .s2_wb_ack_i(mem_sl_wb_ack_o), .s2_wb_err_i(mem_sl_wb_err_o), .s2_wb_dat_i(mem_sl_wb_dat_o), .s2_wb_dat_o(mem_sl_wb_dat_i));// Connecting Ethernet top moduleeth_top ethtop( // WISHBONE common .wb_clk_i(wb_clk_o), .wb_rst_i(wb_rst_o), // WISHBONE slave .wb_adr_i(eth_sl_wb_adr_i[11:2]), .wb_sel_i(eth_sl_wb_sel_i), .wb_we_i(eth_sl_wb_we_i), .wb_cyc_i(eth_sl_wb_cyc_i), .wb_stb_i(eth_sl_wb_stb_i), .wb_ack_o(eth_sl_wb_ack_o), .wb_err_o(eth_sl_wb_err_o), .wb_dat_i(eth_sl_wb_dat_i), .wb_dat_o(eth_sl_wb_dat_o), // WISHBONE master .m_wb_adr_o(eth_ma_wb_adr_o), .m_wb_sel_o(eth_ma_wb_sel_o), .m_wb_we_o(eth_ma_wb_we_o), .m_wb_dat_i(eth_ma_wb_dat_i), .m_wb_dat_o(eth_ma_wb_dat_o), .m_wb_cyc_o(eth_ma_wb_cyc_o), .m_wb_stb_o(eth_ma_wb_stb_o), .m_wb_ack_i(eth_ma_wb_ack_i), .m_wb_err_i(eth_ma_wb_err_i), //TX .mtx_clk_pad_i(mtx_clk), .mtxd_pad_o(MTxD), .mtxen_pad_o(MTxEn), .mtxerr_pad_o(MTxErr), //RX .mrx_clk_pad_i(mrx_clk), .mrxd_pad_i(MRxD), .mrxdv_pad_i(MRxDV), .mrxerr_pad_i(MRxErr), .mcoll_pad_i(MColl), .mcrs_pad_i(MCrs), // MIIM .mdc_pad_o(Mdc_O), .md_pad_i(Mdi_I), .md_pad_o(Mdo_O), .md_padoe_o(Mdo_OE), .int_o());// Connecting Memory Interface Moduleeth_memory i_eth_memory( // WISHBONE common .wb_clk_i(wb_clk_o), .wb_rst_i(wb_rst_o), // WISHBONE slave: Memory Interface is connected here .wb_adr_i(mem_sl_wb_adr_i), .wb_sel_i(mem_sl_wb_sel_i), .wb_we_i (mem_sl_wb_we_i), .wb_cyc_i(mem_sl_wb_cyc_i), .wb_stb_i(mem_sl_wb_stb_i), .wb_ack_o(mem_sl_wb_ack_o), .wb_err_o(mem_sl_wb_err_o), .wb_dat_o(mem_sl_wb_dat_o), .wb_dat_i(mem_sl_wb_dat_i));// Connecting Host Interfaceeth_host eth_host( // WISHBONE common .wb_clk_i(wb_clk_o), .wb_rst_i(wb_rst_o), // WISHBONE master .wb_adr_o(host_ma_wb_adr_o), .wb_sel_o(host_ma_wb_sel_o), .wb_we_o (host_ma_wb_we_o), .wb_dat_i(host_ma_wb_dat_i), .wb_dat_o(host_ma_wb_dat_o), .wb_cyc_o(host_ma_wb_cyc_o), .wb_stb_o(host_ma_wb_stb_o), .wb_ack_i(host_ma_wb_ack_i), .wb_err_i(host_ma_wb_err_i));// Reset pulseinitialbegin MCrs=0; // This should come from PHY MColl=0; // This should come from PHY MRxD=0; // This should come from PHY MRxDV=0; // This should come from PHY MRxErr=0; // This should come from PHY packet_ready_cnt = 0; send_packet_cnt = 0; tx_log = $fopen("ethernet_tx.log"); rx_log = $fopen("ethernet_rx.log"); wb_rst_o = 1'b1;`ifdef ETH_XILINX_RAMB4 gsr = 1'b0; #100 gsr = 1'b1; #100 gsr = 1'b0;`endif #100 wb_rst_o = 1'b0; #100 StartTB = 1'b1;end`ifdef ETH_XILINX_RAMB4 assign glbl.GSR = gsr;`endif// Generating wb_clk_o clockinitialbegin wb_clk_o=0;// forever #2.5 wb_clk_o = ~wb_clk_o; // 2*2.5 ns -> 200.0 MHz // forever #5 wb_clk_o = ~wb_clk_o; // 2*5 ns -> 100.0 MHz // forever #10 wb_clk_o = ~wb_clk_o; // 2*10 ns -> 50.0 MHz forever #12.5 wb_clk_o = ~wb_clk_o; // 2*12.5 ns -> 40 MHz // forever #15 wb_clk_o = ~wb_clk_o; // 2*10 ns -> 33.3 MHz // forever #20 wb_clk_o = ~wb_clk_o; // 2*20 ns -> 25 MHz // forever #25 wb_clk_o = ~wb_clk_o; // 2*25 ns -> 20.0 MHz// forever #31.25 wb_clk_o = ~wb_clk_o; // 2*31.25 ns -> 16.0 MHz // forever #50 wb_clk_o = ~wb_clk_o; // 2*50 ns -> 10.0 MHz// forever #55 wb_clk_o = ~wb_clk_o; // 2*55 ns -> 9.1 MHz
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -