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

Subversion Repositories crcahb

[/] [crcahb/] [trunk/] [rtl/] [crc_comb.v] - Blame information for rev 4

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

Line No. Rev Author Line
1 3 redbear
//////////////////////////////////////////////////////////////////
2
////
3
////
4
////    CRCAHB CORE BLOCK
5
////
6
////
7
////
8
//// This file is part of the APB to I2C project
9
////
10
//// http://www.opencores.org/cores/apbi2c/
11
////
12
////
13
////
14
//// Description
15
////
16
//// Implementation of APB IP core according to
17
////
18
//// crcahb IP core specification document.
19
////
20
////
21
////
22
//// To Do: Things are right here but always all block can suffer changes
23
////
24
////
25
////
26
////
27
////
28
//// Author(s): -  Julio Cesar 
29
////
30
///////////////////////////////////////////////////////////////// 
31
////
32
////
33
//// Copyright (C) 2009 Authors and OPENCORES.ORG
34
////
35
////
36
////
37
//// This source file may be used and distributed without
38
////
39
//// restriction provided that this copyright statement is not
40
////
41
//// removed from the file and that any derivative work contains
42
//// the original copyright notice and the associated disclaimer.
43
////
44
////
45
//// This source file is free software; you can redistribute it
46
////
47
//// and/or modify it under the terms of the GNU Lesser General
48
////
49
//// Public License as published by the Free Software Foundation;
50
//// either version 2.1 of the License, or (at your option) any
51
////
52
//// later version.
53
////
54
////
55
////
56
//// This source is distributed in the hope that it will be
57
////
58
//// useful, but WITHOUT ANY WARRANTY; without even the implied
59
////
60
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
61
////
62
//// PURPOSE. See the GNU Lesser General Public License for more
63
//// details.
64
////
65
////
66
////
67
//// You should have received a copy of the GNU Lesser General
68
////
69
//// Public License along with this source; if not, download it
70
////
71
//// from http://www.opencores.org/lgpl.shtml
72
////
73
////
74
///////////////////////////////////////////////////////////////////
75
 
76
 
77
 
78 2 julioameri
//This module implements the combinational logic for one iteration of CRC Calculation
79
//If conected to shift register and after n clock cycles, this module realize CRC calculation
80
//for n bits of data.
81
//If instantiated in serial form, this module realize the parallel CRC calculation
82
//for n bits of data.
83
module crc_comb
84
#(
85
        parameter CRC_SIZE      = 8,         // Define the size of CRC Code
86
        parameter MASK          = 8'hff      // This mask define the level of configurability of the module
87
)(
88
        //OUTPUTS
89
        output [CRC_SIZE - 1 : 0] crc_out,   // CRC code after one round of calculation
90
        //INPUTS
91
        input                    data_in,    // One bit of data block
92
        input [CRC_SIZE - 1 : 0] crc_in,     // In cascated mode, this input is the previous calculated CRC code
93
        input [CRC_SIZE - 1 : 0] crc_poly,   // Generator Polynomial
94
  input [CRC_SIZE - 2 : 0] crc_poly_size
95
);
96
 
97
wire [CRC_SIZE - 2 : 0] MASK_REVERSED;
98
wire [CRC_SIZE - 1 : 0] feedback;
99
wire [CRC_SIZE - 2 : 0] crc_in_masked;
100
wire [CRC_SIZE - 2 : 0] crc_poly_size_reversed;
101
 
102
generate
103
  genvar i;
104
  for(i = 0; i < CRC_SIZE - 1; i = i + 1)
105
    begin
106
                        assign crc_poly_size_reversed[i] = crc_poly_size[CRC_SIZE - 2 - i];
107
                assign MASK_REVERSED[i] = MASK[CRC_SIZE - 2 - i];
108
                end
109
endgenerate
110
 
111
assign feedback = crc_poly & {CRC_SIZE{crc_in[CRC_SIZE - 1] ^ data_in}};
112
assign crc_in_masked = crc_in[CRC_SIZE - 2 : 0] & (~(crc_poly_size_reversed[CRC_SIZE - 2 : 0] & MASK_REVERSED));
113
assign crc_out = {crc_in_masked ^ feedback[CRC_SIZE - 1 : 1], feedback[0]};
114
 
115
endmodule

powered by: WebSVN 2.1.0

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