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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_00_01_alpha/] [RTL/] [serialInterfaceEngine/] [updateCRC16.v] - Blame information for rev 3

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

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// updateCRC16.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: updateCRC16.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 updateCRC16 (rstCRC, CRCResult, CRCEn, dataIn, ready, clk, rst);
52
input   rstCRC;
53
input   CRCEn;
54
input   [7:0] dataIn;
55
input   clk;
56
input   rst;
57
output  [15:0] CRCResult;
58
output ready;
59
 
60
wire   rstCRC;
61
wire   CRCEn;
62
wire   [7:0] dataIn;
63
wire   clk;
64
wire   rst;
65
reg    [15:0] CRCResult;
66
reg    ready;
67
 
68
reg doUpdateCRC;
69
reg [7:0] data;
70
reg [3:0] i;
71
 
72
always @(posedge clk)
73
begin
74
  if (rst == 1'b1 || rstCRC == 1'b1) begin
75
    doUpdateCRC <= 1'b0;
76
    i <= 4'h0;
77
    CRCResult <= 16'hffff;
78
    ready <= 1'b1;
79
  end
80
  else
81
  begin
82
    if (doUpdateCRC == 1'b0)
83
    begin
84
      if (CRCEn == 1'b1) begin
85
              doUpdateCRC = 1'b1;
86
              data <= dataIn;
87
        ready <= 1'b0;
88
          end
89
    end
90
    else begin
91
            i <= i + 1'b1;
92
            if ( (CRCResult[0] ^ data[0]) == 1'b1) begin
93
              CRCResult <= {1'b0, CRCResult[15:1]} ^ 16'ha001;
94
            end
95
            else begin
96
              CRCResult <= {1'b0, CRCResult[15:1]};
97
            end
98
            data <= {1'b0, data[7:1]};
99
            if (i == 4'h7)
100
            begin
101
              doUpdateCRC <= 1'b0;
102
        i <= 4'h0;
103
        ready <= 1'b1;
104
            end
105
    end
106
  end
107
end
108
 
109
 
110
endmodule

powered by: WebSVN 2.1.0

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