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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [serialInterfaceEngine/] [updateCRC5.v] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// updateCRC5.v                                                 ////
4
////                                                              ////
5
//// This file is part of the usbhostslave opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
//// 
10
////                                                              ////
11
//// To Do:                                                       ////
12
//// 
13
////                                                              ////
14
//// Author(s):                                                   ////
15
//// - Steve Fielding, sfielding@base2designs.com                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG          ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE. See the GNU Lesser General Public License for more  ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from <http://www.opencores.org/lgpl.shtml>                   ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// $Id: updateCRC5.v,v 1.1.1.1 2004-10-11 04:01:04 sfielding Exp $
45
//
46
// CVS Revision History
47
//
48
// $Log: not supported by cvs2svn $
49
//
50
 
51
module updateCRC5 (rstCRC, CRCResult, CRCEn, CRC5_8BitIn, dataIn, ready, clk, rst);
52
input   rstCRC;
53
input   CRCEn;
54
input   CRC5_8BitIn;
55
input   [7:0] dataIn;
56
input   clk;
57
input   rst;
58
output  [4:0] CRCResult;
59
output ready;
60
 
61
wire   rstCRC;
62
wire   CRCEn;
63
wire   CRC5_8BitIn;
64
wire   [7:0] dataIn;
65
wire   clk;
66
wire   rst;
67
reg    [4:0] CRCResult;
68
reg ready;
69
 
70
reg doUpdateCRC;
71
reg [7:0] data;
72
reg [3:0] loopEnd;
73
reg [3:0] i;
74
 
75
always @(posedge clk)
76
begin
77
  if (rst == 1'b1 || rstCRC == 1'b1) begin
78
    doUpdateCRC <= 1'b0;
79
          i <= 4'h0;
80
          CRCResult <= 5'h1f;
81
    ready <= 1'b1;
82
  end
83
  else
84
  begin
85
    if (doUpdateCRC == 1'b0) begin
86
      if (CRCEn == 1'b1) begin
87
        ready <= 1'b0;
88
              doUpdateCRC <= 1'b1;
89
              data <= dataIn;
90
              if (CRC5_8BitIn == 1'b1) begin
91
                loopEnd <= 4'h7;
92
        end
93
              else begin
94
                      loopEnd <= 4'h2;
95
        end
96
            end
97
    end
98
    else begin
99
            i <= i + 1'b1;
100
            if ( (CRCResult[0] ^ data[0]) == 1'b1) begin
101
                    CRCResult <= {1'b0, CRCResult[4:1]} ^ 5'h14;
102
            end
103
      else begin
104
        CRCResult <= {1'b0, CRCResult[4:1]};
105
      end
106
            data <= {1'b0, data[7:1]};
107
            if (i == loopEnd) begin
108
              doUpdateCRC <= 1'b0;
109
                    i <= 4'h0;
110
        ready <= 1'b1;
111
            end
112
    end
113
  end
114
end
115
 
116
 
117
endmodule

powered by: WebSVN 2.1.0

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