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

powered by: WebSVN 2.1.0

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