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

Subversion Repositories crcahb

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

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

Line No. Rev Author Line
1 2 julioameri
//This module implements the combinational logic for one iteration of CRC Calculation
2
//If conected to shift register and after n clock cycles, this module realize CRC calculation
3
//for n bits of data.
4
//If instantiated in serial form, this module realize the parallel CRC calculation
5
//for n bits of data.
6
module crc_comb
7
#(
8
        parameter CRC_SIZE      = 8,         // Define the size of CRC Code
9
        parameter MASK          = 8'hff      // This mask define the level of configurability of the module
10
)(
11
        //OUTPUTS
12
        output [CRC_SIZE - 1 : 0] crc_out,   // CRC code after one round of calculation
13
        //INPUTS
14
        input                    data_in,    // One bit of data block
15
        input [CRC_SIZE - 1 : 0] crc_in,     // In cascated mode, this input is the previous calculated CRC code
16
        input [CRC_SIZE - 1 : 0] crc_poly,   // Generator Polynomial
17
  input [CRC_SIZE - 2 : 0] crc_poly_size
18
);
19
 
20
wire [CRC_SIZE - 2 : 0] MASK_REVERSED;
21
wire [CRC_SIZE - 1 : 0] feedback;
22
wire [CRC_SIZE - 2 : 0] crc_in_masked;
23
wire [CRC_SIZE - 2 : 0] crc_poly_size_reversed;
24
 
25
generate
26
  genvar i;
27
  for(i = 0; i < CRC_SIZE - 1; i = i + 1)
28
    begin
29
                        assign crc_poly_size_reversed[i] = crc_poly_size[CRC_SIZE - 2 - i];
30
                assign MASK_REVERSED[i] = MASK[CRC_SIZE - 2 - i];
31
                end
32
endgenerate
33
 
34
assign feedback = crc_poly & {CRC_SIZE{crc_in[CRC_SIZE - 1] ^ data_in}};
35
assign crc_in_masked = crc_in[CRC_SIZE - 2 : 0] & (~(crc_poly_size_reversed[CRC_SIZE - 2 : 0] & MASK_REVERSED));
36
assign crc_out = {crc_in_masked ^ feedback[CRC_SIZE - 1 : 1], feedback[0]};
37
 
38
endmodule

powered by: WebSVN 2.1.0

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