otsdaq_prepmodernization  v2_05_02_indev
trigger_recv_blk.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 17:02:17 08/01/2011
6 -- Design Name:
7 -- Module Name: trigger_recv_blk - 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 
25 -- Uncomment the following library declaration if using
26 -- arithmetic functions with Signed or Unsigned values
27 --use IEEE.NUMERIC_STD.ALL;
28 
29 -- Uncomment the following library declaration if instantiating
30 -- any Xilinx primitives in this code.
31 --library UNISIM;
32 --use UNISIM.VComponents.all;
33 
35  Port ( scin0 : in STD_LOGIC;
36  scin1 : in STD_LOGIC;
37  scin2 : in STD_LOGIC;
38  scin3 : in STD_LOGIC;
39  selCh0 : in STD_LOGIC;
40  trig : out STD_LOGIC;
41  cnt : out STD_LOGIC_VECTOR (31 downto 0);
42  rst : in STD_LOGIC;
43  clk : in STD_LOGIC);
44 end trigger_recv_blk;
45 
46 architecture Behavioral of trigger_recv_blk is
47 
48  signal trig_in : std_logic;
49  signal trig_old : std_logic;
50  signal cnt_sig : STD_LOGIC_VECTOR (31 downto 0);
51 
52 begin
53 
54  cnt <= cnt_sig;
55 
56  process(clk)
57  begin
58 
59  if rising_edge(clk) then
60 
61  trig_old <= trig_in;
62  trig <= '0';
63 
64  if rst = '1' then
65  cnt_sig <= (others => '0');
66  trig_in <= '0';
67  else
68 
69  if selCh0 = '1' then -- only ch0
70  trig_in <= scin0;
71  else
72  trig_in <= scin0 and scin1 and scin2 and scin3;
73  end if;
74 
75 
76  if trig_old = '0' and trig_in = '1' then
77  cnt_sig <= cnt_sig + 1;
78  trig <= '1';
79  end if;
80 
81  end if;
82 
83  end if;
84 
85  end process;
86 
87 
88 end Behavioral;
89