| 1 |
4 |
dwp |
//////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//// ////
|
| 3 |
|
|
//// File name "ge_1000baseX_tb.v" ////
|
| 4 |
|
|
//// ////
|
| 5 |
|
|
//// This file is part of the : ////
|
| 6 |
|
|
//// ////
|
| 7 |
|
|
//// "1000BASE-X IEEE 802.3-2008 Clause 36 - PCS project" ////
|
| 8 |
|
|
//// ////
|
| 9 |
|
|
//// http://opencores.org/project,1000base-x ////
|
| 10 |
|
|
//// ////
|
| 11 |
|
|
//// Author(s): ////
|
| 12 |
|
|
//// - D.W.Pegler Cambridge Broadband Networks Ltd ////
|
| 13 |
|
|
//// ////
|
| 14 |
|
|
//// { peglerd@gmail.com, dwp@cambridgebroadand.com } ////
|
| 15 |
|
|
//// ////
|
| 16 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 17 |
|
|
//// ////
|
| 18 |
|
|
//// Copyright (C) 2009 AUTHORS. All rights reserved. ////
|
| 19 |
|
|
//// ////
|
| 20 |
|
|
//// This source file may be used and distributed without ////
|
| 21 |
|
|
//// restriction provided that this copyright statement is not ////
|
| 22 |
|
|
//// removed from the file and that any derivative work contains ////
|
| 23 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
| 24 |
|
|
//// ////
|
| 25 |
|
|
//// This source file is free software; you can redistribute it ////
|
| 26 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
| 27 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
| 28 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
| 29 |
|
|
//// later version. ////
|
| 30 |
|
|
//// ////
|
| 31 |
|
|
//// This source is distributed in the hope that it will be ////
|
| 32 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
| 33 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
| 34 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
| 35 |
|
|
//// details. ////
|
| 36 |
|
|
//// ////
|
| 37 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
| 38 |
|
|
//// Public License along with this source; if not, download it ////
|
| 39 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
| 40 |
|
|
//// ////
|
| 41 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 42 |
|
|
//// ////
|
| 43 |
|
|
//// This module is based on the coding method described in ////
|
| 44 |
|
|
//// IEEE Std 802.3-2008 Clause 36 "Physical Coding Sublayer(PCS) ////
|
| 45 |
|
|
//// and Physical Medium Attachment (PMA) sublayer, type ////
|
| 46 |
|
|
//// 1000BASE-X"; see : ////
|
| 47 |
|
|
//// ////
|
| 48 |
|
|
//// http://standards.ieee.org/about/get/802/802.3.html ////
|
| 49 |
|
|
//// and ////
|
| 50 |
|
|
//// doc/802.3-2008_section3.pdf, Clause/Section 36. ////
|
| 51 |
|
|
//// ////
|
| 52 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 53 |
|
|
|
| 54 |
|
|
`include "timescale_tb.v"
|
| 55 |
|
|
|
| 56 |
|
|
module ge_1000baseX_tb #(
|
| 57 |
|
|
parameter test_name = "",
|
| 58 |
|
|
parameter quit_on_stop = 0
|
| 59 |
|
|
) ();
|
| 60 |
|
|
|
| 61 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 62 |
|
|
// Clock and reset generation.
|
| 63 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 64 |
|
|
|
| 65 |
|
|
localparam mdio_ck_period = 1000ns;
|
| 66 |
|
|
|
| 67 |
|
|
localparam GE_125MHz_ref_ck_period = 8ns;
|
| 68 |
|
|
|
| 69 |
|
|
reg running;
|
| 70 |
|
|
|
| 71 |
|
|
// Generate MDIO clock (MDC)
|
| 72 |
|
|
clock_gen #(.period(mdio_ck_period)) mdio_ck_gen(.enable(running), .ck(mdc));
|
| 73 |
|
|
|
| 74 |
|
|
// Generate 125MHz clock reference.
|
| 75 |
|
|
clock_gen #(.period( GE_125MHz_ref_ck_period)) GE_125MHz_ref_ck_gen(.enable(running), .ck(GE_125MHz_ref_ckpin));
|
| 76 |
|
|
|
| 77 |
|
|
|
| 78 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 79 |
|
|
// De-assert main reset 10 clocks after startup
|
| 80 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 81 |
|
|
reg reset;
|
| 82 |
|
|
|
| 83 |
|
|
initial
|
| 84 |
|
|
begin
|
| 85 |
|
|
reset = 1;
|
| 86 |
|
|
repeat(50) @(posedge GE_125MHz_ref_ckpin);
|
| 87 |
|
|
reset = 0;
|
| 88 |
|
|
end
|
| 89 |
|
|
|
| 90 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 91 |
|
|
// Handle to all the virtual interfaces of the testbench models.
|
| 92 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 93 |
|
|
|
| 94 |
|
|
tb_utils::VirIntfHandle h = new();
|
| 95 |
|
|
|
| 96 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 97 |
|
|
// 8B10B bus and PCS GMII interfaces
|
| 98 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 99 |
|
|
|
| 100 |
|
|
wire [9:0] tbi_rxd, tbi_txd;
|
| 101 |
|
|
|
| 102 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 103 |
|
|
// PCS GMII interfaces
|
| 104 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 105 |
|
|
|
| 106 |
|
|
wire [7:0] gmii_rxd, gmii_txd;
|
| 107 |
|
|
|
| 108 |
|
|
wire gmii_rx_dv, gmii_rx_er, gmii_col, gmii_cs, gmii_tx_en, gmii_tx_er;
|
| 109 |
|
|
|
| 110 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 111 |
|
|
// Assert signal_detect a number of clocks after startup
|
| 112 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 113 |
|
|
|
| 114 |
|
|
wire sync = 1'b1; reg signal_detect;
|
| 115 |
|
|
|
| 116 |
|
|
initial
|
| 117 |
|
|
begin
|
| 118 |
|
|
signal_detect = 1'b0;
|
| 119 |
|
|
repeat(1000) @(posedge GE_125MHz_ref_ckpin);
|
| 120 |
|
|
signal_detect = 1'b1;
|
| 121 |
|
|
end
|
| 122 |
|
|
|
| 123 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 124 |
|
|
// Loopback on 10B TX and RX interface
|
| 125 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 126 |
|
|
|
| 127 |
|
|
assign tbi_rxd = tbi_txd;
|
| 128 |
|
|
|
| 129 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 130 |
|
|
//
|
| 131 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 132 |
|
|
|
| 133 |
|
|
wire sync_en, loop_en, prbs_en;
|
| 134 |
|
|
|
| 135 |
|
|
|
| 136 |
|
|
ge_1000baseX_test ge_1000baseX_testi(
|
| 137 |
|
|
|
| 138 |
|
|
// --- Resets ---
|
| 139 |
|
|
.reset_pin(reset),
|
| 140 |
|
|
|
| 141 |
|
|
// --- 125MHz Ref clk
|
| 142 |
|
|
.GE_125MHz_ref_ckpin(GE_125MHz_ref_ckpin),
|
| 143 |
|
|
|
| 144 |
|
|
// --- FO TBI 125MHz Rx clk
|
| 145 |
|
|
.tbi_rx_ckpin(GE_125MHz_ref_ckpin),
|
| 146 |
|
|
|
| 147 |
|
|
// --- TLK1221 transmit TBI bus ---
|
| 148 |
|
|
.tbi_txd(tbi_txd),
|
| 149 |
|
|
.tbi_rxd(tbi_rxd),
|
| 150 |
|
|
|
| 151 |
|
|
// --- Receive GMII bus ---
|
| 152 |
|
|
.gmii_rxd(gmii_rxd),
|
| 153 |
|
|
.gmii_rx_dv(gmii_rx_dv),
|
| 154 |
|
|
.gmii_rx_er(gmii_rx_er),
|
| 155 |
|
|
.gmii_col(gmii_col),
|
| 156 |
|
|
.gmii_cs(gmii_cs),
|
| 157 |
|
|
|
| 158 |
|
|
// --- Transmit GMII bus ---
|
| 159 |
|
|
.gmii_tx_en(gmii_tx_en),
|
| 160 |
|
|
.gmii_tx_er(gmii_tx_er),
|
| 161 |
|
|
.gmii_txd(gmii_txd),
|
| 162 |
|
|
|
| 163 |
|
|
// --- Ctrl/status strobes ---
|
| 164 |
|
|
.sync_en(sync_en),
|
| 165 |
|
|
.loop_en(loop_en),
|
| 166 |
|
|
.prbs_en(prbs_en),
|
| 167 |
|
|
|
| 168 |
|
|
.signal_detect(signal_detect),
|
| 169 |
|
|
.sync(sync),
|
| 170 |
|
|
|
| 171 |
|
|
// --- MDIO interface ---
|
| 172 |
|
|
.mdio(mdio),
|
| 173 |
|
|
.mdio_ckpin(mdc)
|
| 174 |
|
|
);
|
| 175 |
|
|
|
| 176 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 177 |
|
|
// GMII bus tx model
|
| 178 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 179 |
|
|
|
| 180 |
|
|
gmii_tx_if gmii_tx_model_if_i();
|
| 181 |
|
|
|
| 182 |
|
|
gmii_tx_model #(
|
| 183 |
|
|
.DEBUG(1)
|
| 184 |
|
|
) phy_gmii_tx_model_i (
|
| 185 |
|
|
.send_intf(gmii_tx_model_if_i.model),
|
| 186 |
|
|
|
| 187 |
|
|
.mii_txck_in(1'b0),
|
| 188 |
|
|
.gmii_txck_in(GE_125MHz_ref_ckpin),
|
| 189 |
|
|
.txck_out(),
|
| 190 |
|
|
.gigabit_mode(),
|
| 191 |
|
|
|
| 192 |
|
|
.txd(gmii_txd),
|
| 193 |
|
|
.tx_en(gmii_tx_en),
|
| 194 |
|
|
.tx_er(gmii_tx_er),
|
| 195 |
|
|
|
| 196 |
|
|
.crs(gmii_cs),
|
| 197 |
|
|
.col(gmii_col)
|
| 198 |
|
|
);
|
| 199 |
|
|
|
| 200 |
|
|
initial h.gmii_tx_model = gmii_tx_model_if_i;
|
| 201 |
|
|
|
| 202 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 203 |
|
|
// GMII bus rx model
|
| 204 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 205 |
|
|
|
| 206 |
|
|
gmii_rx_if gmii_rx_model_if_i();
|
| 207 |
|
|
|
| 208 |
|
|
gmii_rx_model #(
|
| 209 |
|
|
.DEBUG(2)
|
| 210 |
|
|
) gmii_rx_model_i(
|
| 211 |
|
|
.check_intf(gmii_rx_model_if_i.model),
|
| 212 |
|
|
|
| 213 |
|
|
.mii_rxck_in(1'b0),
|
| 214 |
|
|
.gmii_rxck_in(GE_125MHz_ref_ckpin),
|
| 215 |
|
|
.mii_rxck_out(),
|
| 216 |
|
|
|
| 217 |
|
|
.rxd(gmii_rxd),
|
| 218 |
|
|
.rx_dv(gmii_rx_dv),
|
| 219 |
|
|
.rx_er(gmii_rx_er)
|
| 220 |
|
|
);
|
| 221 |
|
|
|
| 222 |
|
|
initial h.gmii_rx_model = gmii_rx_model_if_i;
|
| 223 |
|
|
|
| 224 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 225 |
|
|
// mdio mdc serial interface model
|
| 226 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 227 |
|
|
|
| 228 |
|
|
serial_model_if serial_model_if_i();
|
| 229 |
|
|
|
| 230 |
|
|
mdio_serial_model #(
|
| 231 |
|
|
.PHY_ADDR(5'b00000)
|
| 232 |
|
|
) mdio_serial_model_i (
|
| 233 |
|
|
.cmd_intf(serial_model_if_i.model),
|
| 234 |
|
|
|
| 235 |
|
|
.reset(reset),
|
| 236 |
|
|
.mdc(mdc),
|
| 237 |
|
|
.mdio(mdio)
|
| 238 |
|
|
);
|
| 239 |
|
|
|
| 240 |
|
|
initial h.serial_model = serial_model_if_i;
|
| 241 |
|
|
|
| 242 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 243 |
|
|
// 8B10B 10B receive model
|
| 244 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 245 |
|
|
|
| 246 |
|
|
encoder_10b_rx_if encoder_10b_rx_model_ifi();
|
| 247 |
|
|
|
| 248 |
|
|
encoder_10b_rx_model #(
|
| 249 |
|
|
.DEBUG(1)
|
| 250 |
|
|
) encoder_10b_rx_modeli (
|
| 251 |
|
|
|
| 252 |
|
|
.check_intf(encoder_10b_rx_model_ifi.model),
|
| 253 |
|
|
|
| 254 |
|
|
.reset(reset),
|
| 255 |
|
|
|
| 256 |
|
|
.SBYTECLK(GE_125MHz_ref_ckpin),
|
| 257 |
|
|
|
| 258 |
|
|
.tbi_rx(tbi_rxd)
|
| 259 |
|
|
);
|
| 260 |
|
|
|
| 261 |
|
|
initial h.encoder_10b_rx_model = encoder_10b_rx_model_ifi;
|
| 262 |
|
|
|
| 263 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 264 |
|
|
// Test script selection and launch.
|
| 265 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 266 |
|
|
int errors;
|
| 267 |
|
|
|
| 268 |
|
|
initial
|
| 269 |
|
|
begin
|
| 270 |
|
|
errors = 0; running = 1;
|
| 271 |
|
|
|
| 272 |
|
|
#0;
|
| 273 |
|
|
|
| 274 |
|
|
case(test_name)
|
| 275 |
|
|
"ge_1000baseX_tb": ge_1000baseX_tb_script::main(h, errors);
|
| 276 |
|
|
default:
|
| 277 |
|
|
begin
|
| 278 |
|
|
errors++;
|
| 279 |
|
|
$display("%m:Unknown test '%s'", test_name);
|
| 280 |
|
|
end
|
| 281 |
|
|
endcase
|
| 282 |
|
|
|
| 283 |
|
|
running = 0;
|
| 284 |
|
|
|
| 285 |
|
|
$display("Test completed,",);
|
| 286 |
|
|
|
| 287 |
|
|
if(errors) $display("%0d errors", errors);
|
| 288 |
|
|
else $display("success.");
|
| 289 |
|
|
|
| 290 |
|
|
if (quit_on_stop) $finish;
|
| 291 |
|
|
else
|
| 292 |
|
|
$stop;
|
| 293 |
|
|
end
|
| 294 |
|
|
|
| 295 |
|
|
endmodule
|