OpenCores
URL https://opencores.org/ocsvn/ethernet_tri_mode/ethernet_tri_mode/trunk

Subversion Repositories ethernet_tri_mode

[/] [ethernet_tri_mode/] [trunk/] [rtl/] [verilog/] [MAC_rx/] [CRC_chk.v] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 maverickis
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  CRC_chk.v                                                   ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects.cgi/web/ethernet_tri_mode/////
7
////                                                              ////
8
////  Author(s):                                                  ////
9 7 maverickis
////      - Jon Gao (gaojon@yahoo.com)                            ////
10 5 maverickis
////                                                              ////
11
////                                                              ////
12
//////////////////////////////////////////////////////////////////////
13
////                                                              ////
14
//// Copyright (C) 2001 Authors                                   ////
15
////                                                              ////
16
//// This source file may be used and distributed without         ////
17
//// restriction provided that this copyright statement is not    ////
18
//// removed from the file and that any derivative work contains  ////
19
//// the original copyright notice and the associated disclaimer. ////
20
////                                                              ////
21
//// This source file is free software; you can redistribute it   ////
22
//// and/or modify it under the terms of the GNU Lesser General   ////
23
//// Public License as published by the Free Software Foundation; ////
24
//// either version 2.1 of the License, or (at your option) any   ////
25
//// later version.                                               ////
26
////                                                              ////
27
//// This source is distributed in the hope that it will be       ////
28
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
29
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
30
//// PURPOSE.  See the GNU Lesser General Public License for more ////
31
//// details.                                                     ////
32
////                                                              ////
33
//// You should have received a copy of the GNU Lesser General    ////
34
//// Public License along with this source; if not, download it   ////
35
//// from http://www.opencores.org/lgpl.shtml                     ////
36
////                                                              ////
37
//////////////////////////////////////////////////////////////////////
38
//                                                                    
39
// CVS Revision History                                               
40
//                                                                    
41 6 maverickis
// $Log: not supported by cvs2svn $
42 7 maverickis
// Revision 1.2  2005/12/16 06:44:16  Administrator
43
// replaced tab with space.
44
// passed 9.6k length frame test.
45
//
46 6 maverickis
// Revision 1.1.1.1  2005/12/13 01:51:45  Administrator
47
// no message
48
//                                           
49 5 maverickis
 
50
module CRC_chk(
51 7 maverickis
Reset       ,
52
Clk         ,
53
CRC_data    ,
54
CRC_init    ,
55
CRC_en      ,
56 5 maverickis
//From CPU  
57 7 maverickis
CRC_chk_en  ,
58
CRC_err
59 5 maverickis
);
60 7 maverickis
input       Reset       ;
61
input       Clk         ;
62
input[7:0]  CRC_data    ;
63
input       CRC_init    ;
64
input       CRC_en      ;
65
            //From CPU
66
input       CRC_chk_en  ;
67
output      CRC_err     ;
68 5 maverickis
//******************************************************************************   
69
//internal signals                                                              
70
//******************************************************************************
71 7 maverickis
reg [31:0]  CRC_reg;
72
wire[31:0]  Next_CRC;
73 5 maverickis
//******************************************************************************
74
//input data width is 8bit, and the first bit is bit[0]
75 7 maverickis
function[31:0]  NextCRC;
76
    input[7:0]      D;
77
    input[31:0]     C;
78
    reg[31:0]       NewCRC;
79
    begin
80
    NewCRC[0]=C[24]^C[30]^D[1]^D[7];
81
    NewCRC[1]=C[25]^C[31]^D[0]^D[6]^C[24]^C[30]^D[1]^D[7];
82
    NewCRC[2]=C[26]^D[5]^C[25]^C[31]^D[0]^D[6]^C[24]^C[30]^D[1]^D[7];
83
    NewCRC[3]=C[27]^D[4]^C[26]^D[5]^C[25]^C[31]^D[0]^D[6];
84
    NewCRC[4]=C[28]^D[3]^C[27]^D[4]^C[26]^D[5]^C[24]^C[30]^D[1]^D[7];
85
    NewCRC[5]=C[29]^D[2]^C[28]^D[3]^C[27]^D[4]^C[25]^C[31]^D[0]^D[6]^C[24]^C[30]^D[1]^D[7];
86
    NewCRC[6]=C[30]^D[1]^C[29]^D[2]^C[28]^D[3]^C[26]^D[5]^C[25]^C[31]^D[0]^D[6];
87
    NewCRC[7]=C[31]^D[0]^C[29]^D[2]^C[27]^D[4]^C[26]^D[5]^C[24]^D[7];
88
    NewCRC[8]=C[0]^C[28]^D[3]^C[27]^D[4]^C[25]^D[6]^C[24]^D[7];
89
    NewCRC[9]=C[1]^C[29]^D[2]^C[28]^D[3]^C[26]^D[5]^C[25]^D[6];
90
    NewCRC[10]=C[2]^C[29]^D[2]^C[27]^D[4]^C[26]^D[5]^C[24]^D[7];
91
    NewCRC[11]=C[3]^C[28]^D[3]^C[27]^D[4]^C[25]^D[6]^C[24]^D[7];
92
    NewCRC[12]=C[4]^C[29]^D[2]^C[28]^D[3]^C[26]^D[5]^C[25]^D[6]^C[24]^C[30]^D[1]^D[7];
93
    NewCRC[13]=C[5]^C[30]^D[1]^C[29]^D[2]^C[27]^D[4]^C[26]^D[5]^C[25]^C[31]^D[0]^D[6];
94
    NewCRC[14]=C[6]^C[31]^D[0]^C[30]^D[1]^C[28]^D[3]^C[27]^D[4]^C[26]^D[5];
95
    NewCRC[15]=C[7]^C[31]^D[0]^C[29]^D[2]^C[28]^D[3]^C[27]^D[4];
96
    NewCRC[16]=C[8]^C[29]^D[2]^C[28]^D[3]^C[24]^D[7];
97
    NewCRC[17]=C[9]^C[30]^D[1]^C[29]^D[2]^C[25]^D[6];
98
    NewCRC[18]=C[10]^C[31]^D[0]^C[30]^D[1]^C[26]^D[5];
99
    NewCRC[19]=C[11]^C[31]^D[0]^C[27]^D[4];
100
    NewCRC[20]=C[12]^C[28]^D[3];
101
    NewCRC[21]=C[13]^C[29]^D[2];
102
    NewCRC[22]=C[14]^C[24]^D[7];
103
    NewCRC[23]=C[15]^C[25]^D[6]^C[24]^C[30]^D[1]^D[7];
104
    NewCRC[24]=C[16]^C[26]^D[5]^C[25]^C[31]^D[0]^D[6];
105
    NewCRC[25]=C[17]^C[27]^D[4]^C[26]^D[5];
106
    NewCRC[26]=C[18]^C[28]^D[3]^C[27]^D[4]^C[24]^C[30]^D[1]^D[7];
107
    NewCRC[27]=C[19]^C[29]^D[2]^C[28]^D[3]^C[25]^C[31]^D[0]^D[6];
108
    NewCRC[28]=C[20]^C[30]^D[1]^C[29]^D[2]^C[26]^D[5];
109
    NewCRC[29]=C[21]^C[31]^D[0]^C[30]^D[1]^C[27]^D[4];
110
    NewCRC[30]=C[22]^C[31]^D[0]^C[28]^D[3];
111
    NewCRC[31]=C[23]^C[29]^D[2];
112
    NextCRC=NewCRC;
113
    end
114
        endfunction
115 5 maverickis
 
116
always @ (posedge Clk or posedge Reset)
117 7 maverickis
    if (Reset)
118
        CRC_reg     <=32'hffffffff;
119
    else if (CRC_init)
120
        CRC_reg     <=32'hffffffff;
121
    else if (CRC_en)
122
        CRC_reg     <=NextCRC(CRC_data,CRC_reg);
123 5 maverickis
 
124 7 maverickis
assign  CRC_err = CRC_chk_en&(CRC_reg[31:0] != 32'hc704dd7b);
125 5 maverickis
 
126
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.