CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
CRC_CHECK.vhd
Go to the documentation of this file.
1 ----------------------------------------------------------------------------------
11 ----------------------------------------------------------------------------------
12 library IEEE;
13 use IEEE.STD_LOGIC_1164.ALL;
14 
15 library work;
16 use work.CMXpackage.all;
17 
18 
19 -- Uncomment the following library declaration if using
20 -- arithmetic functions with Signed or Unsigned values
21 use IEEE.NUMERIC_STD.ALL;
22 
23 -- Uncomment the following library declaration if instantiating
24 -- any Xilinx primitives in this code.
25 --library UNISIM;
26 --use UNISIM.VComponents.all;
27 
28 entity CRC_CHECK is
29  port (
30  DATA_in : in std_logic_vector(15 downto 0);
31  CRC_ERR : out std_logic;
32  clk : in std_logic;
33  rx_subtick_counter : in unsigned(2 downto 0));
34 end CRC_CHECK;
35 
36 architecture Behavioral of CRC_CHECK is
37 
38  attribute keep_hierarchy : string;
39 
40  signal b0, b1 : std_logic_vector(7 downto 0);
41  signal r0, r1, r2, r3, r4, r5, r6, r4_reg, r5_reg : std_logic_vector(11 downto 0);
42  -- crc register at varoius stages of the computation
43 
44  signal rx_subtick_counter_reg : unsigned(2 downto 0);
45 
46  --signal or_all_r6 : std_logic;
47 
48 
49 -- component crc_lut
50 -- port (
51 -- addr : in std_logic_vector(7 downto 0);
52 -- data : out std_logic_vector(11 downto 0));
53 -- end component;
54 --
55 
56  --component or_all
57  -- generic (
58  -- numbits : integer);
59  -- port (
60  -- DATA : in std_logic_vector(numbits - 1 downto 0);
61  -- or_all : out std_logic);
62  --end component;
63 
64  COMPONENT crc_distmem
65  PORT (
66  a : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
67  spo : OUT STD_LOGIC_VECTOR(11 DOWNTO 0)
68  );
69  END COMPONENT;
70 
71  attribute keep_hierarchy of Behavioral : architecture is "TRUE";
72 
73 begin
74 
75  b0<=DATA_in(7 downto 0);
76  b1<=DATA_in(15 downto 8);
77 
78  r1(11 downto 8)<=r0(3 downto 0);
79  r1(7 downto 0)<=b1;
80 
81 -- lut_0: crc_lut
82 -- port map (
83 -- addr => r0(11 downto 4),
84 -- data => r2);
85 --
86 
87  lut_0: crc_distmem
88  port map (
89  a => r0(11 downto 4),
90  spo => r2);
91 
92  r3<=r1 xor r2;
93 
94  r4(11 downto 8)<=r3(3 downto 0);
95  r4(7 downto 0)<=b0;
96 
97 -- lut_1: crc_lut
98 -- port map (
99 -- addr => r3(11 downto 4),
100 -- data => r5);
101 --
102 
103  lut_1: crc_distmem
104  port map (
105  a => r3(11 downto 4),
106  spo => r5);
107 
108  r6<= r5 xor r4;
109 
110  --or_all_1: or_all
111  -- generic map (
112  -- numbits => 12)
113  -- port map (
114  -- DATA => r6,
115  -- or_all => or_all_r6);
116 
117  process (clk)
118  begin -- process
119  if rising_edge(clk) then -- rising clock edge
120 
121  if rx_subtick_counter=to_unsigned(0,3) then
122  r0<=(others=>'0');
123  else
124  r0<=r6;
125  end if;
126 
127  if rx_subtick_counter_reg=to_unsigned(0,3) then
128  if r5_reg=r4_reg then --r6="000000000000" then
129  CRC_ERR<='0';
130  else
131  CRC_ERR<='1';
132  end if;
133  end if;
134 
136  r5_reg<=r5;
137  r4_reg<=r4;
138 
139  end if;
140  end process;
141 
142 end Behavioral;
143 
std_logic_vector (11 downto 0) r5_reg
Definition: CRC_CHECK.vhd:41
crc_distmem lut_0lut_0
Definition: CRC_CHECK.vhd:87
std_logic_vector (7 downto 0) b0
Definition: CRC_CHECK.vhd:40
in rx_subtick_counterunsigned (2 downto 0)
Definition: CRC_CHECK.vhd:33
std_logic_vector (11 downto 0) r4
Definition: CRC_CHECK.vhd:41
std_logic_vector (11 downto 0) r5
Definition: CRC_CHECK.vhd:41
in DATA_instd_logic_vector (15 downto 0)
Definition: CRC_CHECK.vhd:30
out CRC_ERRstd_logic
Definition: CRC_CHECK.vhd:31
std_logic_vector (11 downto 0) r1
Definition: CRC_CHECK.vhd:41
crc_distmem lut_1lut_1
Definition: CRC_CHECK.vhd:103
std_logic_vector (11 downto 0) r4_reg
Definition: CRC_CHECK.vhd:41
std_logic_vector (11 downto 0) r0
Definition: CRC_CHECK.vhd:41
std_logic_vector (11 downto 0) r6
Definition: CRC_CHECK.vhd:41
std_logic_vector (11 downto 0) r3
Definition: CRC_CHECK.vhd:41
std_logic_vector (7 downto 0) b1
Definition: CRC_CHECK.vhd:40
in clkstd_logic
Definition: CRC_CHECK.vhd:32
std_logic_vector (11 downto 0) r2
Definition: CRC_CHECK.vhd:41
unsigned (2 downto 0) rx_subtick_counter_reg
Definition: CRC_CHECK.vhd:44