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

Subversion Repositories crcahb

[/] [crcahb/] [trunk/] [rtl/] [crc_parrallel.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 2 julioameri
module crc_parallel
76
#(
77
        parameter CRC_SIZE      = 8,         // Define the size of CRC Code
78
        parameter FRAME_SIZE    = 8          // Number of bits in the data block
79
)(
80
        //OUTPUTS
81
        output [CRC_SIZE   - 1 : 0] crc_out,
82
        //INPUTS
83
        input  [FRAME_SIZE - 1 : 0] data_in,
84
        input  [CRC_SIZE   - 1 : 0] crc_init,
85
        input  [CRC_SIZE   - 1 : 0] crc_poly,
86
        input  [CRC_SIZE   - 1 : 0] crc_poly_size
87
);
88
localparam ENABLE  = {CRC_SIZE{1'b1}};
89
localparam DISABLE = {CRC_SIZE{1'b0}};
90
 
91
wire [CRC_SIZE - 1 : 0] crc_comb_out[0 : FRAME_SIZE];
92
wire [CRC_SIZE - 1 : 0] poly_sel    [1 : CRC_SIZE - 1];
93
wire [CRC_SIZE - 1 : 0] sel_out     [0 : CRC_SIZE - 1];
94
wire [CRC_SIZE - 1 : 0] crc_init_sel[0 : CRC_SIZE - 1];
95
wire [CRC_SIZE - 1 : 0] poly_mux;
96
wire [CRC_SIZE - 1 : 0] crc_poly_size_reversed;
97
wire [CRC_SIZE - 1 : 0] crc_init_justified;
98
 
99
assign poly_mux[0] = crc_poly[0];
100
generate
101
  genvar k;
102
        for(k = 1; k < CRC_SIZE; k = k + 1)
103
                begin
104
                        assign poly_sel[CRC_SIZE - k] = crc_poly_size >> (k - 1);
105
                        assign poly_mux[k] = |(crc_poly & poly_sel[k]);
106
                end
107
endgenerate
108
 
109
generate
110
        genvar l;
111
        for(l = 0; l < CRC_SIZE; l = l + 1)
112
                begin
113
                        assign crc_poly_size_reversed[l] = crc_poly_size[CRC_SIZE - 1 - l];
114
                        assign sel_out[l] = crc_poly_size_reversed << l;
115
                        assign crc_out[l] = |(sel_out[l] & crc_comb_out[FRAME_SIZE]);
116
                end
117
endgenerate
118
 
119
generate
120
        genvar m;
121
        for(m = CRC_SIZE - 1; m >= 0; m = m - 1)
122
                begin
123
                        assign crc_init_sel[m] = crc_poly_size >> (CRC_SIZE - 1 - m);
124
                        assign crc_init_justified[m] = |(crc_init & crc_init_sel[m]);
125
                end
126
endgenerate
127
 
128
assign crc_comb_out[0] = crc_init_justified;
129
 
130
generate
131
        genvar i;
132
        for(i = 0; i < FRAME_SIZE; i = i + 1)
133
                begin
134
                        crc_comb
135
                        #(
136
                                .CRC_SIZE      ( CRC_SIZE      ),
137
                                .MASK          ( ENABLE        )
138
                        ) CRC_COMB
139
                        (
140
                                .crc_out       ( crc_comb_out[i + 1]           ),
141
                                .data_in       ( data_in[FRAME_SIZE - 1 - i]   ),
142
                                .crc_in        ( crc_comb_out[i]               ),
143
                                .crc_poly      ( poly_mux                      ),
144
                                .crc_poly_size ( crc_poly_size[CRC_SIZE - 2:0] )
145
                        );
146
                end
147
endgenerate
148
 
149
endmodule

powered by: WebSVN 2.1.0

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