00001 --**************************************************************
00002 --* *
00003 --* The source code for the ATLAS BCM "AAA" FPGA is made *
00004 --* available via the GNU General Public License (GPL) *
00005 --* unless otherwise stated below. *
00006 --* *
00007 --* In case of problems/questions/bug reports etc. please *
00008 --* contact michael.niegl@cern.ch *
00009 --* *
00010 --**************************************************************
00011
00012 --**************************************************************
00013 --* *
00014 --* $Source: /local/reps/bcmfpga/bcm_aaa/bcm_aaa/div/status_collector.vhd,v $
00015 --* $Revision: 1.16.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:45 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023
00024
00025 library ieee;
00026
00027 use ieee.std_logic_1164.all;
00028
00029 use ieee.std_logic_arith.all;
00030
00031 use ieee.std_logic_unsigned.all;
00032
00033 library work;
00034
00035 use work.build_parameters.all;
00036
00037
00038
00039
00040
00041
00042
00043 entity status_collector is
00044
00045 port (
00046 DEBUG : out (14 downto 0);
00047 EMAC_CLK : in ;
00048 RATES_CLK : in ;
00049 STATUS_CLK : in ;
00050 RIO_CLK : in ;
00051 RESET : in ;
00052 START : in ;
00053 FETCH_BYTE : in ;
00054 FETCH_CHKSUM : in ;
00055 ERROR_FLAG : in ;
00056 EXT_CLK_DET : in ;
00057 RIO_DAQ : in ;
00058 RIO_SATA : in ;
00059 MODE : in ;
00060 DCM_STATUS : in ;
00061 ROD_STATUS : in ;
00062 FPGA_ID : in (7 downto 0) := x"00";
00063 MAIN_FSM : in (7 downto 0);
00064 ERROR_CODE : in (31 downto 0);
00065 DSS_CIBU_STATUS : in (31 downto 0);
00066 INPUT_STATUS : in (63 downto 0);
00067 TDAQ_PARAMS : in (159 downto 0) := (others => '0');
00068 HITRATE_CH1 : in (31 downto 0) := (others => '0');
00069 HITRATE_CH2 : in (31 downto 0) := (others => '0');
00070 HITRATE_CH3 : in (31 downto 0) := (others => '0');
00071 HITRATE_CH4 : in (31 downto 0) := (others => '0');
00072 HITRATE_CH5 : in (31 downto 0) := (others => '0');
00073 HITRATE_CH6 : in (31 downto 0) := (others => '0');
00074 HITRATE_CH7 : in (31 downto 0) := (others => '0');
00075 HITRATE_CH8 : in (31 downto 0) := (others => '0');
00076 ALGO_STATE : in (31 downto 0) := (others => '0');
00077 HITRATE_A_CH1 : in (31 downto 0) := (others => '0');
00078 HITRATE_A_CH2 : in (31 downto 0) := (others => '0');
00079 HITRATE_A_CH3 : in (31 downto 0) := (others => '0');
00080 HITRATE_A_CH4 : in (31 downto 0) := (others => '0');
00081 HITRATE_A_CH5 : in (31 downto 0) := (others => '0');
00082 HITRATE_A_CH6 : in (31 downto 0) := (others => '0');
00083 HITRATE_A_CH7 : in (31 downto 0) := (others => '0');
00084 HITRATE_A_CH8 : in (31 downto 0) := (others => '0');
00085 HITRATE_B_CH1 : in (31 downto 0) := (others => '0');
00086 HITRATE_B_CH2 : in (31 downto 0) := (others => '0');
00087 HITRATE_B_CH3 : in (31 downto 0) := (others => '0');
00088 HITRATE_B_CH4 : in (31 downto 0) := (others => '0');
00089 HITRATE_B_CH5 : in (31 downto 0) := (others => '0');
00090 HITRATE_B_CH6 : in (31 downto 0) := (others => '0');
00091 HITRATE_B_CH7 : in (31 downto 0) := (others => '0');
00092 HITRATE_B_CH8 : in (31 downto 0) := (others => '0');
00093 HITRATE_C_CH1 : in (31 downto 0) := (others => '0');
00094 HITRATE_C_CH2 : in (31 downto 0) := (others => '0');
00095 HITRATE_C_CH3 : in (31 downto 0) := (others => '0');
00096 HITRATE_C_CH4 : in (31 downto 0) := (others => '0');
00097 HITRATE_C_CH5 : in (31 downto 0) := (others => '0');
00098 HITRATE_C_CH6 : in (31 downto 0) := (others => '0');
00099 HITRATE_C_CH7 : in (31 downto 0) := (others => '0');
00100 HITRATE_C_CH8 : in (31 downto 0) := (others => '0');
00101 HITRATE_D_CH1 : in (31 downto 0) := (others => '0');
00102 HITRATE_D_CH2 : in (31 downto 0) := (others => '0');
00103 HITRATE_D_CH3 : in (31 downto 0) := (others => '0');
00104 HITRATE_D_CH4 : in (31 downto 0) := (others => '0');
00105 HITRATE_D_CH5 : in (31 downto 0) := (others => '0');
00106 HITRATE_D_CH6 : in (31 downto 0) := (others => '0');
00107 HITRATE_D_CH7 : in (31 downto 0) := (others => '0');
00108 HITRATE_D_CH8 : in (31 downto 0) := (others => '0');
00109 ASM_DONE : out ;
00110 TRANS_DONE : out ;
00111 CHKSUM_OUT : out (15 downto 0);
00112 DATA_OUT : out (7 downto 0)
00113 );
00114
00115 attribute MAX_FANOUT : ;
00116 attribute MAX_FANOUT of status_collector : entity is "10";
00117
00118 end status_collector;
00119
00120
00121
00122
00123
00124
00125 architecture status_collector_arc of status_collector is
00126
00127
00128 component edge
00129 port(
00130 CLK : in ;
00131 A : in ;
00132 PULSE : out
00133 );
00134 end component;
00135
00136
00137 component ddr2_chksum_cal
00138 port(
00139 CLK : in ;
00140 RESET : in ;
00141 EN : in ;
00142 DATA_IN : in (127 downto 0);
00143 WRITE_DONE : in ;
00144 READ_DATA : in ;
00145 CAL_COMPL : out ;
00146 DATA_OUT : out (15 downto 0)
00147 );
00148 end component;
00149
00150
00151 constant hr_vld : (7 downto 0) := kSendHitRate;
00152
00153 constant hr_vld_bit : := hr_vld(7) and hr_vld(6) and hr_vld(5) and hr_vld(4) and hr_vld(3) and hr_vld(2) and hr_vld(1) and hr_vld(0);
00154
00155 constant algo_vld : (7 downto 0) := kSendAlgoRate;
00156
00157 constant algo_vld_bit : := algo_vld(7) and algo_vld(6) and algo_vld(5) and algo_vld(4) and algo_vld(3) and algo_vld(2) and algo_vld(1) and algo_vld(0);
00158
00159 constant reserved : (7 downto 0) := x"00";
00160
00161 alias rsv is reserved;
00162
00163 signal en_wr : := '0';
00164 signal en_asm : := '0';
00165 signal en_cal : := '0';
00166 signal en_calfsm : := '0';
00167 signal done_i : := '0';
00168 signal cal_wr_done : := '0';
00169 signal cal_done : := '0';
00170 signal start_p_i : := '0';
00171 signal start_p_ii : := '0';
00172 signal start_del : := '0';
00173 signal chksum_out_i : (15 downto 0) := (others => '0');
00174 signal chk_in : (127 downto 0) := (others => '0');
00175 signal reg_fpga_id : (7 downto 0) := (others => '0');
00176 signal pktcnt : (7 downto 0) := (others => '0');
00177 signal pktcntwr : (7 downto 0) := (others => '0');
00178 signal reg_dsscibu : (31 downto 0) := (others => '0');
00179 signal reg_err : (7 downto 0) := (others => '0');
00180 signal reg_extclk : (7 downto 0) := (others => '0');
00181 signal reg_daq : (7 downto 0) := (others => '0');
00182 signal reg_sata : (7 downto 0) := (others => '0');
00183 signal reg_mac : (7 downto 0) := (others => '0');
00184 signal reg_dcm : (7 downto 0) := (others => '0');
00185 signal reg_rod : (7 downto 0) := (others => '0');
00186 signal reg_fsm : (7 downto 0) := (others => '0');
00187 signal reg_ins : (63 downto 0) := (others => '0');
00188 signal reg_tdaq : (159 downto 0) := (others => '0');
00189 signal reg_errcode : (31 downto 0) := (others => '0');
00190 signal reg_algo : (31 downto 0) := (others => '0');
00191 signal reg_hr_1 : (31 downto 0) := (others => '0');
00192 signal reg_hr_2 : (31 downto 0) := (others => '0');
00193 signal reg_hr_3 : (31 downto 0) := (others => '0');
00194 signal reg_hr_4 : (31 downto 0) := (others => '0');
00195 signal reg_hr_5 : (31 downto 0) := (others => '0');
00196 signal reg_hr_6 : (31 downto 0) := (others => '0');
00197 signal reg_hr_7 : (31 downto 0) := (others => '0');
00198 signal reg_hr_8 : (31 downto 0) := (others => '0');
00199 signal reg_hr_a1 : (31 downto 0) := (others => '0');
00200 signal reg_hr_a2 : (31 downto 0) := (others => '0');
00201 signal reg_hr_a3 : (31 downto 0) := (others => '0');
00202 signal reg_hr_a4 : (31 downto 0) := (others => '0');
00203 signal reg_hr_a5 : (31 downto 0) := (others => '0');
00204 signal reg_hr_a6 : (31 downto 0) := (others => '0');
00205 signal reg_hr_a7 : (31 downto 0) := (others => '0');
00206 signal reg_hr_a8 : (31 downto 0) := (others => '0');
00207 signal reg_hr_b1 : (31 downto 0) := (others => '0');
00208 signal reg_hr_b2 : (31 downto 0) := (others => '0');
00209 signal reg_hr_b3 : (31 downto 0) := (others => '0');
00210 signal reg_hr_b4 : (31 downto 0) := (others => '0');
00211 signal reg_hr_b5 : (31 downto 0) := (others => '0');
00212 signal reg_hr_b6 : (31 downto 0) := (others => '0');
00213 signal reg_hr_b7 : (31 downto 0) := (others => '0');
00214 signal reg_hr_b8 : (31 downto 0) := (others => '0');
00215 signal reg_hr_c1 : (31 downto 0) := (others => '0');
00216 signal reg_hr_c2 : (31 downto 0) := (others => '0');
00217 signal reg_hr_c3 : (31 downto 0) := (others => '0');
00218 signal reg_hr_c4 : (31 downto 0) := (others => '0');
00219 signal reg_hr_c5 : (31 downto 0) := (others => '0');
00220 signal reg_hr_c6 : (31 downto 0) := (others => '0');
00221 signal reg_hr_c7 : (31 downto 0) := (others => '0');
00222 signal reg_hr_c8 : (31 downto 0) := (others => '0');
00223 signal reg_hr_d1 : (31 downto 0) := (others => '0');
00224 signal reg_hr_d2 : (31 downto 0) := (others => '0');
00225 signal reg_hr_d3 : (31 downto 0) := (others => '0');
00226 signal reg_hr_d4 : (31 downto 0) := (others => '0');
00227 signal reg_hr_d5 : (31 downto 0) := (others => '0');
00228 signal reg_hr_d6 : (31 downto 0) := (others => '0');
00229 signal reg_hr_d7 : (31 downto 0) := (others => '0');
00230 signal reg_hr_d8 : (31 downto 0) := (others => '0');
00231 signal data_out_i : (7 downto 0) := (others => '0');
00232 signal ocnt : range 0 to 255 := 0;
00233 signal ocnto : := 255;
00234 signal cnt : range 0 to 31 := 0;
00235 signal cnto : := 31;
00236
00237 begin -- status_collector_arc
00238
00239 DEBUG(14 downto 10) <= conv_std_logic_vector(cnt, 5);
00240 DEBUG(9) <= start_p_i;
00241 DEBUG(8) <= start_del;
00242 DEBUG(7) <= done_i;
00243 DEBUG(6) <= cal_done;
00244 DEBUG(5) <= en_asm;
00245 DEBUG(4) <= en_calfsm;
00246 DEBUG(3) <= cal_wr_done;
00247 DEBUG(2) <= en_wr;
00248 DEBUG(1) <= en_cal;
00249 DEBUG(0) <= '0';
00250
00251
00252 start_pulse : edge
00253 port map(
00254 CLK => EMAC_CLK ,
00255 A => START ,
00256 PULSE => start_p_i
00257 );
00258
00259 start_p_ii <= start_p_i when rising_edge(EMAC_CLK);
00260 start_del <= START when rising_edge(EMAC_CLK);
00261 TRANS_DONE <= done_i;
00262 ASM_DONE <= cal_done;
00263
00264
00265 latch_enable_assembly : process (EMAC_CLK, RESET)
00266 begin -- process latch_enable_assembly
00267 if RESET = '1' then -- asynchronous reset (active high)
00268 en_asm <= '0';
00269 elsif EMAC_CLK'event and EMAC_CLK = '1' then -- rising clock edge
00270 if done_i = '1' then
00271 en_asm <= '0';
00272 elsif start_p_ii = '1' then
00273 en_asm <= '1';
00274 end if;
00275 end if;
00276 end process latch_enable_assembly;
00277
00278
00279 latch_enable_calculation : process (EMAC_CLK, RESET)
00280 begin -- process latch_enable_assembly
00281 if RESET = '1' then -- asynchronous reset (active high)
00282 en_calfsm <= '0';
00283 elsif EMAC_CLK'event and EMAC_CLK = '1' then -- rising clock edge
00284 if cal_wr_done = '1' then
00285 en_calfsm <= '0';
00286 elsif start_p_i = '1' then
00287 en_calfsm <= '1';
00288 end if;
00289 end if;
00290 end process latch_enable_calculation;
00291
00292 en_wr <= not en_asm;
00293
00294
00295 pkt_id_cnt : process (EMAC_CLK, RESET)
00296 begin -- process pkt_id_cnt
00297 if RESET = '1' then -- asynchronous reset (active high)
00298 pktcnt <= (others => '0');
00299 pktcntwr <= (others => '0');
00300 elsif EMAC_CLK'event and EMAC_CLK = '1' then -- rising clock edge
00301 if start_p_i = '1' then
00302 pktcntwr <= pktcnt;
00303 pktcnt <= pktcnt + 1;
00304 end if;
00305 end if;
00306 end process pkt_id_cnt;
00307
00308
00309 rate_registers : process (RATES_CLK, RESET)
00310 begin -- process registers
00311 if RESET = '1' then -- asynchronous reset (active high)
00312 reg_dsscibu <= (others => '0');
00313 reg_rod <= (others => '0');
00314 reg_tdaq <= (others => '0');
00315 reg_algo <= (others => '0');
00316 reg_hr_1 <= (others => '0');
00317 reg_hr_2 <= (others => '0');
00318 reg_hr_3 <= (others => '0');
00319 reg_hr_4 <= (others => '0');
00320 reg_hr_5 <= (others => '0');
00321 reg_hr_6 <= (others => '0');
00322 reg_hr_7 <= (others => '0');
00323 reg_hr_8 <= (others => '0');
00324 reg_hr_a1 <= (others => '0');
00325 reg_hr_a2 <= (others => '0');
00326 reg_hr_a3 <= (others => '0');
00327 reg_hr_a4 <= (others => '0');
00328 reg_hr_a5 <= (others => '0');
00329 reg_hr_a6 <= (others => '0');
00330 reg_hr_a7 <= (others => '0');
00331 reg_hr_a8 <= (others => '0');
00332 reg_hr_b1 <= (others => '0');
00333 reg_hr_b2 <= (others => '0');
00334 reg_hr_b3 <= (others => '0');
00335 reg_hr_b4 <= (others => '0');
00336 reg_hr_b5 <= (others => '0');
00337 reg_hr_b6 <= (others => '0');
00338 reg_hr_b7 <= (others => '0');
00339 reg_hr_b8 <= (others => '0');
00340 reg_hr_c1 <= (others => '0');
00341 reg_hr_c2 <= (others => '0');
00342 reg_hr_c3 <= (others => '0');
00343 reg_hr_c4 <= (others => '0');
00344 reg_hr_c5 <= (others => '0');
00345 reg_hr_c6 <= (others => '0');
00346 reg_hr_c7 <= (others => '0');
00347 reg_hr_c8 <= (others => '0');
00348 reg_hr_d1 <= (others => '0');
00349 reg_hr_d2 <= (others => '0');
00350 reg_hr_d3 <= (others => '0');
00351 reg_hr_d4 <= (others => '0');
00352 reg_hr_d5 <= (others => '0');
00353 reg_hr_d6 <= (others => '0');
00354 reg_hr_d7 <= (others => '0');
00355 reg_hr_d8 <= (others => '0');
00356 elsif RATES_CLK'event and RATES_CLK = '1' then -- rising clock edge
00357 if en_wr = '1' then
00358 if ROD_STATUS = '1' then
00359 reg_rod <= (others => '1');
00360 else
00361 reg_rod <= (others => '0');
00362 end if;
00363 reg_tdaq <= TDAQ_PARAMS;
00364 reg_dsscibu <= DSS_CIBU_STATUS;
00365 reg_algo <= ALGO_STATE;
00366 if hr_vld_bit = '1' then
00367 reg_hr_1 <= HITRATE_CH1;
00368 reg_hr_2 <= HITRATE_CH2;
00369 reg_hr_3 <= HITRATE_CH3;
00370 reg_hr_4 <= HITRATE_CH4;
00371 reg_hr_5 <= HITRATE_CH5;
00372 reg_hr_6 <= HITRATE_CH6;
00373 reg_hr_7 <= HITRATE_CH7;
00374 reg_hr_8 <= HITRATE_CH8;
00375 else
00376 reg_hr_1 <= (others => '0');
00377 reg_hr_2 <= (others => '0');
00378 reg_hr_3 <= (others => '0');
00379 reg_hr_4 <= (others => '0');
00380 reg_hr_5 <= (others => '0');
00381 reg_hr_6 <= (others => '0');
00382 reg_hr_7 <= (others => '0');
00383 reg_hr_8 <= (others => '0');
00384 end if;
00385 if algo_vld_bit = '1' then
00386 reg_hr_a1 <= HITRATE_A_CH1;
00387 reg_hr_a2 <= HITRATE_A_CH2;
00388 reg_hr_a3 <= HITRATE_A_CH3;
00389 reg_hr_a4 <= HITRATE_A_CH4;
00390 reg_hr_a5 <= HITRATE_A_CH5;
00391 reg_hr_a6 <= HITRATE_A_CH6;
00392 reg_hr_a7 <= HITRATE_A_CH7;
00393 reg_hr_a8 <= HITRATE_A_CH8;
00394 reg_hr_b1 <= HITRATE_B_CH1;
00395 reg_hr_b2 <= HITRATE_B_CH2;
00396 reg_hr_b3 <= HITRATE_B_CH3;
00397 reg_hr_b4 <= HITRATE_B_CH4;
00398 reg_hr_b5 <= HITRATE_B_CH5;
00399 reg_hr_b6 <= HITRATE_B_CH6;
00400 reg_hr_b7 <= HITRATE_B_CH7;
00401 reg_hr_b8 <= HITRATE_B_CH8;
00402 reg_hr_c1 <= HITRATE_C_CH1;
00403 reg_hr_c2 <= HITRATE_C_CH2;
00404 reg_hr_c3 <= HITRATE_C_CH3;
00405 reg_hr_c4 <= HITRATE_C_CH4;
00406 reg_hr_c5 <= HITRATE_C_CH5;
00407 reg_hr_c6 <= HITRATE_C_CH6;
00408 reg_hr_c7 <= HITRATE_C_CH7;
00409 reg_hr_c8 <= HITRATE_C_CH8;
00410 reg_hr_d1 <= HITRATE_D_CH1;
00411 reg_hr_d2 <= HITRATE_D_CH2;
00412 reg_hr_d3 <= HITRATE_D_CH3;
00413 reg_hr_d4 <= HITRATE_D_CH4;
00414 reg_hr_d5 <= HITRATE_D_CH5;
00415 reg_hr_d6 <= HITRATE_D_CH6;
00416 reg_hr_d7 <= HITRATE_D_CH7;
00417 reg_hr_d8 <= HITRATE_D_CH8;
00418 else
00419 reg_hr_a1 <= (others => '0');
00420 reg_hr_a2 <= (others => '0');
00421 reg_hr_a3 <= (others => '0');
00422 reg_hr_a4 <= (others => '0');
00423 reg_hr_a5 <= (others => '0');
00424 reg_hr_a6 <= (others => '0');
00425 reg_hr_a7 <= (others => '0');
00426 reg_hr_a8 <= (others => '0');
00427 reg_hr_b1 <= (others => '0');
00428 reg_hr_b2 <= (others => '0');
00429 reg_hr_b3 <= (others => '0');
00430 reg_hr_b4 <= (others => '0');
00431 reg_hr_b5 <= (others => '0');
00432 reg_hr_b6 <= (others => '0');
00433 reg_hr_b7 <= (others => '0');
00434 reg_hr_b8 <= (others => '0');
00435 reg_hr_c1 <= (others => '0');
00436 reg_hr_c2 <= (others => '0');
00437 reg_hr_c3 <= (others => '0');
00438 reg_hr_c4 <= (others => '0');
00439 reg_hr_c5 <= (others => '0');
00440 reg_hr_c6 <= (others => '0');
00441 reg_hr_c7 <= (others => '0');
00442 reg_hr_c8 <= (others => '0');
00443 reg_hr_d1 <= (others => '0');
00444 reg_hr_d2 <= (others => '0');
00445 reg_hr_d3 <= (others => '0');
00446 reg_hr_d4 <= (others => '0');
00447 reg_hr_d5 <= (others => '0');
00448 reg_hr_d6 <= (others => '0');
00449 reg_hr_d7 <= (others => '0');
00450 reg_hr_d8 <= (others => '0');
00451 end if;
00452 end if;
00453 end if;
00454 end process rate_registers;
00455
00456
00457 input_status_registers : process (RIO_CLK, RESET)
00458 begin -- process input_status_registers
00459 if RESET = '1' then -- asynchronous reset (active high)
00460 reg_daq <= (others => '0');
00461 reg_sata <= (others => '0');
00462 reg_ins <= (others => '0');
00463 elsif RIO_CLK'event and RIO_CLK = '1' then -- rising clock edge
00464 if en_wr = '1' then
00465 reg_ins <= INPUT_STATUS;
00466 if RIO_DAQ = '1' then
00467 reg_daq <= (others => '1');
00468 else
00469 reg_daq <= (others => '0');
00470 end if;
00471 if RIO_SATA = '1' then
00472 reg_sata <= (others => '1');
00473 else
00474 reg_sata <= (others => '0');
00475 end if;
00476 end if;
00477 end if;
00478 end process input_status_registers;
00479
00480
00481 status_registers : process (STATUS_CLK, RESET)
00482 begin -- process status_registers
00483 if RESET = '1' then -- asynchronous reset (active high)
00484 reg_err <= (others => '0');
00485 reg_errcode <= (others => '0');
00486 reg_extclk <= (others => '0');
00487 reg_dcm <= (others => '0');
00488 reg_fsm <= (others => '0');
00489 elsif STATUS_CLK'event and STATUS_CLK = '1' then -- rising clock edge
00490 if en_wr = '1' then
00491 if ERROR_FLAG = '1' then
00492 reg_err <= (others => '1');
00493 else
00494 reg_err <= (others => '0');
00495 end if;
00496 if EXT_CLK_DET = '1' then
00497 reg_extclk <= (others => '1');
00498 else
00499 reg_extclk <= (others => '0');
00500 end if;
00501 if DCM_STATUS = '1' then
00502 reg_dcm <= (others => '1');
00503 else
00504 reg_dcm <= (others => '0');
00505 end if;
00506 reg_fsm <= MAIN_FSM;
00507 reg_errcode <= ERROR_CODE;
00508 end if;
00509 end if;
00510 end process status_registers;
00511
00512
00513 general_registers : process (EMAC_CLK, RESET)
00514 begin -- process general_registers
00515 if RESET = '1' then -- asynchronous reset (active high)
00516 reg_mac <= (others => '0');
00517 reg_fpga_id <= (others => '0');
00518 elsif EMAC_CLK'event and EMAC_CLK = '1' then -- rising clock edge
00519 if en_wr = '1' then
00520 reg_fpga_id <= FPGA_ID;
00521 if MODE = '1' then
00522 reg_mac <= (others => '1');
00523 else
00524 reg_mac <= (others => '0');
00525 end if;
00526 end if;
00527 end if;
00528 end process general_registers;
00529
00530 chksum_cnt : process (EMAC_CLK, RESET)
00531 begin -- process chksum_cnt
00532 if RESET = '1' then -- asynchronous reset (active high)
00533 cnt <= 0;
00534 elsif EMAC_CLK'event and EMAC_CLK = '1' then -- rising clock edge
00535 if en_calfsm = '1' then
00536 cnt <= cnt + 1;
00537 if cnt > 15 then
00538 cnt <= cnt;
00539 end if;
00540 else
00541 cnt <= 0;
00542 end if;
00543 end if;
00544 end process chksum_cnt;
00545
00546 checksum_assembly : process (cnt)
00547 begin -- process checksum_assembly
00548 cnto <= cnt - 1;
00549 en_cal <= '1';
00550 cal_wr_done <= '0';
00551 case cnto is
00552 when 0 => chk_in <= hr_vld & algo_vld & reg_fpga_id & pktcntwr & reg_err & reg_extclk & reg_fsm & reg_daq &
00553 reg_sata & reg_rod & reg_mac & reg_dcm & reg_dsscibu;
00554 when 1 => chk_in <= reg_errcode & reg_ins & reg_tdaq(159 downto 128);
00555 when 2 => chk_in <= reg_tdaq(127 downto 0);
00556 when 3 => chk_in <= reg_hr_1 & reg_hr_2 & reg_hr_3 & reg_hr_4;
00557 when 4 => chk_in <= reg_hr_5 & reg_hr_6 & reg_hr_7 & reg_hr_8;
00558 when 5 => chk_in <= reg_hr_a1 & reg_hr_a2 & reg_hr_a3 & reg_hr_a4;
00559 when 6 => chk_in <= reg_hr_a5 & reg_hr_a6 & reg_hr_a7 & reg_hr_a8;
00560 when 7 => chk_in <= reg_hr_b1 & reg_hr_b2 & reg_hr_b3 & reg_hr_b4;
00561 when 8 => chk_in <= reg_hr_b5 & reg_hr_b6 & reg_hr_b7 & reg_hr_b8;
00562 when 9 => chk_in <= reg_hr_c1 & reg_hr_c2 & reg_hr_c3 & reg_hr_c4;
00563 when 10 => chk_in <= reg_hr_c5 & reg_hr_c6 & reg_hr_c7 & reg_hr_c8;
00564 when 11 => chk_in <= reg_hr_d1 & reg_hr_d2 & reg_hr_d3 & reg_hr_d4;
00565 when 12 => chk_in <= reg_hr_d5 & reg_hr_d6 & reg_hr_d7 & reg_hr_d8;
00566 when 13 => chk_in <= reg_algo & x"0000_0000_0000_0000_0000_0000";
00567 when 14 => chk_in <= (others => '0');
00568 cal_wr_done <= '1';
00569 when others =>
00570 en_cal <= '0';
00571 cal_wr_done <= '0';
00572 chk_in <= (others => '0');
00573 end case;
00574 end process checksum_assembly;
00575
00576
00577 chksum_cal : ddr2_chksum_cal
00578 port map(
00579 CLK => EMAC_CLK,
00580 RESET => RESET,
00581 EN => en_cal,
00582 DATA_IN => chk_in,
00583 WRITE_DONE => cal_wr_done,
00584 CAL_COMPL => cal_done,
00585 READ_DATA => FETCH_CHKSUM,
00586 DATA_OUT => chksum_out_i
00587 );
00588
00589 CHKSUM_OUT <= (others => '0') when RESET = '1' else chksum_out_i;
00590
00591 assembly_cnt : process (EMAC_CLK, RESET)
00592 begin -- process assembly_cnt
00593 if RESET = '1' then -- asynchronous reset (active high)
00594 ocnt <= 0;
00595 elsif EMAC_CLK'event and EMAC_CLK = '1' then -- rising clock edge
00596 if FETCH_BYTE = '1' then
00597 ocnt <= ocnt + 1;
00598 if ocnt > 212 then
00599 ocnt <= ocnt;
00600 end if;
00601 else
00602 ocnt <= 0;
00603 end if;
00604 end if;
00605 end process assembly_cnt;
00606
00607 byte_assembly : process (ocnt)
00608 begin -- process byte_assembly
00609 ocnto <= ocnt - 1;
00610 done_i <= '0';
00611 case ocnto is
00612 when 0 => data_out_i <= hr_vld;
00613 when 1 => data_out_i <= algo_vld;
00614 when 2 => data_out_i <= reg_fpga_id;
00615 when 3 => data_out_i <= pktcntwr;
00616 when 4 => data_out_i <= reg_err;
00617 when 5 => data_out_i <= reg_extclk;
00618 when 6 => data_out_i <= reg_fsm;
00619 when 7 => data_out_i <= reg_daq;
00620 when 8 => data_out_i <= reg_sata;
00621 when 9 => data_out_i <= reg_rod;
00622 when 10 => data_out_i <= reg_mac;
00623 when 11 => data_out_i <= reg_dcm;
00624 when 12 => data_out_i <= reg_dsscibu(31 downto 24);
00625 when 13 => data_out_i <= reg_dsscibu(23 downto 16);
00626 when 14 => data_out_i <= reg_dsscibu(15 downto 8);
00627 when 15 => data_out_i <= reg_dsscibu(7 downto 0);
00628 when 16 => data_out_i <= reg_errcode(31 downto 24);
00629 when 17 => data_out_i <= reg_errcode(23 downto 16);
00630 when 18 => data_out_i <= reg_errcode(15 downto 8);
00631 when 19 => data_out_i <= reg_errcode(7 downto 0);
00632 when 20 => data_out_i <= reg_ins(63 downto 56);
00633 when 21 => data_out_i <= reg_ins(55 downto 48);
00634 when 22 => data_out_i <= reg_ins(47 downto 40);
00635 when 23 => data_out_i <= reg_ins(39 downto 32);
00636 when 24 => data_out_i <= reg_ins(31 downto 24);
00637 when 25 => data_out_i <= reg_ins(23 downto 16);
00638 when 26 => data_out_i <= reg_ins(15 downto 8);
00639 when 27 => data_out_i <= reg_ins(7 downto 0);
00640 when 28 => data_out_i <= reg_tdaq(159 downto 152);
00641 when 29 => data_out_i <= reg_tdaq(151 downto 144);
00642 when 30 => data_out_i <= reg_tdaq(143 downto 136);
00643 when 31 => data_out_i <= reg_tdaq(135 downto 128);
00644 when 32 => data_out_i <= reg_tdaq(127 downto 120);
00645 when 33 => data_out_i <= reg_tdaq(119 downto 112);
00646 when 34 => data_out_i <= reg_tdaq(111 downto 104);
00647 when 35 => data_out_i <= reg_tdaq(103 downto 96);
00648 when 36 => data_out_i <= reg_tdaq(95 downto 88);
00649 when 37 => data_out_i <= reg_tdaq(87 downto 80);
00650 when 38 => data_out_i <= reg_tdaq(79 downto 72);
00651 when 39 => data_out_i <= reg_tdaq(71 downto 64);
00652 when 40 => data_out_i <= reg_tdaq(63 downto 56);
00653 when 41 => data_out_i <= reg_tdaq(55 downto 48);
00654 when 42 => data_out_i <= reg_tdaq(47 downto 40);
00655 when 43 => data_out_i <= reg_tdaq(39 downto 32);
00656 when 44 => data_out_i <= reg_tdaq(31 downto 24);
00657 when 45 => data_out_i <= reg_tdaq(23 downto 16);
00658 when 46 => data_out_i <= reg_tdaq(15 downto 8);
00659 when 47 => data_out_i <= reg_tdaq(7 downto 0);
00660 when 48 => data_out_i <= reg_hr_1(31 downto 24);
00661 when 49 => data_out_i <= reg_hr_1(23 downto 16);
00662 when 50 => data_out_i <= reg_hr_1(15 downto 8);
00663 when 51 => data_out_i <= reg_hr_1(7 downto 0);
00664 when 52 => data_out_i <= reg_hr_2(31 downto 24);
00665 when 53 => data_out_i <= reg_hr_2(23 downto 16);
00666 when 54 => data_out_i <= reg_hr_2(15 downto 8);
00667 when 55 => data_out_i <= reg_hr_2(7 downto 0);
00668 when 56 => data_out_i <= reg_hr_3(31 downto 24);
00669 when 57 => data_out_i <= reg_hr_3(23 downto 16);
00670 when 58 => data_out_i <= reg_hr_3(15 downto 8);
00671 when 59 => data_out_i <= reg_hr_3(7 downto 0);
00672 when 60 => data_out_i <= reg_hr_4(31 downto 24);
00673 when 61 => data_out_i <= reg_hr_4(23 downto 16);
00674 when 62 => data_out_i <= reg_hr_4(15 downto 8);
00675 when 63 => data_out_i <= reg_hr_4(7 downto 0);
00676 when 64 => data_out_i <= reg_hr_5(31 downto 24);
00677 when 65 => data_out_i <= reg_hr_5(23 downto 16);
00678 when 66 => data_out_i <= reg_hr_5(15 downto 8);
00679 when 67 => data_out_i <= reg_hr_5(7 downto 0);
00680 when 68 => data_out_i <= reg_hr_6(31 downto 24);
00681 when 69 => data_out_i <= reg_hr_6(23 downto 16);
00682 when 70 => data_out_i <= reg_hr_6(15 downto 8);
00683 when 71 => data_out_i <= reg_hr_6(7 downto 0);
00684 when 72 => data_out_i <= reg_hr_7(31 downto 24);
00685 when 73 => data_out_i <= reg_hr_7(23 downto 16);
00686 when 74 => data_out_i <= reg_hr_7(15 downto 8);
00687 when 75 => data_out_i <= reg_hr_7(7 downto 0);
00688 when 76 => data_out_i <= reg_hr_8(31 downto 24);
00689 when 77 => data_out_i <= reg_hr_8(23 downto 16);
00690 when 78 => data_out_i <= reg_hr_8(15 downto 8);
00691 when 79 => data_out_i <= reg_hr_8(7 downto 0);
00692 when 80 => data_out_i <= reg_hr_a1(31 downto 24);
00693 when 81 => data_out_i <= reg_hr_a1(23 downto 16);
00694 when 82 => data_out_i <= reg_hr_a1(15 downto 8);
00695 when 83 => data_out_i <= reg_hr_a1(7 downto 0);
00696 when 84 => data_out_i <= reg_hr_a2(31 downto 24);
00697 when 85 => data_out_i <= reg_hr_a2(23 downto 16);
00698 when 86 => data_out_i <= reg_hr_a2(15 downto 8);
00699 when 87 => data_out_i <= reg_hr_a2(7 downto 0);
00700 when 88 => data_out_i <= reg_hr_a3(31 downto 24);
00701 when 89 => data_out_i <= reg_hr_a3(23 downto 16);
00702 when 90 => data_out_i <= reg_hr_a3(15 downto 8);
00703 when 91 => data_out_i <= reg_hr_a3(7 downto 0);
00704 when 92 => data_out_i <= reg_hr_a4(31 downto 24);
00705 when 93 => data_out_i <= reg_hr_a4(23 downto 16);
00706 when 94 => data_out_i <= reg_hr_a4(15 downto 8);
00707 when 95 => data_out_i <= reg_hr_a4(7 downto 0);
00708 when 96 => data_out_i <= reg_hr_a5(31 downto 24);
00709 when 97 => data_out_i <= reg_hr_a5(23 downto 16);
00710 when 98 => data_out_i <= reg_hr_a5(15 downto 8);
00711 when 99 => data_out_i <= reg_hr_a5(7 downto 0);
00712 when 100 => data_out_i <= reg_hr_a6(31 downto 24);
00713 when 101 => data_out_i <= reg_hr_a6(23 downto 16);
00714 when 102 => data_out_i <= reg_hr_a6(15 downto 8);
00715 when 103 => data_out_i <= reg_hr_a6(7 downto 0);
00716 when 104 => data_out_i <= reg_hr_a7(31 downto 24);
00717 when 105 => data_out_i <= reg_hr_a7(23 downto 16);
00718 when 106 => data_out_i <= reg_hr_a7(15 downto 8);
00719 when 107 => data_out_i <= reg_hr_a7(7 downto 0);
00720 when 108 => data_out_i <= reg_hr_a8(31 downto 24);
00721 when 109 => data_out_i <= reg_hr_a8(23 downto 16);
00722 when 110 => data_out_i <= reg_hr_a8(15 downto 8);
00723 when 111 => data_out_i <= reg_hr_a8(7 downto 0);
00724 when 112 => data_out_i <= reg_hr_b1(31 downto 24);
00725 when 113 => data_out_i <= reg_hr_b1(23 downto 16);
00726 when 114 => data_out_i <= reg_hr_b1(15 downto 8);
00727 when 115 => data_out_i <= reg_hr_b1(7 downto 0);
00728 when 116 => data_out_i <= reg_hr_b2(31 downto 24);
00729 when 117 => data_out_i <= reg_hr_b2(23 downto 16);
00730 when 118 => data_out_i <= reg_hr_b2(15 downto 8);
00731 when 119 => data_out_i <= reg_hr_b2(7 downto 0);
00732 when 120 => data_out_i <= reg_hr_b3(31 downto 24);
00733 when 121 => data_out_i <= reg_hr_b3(23 downto 16);
00734 when 122 => data_out_i <= reg_hr_b3(15 downto 8);
00735 when 123 => data_out_i <= reg_hr_b3(7 downto 0);
00736 when 124 => data_out_i <= reg_hr_b4(31 downto 24);
00737 when 125 => data_out_i <= reg_hr_b4(23 downto 16);
00738 when 126 => data_out_i <= reg_hr_b4(15 downto 8);
00739 when 127 => data_out_i <= reg_hr_b4(7 downto 0);
00740 when 128 => data_out_i <= reg_hr_b5(31 downto 24);
00741 when 129 => data_out_i <= reg_hr_b5(23 downto 16);
00742 when 130 => data_out_i <= reg_hr_b5(15 downto 8);
00743 when 131 => data_out_i <= reg_hr_b5(7 downto 0);
00744 when 132 => data_out_i <= reg_hr_b6(31 downto 24);
00745 when 133 => data_out_i <= reg_hr_b6(23 downto 16);
00746 when 134 => data_out_i <= reg_hr_b6(15 downto 8);
00747 when 135 => data_out_i <= reg_hr_b6(7 downto 0);
00748 when 136 => data_out_i <= reg_hr_b7(31 downto 24);
00749 when 137 => data_out_i <= reg_hr_b7(23 downto 16);
00750 when 138 => data_out_i <= reg_hr_b7(15 downto 8);
00751 when 139 => data_out_i <= reg_hr_b7(7 downto 0);
00752 when 140 => data_out_i <= reg_hr_b8(31 downto 24);
00753 when 141 => data_out_i <= reg_hr_b8(23 downto 16);
00754 when 142 => data_out_i <= reg_hr_b8(15 downto 8);
00755 when 143 => data_out_i <= reg_hr_b8(7 downto 0);
00756 when 144 => data_out_i <= reg_algo(31 downto 24);
00757 when 145 => data_out_i <= reg_algo(23 downto 16);
00758 when 146 => data_out_i <= reg_algo(15 downto 8);
00759 when 147 => data_out_i <= reg_algo(7 downto 0);
00760 when 148 => data_out_i <= reg_hr_c1(31 downto 24);
00761 when 149 => data_out_i <= reg_hr_c1(23 downto 16);
00762 when 150 => data_out_i <= reg_hr_c1(15 downto 8);
00763 when 151 => data_out_i <= reg_hr_c1(7 downto 0);
00764 when 152 => data_out_i <= reg_hr_c2(31 downto 24);
00765 when 153 => data_out_i <= reg_hr_c2(23 downto 16);
00766 when 154 => data_out_i <= reg_hr_c2(15 downto 8);
00767 when 155 => data_out_i <= reg_hr_c2(7 downto 0);
00768 when 156 => data_out_i <= reg_hr_c3(31 downto 24);
00769 when 157 => data_out_i <= reg_hr_c3(23 downto 16);
00770 when 158 => data_out_i <= reg_hr_c3(15 downto 8);
00771 when 159 => data_out_i <= reg_hr_c3(7 downto 0);
00772 when 160 => data_out_i <= reg_hr_c4(31 downto 24);
00773 when 161 => data_out_i <= reg_hr_c4(23 downto 16);
00774 when 162 => data_out_i <= reg_hr_c4(15 downto 8);
00775 when 163 => data_out_i <= reg_hr_c4(7 downto 0);
00776 when 164 => data_out_i <= reg_hr_c5(31 downto 24);
00777 when 165 => data_out_i <= reg_hr_c5(23 downto 16);
00778 when 166 => data_out_i <= reg_hr_c5(15 downto 8);
00779 when 167 => data_out_i <= reg_hr_c5(7 downto 0);
00780 when 168 => data_out_i <= reg_hr_c6(31 downto 24);
00781 when 169 => data_out_i <= reg_hr_c6(23 downto 16);
00782 when 170 => data_out_i <= reg_hr_c6(15 downto 8);
00783 when 171 => data_out_i <= reg_hr_c6(7 downto 0);
00784 when 172 => data_out_i <= reg_hr_c7(31 downto 24);
00785 when 173 => data_out_i <= reg_hr_c7(23 downto 16);
00786 when 174 => data_out_i <= reg_hr_c7(15 downto 8);
00787 when 175 => data_out_i <= reg_hr_c7(7 downto 0);
00788 when 176 => data_out_i <= reg_hr_c8(31 downto 24);
00789 when 177 => data_out_i <= reg_hr_c8(23 downto 16);
00790 when 178 => data_out_i <= reg_hr_c8(15 downto 8);
00791 when 179 => data_out_i <= reg_hr_c8(7 downto 0);
00792 when 180 => data_out_i <= reg_hr_d1(31 downto 24);
00793 when 181 => data_out_i <= reg_hr_d1(23 downto 16);
00794 when 182 => data_out_i <= reg_hr_d1(15 downto 8);
00795 when 183 => data_out_i <= reg_hr_d1(7 downto 0);
00796 when 184 => data_out_i <= reg_hr_d2(31 downto 24);
00797 when 185 => data_out_i <= reg_hr_d2(23 downto 16);
00798 when 186 => data_out_i <= reg_hr_d2(15 downto 8);
00799 when 187 => data_out_i <= reg_hr_d2(7 downto 0);
00800 when 188 => data_out_i <= reg_hr_d3(31 downto 24);
00801 when 189 => data_out_i <= reg_hr_d3(23 downto 16);
00802 when 190 => data_out_i <= reg_hr_d3(15 downto 8);
00803 when 191 => data_out_i <= reg_hr_d3(7 downto 0);
00804 when 192 => data_out_i <= reg_hr_d4(31 downto 24);
00805 when 193 => data_out_i <= reg_hr_d4(23 downto 16);
00806 when 194 => data_out_i <= reg_hr_d4(15 downto 8);
00807 when 195 => data_out_i <= reg_hr_d4(7 downto 0);
00808 when 196 => data_out_i <= reg_hr_d5(31 downto 24);
00809 when 197 => data_out_i <= reg_hr_d5(23 downto 16);
00810 when 198 => data_out_i <= reg_hr_d5(15 downto 8);
00811 when 199 => data_out_i <= reg_hr_d5(7 downto 0);
00812 when 200 => data_out_i <= reg_hr_d6(31 downto 24);
00813 when 201 => data_out_i <= reg_hr_d6(23 downto 16);
00814 when 202 => data_out_i <= reg_hr_d6(15 downto 8);
00815 when 203 => data_out_i <= reg_hr_d6(7 downto 0);
00816 when 204 => data_out_i <= reg_hr_d7(31 downto 24);
00817 when 205 => data_out_i <= reg_hr_d7(23 downto 16);
00818 when 206 => data_out_i <= reg_hr_d7(15 downto 8);
00819 when 207 => data_out_i <= reg_hr_d7(7 downto 0);
00820 when 208 => data_out_i <= reg_hr_d8(31 downto 24);
00821 when 209 => data_out_i <= reg_hr_d8(23 downto 16);
00822 when 210 => data_out_i <= reg_hr_d8(15 downto 8);
00823 when 211 => data_out_i <= reg_hr_d8(7 downto 0);
00824 done_i <= '1';
00825 when others => data_out_i <= (others => '0');
00826 done_i <= '0';
00827 end case;
00828 end process byte_assembly;
00829
00830 DATA_OUT <= data_out_i when rising_edge(EMAC_CLK);
00831
00832 end status_collector_arc;