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 3

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 3 erwing
--     Authors        : Erwing R. Sanchez <erwing.sanchez@polito.it>
14 2 erwing
--
15
-------------------------------------------------------------------------------            
16
-------------------------------------------------------------------------------
17
 
18
library IEEE;
19
use IEEE.STD_LOGIC_1164.all;
20
use IEEE.std_logic_unsigned.all;
21
use IEEE.STD_LOGIC_ARITH.all;
22
 
23
 
24
entity crc16encdec is
25
 
26
  generic(
27
    PRESET_CRC16 : integer := 65535);  -- X"FFFF"
28
  port (
29
    clk   : in  std_logic;
30
    rst_n : in  std_logic;
31
    init  : in  std_logic;
32
    ce    : in  std_logic;
33
    sdi   : in  std_logic;
34
    cout  : out std_logic_vector(15 downto 0));
35
 
36
end crc16encdec;
37
 
38
architecture CRC16beh of crc16encdec is
39
 
40
 
41
  signal crc16reg : std_logic_vector(15 downto 0);
42
 
43
begin  -- CRC16beh
44
 
45
  process (clk, rst_n)
46
  begin  -- process
47
    if rst_n = '0' then                 -- asynchronous reset (active low)
48
      crc16reg <= (others => '0');
49
    elsif clk'event and clk = '1' then  -- rising clock edge
50
      if init = '1' then
51
        crc16reg <= conv_std_logic_vector(PRESET_CRC16,16);
52
      elsif ce = '1' then
53
        crc16reg(0)            <= crc16reg(15) xor sdi;
54
        crc16reg(4 downto 1)   <= crc16reg(3 downto 0);
55
        crc16reg(5)            <= crc16reg(15) xor sdi xor crc16reg(4);
56
        crc16reg(11 downto 6)  <= crc16reg(10 downto 5);
57
        crc16reg(12)           <= crc16reg(15) xor sdi xor crc16reg(11);
58
        crc16reg(15 downto 13) <= crc16reg(14 downto 12);
59
      end if;
60
    end if;
61
  end process;
62
 
63
  cout <= crc16reg;
64
 
65
end CRC16beh;

powered by: WebSVN 2.1.0

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