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

Subversion Repositories adv_debug_sys

[/] [adv_debug_sys/] [trunk/] [Hardware/] [adv_dbg_if/] [rtl/] [verilog/] [adbg_crc32.v] - Blame information for rev 69

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 nyawn
//////////////////////////////////////////////////////////////////////
2
// File:  CRC32.v                             
3
// Date:  Thu Nov 27 13:56:49 2003                                                      
4
//                                                                     
5
// Copyright (C) 1999-2003 Easics NV.                 
6
// This source file may be used and distributed without restriction    
7
// provided that this copyright statement is not removed from the file 
8
// and that any derivative work contains the original copyright notice
9
// and the associated disclaimer.
10
//
11
// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
12
// OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
13
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
//
15
// Purpose: Verilog module containing a synthesizable CRC function
16
//   * polynomial: (0 1 2 4 5 7 8 10 11 12 16 22 23 26 32)
17
//   * data width: 1
18
//                                                                     
19
// Info: janz@easics.be (Jan Zegers)                           
20
//       http://www.easics.com
21
//
22
// Modified by Nathan Yawn for the Advanced Debug Module
23 32 nyawn
// Changes (C) 2008 - 2010 Nathan Yawn                                 
24 3 nyawn
///////////////////////////////////////////////////////////////////////
25
//
26
// CVS Revision History
27
//
28
// $Log: adbg_crc32.v,v $
29 69 nyawn
// Revision 1.3  2011-10-24 02:25:11  natey
30
// Removed extraneous '#1' delays, which were a holdover from the original
31
// versions in the previous dbg_if core.
32
//
33 32 nyawn
// Revision 1.2  2010-01-10 22:54:10  Nathan
34
// Update copyright dates
35
//
36 3 nyawn
// Revision 1.1  2008/07/22 20:28:29  Nathan
37
// Changed names of all files and modules (prefixed an a, for advanced).  Cleanup, indenting.  No functional changes.
38
//
39
// Revision 1.3  2008/07/06 20:02:53  Nathan
40
// Fixes for synthesis with Xilinx ISE (also synthesizable with 
41
// Quartus II 7.0).  Ran through dos2unix.
42
//
43
// Revision 1.2  2008/06/20 19:22:10  Nathan
44
// Reversed the direction of the CRC computation shift, for a more 
45
// hardware-efficient implementation.
46
//
47
//
48
//
49
//
50
 
51
 
52
module adbg_crc32 (clk, data, enable, shift, clr, rst, crc_out, serial_out);
53
 
54
input         clk;
55
input         data;
56
input         enable;
57
input         shift;
58
input         clr;
59
input         rst;
60
output [31:0] crc_out;
61
output        serial_out;
62
 
63
 
64
reg    [31:0] crc;
65
wire   [31:0] new_crc;
66
 
67
 
68
// You may notice that the 'poly' in this implementation is backwards.
69
// This is because the shift is also 'backwards', so that the data can
70
// be shifted out in the same direction, which saves on logic + routing.
71
assign new_crc[0] = crc[1];
72
assign new_crc[1] = crc[2];
73
assign new_crc[2] = crc[3];
74
assign new_crc[3] = crc[4];
75
assign new_crc[4] = crc[5];
76
assign new_crc[5] = crc[6] ^ data ^ crc[0];
77
assign new_crc[6] = crc[7];
78
assign new_crc[7] = crc[8];
79
assign new_crc[8] = crc[9] ^ data ^ crc[0];
80
assign new_crc[9] = crc[10] ^ data ^ crc[0];
81
assign new_crc[10] = crc[11];
82
assign new_crc[11] = crc[12];
83
assign new_crc[12] = crc[13];
84
assign new_crc[13] = crc[14];
85
assign new_crc[14] = crc[15];
86
assign new_crc[15] = crc[16] ^ data ^ crc[0];
87
assign new_crc[16] = crc[17];
88
assign new_crc[17] = crc[18];
89
assign new_crc[18] = crc[19];
90
assign new_crc[19] = crc[20] ^ data ^ crc[0];
91
assign new_crc[20] = crc[21] ^ data ^ crc[0];
92
assign new_crc[21] = crc[22] ^ data ^ crc[0];
93
assign new_crc[22] = crc[23];
94
assign new_crc[23] = crc[24] ^ data ^ crc[0];
95
assign new_crc[24] = crc[25] ^ data ^ crc[0];
96
assign new_crc[25] = crc[26];
97
assign new_crc[26] = crc[27] ^ data ^ crc[0];
98
assign new_crc[27] = crc[28] ^ data ^ crc[0];
99
assign new_crc[28] = crc[29];
100
assign new_crc[29] = crc[30] ^ data ^ crc[0];
101
assign new_crc[30] = crc[31] ^ data ^ crc[0];
102
assign new_crc[31] =           data ^ crc[0];
103
 
104
always @ (posedge clk or posedge rst)
105
begin
106
  if(rst)
107 69 nyawn
    crc[31:0] <= 32'hffffffff;
108 3 nyawn
  else if(clr)
109 69 nyawn
    crc[31:0] <= 32'hffffffff;
110 3 nyawn
  else if(enable)
111 69 nyawn
    crc[31:0] <= new_crc;
112 3 nyawn
  else if (shift)
113 69 nyawn
    crc[31:0] <= {1'b0, crc[31:1]};
114 3 nyawn
end
115
 
116
 
117
//assign crc_match = (crc == 32'h0);
118
assign crc_out = crc; //[31];
119
assign serial_out = crc[0];
120
 
121
endmodule

powered by: WebSVN 2.1.0

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