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

Subversion Repositories spi_slave

[/] [spi_slave/] [trunk/] [pcore/] [opb_spi_slave_v1_00_a/] [hdl/] [vhdl/] [PCK_CRC8_D8.vhd] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 20 dkoethe
-----------------------------------------------------------------------
2
-- File:  PCK_CRC8_D8.vhd                              
3
-- Date:  Fri Mar 21 22:28:05 2008                                                      
4
--                                                                     
5
-- Copyright (C) 1999-2003 Easics NV.                 
6
-- This source file may be used and distributed without restriction    
7
-- provided that this copyright statement is not removed from the file 
8
-- and that any derivative work contains the original copyright notice
9
-- and the associated disclaimer.
10
--
11
-- THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
12
-- OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
13
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
--
15
-- Purpose: VHDL package containing a synthesizable CRC function
16
--   * polynomial: (0 1 2 8)
17
--   * data width: 8
18
--                                                                     
19
-- Info: tools@easics.be
20
--       http://www.easics.com                                  
21
-----------------------------------------------------------------------
22
 
23
 
24
library IEEE;
25
use IEEE.std_logic_1164.all;
26
 
27
package PCK_CRC8_D8 is
28
 
29
  -- polynomial: (0 1 2 8)
30
  -- data width: 8
31
  -- convention: the first serial data bit is D(7)
32
  function nextCRC8_D8
33
    ( Data:  std_logic_vector(7 downto 0);
34
      CRC:   std_logic_vector(7 downto 0) )
35
    return std_logic_vector;
36
 
37
end PCK_CRC8_D8;
38
 
39
library IEEE;
40
use IEEE.std_logic_1164.all;
41
 
42
package body PCK_CRC8_D8 is
43
 
44
  -- polynomial: (0 1 2 8)
45
  -- data width: 8
46
  -- convention: the first serial data bit is D(7)
47
  function nextCRC8_D8
48
    ( Data:  std_logic_vector(7 downto 0);
49
      CRC:   std_logic_vector(7 downto 0) )
50
    return std_logic_vector is
51
 
52
    variable D: std_logic_vector(7 downto 0);
53
    variable C: std_logic_vector(7 downto 0);
54
    variable NewCRC: std_logic_vector(7 downto 0);
55
 
56
  begin
57
 
58
    D := Data;
59
    C := CRC;
60
 
61
    NewCRC(0) := D(7) xor D(6) xor D(0) xor C(0) xor C(6) xor C(7);
62
    NewCRC(1) := D(6) xor D(1) xor D(0) xor C(0) xor C(1) xor C(6);
63
    NewCRC(2) := D(6) xor D(2) xor D(1) xor D(0) xor C(0) xor C(1) xor
64
                 C(2) xor C(6);
65
    NewCRC(3) := D(7) xor D(3) xor D(2) xor D(1) xor C(1) xor C(2) xor
66
                 C(3) xor C(7);
67
    NewCRC(4) := D(4) xor D(3) xor D(2) xor C(2) xor C(3) xor C(4);
68
    NewCRC(5) := D(5) xor D(4) xor D(3) xor C(3) xor C(4) xor C(5);
69
    NewCRC(6) := D(6) xor D(5) xor D(4) xor C(4) xor C(5) xor C(6);
70
    NewCRC(7) := D(7) xor D(6) xor D(5) xor C(5) xor C(6) xor C(7);
71
 
72
    return NewCRC;
73
 
74
  end nextCRC8_D8;
75
 
76
end PCK_CRC8_D8;
77
 

powered by: WebSVN 2.1.0

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