eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
orbit_sm.vhd
Go to the documentation of this file.
1 
7 
8 
9 LIBRARY ieee;
10 USE ieee.std_logic_1164.all;
11 USE ieee.std_logic_arith.all;
13 ENTITY orbit_sm IS
14  PORT(
16  chan_orbit : IN std_logic;
18  clk : IN std_logic;
20  ref_orbit : IN std_logic;
22  reset : IN std_logic;
24  start : IN std_logic;
26  A_eq_B : OUT std_logic;
28  cntr_value : OUT std_logic_vector (4 DOWNTO 0)
29  );
30 
31 
32 END ENTITY orbit_sm ;
34 ARCHITECTURE fsm OF orbit_sm IS
35  -- Architecture Declarations
36  signal cntr_0, cntr_1 :unsigned(4 downto 0);
37 
38  SUBTYPE STATE_TYPE IS
39  std_logic_vector(5 DOWNTO 0);
40 
41  -- Hard encoding
42  CONSTANT idle : STATE_TYPE := "000001";
43  CONSTANT cnt0_inc : STATE_TYPE := "000010";
44  CONSTANT cnt_ref0 : STATE_TYPE := "000100";
45  CONSTANT cnt1_inc : STATE_TYPE := "001000";
46  CONSTANT cnt_ref1 : STATE_TYPE := "010000";
47  CONSTANT s1 : STATE_TYPE := "100000";
48 
49  -- Declare current and next state signals
50  SIGNAL current_state : STATE_TYPE;
51 
52 BEGIN
53 
54  -----------------------------------------------------------------
55  clocked_proc : PROCESS (
56  clk
57  )
58  -----------------------------------------------------------------
59  BEGIN
60  IF (clk'EVENT AND clk = '1') THEN
61  IF (reset = '1') THEN
62  current_state <= idle;
63  -- Default Reset Values
64  A_eq_B <= '0';
65  cntr_value <= (others => '0');
66  cntr_0 <= (others => '0');
67  cntr_1 <= (others => '0');
68  ELSE
69  -- Default Assignment To Internals and Outputs
70  cntr_0 <= (others => '0');
71  cntr_1 <= (others => '0');
72  A_eq_B <= '0';
73  cntr_value <= (others => '0');
74 
75  -- Combined Actions
76  CASE current_state IS
77  WHEN idle =>
78  cntr_0 <= (others => '0');
79  cntr_1 <= (others => '0');
80  IF (start ='1') THEN
81  current_state <= cnt0_inc;
82  ELSE
83  current_state <= idle;
84  END IF;
85  WHEN cnt0_inc =>
86  IF (ref_orbit = '1') THEN
87  cntr_0 <= cntr_0 +1;
88  current_state <= cnt_ref0;
89  ELSE
90  current_state <= cnt0_inc;
91  END IF;
92  WHEN cnt_ref0 =>
93  cntr_0 <= cntr_0 +1;
94  IF (chan_orbit ='1') THEN
95  cntr_0 <= cntr_0;
96  current_state <= cnt1_inc;
97  ELSE
98  current_state <= cnt_ref0;
99  END IF;
100  WHEN cnt1_inc =>
101  cntr_0 <= cntr_0;
102  IF (ref_orbit = '1') THEN
103  cntr_1 <= cntr_1 +1;
104  current_state <= cnt_ref1;
105  ELSE
106  current_state <= cnt1_inc;
107  END IF;
108  WHEN cnt_ref1 =>
109  cntr_1 <= cntr_1 +1;
110  cntr_0 <= cntr_0;
111  IF (chan_orbit ='1') THEN
112  cntr_1 <= cntr_1;
113  current_state <= s1;
114  ELSE
115  current_state <= cnt_ref1;
116  END IF;
117  WHEN s1 =>
118  cntr_0 <= cntr_0;
119  cntr_1 <= cntr_1;
120  IF (cntr_0 = cntr_1) THEN
121  A_eq_B <= '1';
122  cntr_value <= std_logic_vector(cntr_0);
123  current_state <= idle;
124  ELSE
125  cntr_0 <= (others => '0');
126  cntr_1 <= (others => '0');
127  current_state <= cnt0_inc;
128  END IF;
129  WHEN OTHERS =>
130  current_state <= idle;
131  END CASE;
132  END IF;
133  END IF;
134  END PROCESS clocked_proc;
135 
136 END ARCHITECTURE fsm;
orbit sm
Definition: orbit_sm.vhd:34
orbit sm
Definition: orbit_sm.vhd:13
in reset std_logic
reset
Definition: orbit_sm.vhd:22
in clk std_logic
clock
Definition: orbit_sm.vhd:18
out cntr_value std_logic_vector( 4 DOWNTO 0)
count value
Definition: orbit_sm.vhd:29
out A_eq_B std_logic
two counter equal
Definition: orbit_sm.vhd:26
in chan_orbit std_logic
channel orbit
Definition: orbit_sm.vhd:16
in start std_logic
start
Definition: orbit_sm.vhd:24
in ref_orbit std_logic
reference orbit channel
Definition: orbit_sm.vhd:20