1 | ----------------------------------------------------------------------------------
|
---|
2 | -- Company: ETH Zurich, Institute for Particle Physics
|
---|
3 | -- Engineer: Q. Weitzel
|
---|
4 | --
|
---|
5 | -- Create Date: 15:56:13 02/28/2011
|
---|
6 | -- Design Name:
|
---|
7 | -- Module Name: FTM_central_control - Behavioral
|
---|
8 | -- Project Name:
|
---|
9 | -- Target Devices:
|
---|
10 | -- Tool versions:
|
---|
11 | -- Description: Central FSM for FTM firmware
|
---|
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 | library ftm_definitions;
|
---|
26 | USE ftm_definitions.ftm_array_types.all;
|
---|
27 | USE ftm_definitions.ftm_constants.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 |
|
---|
34 | entity FTM_central_control is
|
---|
35 | port(
|
---|
36 | clk : IN std_logic;
|
---|
37 | new_config : IN std_logic;
|
---|
38 | config_started : OUT std_logic := '0';
|
---|
39 | config_started_ack : IN std_logic;
|
---|
40 | config_start_eth : OUT std_logic := '0';
|
---|
41 | config_started_eth : IN std_logic;
|
---|
42 | config_ready_eth : IN std_logic;
|
---|
43 | config_start_ftu : OUT std_logic := '0';
|
---|
44 | config_started_ftu : IN std_logic ;
|
---|
45 | config_ready_ftu : IN std_logic ;
|
---|
46 | ping_ftu_start : IN std_logic;
|
---|
47 | ping_ftu_started : OUT std_logic := '0';
|
---|
48 | ping_ftu_ready : OUT std_logic := '0';
|
---|
49 | ping_ftu_start_ftu : OUT std_logic := '0';
|
---|
50 | ping_ftu_started_ftu : IN std_logic;
|
---|
51 | ping_ftu_ready_ftu : IN std_logic
|
---|
52 | );
|
---|
53 | end FTM_central_control;
|
---|
54 |
|
---|
55 | architecture Behavioral of FTM_central_control is
|
---|
56 |
|
---|
57 | type state_central_proc_type is (CP_INIT, CP_CONFIG_START, CP_CONFIG, CP_CONFIG_01,
|
---|
58 | CP_CONFIG_FTU, CP_CONFIG_FTU_01,
|
---|
59 | CP_IDLE, CP_PING);
|
---|
60 | signal state_central_proc : state_central_proc_type := CP_INIT;
|
---|
61 |
|
---|
62 | begin
|
---|
63 |
|
---|
64 | central_proc : process (clk)
|
---|
65 | begin
|
---|
66 | if rising_edge (clk) then
|
---|
67 | case state_central_proc is
|
---|
68 |
|
---|
69 | when CP_INIT =>
|
---|
70 | state_central_proc <= CP_CONFIG;
|
---|
71 |
|
---|
72 | when CP_CONFIG_START =>
|
---|
73 | if (config_started_ack = '1') then
|
---|
74 | config_started <= '0';
|
---|
75 | state_central_proc <= CP_CONFIG;
|
---|
76 | end if;
|
---|
77 |
|
---|
78 | when CP_CONFIG =>
|
---|
79 | config_start_eth <= '1';
|
---|
80 | if (config_started_eth = '1') then
|
---|
81 | config_start_eth <= '0';
|
---|
82 | state_central_proc <= CP_CONFIG_01;
|
---|
83 | end if;
|
---|
84 |
|
---|
85 | when CP_CONFIG_01 =>
|
---|
86 | if (config_ready_eth = '1') then
|
---|
87 | state_central_proc <= CP_CONFIG_FTU;
|
---|
88 | end if;
|
---|
89 |
|
---|
90 | when CP_CONFIG_FTU =>
|
---|
91 | config_start_ftu <= '1';
|
---|
92 | if (config_started_ftu = '1') then
|
---|
93 | config_start_ftu <= '0';
|
---|
94 | state_central_proc <= CP_CONFIG_FTU_01;
|
---|
95 | end if;
|
---|
96 |
|
---|
97 | when CP_CONFIG_FTU_01 =>
|
---|
98 | if (config_ready_ftu = '1') then
|
---|
99 | state_central_proc <= CP_IDLE;
|
---|
100 | end if;
|
---|
101 |
|
---|
102 | when CP_IDLE =>
|
---|
103 | if (new_config = '1') then
|
---|
104 | config_started <= '1';
|
---|
105 | state_central_proc <= CP_CONFIG_START;
|
---|
106 |
|
---|
107 | elsif (ping_ftu_start = '1') then
|
---|
108 | ping_ftu_start_ftu <= '1';
|
---|
109 | if (ping_ftu_started_ftu = '1') then
|
---|
110 | ping_ftu_start_ftu <= '0';
|
---|
111 | ping_ftu_started <= '1';
|
---|
112 | ping_ftu_ready <= '0';
|
---|
113 | state_central_proc <= CP_PING;
|
---|
114 | end if;
|
---|
115 |
|
---|
116 | end if;
|
---|
117 |
|
---|
118 | when CP_PING =>
|
---|
119 | if (ping_ftu_ready_ftu = '1') then
|
---|
120 | if (ping_ftu_start = '0') then
|
---|
121 | ping_ftu_started <= '0';
|
---|
122 | ping_ftu_ready <= '1';
|
---|
123 | state_central_proc <= CP_IDLE;
|
---|
124 | end if;
|
---|
125 | end if;
|
---|
126 |
|
---|
127 | end case;
|
---|
128 | end if;
|
---|
129 | end process central_proc;
|
---|
130 |
|
---|
131 | end Behavioral;
|
---|