1 |
746 |
lampret |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// dbg_crc8_d1 crc1.v ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// ////
|
6 |
|
|
//// This file is part of the SoC/OpenRISC Development Interface ////
|
7 |
|
|
//// http://www.opencores.org/cores/DebugInterface/ ////
|
8 |
|
|
//// ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// Author(s): ////
|
11 |
|
|
//// Igor Mohor ////
|
12 |
|
|
//// igorm@opencores.org ////
|
13 |
|
|
//// ////
|
14 |
|
|
//// ////
|
15 |
|
|
//// All additional information is avaliable in the README.txt ////
|
16 |
|
|
//// file. ////
|
17 |
|
|
//// ////
|
18 |
|
|
//////////////////////////////////////////////////////////////////////
|
19 |
|
|
//// ////
|
20 |
|
|
//// Copyright (C) 2000,2001 Authors ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// This source file may be used and distributed without ////
|
23 |
|
|
//// restriction provided that this copyright statement is not ////
|
24 |
|
|
//// removed from the file and that any derivative work contains ////
|
25 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
26 |
|
|
//// ////
|
27 |
|
|
//// This source file is free software; you can redistribute it ////
|
28 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
29 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
30 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
31 |
|
|
//// later version. ////
|
32 |
|
|
//// ////
|
33 |
|
|
//// This source is distributed in the hope that it will be ////
|
34 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
35 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
36 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
37 |
|
|
//// details. ////
|
38 |
|
|
//// ////
|
39 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
40 |
|
|
//// Public License along with this source; if not, download it ////
|
41 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
42 |
|
|
//// ////
|
43 |
|
|
//////////////////////////////////////////////////////////////////////
|
44 |
|
|
//
|
45 |
|
|
// CVS Revision History
|
46 |
|
|
//
|
47 |
|
|
// $Log: not supported by cvs2svn $
|
48 |
|
|
// Revision 1.5 2001/12/06 10:01:57 mohor
|
49 |
|
|
// Warnings from synthesys tools fixed.
|
50 |
|
|
//
|
51 |
|
|
// Revision 1.4 2001/11/26 10:47:09 mohor
|
52 |
|
|
// Crc generation is different for read or write commands. Small synthesys fixes.
|
53 |
|
|
//
|
54 |
|
|
// Revision 1.3 2001/10/19 11:40:02 mohor
|
55 |
|
|
// dbg_timescale.v changed to timescale.v This is done for the simulation of
|
56 |
|
|
// few different cores in a single project.
|
57 |
|
|
//
|
58 |
|
|
// Revision 1.2 2001/09/20 10:11:25 mohor
|
59 |
|
|
// Working version. Few bugs fixed, comments added.
|
60 |
|
|
//
|
61 |
|
|
// Revision 1.1.1.1 2001/09/13 13:49:19 mohor
|
62 |
|
|
// Initial official release.
|
63 |
|
|
//
|
64 |
|
|
// Revision 1.3 2001/06/01 22:22:36 mohor
|
65 |
|
|
// This is a backup. It is not a fully working version. Not for use, yet.
|
66 |
|
|
//
|
67 |
|
|
// Revision 1.2 2001/05/18 13:10:00 mohor
|
68 |
|
|
// Headers changed. All additional information is now avaliable in the README.txt file.
|
69 |
|
|
//
|
70 |
|
|
// Revision 1.1.1.1 2001/05/18 06:35:03 mohor
|
71 |
|
|
// Initial release
|
72 |
|
|
//
|
73 |
|
|
//
|
74 |
|
|
///////////////////////////////////////////////////////////////////////
|
75 |
|
|
// File: CRC8_D1.v
|
76 |
|
|
// Date: Fri Apr 27 20:56:55 2001
|
77 |
|
|
//
|
78 |
|
|
// Copyright (C) 1999 Easics NV.
|
79 |
|
|
// This source file may be used and distributed without restriction
|
80 |
|
|
// provided that this copyright statement is not removed from the file
|
81 |
|
|
// and that any derivative work contains the original copyright notice
|
82 |
|
|
// and the associated disclaimer.
|
83 |
|
|
//
|
84 |
|
|
// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
|
85 |
|
|
// OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
86 |
|
|
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
87 |
|
|
//
|
88 |
|
|
// Purpose: Verilog module containing a synthesizable CRC function
|
89 |
|
|
// * polynomial: (0 1 2 8)
|
90 |
|
|
// * data width: 1
|
91 |
|
|
//
|
92 |
|
|
// Info: jand@easics.be (Jan Decaluwe)
|
93 |
|
|
// http://www.easics.com
|
94 |
|
|
///////////////////////////////////////////////////////////////////////
|
95 |
|
|
|
96 |
|
|
// synopsys translate_off
|
97 |
|
|
`include "timescale.v"
|
98 |
|
|
// synopsys translate_on
|
99 |
|
|
`include "dbg_defines.v"
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
module dbg_crc8_d1 (Data, EnableCrc, Reset, SyncResetCrc, CrcOut, Clk);
|
103 |
|
|
|
104 |
|
|
parameter Tp = 1;
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
input Data;
|
108 |
|
|
input EnableCrc;
|
109 |
|
|
input Reset;
|
110 |
|
|
input SyncResetCrc;
|
111 |
|
|
input Clk;
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
output [7:0] CrcOut;
|
115 |
|
|
reg [7:0] CrcOut;
|
116 |
|
|
|
117 |
|
|
// polynomial: (0 1 2 8)
|
118 |
|
|
// data width: 1
|
119 |
|
|
function [7:0] nextCRC8_D1;
|
120 |
|
|
|
121 |
|
|
input Data;
|
122 |
|
|
input [7:0] Crc;
|
123 |
|
|
|
124 |
|
|
reg [0:0] D;
|
125 |
|
|
reg [7:0] C;
|
126 |
|
|
reg [7:0] NewCRC;
|
127 |
|
|
|
128 |
|
|
begin
|
129 |
|
|
D[0] = Data;
|
130 |
|
|
C = Crc;
|
131 |
|
|
|
132 |
|
|
NewCRC[0] = D[0] ^ C[7];
|
133 |
|
|
NewCRC[1] = D[0] ^ C[0] ^ C[7];
|
134 |
|
|
NewCRC[2] = D[0] ^ C[1] ^ C[7];
|
135 |
|
|
NewCRC[3] = C[2];
|
136 |
|
|
NewCRC[4] = C[3];
|
137 |
|
|
NewCRC[5] = C[4];
|
138 |
|
|
NewCRC[6] = C[5];
|
139 |
|
|
NewCRC[7] = C[6];
|
140 |
|
|
|
141 |
|
|
nextCRC8_D1 = NewCRC;
|
142 |
|
|
end
|
143 |
|
|
endfunction
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
always @ (posedge Clk or posedge Reset)
|
147 |
|
|
begin
|
148 |
|
|
if(Reset)
|
149 |
|
|
CrcOut[7:0] <= #Tp 0;
|
150 |
|
|
else
|
151 |
|
|
if(SyncResetCrc)
|
152 |
|
|
CrcOut[7:0] <= #Tp 0;
|
153 |
|
|
else
|
154 |
|
|
if(EnableCrc)
|
155 |
|
|
CrcOut[7:0] <= #Tp nextCRC8_D1(Data, CrcOut);
|
156 |
|
|
end
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
endmodule
|