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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_00_04_alpha/] [RTL/] [serialInterfaceEngine/] [updateCRC5.v] - Blame information for rev 43

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 5 sfielding
// $Id: updateCRC5.v,v 1.2 2004-12-18 14:36:16 sfielding Exp $
45 2 sfielding
//
46
// CVS Revision History
47
//
48
// $Log: not supported by cvs2svn $
49 5 sfielding
// Revision 1.1.1.1  2004/10/11 04:01:04  sfielding
50
// Created
51 2 sfielding
//
52 5 sfielding
//
53 2 sfielding
 
54
module updateCRC5 (rstCRC, CRCResult, CRCEn, CRC5_8BitIn, dataIn, ready, clk, rst);
55
input   rstCRC;
56
input   CRCEn;
57
input   CRC5_8BitIn;
58
input   [7:0] dataIn;
59
input   clk;
60
input   rst;
61
output  [4:0] CRCResult;
62
output ready;
63
 
64
wire   rstCRC;
65
wire   CRCEn;
66
wire   CRC5_8BitIn;
67
wire   [7:0] dataIn;
68
wire   clk;
69
wire   rst;
70
reg    [4:0] CRCResult;
71
reg ready;
72
 
73
reg doUpdateCRC;
74
reg [7:0] data;
75
reg [3:0] loopEnd;
76
reg [3:0] i;
77
 
78
always @(posedge clk)
79
begin
80
  if (rst == 1'b1 || rstCRC == 1'b1) begin
81
    doUpdateCRC <= 1'b0;
82 5 sfielding
    i <= 4'h0;
83
    CRCResult <= 5'h1f;
84 2 sfielding
    ready <= 1'b1;
85
  end
86
  else
87
  begin
88
    if (doUpdateCRC == 1'b0) begin
89
      if (CRCEn == 1'b1) begin
90
        ready <= 1'b0;
91 5 sfielding
        doUpdateCRC <= 1'b1;
92
        data <= dataIn;
93
        if (CRC5_8BitIn == 1'b1) begin
94
          loopEnd <= 4'h7;
95 2 sfielding
        end
96 5 sfielding
        else begin
97
          loopEnd <= 4'h2;
98 2 sfielding
        end
99 5 sfielding
      end
100 2 sfielding
    end
101
    else begin
102 5 sfielding
      i <= i + 1'b1;
103
      if ( (CRCResult[0] ^ data[0]) == 1'b1) begin
104
        CRCResult <= {1'b0, CRCResult[4:1]} ^ 5'h14;
105
      end
106 2 sfielding
      else begin
107
        CRCResult <= {1'b0, CRCResult[4:1]};
108
      end
109 5 sfielding
      data <= {1'b0, data[7:1]};
110
      if (i == loopEnd) begin
111
        doUpdateCRC <= 1'b0;
112
        i <= 4'h0;
113 2 sfielding
        ready <= 1'b1;
114 5 sfielding
      end
115 2 sfielding
    end
116
  end
117
end
118 5 sfielding
 
119 2 sfielding
 
120
endmodule

powered by: WebSVN 2.1.0

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