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

Subversion Repositories usb11

[/] [usb11/] [trunk/] [rtl/] [systemc/] [usb_crc16.cpp] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfoltran
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  USB CRC16                                                  ////
4
////                                                             ////
5
////  SystemC Version: usb_crc16.cpp                             ////
6
////  Author: Alfredo Luiz Foltran Fialho                        ////
7
////          alfoltran@ig.com.br                                ////
8
////                                                             ////
9
////                                                             ////
10
/////////////////////////////////////////////////////////////////////
11
////                                                             ////
12
//// Verilog Version: usb1_crc16.v                               ////
13
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
14
////                         www.asics.ws                        ////
15
////                         rudi@asics.ws                       ////
16
////                                                             ////
17
//// This source file may be used and distributed without        ////
18
//// restriction provided that this copyright statement is not   ////
19
//// removed from the file and that any derivative work contains ////
20
//// the original copyright notice and the associated disclaimer.////
21
////                                                             ////
22
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
23
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
24
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
25
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
26
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
27
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
28
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
29
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
30
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
31
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
32
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
33
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
34
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
35
////                                                             ////
36
/////////////////////////////////////////////////////////////////////
37
 
38
#include "systemc.h"
39
#include "usb_crc16.h"
40
 
41
void usb_crc16::update(void) {
42
        sc_uint<16> temp;
43
 
44
        temp[0] = din.read()[7] ^ din.read()[6] ^ din.read()[5] ^ din.read()[4] ^ din.read()[3] ^ din.read()[2] ^
45
                        din.read()[1] ^ din.read()[0] ^ crc_in.read()[8] ^ crc_in.read()[9] ^ crc_in.read()[10] ^
46
                        crc_in.read()[11] ^ crc_in.read()[12] ^ crc_in.read()[13] ^ crc_in.read()[14] ^
47
                        crc_in.read()[15];
48
        temp[1] = din.read()[7] ^ din.read()[6] ^ din.read()[5] ^ din.read()[4] ^ din.read()[3] ^ din.read()[2] ^
49
                        din.read()[1] ^ crc_in.read()[9] ^ crc_in.read()[10] ^ crc_in.read()[11] ^ crc_in.read()[12] ^
50
                        crc_in.read()[13] ^ crc_in.read()[14] ^ crc_in.read()[15];
51
        temp[2] = din.read()[1] ^ din.read()[0] ^ crc_in.read()[8] ^ crc_in.read()[9];
52
        temp[3] = din.read()[2] ^ din.read()[1] ^ crc_in.read()[9] ^ crc_in.read()[10];
53
        temp[4] = din.read()[3] ^ din.read()[2] ^ crc_in.read()[10] ^ crc_in.read()[11];
54
        temp[5] = din.read()[4] ^ din.read()[3] ^ crc_in.read()[11] ^ crc_in.read()[12];
55
        temp[6] = din.read()[5] ^ din.read()[4] ^ crc_in.read()[12] ^ crc_in.read()[13];
56
        temp[7] = din.read()[6] ^ din.read()[5] ^ crc_in.read()[13] ^ crc_in.read()[14];
57
        temp[8] = din.read()[7] ^ din.read()[6] ^ crc_in.read()[0] ^ crc_in.read()[14] ^ crc_in.read()[15];
58
        temp[9] = din.read()[7] ^ crc_in.read()[1] ^ crc_in.read()[15];
59
        temp[10] = crc_in.read()[2];
60
        temp[11] = crc_in.read()[3];
61
        temp[12] = crc_in.read()[4];
62
        temp[13] = crc_in.read()[5];
63
        temp[14] = crc_in.read()[6];
64
        temp[15] = din.read()[7] ^ din.read()[6] ^ din.read()[5] ^ din.read()[4] ^ din.read()[3] ^
65
                        din.read()[2] ^ din.read()[1] ^ din.read()[0] ^ crc_in.read()[7] ^ crc_in.read()[8] ^
66
                        crc_in.read()[9] ^ crc_in.read()[10] ^ crc_in.read()[11] ^ crc_in.read()[12] ^
67
                        crc_in.read()[13] ^ crc_in.read()[14] ^ crc_in.read()[15];
68
 
69
        crc_out.write(temp);
70
}
71
 

powered by: WebSVN 2.1.0

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