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

Subversion Repositories srdydrdy_lib

[/] [srdydrdy_lib/] [trunk/] [external/] [ethernet_tri_mode/] [MAC_tx/] [CRC_gen.v] - Blame information for rev 23

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 23 ghutchis
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  CRC_gen.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
////      - Jon Gao (gaojon@yahoo.com)                            ////
10
////                                                              ////
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
// $Log: CRC_gen.v,v $
42
// Revision 1.3  2006/01/19 14:07:54  maverickist
43
// verification is complete.
44
//
45
// Revision 1.2  2005/12/16 06:44:17  Administrator
46
// replaced tab with space.
47
// passed 9.6k length frame test.
48
//
49
// Revision 1.1.1.1  2005/12/13 01:51:45  Administrator
50
// no message
51
//                                           
52
 
53
module CRC_gen (
54
Reset       ,
55
Clk         ,
56
Init        ,
57
Frame_data  ,
58
Data_en     ,
59
CRC_rd      ,
60
CRC_end     ,
61
CRC_out
62
 
63
);
64
input           Reset       ;
65
input           Clk         ;
66
input           Init        ;
67
input   [7:0]   Frame_data  ;
68
input           Data_en     ;
69
input           CRC_rd      ;
70
output  [7:0]   CRC_out     ;
71
output          CRC_end     ;
72
 
73
//******************************************************************************   
74
//internal signals                                                              
75
//******************************************************************************
76
reg [7:0]       CRC_out     ;
77
reg [31:0]      CRC_reg;
78
reg             CRC_end;
79
reg [3:0]       Counter;
80
//******************************************************************************
81
//******************************************************************************
82
//input data width is 8bit, and the first bit is bit[0]
83
function[31:0]  NextCRC;
84
    input[7:0]      D;
85
    input[31:0]     C;
86
    reg[31:0]       NewCRC;
87
    begin
88
    NewCRC[0]=C[24]^C[30]^D[1]^D[7];
89
    NewCRC[1]=C[25]^C[31]^D[0]^D[6]^C[24]^C[30]^D[1]^D[7];
90
    NewCRC[2]=C[26]^D[5]^C[25]^C[31]^D[0]^D[6]^C[24]^C[30]^D[1]^D[7];
91
    NewCRC[3]=C[27]^D[4]^C[26]^D[5]^C[25]^C[31]^D[0]^D[6];
92
    NewCRC[4]=C[28]^D[3]^C[27]^D[4]^C[26]^D[5]^C[24]^C[30]^D[1]^D[7];
93
    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];
94
    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];
95
    NewCRC[7]=C[31]^D[0]^C[29]^D[2]^C[27]^D[4]^C[26]^D[5]^C[24]^D[7];
96
    NewCRC[8]=C[0]^C[28]^D[3]^C[27]^D[4]^C[25]^D[6]^C[24]^D[7];
97
    NewCRC[9]=C[1]^C[29]^D[2]^C[28]^D[3]^C[26]^D[5]^C[25]^D[6];
98
    NewCRC[10]=C[2]^C[29]^D[2]^C[27]^D[4]^C[26]^D[5]^C[24]^D[7];
99
    NewCRC[11]=C[3]^C[28]^D[3]^C[27]^D[4]^C[25]^D[6]^C[24]^D[7];
100
    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];
101
    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];
102
    NewCRC[14]=C[6]^C[31]^D[0]^C[30]^D[1]^C[28]^D[3]^C[27]^D[4]^C[26]^D[5];
103
    NewCRC[15]=C[7]^C[31]^D[0]^C[29]^D[2]^C[28]^D[3]^C[27]^D[4];
104
    NewCRC[16]=C[8]^C[29]^D[2]^C[28]^D[3]^C[24]^D[7];
105
    NewCRC[17]=C[9]^C[30]^D[1]^C[29]^D[2]^C[25]^D[6];
106
    NewCRC[18]=C[10]^C[31]^D[0]^C[30]^D[1]^C[26]^D[5];
107
    NewCRC[19]=C[11]^C[31]^D[0]^C[27]^D[4];
108
    NewCRC[20]=C[12]^C[28]^D[3];
109
    NewCRC[21]=C[13]^C[29]^D[2];
110
    NewCRC[22]=C[14]^C[24]^D[7];
111
    NewCRC[23]=C[15]^C[25]^D[6]^C[24]^C[30]^D[1]^D[7];
112
    NewCRC[24]=C[16]^C[26]^D[5]^C[25]^C[31]^D[0]^D[6];
113
    NewCRC[25]=C[17]^C[27]^D[4]^C[26]^D[5];
114
    NewCRC[26]=C[18]^C[28]^D[3]^C[27]^D[4]^C[24]^C[30]^D[1]^D[7];
115
    NewCRC[27]=C[19]^C[29]^D[2]^C[28]^D[3]^C[25]^C[31]^D[0]^D[6];
116
    NewCRC[28]=C[20]^C[30]^D[1]^C[29]^D[2]^C[26]^D[5];
117
    NewCRC[29]=C[21]^C[31]^D[0]^C[30]^D[1]^C[27]^D[4];
118
    NewCRC[30]=C[22]^C[31]^D[0]^C[28]^D[3];
119
    NewCRC[31]=C[23]^C[29]^D[2];
120
    NextCRC=NewCRC;
121
    end
122
        endfunction
123
//******************************************************************************
124
 
125
always @ (posedge Clk or posedge Reset)
126
    if (Reset)
127
        CRC_reg     <=32'hffffffff;
128
    else if (Init)
129
        CRC_reg     <=32'hffffffff;
130
    else if (Data_en)
131
        CRC_reg     <=NextCRC(Frame_data,CRC_reg);
132
    else if (CRC_rd)
133
        CRC_reg     <={CRC_reg[23:0],8'hff};
134
 
135
always @ (CRC_rd or CRC_reg)
136
    if (CRC_rd)
137
        CRC_out     <=~{
138
                        CRC_reg[24],
139
                        CRC_reg[25],
140
                        CRC_reg[26],
141
                        CRC_reg[27],
142
                        CRC_reg[28],
143
                        CRC_reg[29],
144
                        CRC_reg[30],
145
                        CRC_reg[31]
146
                        };
147
    else
148
        CRC_out     <=0;
149
 
150
//caculate CRC out length ,4 cycles     
151
//CRC_end aligned to last CRC checksum data
152
always @(posedge Clk or posedge Reset)
153
    if (Reset)
154
        Counter     <=0;
155
    else if (!CRC_rd)
156
        Counter     <=0;
157
    else
158
        Counter     <=Counter + 1;
159
 
160
always @ (Counter)
161
    if (Counter==3)
162
        CRC_end=1;
163
    else
164
        CRC_end=0;
165
 
166
endmodule
167
 
168
 

powered by: WebSVN 2.1.0

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