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

Subversion Repositories epc_rfid_transponder

[/] [epc_rfid_transponder/] [trunk/] [crc5encdec.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 - CRC5 encoder/decoder
8
--
9
--     File name      : crc5encdec.vhd 
10
--
11
--     Description    : Tag CRC5 encoder/decoder    
12
--
13 3 erwing
--     Authors        : Erwing R. Sanchez <erwing.sanchez@polito.it>
14
--                        
15 2 erwing
-------------------------------------------------------------------------------            
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 crc5encdec is
25
 
26
  generic(
27
    PRESET_CRC5 : integer := 9);        -- "01001"
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(4 downto 0));
35
 
36
end crc5encdec;
37
 
38
architecture CRC5beh of crc5encdec is
39
 
40
 
41
  signal crc5reg : std_logic_vector(4 downto 0);
42
 
43
begin  -- CRC5beh
44
 
45
  process (clk, rst_n)
46
  begin  -- process
47
    if rst_n = '0' then                 -- asynchronous reset (active low)
48
      crc5reg <= (others => '0');
49
    elsif clk'event and clk = '1' then  -- rising clock edge
50
      if init = '1' then
51
        crc5reg <= conv_std_logic_vector(PRESET_CRC5,5);
52
      elsif ce = '1' then
53
        crc5reg(0)          <= crc5reg(4) xor sdi;
54
        crc5reg(2 downto 1) <= crc5reg(1 downto 0);
55
        crc5reg(3)          <= crc5reg(4) xor sdi xor crc5reg(2);
56
        crc5reg(4)          <= crc5reg(3);
57
      end if;
58
    end if;
59
  end process;
60
 
61
  cout <= crc5reg;
62
 
63
end CRC5beh;

powered by: WebSVN 2.1.0

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