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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.5/] [rtl/] [vlib/] [comlib/] [crc8.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
-- $Id: crc8.vhd 314 2010-07-09 17:38:41Z mueller $
2
--
3
-- Copyright 2007- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    crc8 - syn
16
-- Description:    8bit CRC generator, use CRC-8-SAE J1850 polynomial.
17
--                 Based on  CRC-8-SAE J1850 polynomial:
18
--                      x^8 + x^4 + x^3 + x^2 + 1   (0x1d)
19
--                 It is irreducible, and can be implemented with <= 54 xor's
20
--
21
-- Notes:       #  XST synthesis for a Spartan-3 gives:
22
--                   1-bit xor2  :           11
23
--                   1-bit xor4  :            5
24
--                   1-bit xor5  :            1
25
--                   Number of 4 input LUTs: 20
26
--              #  Synthesis with crc8_update_tbl gives a lut-rom based table
27
--                 design. Even though a 256x8 bit ROM is behind, the optimizer
28
--                 gets it into 12 slices with 22 4 input LUTs, thus only
29
--                 little larger than with xor's.
30
--
31
-- Dependencies:   -
32
-- Test bench:     -
33
-- Target Devices: generic
34
-- Tool versions:  xst 8.1, 8.2, 9.1, 9.2; ghdl 0.18-0.25
35
-- Revision History: 
36
-- Date         Rev Version  Comment
37
-- 2007-07-08    65   1.0    Initial version 
38
------------------------------------------------------------------------------
39
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42
use ieee.std_logic_arith.all;
43
 
44
use work.slvtypes.all;
45
use work.comlib.all;
46
 
47
entity crc8 is                          -- crc-8 generator, checker
48
  generic (
49
    INIT: slv8 :=  "00000000");         -- initial state of crc register
50
  port (
51
    CLK : in slbit;                     -- clock
52
    RESET : in slbit;                   -- reset
53
    ENA : in slbit;                     -- update enable
54
    DI : in slv8;                       -- input data
55
    CRC : out slv8                      -- crc code
56
  );
57
end crc8;
58
 
59
 
60
architecture syn of crc8 is
61
 
62
  signal R_CRC : slv8 := INIT;         -- state registers
63
  signal N_CRC : slv8 := INIT;         -- next value state regs
64
 
65
begin
66
 
67
  proc_regs: process (CLK)
68
  begin
69
 
70
    if CLK'event and CLK='1' then
71
      if RESET = '1' then
72
        R_CRC <= INIT;
73
      else
74
        R_CRC <= N_CRC;
75
      end if;
76
    end if;
77
 
78
  end process proc_regs;
79
 
80
  proc_next: process (R_CRC, DI, ENA)
81
 
82
    variable r : slv8 := INIT;
83
    variable n : slv8 := INIT;
84
 
85
  begin
86
 
87
    r := R_CRC;
88
    n := R_CRC;
89
 
90
    if ENA = '1' then
91
      crc8_update(n, DI);
92
    end if;
93
 
94
    N_CRC <= n;
95
 
96
    CRC <= R_CRC;
97
 
98
  end process proc_next;
99
 
100
 
101
end syn;

powered by: WebSVN 2.1.0

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