// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: xmac_fcs.v
// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
// This program 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// For the avoidance of doubt, and except that if any non-GPL license
// choice is available it will apply instead, Sun elects to use only
// the General Public License version 2 (GPLv2) at this time for any
// software where a choice of GPL license versions is made
// available with the language indicating that GPLv2 or any later version
// may be used, or where a choice of which version of the GPL is applied is
// otherwise unspecified.
// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
// CA 95054 USA or visit www.sun.com if you need additional information or
// ========== Copyright Header End ============================================
/*************************************************************************
* Description : xmac frame check sequence logic.
* Parent Module: rx_xmac or tx_xmac
* Child Module: crc_gen_xmii
* Copyright (c) 2002, Sun Microsystems, Inc.
* Sun Proprietary and Confidential
* Synthesis Notes: This module is very timing critical. Need custom layout.
*************************************************************************/
module xmac_fcs (clk,initialize_crc,compute_en,
crc_chk_dis,data_valid,dv_8bit,
data_64bit,new_crc5_result,crc_result,crc_error);
output [31:0] new_crc5_result;
output [31:0] crc_result;
// The 32 bits of the CRC value are placed in the frame check seqeunce
// field so that the x31 term is the left-most bit of the first octet,
// and the x0 term is the right most bit of the last octet.
// The bits of the CRC are thus transmitted in the order X31,x30,...,x1,x0.
// 802.3 3.3 pp-15: Each octec of the MAC frame, with the exception of
// the FCS, is transmitted low_order bit first.
// bit0 has to come into crc logic first.
wire initialize_crc,compute_en,crc_compute_error;
wire [7:0] swap_byte0 = {data_64bit[0],
wire [7:0] swap_byte1 = {data_64bit[8],
wire [7:0] swap_byte2 = {data_64bit[16],
wire [7:0] swap_byte3 = {data_64bit[24],
wire [7:0] swap_byte4 = {data_64bit[32],
wire [7:0] swap_byte5 = {data_64bit[40],
wire [7:0] swap_byte6 = {data_64bit[48],
wire [7:0] swap_byte7 = {data_64bit[56],
wire [31:0] new_crc5_result;
crc_gen_xmii crc_gen_xmii (.clk(clk),.initialize_crc(initialize_crc),
.input_byte0(swap_byte0),.input_byte1(swap_byte1),
.input_byte2(swap_byte2),.input_byte3(swap_byte3),
.input_byte4(swap_byte4),.input_byte5(swap_byte5),
.input_byte6(swap_byte6),.input_byte7(swap_byte7),
.new_crc5_result(new_crc5_result),
.crc_result(crc_result));
assign crc_compute_error = (crc_result != 32'h38FB2284);
assign crc_error = crc_compute_error & !crc_chk_dis;