CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
CRC_CALC.vhd
Go to the documentation of this file.
1 ----------------------------------------------------------------------------------
14 ----------------------------------------------------------------------------------
15 library IEEE;
16 use IEEE.STD_LOGIC_1164.ALL;
17 
18 library work;
19 use work.CMXpackage.all;
20 
21 
22 -- Uncomment the following library declaration if using
23 -- arithmetic functions with Signed or Unsigned values
24 use IEEE.NUMERIC_STD.ALL;
25 
26 -- Uncomment the following library declaration if instantiating
27 -- any Xilinx primitives in this code.
28 --library UNISIM;
29 --use UNISIM.VComponents.all;
30 
31 entity CRC_CALC is
32  port (
33  DATA_in : in std_logic_vector(17 downto 0);
34  DATA_out : out std_logic_vector(17 downto 0);
35  clk : in std_logic;
36  subtick_counter : in unsigned(2 downto 0));
37 end CRC_CALC;
38 
39 architecture Behavioral of CRC_CALC is
40 
41  --attribute RLOC: string;
42  attribute keep_hierarchy : string;
43 
44 
45  signal b0, b1 : std_logic_vector(7 downto 0);
46  signal r0, r1, r2, r3, r4, r5, r6 : std_logic_vector(11 downto 0);
47  -- crc register at varoius stages of the computation
48 
49  signal subtick_counter_reg_local : unsigned(2 downto 0); -- local copy of the subtick counter to ease timing
50 
51 
52 
53 -- component crc_lut
54 -- port (
55 -- addr : in std_logic_vector(7 downto 0);
56 -- data : out std_logic_vector(11 downto 0));
57 -- end component;
58 --
59 
60  COMPONENT crc_distmem
61  PORT (
62  a : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
63  spo : OUT STD_LOGIC_VECTOR(11 DOWNTO 0)
64  );
65 
66  END COMPONENT;
67 
68  --attribute RLOC of crc_distmem: component is "X0Y0";
69  --attribute RLOC of r0: signal is "X0Y0 X0Y0 X0Y0 X0Y0 X0Y0 X0Y0 X0Y0 X0Y0 X0Y1 X0Y1 X0Y1 X0Y1";
70 
71 
72  --attribute RLOC of lut_0: entity is "X1Y0"; -- ERROR:HDLCompiler:69 - "/home/wfedorko/L1Calo/Base/Test_2b_Backplane_Capture/trunk/sources/CRC_CALC.vhd" Line 67: <lut_0> is not declared.
73 
74  --attribute RLOC of lut_0: component is "X1Y0"; --ERROR:HDLCompiler:69 - "/home/wfedorko/L1Calo/Base/Test_2b_Backplane_Capture/trunk/sources/CRC_CALC.vhd" Line 66: <lut_0> is not declared.
75  --attribute RLOC of r2: signal is "X1Y0";
76 
77  --attribute RLOC of lut_0: label is "X1Y0";
78 
79  --attribute RLOC of lut_0: label is "R0C1.S0"; --ERROR:Map:201 - Illegal format for RLOC constraint on crc_distmem symbol
80  --"Topo_Data_TX_inst/txdatagen_grp[1].txdatagen_fifo[11].CRC_CALC_inst/lut_0".
81  --The value specified is "R0C1.S0".
82  --Map:91 - crc_distmem symbol "Topo_Data_TX_inst/txdatagen_grp[0].txdatagen_fifo[0].CRC_CALC_inst/lut_0" has an RLOC attribute but the attribute will be ignored because the hierarchy contains no symbols with RLOC attributes.
83 
84  attribute keep_hierarchy of Behavioral : architecture is "TRUE";
85 
86 begin
87 
88  b0<=DATA_in(7 downto 0);
89  b1<=DATA_in(15 downto 8);
90 
91  r1(11 downto 8)<=r0(3 downto 0);
92  r1(7 downto 0)<=b1;
93 
94 -- lut_0: crc_lut
95 -- port map (
96 -- addr => r0(11 downto 4),
97 -- data => r2);
98 --
99 
100  --attribute RLOC of lut_0: component is "X1Y0";
101 
102  lut_0: crc_distmem
103  port map (
104  a => r0(11 downto 4),
105  spo => r2);
106 
107 
108 
109  r3<=r1 xor r2;
110 
111  r4(11 downto 8)<=r3(3 downto 0);
112  r4(7 downto 0)<=b0;
113 
114 -- lut_1: crc_lut
115 -- port map (
116 -- addr => r3(11 downto 4),
117 -- data => r5);
118 --
119 
120  lut_1: crc_distmem
121  port map (
122  a => r3(11 downto 4),
123  spo => r5);
124 
125  r6<= r5 xor r4;
126 
127  process (clk)
128  begin -- process
129  if rising_edge(clk) then -- rising clock edge
130  if subtick_counter_reg_local=to_unsigned(7,3) then --=to_unsigned(0,3) then
131  DATA_out(11 downto 0)<=r6;
132  DATA_out(17 downto 12)<=DATA_in(17 downto 12);
133  r0<=(others=>'0');
134  else
135  DATA_out<=DATA_in;
136  r0<=r6;
137  end if;
138  subtick_counter_reg_local<=subtick_counter;
139  end if;
140  end process;
141 
142 end Behavioral;
143 
std_logic_vector (7 downto 0) b1
Definition: CRC_CALC.vhd:45
std_logic_vector (11 downto 0) r1
Definition: CRC_CALC.vhd:46
std_logic_vector (11 downto 0) r5
Definition: CRC_CALC.vhd:46
std_logic_vector (7 downto 0) b0
Definition: CRC_CALC.vhd:45
std_logic_vector (11 downto 0) r0
Definition: CRC_CALC.vhd:46
_library_ IEEEIEEE
Definition: CMXpackage.vhd:6
std_logic_vector (11 downto 0) r4
Definition: CRC_CALC.vhd:46
std_logic_vector (11 downto 0) r3
Definition: CRC_CALC.vhd:46
std_logic_vector (11 downto 0) r2
Definition: CRC_CALC.vhd:46
std_logic_vector (11 downto 0) r6
Definition: CRC_CALC.vhd:46
string keep_hierarchy
Definition: CRC_CALC.vhd:42
unsigned (2 downto 0) subtick_counter_reg_local
Definition: CRC_CALC.vhd:49