Documentation for architecture MGTEVB/MakeHeader/a0
VHDL Contents
1 architecture a0 of MakeHeader is
31
32 constant CNT_HEAD : integer := 10; constant CNT_TRAIL: integer := 5; type states is (init, head, pause, trail);
36 signal state : states;
37
38 signal HregFile : std_logic_v32array(10 downto 0);
39 signal TregFile : std_logic_v32array(5 downto 0);
40 signal TrigType : std_logic_vector(7 downto 0);
41 signal TestCnt : std_logic_vector(23 downto 0);
42 signal EvtNumber : std_logic_vector(31 downto 0);
43 signal BcntNumber : std_logic_vector(11 downto 0);
44 signal TrigTypeNumber : std_logic_vector(7 downto 0);
45 signal IncDelay : std_logic_vector(1 downto 0);
46 signal IncEvtNr : std_logic;
47
48 begin
49
50 EvtNumber <=
55 TTCdata(31 downto 0) when (EBMGTtest = '0') else Reg2Bd(31 downto 24) & TestCnt;
56 BcntNumber <=
57 TTCdata(43 downto 32) when (EBMGTtest = '0') else (others => '0');
58 TrigTypeNumber <=
59 TTCdata(51 downto 44) when (EBMGTtest = '0') else (others => '0');
60
61 prStates:
62 process (SClk, Rst_n, ECReset_n)
63 variable cnt : unsigned(3 downto 0);
64 begin
65 if (Rst_n = '0' Or ECReset_n = '0') then
66 cnt := (others => '0');
67 state <= init;
68 Inc_RunN <= '0';
69 IncEvtNr <= '0';
70 elsif (rising_edge(SClk)) then
71 case state is
72 when init =>
73 cnt := (others => '0');
74 Inc_RunN <= '0';
75 IncEvtNr <= '0';
76 if (SxHead = '1') then
77 state <= head;
78 else
79 state <= init;
80 end if;
81 when head =>
82 if (cnt = 10) then cnt := (others => '0');
84 state <= pause;
85 else
86 cnt := cnt + 1;
87 state <= head;
88 end if;
89 when pause =>
90 cnt := (others => '0');
91 if (SxTrail = '1') then
92 state <= trail;
93 else
94 state <= pause;
95 end if;
96 when trail =>
97 if (cnt = 5) then IncEvtNr <= '1';
99 cnt := (others => '0');
100 state <= init;
101 else
102 cnt := cnt + 1;
103 state <= trail;
104 end if;
105 if (cnt = 4) then
106 if (Trigtype = x"07") then Inc_RunN <= '1'; end if;
109 else
110 Inc_RunN <= '0';
111 end if;
112 when others =>
113 state <= init;
114 end case;
115 end if;
116 end process prStates;
117
118 prFile:
119 process (SClk, Rst_n, ECReset_n)
120 variable dat : std_logic_vector(31 downto 0);
121 variable ctrlpipe : std_logic_vector(5 downto 0); begin
123 if (Rst_n = '0' Or ECReset_n = '0') then
124 TrigType <= (others => '0');
125 Ctrlbit <= '0';
126 HValid <= '0';
127 HFile <= (others => '0');
128 for i in 0 to CNT_HEAD loop
129 HregFile(i) <= (others => '0');
130 end loop;
131 for i in 0 to CNT_TRAIL loop
132 TregFile(i) <= (others => '0');
133 end loop;
134 TTCeb <= (others => '0');
135 if (Rst_n = '0') then
136 LastEvID <= (others => '1'); end if;
138 elsif (rising_edge(SClk)) then
139 case state is
140 when init =>
141 ctrlpipe := "000001"; HValid <= '0'; HFile <= HregFile(0); Ctrlbit <= ctrlpipe(0); dat(31 downto 0) := SLINKBOF; HregFile(0) <= dat; dat(31 downto 0) := HEADMARK; HregFile(1) <= dat; dat(31 downto 0) := HEADSIZE; HregFile(2) <= dat; dat(31 downto 0) := HDRdata(31 downto 0); HregFile(3) <= dat; dat(31 downto 0) := HDRdata(63 downto 32); HregFile(4) <= dat; dat(31 downto 0) := HDRdata(95 downto 64); HregFile(5) <= dat; dat(31 downto 0) := EvtNumber(31 downto 0); HregFile(6) <= dat; dat(31 downto 12) := x"00000"; dat(11 downto 0) := BcntNumber(11 downto 0); HregFile(7) <= dat; dat(31 downto 8) := x"000000"; dat( 7 downto 0) := TrigTypeNumber(7 downto 0); HregFile(8) <= dat; TrigType <= dat(7 downto 0); dat(31 downto 0) := HDRdata(127 downto 96); HregFile(9) <= dat; dat(31 downto 24) := ID_BOB; dat(23 downto 0) := EvtNumber(23 downto 0); HregFile(10) <= dat; TregFile(0) <= ID_EOB & x"000000"; TTCeb(23 downto 12) <= EvtNumber(11 downto 0); TTCeb(11 downto 0) <= BcntNumber(11 downto 0); when pause =>
190 ctrlpipe := "100000"; HValid <= '0'; HFile <= TregFile(0); Ctrlbit <= ctrlpipe(0); dat(31 downto 24) := ID_EOB; dat(23 downto 16) := x"00"; dat(15 downto 0) := NDE; TregFile(0) <= dat; dat(31 downto 0) := MSE; TregFile(1) <= dat; dat(31 downto 0) := TRAILNSE; TregFile(2) <= dat; dat(31 downto 16) := x"0000"; dat(15 downto 0) := NDE; TregFile(3) <= dat; dat(31 downto 0) := TRAILSBP; TregFile(4) <= dat; dat(31 downto 0) := SLINKEOF; TregFile(5) <= dat; when head =>
217 HValid <= '1'; HFile <= HregFile(0); Ctrlbit <= ctrlpipe(0); for i in 0 to 9 loop
221 HregFile(i) <= HregFile(i+1); end loop;
223 HregFile(10) <= (others => '1'); ctrlpipe(5 downto 0) := '0' & ctrlpipe(5 downto 1); LastEvID (31 downto 0) <= EvtNumber(31 downto 0); when trail =>
228 HValid <= '1'; HFile <= TregFile(0); Ctrlbit <= ctrlpipe(0); for i in 0 to 4 loop
232 TregFile(i) <= TregFile(i+1); end loop;
234 TregFile(5) <= (others => '1'); ctrlpipe(5 downto 0) := '0' & ctrlpipe(5 downto 1); when others =>
238 HValid <= '0'; Ctrlbit <= '0';
240 end case;
241 end if;
242 end process;
243
244 prCnt:
245 process (SClk, Rst_n, ECReset_n)
246 variable cnt: unsigned(23 downto 0);
247 begin
248 if (Rst_n = '0' Or ECReset_n = '0') then
249 cnt := (others => '0'); IncDelay <= "00";
251 elsif (rising_edge(SClk)) then
252 if (IncDelay(1) = '1') then cnt := cnt + 1;
254 end if;
255 IncDelay(1 downto 0) <= IncDelay(0) & IncEvtNr; end if;
257 TestCnt <= std_logic_vector(cnt);
258 end process;
259
260 end architecture a0 ;