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

Subversion Repositories epc_rfid_transponder

[/] [epc_rfid_transponder/] [trunk/] [crc16encdec.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 erwing
-------------------------------------------------------------------------------
2
--     Politecnico di Torino                                              
3
--     Dipartimento di Automatica e Informatica             
4
-------------------------------------------------------------------------------
5
-------------------------------------------------------------------------------     
6
--
7
--     Title          : EPC Class1 Gen2 RFID Tag - CRC16 encoder/decoder
8
--
9
--     File name      : crc16encdec.vhd 
10
--
11
--     Description    : Tag CRC16 encoder/decoder    
12
--
13
--     Authors        : Erwing R. Sanchez <erwing.sanchezsanchez@polito.it>
14
--
15
--     Rev. History   : 10 July 06  
16
--                                 
17
-------------------------------------------------------------------------------            
18
-------------------------------------------------------------------------------
19
 
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.all;
22
use IEEE.std_logic_unsigned.all;
23
use IEEE.STD_LOGIC_ARITH.all;
24
 
25
 
26
entity crc16encdec is
27
 
28
  generic(
29
    PRESET_CRC16 : integer := 65535);  -- X"FFFF"
30
  port (
31
    clk   : in  std_logic;
32
    rst_n : in  std_logic;
33
    init  : in  std_logic;
34
    ce    : in  std_logic;
35
    sdi   : in  std_logic;
36
    cout  : out std_logic_vector(15 downto 0));
37
 
38
end crc16encdec;
39
 
40
architecture CRC16beh of crc16encdec is
41
 
42
 
43
  signal crc16reg : std_logic_vector(15 downto 0);
44
 
45
begin  -- CRC16beh
46
 
47
  process (clk, rst_n)
48
  begin  -- process
49
    if rst_n = '0' then                 -- asynchronous reset (active low)
50
      crc16reg <= (others => '0');
51
    elsif clk'event and clk = '1' then  -- rising clock edge
52
      if init = '1' then
53
        crc16reg <= conv_std_logic_vector(PRESET_CRC16,16);
54
      elsif ce = '1' then
55
        crc16reg(0)            <= crc16reg(15) xor sdi;
56
        crc16reg(4 downto 1)   <= crc16reg(3 downto 0);
57
        crc16reg(5)            <= crc16reg(15) xor sdi xor crc16reg(4);
58
        crc16reg(11 downto 6)  <= crc16reg(10 downto 5);
59
        crc16reg(12)           <= crc16reg(15) xor sdi xor crc16reg(11);
60
        crc16reg(15 downto 13) <= crc16reg(14 downto 12);
61
      end if;
62
    end if;
63
  end process;
64
 
65
  cout <= crc16reg;
66
 
67
end CRC16beh;

powered by: WebSVN 2.1.0

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