AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
RETXdata_chksum.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 08:23:00 08/14/2013
6 -- Design Name:
7 -- Module Name: TCPdata_chksum - Behavioral
8 -- Project Name:
9 -- Target Devices:
10 -- Tool versions:
11 -- Description:
12 --
13 -- Dependencies:
14 --
15 -- Revision:
16 -- Revision 0.01 - File Created
17 -- Additional Comments:
18 --
19 ----------------------------------------------------------------------------------
20 library IEEE;
21 use IEEE.STD_LOGIC_1164.ALL;
22 use IEEE.STD_LOGIC_ARITH.ALL;
23 use IEEE.STD_LOGIC_UNSIGNED.ALL;
24 use IEEE.std_logic_misc.all;
25 
26 -- Uncomment the following library declaration if using
27 -- arithmetic functions with Signed or Unsigned values
28 --use IEEE.NUMERIC_STD.ALL;
29 
30 -- Uncomment the following library declaration if instantiating
31 -- any Xilinx primitives in this code.
32 library UNISIM;
33 use UNISIM.VComponents.all;
34 
35 entity RETXdata_chksum is
36  Port ( c : in STD_LOGIC;
37  r : in STD_LOGIC;
38  ce : in STD_LOGIC;
39  d : in STD_LOGIC_VECTOR (31 downto 0);
40  s : out STD_LOGIC_VECTOR (15 downto 0));
41 end RETXdata_chksum;
42 
43 architecture Behavioral of RETXdata_chksum is
44 signal acc: std_logic_vector(16 downto 0) := (others => '0');
45 signal d_sum: std_logic_vector(16 downto 0) := (others => '0');
46 signal r_sum: std_logic_vector(16 downto 0) := (others => '0');
47 signal ce_dl : std_logic := '0';
48 signal r_dl : std_logic := '0';
49 --signal length_r: std_logic_vector(10 downto 0) := (others => '0');
50 begin
51 process(c)
52 begin
53  if(c'event and c = '1')then
54  ce_dl <= ce;
55  r_dl <= r;
56  d_sum <= ('0' & d(31 downto 16)) + ('0' & d(15 downto 0));
57  if(r_dl = '1')then
58 -- acc <= "00000000000000110" + ('0' & d_sum(15 downto 0)) + d_sum(16);
59  acc <= "00000000000000110";
60  elsif(ce_dl = '1')then
61  acc <= ('0' & acc(15 downto 0)) + ('0' & d_sum(15 downto 0)) + acc(16) + d_sum(16);
62  end if;
63  s <= acc(15 downto 0) + acc(16);
64  end if;
65 end process;
66 end Behavioral;
67