AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
TCPdata_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 TCPdata_chksum is
36  Port ( c : in STD_LOGIC;
37  r : in STD_LOGIC;
38  ce : in STD_LOGIC;
39  d : in STD_LOGIC_VECTOR (63 downto 0);
40  DATA_OFFSET : in STD_LOGIC_VECTOR (3 downto 0);
41  length_in : in STD_LOGIC_VECTOR (12 downto 0); -- in unit of 64bit words
42  en_out : in STD_LOGIC;
43  s : out STD_LOGIC_VECTOR (15 downto 0);
44  chksum : out STD_LOGIC_VECTOR (15 downto 0);
45  DATA_SIZE : out STD_LOGIC_VECTOR (31 downto 0); -- in bytes
46  DATA_LEN : out STD_LOGIC_VECTOR (15 downto 0)); -- in bytes
47 end TCPdata_chksum;
48 
49 architecture Behavioral of TCPdata_chksum is
50 signal acc: std_logic_vector(16 downto 0) := (others => '0');
51 signal sum: std_logic_vector(32 downto 0) := (others => '0');
52 signal sum1: std_logic_vector(16 downto 0) := (others => '0');
53 signal sum2: std_logic_vector(15 downto 0) := (others => '0');
54 signal ce_dl : std_logic := '0';
55 begin
56 process(c)
57 begin
58  if(c'event and c = '1')then
59  sum <= ('0' & d(63 downto 32)) + ('0' & d(31 downto 0));
60  sum1 <= ('0' & sum(31 downto 16)) + ('0' & sum(15 downto 0)) + sum(32);
61  sum2 <= sum1(15 downto 0) + sum1(16);
62  if(r = '1')then
63  acc(16) <= '0';
64  acc(15 downto 0) <= x"0006";
65  elsif(ce_dl = '1')then
66  acc <= ('0' & acc(15 downto 0)) + ('0' & sum2) + acc(16);
67  end if;
68  if(en_out = '0')then
69  s <= x"0006";
70  DATA_LEN <= (others => '0');
71  else
72  s <= acc(15 downto 0) + acc(16);
73  DATA_LEN <= length_in & "000";
74  end if;
75  chksum <= acc(15 downto 0) + acc(16);
76  DATA_SIZE <= x"0000" & length_in & "000";
77  end if;
78 end process;
79 i_ce_DATA_chksum : SRL16E
80  port map (
81  Q => ce_dl, -- SRL data output
82  A0 => '0', -- Select[0] input
83  A1 => '1', -- Select[1] input
84  A2 => '0', -- Select[2] input
85  A3 => '0', -- Select[3] input
86  CE => '1', -- Clock enable input
87  CLK => c, -- Clock input
88  D => ce -- SRL data input
89  );
90 
91 
92 end Behavioral;
93