Changeset 10441 for firmware/FTM/ethernet
- Timestamp:
- 04/21/11 11:17:11 (14 years ago)
- Location:
- firmware/FTM/ethernet
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/FTM/ethernet/dd_write_general_modul_beha.vhd
r10418 r10441 8 8 -- using Mentor Graphics HDL Designer(TM) 2009.1 (Build 12) 9 9 -- 10 11 10 LIBRARY ieee; 12 11 USE ieee.std_logic_1164.all; 13 12 USE ieee.std_logic_arith.all; 14 13 USE IEEE.STD_LOGIC_UNSIGNED.all; 15 -- LIBRARY FACT_FTM_lib; 16 -- USE FACT_FTM_lib.ftm_array_types.all; 17 -- USE FACT_FTM_lib.ftm_constants.all; 14 18 15 library ftm_definitions; 19 16 USE ftm_definitions.ftm_array_types.all; … … 26 23 dd_write_general_started : OUT std_logic := '0'; 27 24 dd_write_general_ready : OUT std_logic := '0'; 28 dd_busy : IN std_logic; 29 dd_write : OUT std_logic := '0'; 30 dd_started : IN std_logic; 31 dd_ready : IN std_logic; 32 dd_addr : OUT std_logic_vector (11 DOWNTO 0) := (others => '0'); 33 dd_data : OUT std_logic_vector (15 DOWNTO 0) := (others => '0') 25 dd_busy : IN std_logic; 26 dd_write : OUT std_logic := '0'; 27 dd_started : IN std_logic; 28 dd_ready : IN std_logic; 29 dd_addr : OUT std_logic_vector (11 DOWNTO 0) := (others => '0'); 30 dd_data : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 31 get_ot_counter : OUT std_logic := '0'; 32 get_ot_counter_started : IN std_logic; 33 get_ot_counter_ready : IN std_logic; 34 on_time_counter : IN std_logic_vector (47 DOWNTO 0); 35 temp_sensor_ready : IN std_logic; 36 temp_sensor_array : IN sensor_array_type 34 37 ); 35 38 END ENTITY dd_write_general_modul; … … 38 41 ARCHITECTURE beha OF dd_write_general_modul IS 39 42 40 type state_write_general_proc_type is (WGP_INIT, WGP_CONFIG, WGP_IDLE, WGP_WRITE_COUNTER_01, WGP_WRITE_COUNTER_02, WGP_WRITE_COUNTER_03, 43 type state_write_general_proc_type is (WGP_INIT, WGP_CONFIG, WGP_IDLE, 44 WGP_OT_CNT, WGP_OT_CNT_END, 45 WGP_WRITE_COUNTER_00, WGP_WRITE_COUNTER_01, WGP_WRITE_COUNTER_02, WGP_WRITE_COUNTER_03, 41 46 WGP_WRITE_TEMP_01, WGP_WRITE_TEMP_02, WGP_WRITE_TEMP_03, WGP_WRITE_TEMP_04, WGP_WRITE_READY, WRITE_TO_DD_ADDR); 42 47 type state_write_dd_type is (WRITE_DD_START, WRITE_DD_WAIT, WRITE_DD_END); … … 49 54 signal local_dd_data : std_logic_vector (15 DOWNTO 0) := (others => '0'); 50 55 51 signal on_time_counter : std_logic_vector (47 DOWNTO 0) := X"333322221111";52 signal temp_sensor_0 : std_logic_vector (15 DOWNTO 0) := X"00FF";53 signal temp_sensor_1 : std_logic_vector (15 DOWNTO 0) := X"11FF";54 signal temp_sensor_2 : std_logic_vector (15 DOWNTO 0) := X"22FF";55 signal temp_sensor_3 : std_logic_vector (15 DOWNTO 0) := X"33FF";56 56 57 57 BEGIN … … 71 71 dd_write_general_started <= '1'; 72 72 dd_write_general_ready <= '0'; 73 state_write_general_proc <= WGP_WRITE_COUNTER_01; 73 get_ot_counter <= '1'; 74 state_write_general_proc <= WGP_OT_CNT; 74 75 end if; 75 76 77 when WGP_OT_CNT => 78 if (get_ot_counter_started = '1') then 79 get_ot_counter <= '0'; 80 state_write_general_proc <= WGP_OT_CNT_END; 81 end if; 82 83 when WGP_OT_CNT_END => 84 if (get_ot_counter_ready = '1') then 85 state_write_general_proc <= WGP_WRITE_COUNTER_00; 86 end if; 87 88 when WGP_WRITE_COUNTER_00 => 89 local_dd_addr <= X"000"; 90 local_dd_data <= X"0000"; 91 next_state_dd <= WGP_WRITE_COUNTER_01; 92 state_write_general_proc <= WRITE_TO_DD_ADDR; 93 76 94 when WGP_WRITE_COUNTER_01 => 77 local_dd_addr <= X"00 0";95 local_dd_addr <= X"001"; 78 96 local_dd_data <= on_time_counter (47 DOWNTO 32); 79 97 next_state_dd <= WGP_WRITE_COUNTER_02; … … 81 99 82 100 when WGP_WRITE_COUNTER_02 => 83 local_dd_addr <= X"00 1";101 local_dd_addr <= X"002"; 84 102 local_dd_data <= on_time_counter (31 DOWNTO 16); 85 103 next_state_dd <= WGP_WRITE_COUNTER_03; … … 87 105 88 106 when WGP_WRITE_COUNTER_03 => 89 local_dd_addr <= X"00 2";107 local_dd_addr <= X"003"; 90 108 local_dd_data <= on_time_counter (15 DOWNTO 0); 91 109 next_state_dd <= WGP_WRITE_TEMP_01; … … 93 111 94 112 when WGP_WRITE_TEMP_01 => 95 local_dd_addr <= X"003"; 96 local_dd_data <= temp_sensor_0; 97 next_state_dd <= WGP_WRITE_TEMP_02; 98 state_write_general_proc <= WRITE_TO_DD_ADDR; 113 if (temp_sensor_ready = '1') then 114 local_dd_addr <= X"004"; 115 local_dd_data <= conv_std_logic_vector (temp_sensor_array (0), 16); 116 next_state_dd <= WGP_WRITE_TEMP_02; 117 state_write_general_proc <= WRITE_TO_DD_ADDR; 118 end if; 99 119 100 120 when WGP_WRITE_TEMP_02 => 101 local_dd_addr <= X"004"; 102 local_dd_data <= temp_sensor_1; 103 next_state_dd <= WGP_WRITE_TEMP_03; 104 state_write_general_proc <= WRITE_TO_DD_ADDR; 121 if (temp_sensor_ready = '1') then 122 local_dd_addr <= X"005"; 123 local_dd_data <= conv_std_logic_vector (temp_sensor_array (1), 16); 124 next_state_dd <= WGP_WRITE_TEMP_03; 125 state_write_general_proc <= WRITE_TO_DD_ADDR; 126 end if; 105 127 106 128 when WGP_WRITE_TEMP_03 => 107 local_dd_addr <= X"005"; 108 local_dd_data <= temp_sensor_2; 109 next_state_dd <= WGP_WRITE_TEMP_04; 110 state_write_general_proc <= WRITE_TO_DD_ADDR; 129 if (temp_sensor_ready = '1') then 130 local_dd_addr <= X"006"; 131 local_dd_data <= conv_std_logic_vector (temp_sensor_array (2), 16); 132 next_state_dd <= WGP_WRITE_TEMP_04; 133 state_write_general_proc <= WRITE_TO_DD_ADDR; 134 end if; 111 135 112 136 when WGP_WRITE_TEMP_04 => 113 local_dd_addr <= X"006"; 114 local_dd_data <= temp_sensor_3; 115 next_state_dd <= WGP_WRITE_READY; 116 state_write_general_proc <= WRITE_TO_DD_ADDR; 137 if (temp_sensor_ready = '1') then 138 local_dd_addr <= X"007"; 139 local_dd_data <= conv_std_logic_vector (temp_sensor_array (3), 16); 140 next_state_dd <= WGP_WRITE_READY; 141 state_write_general_proc <= WRITE_TO_DD_ADDR; 142 end if; 117 143 118 144 when WGP_WRITE_READY => … … 150 176 151 177 END ARCHITECTURE beha; 178 -
firmware/FTM/ethernet/ethernet_modul_beha.vhd
r10366 r10441 3 3 -- Created: 4 4 -- by - kai.users (tpkw.local.priv) 5 -- at - 1 0:39:41 04/13/115 -- at - 11:20:56 04/20/11 6 6 -- 7 7 -- Generated by Mentor Graphics' HDL Designer(TM) 2009.1 (Build 12) … … 10 10 USE ieee.std_logic_1164.all; 11 11 USE ieee.std_logic_arith.all; 12 --LIBRARY FACT_FTM_lib; 12 13 13 library ftm_definitions; 14 14 USE ftm_definitions.ftm_array_types.all; 15 15 USE ftm_definitions.ftm_constants.all; 16 17 16 18 17 ENTITY ethernet_modul IS … … 70 69 fl_addr_ftu : IN std_logic_vector (11 DOWNTO 0); 71 70 fl_data_in_ftu : IN std_logic_vector (15 DOWNTO 0) := (others => '0'); 71 -- 72 72 ping_ftu_start : OUT std_logic := '0'; 73 73 ping_ftu_started : IN std_logic; … … 89 89 ftu_error_calls : IN std_logic_vector (15 DOWNTO 0); 90 90 ftu_error_data : IN std_logic_vector (223 DOWNTO 0); -- (28 * 8) - 1 91 -- 91 92 ftu_error_send : IN std_logic; 92 93 ftu_error_send_ack : OUT std_logic := '1'; … … 95 96 trigger_counter : IN std_logic_vector (31 DOWNTO 0) := (others => '0'); 96 97 trigger_counter_read : OUT std_logic := '0'; 97 trigger_counter_valid : IN std_logic 98 trigger_counter_valid : IN std_logic; 99 board_id : IN std_logic_vector (63 DOWNTO 0); 100 get_ts_counter : OUT std_logic := '0'; 101 get_ts_counter_ready : IN std_logic; 102 get_ts_counter_started : IN std_logic; 103 timestamp_counter : IN std_logic_vector (47 DOWNTO 0); 104 get_ot_counter : OUT std_logic := '0'; 105 get_ot_counter_ready : IN std_logic; 106 get_ot_counter_started : IN std_logic; 107 on_time_counter : IN std_logic_vector (47 DOWNTO 0); 108 temp_sensor_array : IN sensor_array_type; 109 temp_sensor_ready : IN std_logic; 110 crate_reset : OUT std_logic := '0'; 111 crate_reset_ack : IN std_logic; 112 crate_reset_param : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 113 -- 114 start_run : OUT std_logic := '0'; 115 start_run_ack : IN std_logic; 116 stop_run : OUT std_logic := '0'; 117 stop_run_ack : IN std_logic; 118 current_cc_state : IN std_logic_vector (15 DOWNTO 0); 119 start_run_param : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 120 start_run_num_events : OUT std_logic_vector (31 DOWNTO 0) := (others => '0') 98 121 ); 99 122 … … 159 182 SIGNAL header_timestamp_counter : std_logic_vector(47 DOWNTO 0); 160 183 SIGNAL header_trigger_counter : std_logic_vector(31 DOWNTO 0); 184 SIGNAL header_current_state : std_logic_vector(15 DOWNTO 0) := (others => '0'); 161 185 162 186 -- Implicit buffer signal declarations … … 268 292 dd_ready : IN std_logic ; 269 293 dd_addr : OUT std_logic_vector (11 DOWNTO 0) := (others => '0'); 270 dd_data : OUT std_logic_vector (15 DOWNTO 0) := (others => '0') 294 dd_data : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 295 get_ot_counter : OUT std_logic := '0'; 296 get_ot_counter_started : IN std_logic ; 297 get_ot_counter_ready : IN std_logic ; 298 on_time_counter : IN std_logic_vector (47 DOWNTO 0); 299 temp_sensor_ready : IN std_logic ; 300 temp_sensor_array : IN sensor_array_type 271 301 ); 272 302 END COMPONENT; … … 338 368 get_header_started : OUT std_logic := '0'; 339 369 get_header_ready : OUT std_logic := '0'; 370 board_id : IN std_logic_vector (63 DOWNTO 0); 340 371 trigger_counter_read : OUT std_logic := '0'; 341 372 trigger_counter_valid : IN std_logic ; 342 373 trigger_counter : IN std_logic_vector (31 DOWNTO 0) := (others => '0'); 374 get_ts_counter : OUT std_logic := '0'; 375 get_ts_counter_started : IN std_logic ; 376 get_ts_counter_ready : IN std_logic ; 377 timestamp_counter : IN std_logic_vector (47 DOWNTO 0); 343 378 header_board_id : OUT std_logic_vector (63 DOWNTO 0) := (others => '0'); 344 379 header_firmware_id : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 345 380 header_trigger_counter : OUT std_logic_vector (31 DOWNTO 0) := (others => '0'); 346 header_timestamp_counter : OUT std_logic_vector (47 DOWNTO 0) := (others => '0') 381 header_timestamp_counter : OUT std_logic_vector (47 DOWNTO 0) := (others => '0'); 382 header_current_state : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 383 current_cc_state : IN std_logic_vector (15 DOWNTO 0) 347 384 ); 348 385 END COMPONENT; … … 411 448 header_firmware_id : IN std_logic_vector (15 DOWNTO 0); 412 449 header_trigger_counter : IN std_logic_vector (31 DOWNTO 0); 413 header_timestamp_counter : IN std_logic_vector (47 DOWNTO 0) 450 header_timestamp_counter : IN std_logic_vector (47 DOWNTO 0); 451 header_current_state : IN std_logic_vector (15 DOWNTO 0); 452 -- 453 start_run : OUT std_logic := '0'; 454 start_run_ack : IN std_logic ; 455 start_run_param : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 456 start_run_num_events : OUT std_logic_vector (31 DOWNTO 0) := (others => '0'); 457 stop_run : OUT std_logic := '0'; 458 stop_run_ack : IN std_logic ; 459 crate_reset : OUT std_logic := '0'; 460 crate_reset_ack : IN std_logic ; 461 crate_reset_param : OUT std_logic_vector (15 DOWNTO 0) := (others => '0') 414 462 ); 415 463 END COMPONENT; … … 514 562 dd_ready => dd_ready_internal, 515 563 dd_addr => dd_addr1, 516 dd_data => dd_data 564 dd_data => dd_data, 565 get_ot_counter => get_ot_counter, 566 get_ot_counter_started => get_ot_counter_started, 567 get_ot_counter_ready => get_ot_counter_ready, 568 on_time_counter => on_time_counter, 569 temp_sensor_ready => temp_sensor_ready, 570 temp_sensor_array => temp_sensor_array 517 571 ); 518 572 U_8 : dram_control … … 580 634 get_header_started => get_header_started, 581 635 get_header_ready => get_header_ready, 636 board_id => board_id, 582 637 trigger_counter_read => trigger_counter_read, 583 638 trigger_counter_valid => trigger_counter_valid, 584 639 trigger_counter => trigger_counter, 640 get_ts_counter => get_ts_counter, 641 get_ts_counter_started => get_ts_counter_started, 642 get_ts_counter_ready => get_ts_counter_ready, 643 timestamp_counter => timestamp_counter, 585 644 header_board_id => header_board_id, 586 645 header_firmware_id => header_firmware_id, 587 646 header_trigger_counter => header_trigger_counter, 588 header_timestamp_counter => header_timestamp_counter 647 header_timestamp_counter => header_timestamp_counter, 648 header_current_state => header_current_state, 649 current_cc_state => current_cc_state 589 650 ); 590 651 U_0 : w5300_modul … … 646 707 header_firmware_id => header_firmware_id, 647 708 header_trigger_counter => header_trigger_counter, 648 header_timestamp_counter => header_timestamp_counter 709 header_timestamp_counter => header_timestamp_counter, 710 header_current_state => header_current_state, 711 start_run => start_run, 712 start_run_ack => start_run_ack, 713 start_run_param => start_run_param, 714 start_run_num_events => start_run_num_events, 715 stop_run => stop_run, 716 stop_run_ack => stop_run_ack, 717 crate_reset => crate_reset, 718 crate_reset_ack => crate_reset_ack, 719 crate_reset_param => crate_reset_param 649 720 ); 650 721 -
firmware/FTM/ethernet/header_modul_beha.vhd
r10366 r10441 12 12 USE ieee.std_logic_arith.all; 13 13 USE IEEE.STD_LOGIC_UNSIGNED.all; 14 --LIBRARY FACT_FTM_lib; 15 --USE FACT_FTM_lib.ftm_array_types.all; 16 --USE FACT_FTM_lib.ftm_constants.all; 14 17 15 library ftm_definitions; 18 16 USE ftm_definitions.ftm_array_types.all; … … 25 23 get_header_started : OUT std_logic := '0'; 26 24 get_header_ready : OUT std_logic := '0'; 25 board_id : IN std_logic_vector (63 DOWNTO 0); 27 26 trigger_counter_read : OUT std_logic := '0'; 28 27 trigger_counter_valid : IN std_logic; 29 28 trigger_counter : IN std_logic_vector (31 DOWNTO 0) := (others => '0'); 29 get_ts_counter : OUT std_logic := '0'; 30 get_ts_counter_started : IN std_logic; 31 get_ts_counter_ready : IN std_logic; 32 timestamp_counter : IN std_logic_vector (47 DOWNTO 0); 30 33 header_board_id : OUT std_logic_vector (63 DOWNTO 0) := (others => '0'); 31 34 header_firmware_id : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 32 35 header_trigger_counter : OUT std_logic_vector (31 DOWNTO 0) := (others => '0'); 33 header_timestamp_counter : OUT std_logic_vector (47 DOWNTO 0) := (others => '0') 36 header_timestamp_counter : OUT std_logic_vector (47 DOWNTO 0) := (others => '0'); 37 header_current_state : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 38 current_cc_state : IN std_logic_vector (15 DOWNTO 0) 34 39 ); 35 40 END ENTITY header_modul; … … 38 43 ARCHITECTURE beha OF header_modul IS 39 44 40 type state_header_proc_type is (HP_INIT, HP_CONFIG, HP_IDLE, HP_START, HP_TRG_CNT, HP_END); 45 type state_header_proc_type is (HP_INIT, HP_CONFIG, HP_IDLE, HP_START, HP_TRG_CNT, 46 HP_TS_CNT, HP_TS_CNT_END, HP_END); 41 47 42 48 signal state_header_proc : state_header_proc_type := HP_INIT; … … 47 53 if rising_edge (clk) then 48 54 case state_header_proc is 49 50 when HP_INIT =>51 state_header_proc <= HP_CONFIG;52 55 53 when HP_CONFIG => 54 state_header_proc <= HP_IDLE; 56 when HP_INIT => 57 state_header_proc <= HP_CONFIG; 58 59 when HP_CONFIG => 60 state_header_proc <= HP_IDLE; 61 62 when HP_IDLE => 63 if (get_header = '1') then 64 get_header_started <= '1'; 65 get_header_ready <= '0'; 66 state_header_proc <= HP_START; 67 end if; 68 69 when HP_START => 70 header_board_id <= board_id; 71 header_firmware_id <= X"00" & FIRMWARE_ID; 72 header_current_state <= current_cc_state; 73 74 trigger_counter_read <= '1'; 75 state_header_proc <= HP_TRG_CNT; 76 77 when HP_TRG_CNT => 78 trigger_counter_read <= '0'; 79 if (trigger_counter_valid = '1') then 80 header_trigger_counter <= trigger_counter; 81 get_ts_counter <= '1'; 82 state_header_proc <= HP_TS_CNT; 83 end if; 84 85 when HP_TS_CNT => 86 if (get_ts_counter_started = '1') then 87 get_ts_counter <= '0'; 88 state_header_proc <= HP_TS_CNT_END; 89 end if; 90 91 when HP_TS_CNT_END => 92 if (get_ts_counter_ready = '1') then 93 header_timestamp_counter <= timestamp_counter; 94 state_header_proc <= HP_END; 95 end if; 96 97 when HP_END => 98 if (get_header <= '0') then 99 get_header_started <= '0'; 100 get_header_ready <= '1'; 101 state_header_proc <= HP_IDLE; 102 end if; 55 103 56 when HP_IDLE =>57 if (get_header = '1') then58 get_header_started <= '1';59 get_header_ready <= '0';60 state_header_proc <= HP_START;61 end if;62 63 when HP_START =>64 header_board_id <= to_stdlogicvector (DNA_FOR_SIM);65 header_firmware_id <= X"00" & FIRMWARE_ID;66 header_timestamp_counter <= X"333322221111";67 68 trigger_counter_read <= '1';69 state_header_proc <= HP_TRG_CNT;70 71 when HP_TRG_CNT =>72 trigger_counter_read <= '0';73 if (trigger_counter_valid = '1') then74 header_trigger_counter <= trigger_counter;75 state_header_proc <= HP_END;76 end if;77 78 when HP_END =>79 if (get_header <= '0') then80 get_header_started <= '0';81 get_header_ready <= '1';82 state_header_proc <= HP_IDLE;83 end if;84 85 104 end case; 86 105 end if; -
firmware/FTM/ethernet/w5300_modul.vhd
r10366 r10441 18 18 -- 19 19 ---------------------------------------------------------------------------------- 20 20 -- hds interface_start 21 21 LIBRARY IEEE; 22 22 USE IEEE.STD_LOGIC_1164.all; … … 24 24 USE IEEE.STD_LOGIC_UNSIGNED.all; 25 25 26 --LIBRARY FACT_FTM_lib;27 --USE FACT_FTM_lib.ftm_array_types.all;28 --USE FACT_FTM_lib.ftm_constants.all;29 26 library ftm_definitions; 30 27 USE ftm_definitions.ftm_array_types.all; … … 100 97 header_firmware_id : IN std_logic_vector (15 DOWNTO 0); 101 98 header_trigger_counter : IN std_logic_vector (31 DOWNTO 0); 102 header_timestamp_counter : IN std_logic_vector (47 DOWNTO 0) 103 99 header_timestamp_counter : IN std_logic_vector (47 DOWNTO 0); 100 header_current_state : IN std_logic_vector (15 DOWNTO 0); 101 -- 102 start_run : OUT std_logic := '0'; 103 start_run_ack : IN std_logic; 104 start_run_param : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 105 start_run_num_events : OUT std_logic_vector (31 DOWNTO 0) := (others => '0'); 106 stop_run : OUT std_logic := '0'; 107 stop_run_ack : IN std_logic; 108 crate_reset : OUT std_logic := '0'; 109 crate_reset_ack : IN std_logic; 110 crate_reset_param : OUT std_logic_vector (15 DOWNTO 0) := (others => '0') 104 111 ); 105 112 … … 113 120 READ_DATA, WRITE_TO_SD_ADDR, READ_FTU_ERROR, READ_FROM_SD_ADDR, READ_FROM_DD_ADDR, READ_FROM_FL_ADDR, READ_FROM_HEADER_MODUL); 114 121 type state_write_type is (WR_START, WR_LENGTH, WR_01, WR_02, WR_03, WR_04, WR_05, WR_06, WR_07, WR_08, 115 WR_ GET_HEADER, WR_GET_HEADER_WAIT, WR_FIFO_DATA, WR_FIFO_DATA_01, WR_FIFO_HEADER, WR_FIFO_HEADER_01);122 WR_WRITE_START_DEL, WR_GET_HEADER, WR_GET_HEADER_WAIT, WR_FIFO_DATA, WR_FIFO_DATA_01, WR_FIFO_HEADER, WR_FIFO_HEADER_01, WR_WRITE_END_DEL); 116 123 type state_interrupt_1_type is (IR1_01, IR1_02, IR1_03, IR1_04); 117 124 type state_interrupt_2_type is (IR2_01, IR2_02, IR2_03, IR2_04, IR2_05, IR2_06); 118 type state_read_data_type is (RD_1, RD_2, RD_3, RD_4, RD_5, RD_CMD, RD_CMD_PARSE, RD_PING, RD_WRITE_SD_ADDR, RD_READ_SD_ADDR, RD_READ_SD_BLOCK, RD_READ_DD_BLOCK, RD_WRITE_SD_BLOCK, RD_ END);125 type state_read_data_type is (RD_1, RD_2, RD_3, RD_4, RD_5, RD_CMD, RD_CMD_PARSE, RD_PING, RD_WRITE_SD_ADDR, RD_READ_SD_ADDR, RD_READ_SD_BLOCK, RD_READ_DD_BLOCK, RD_WRITE_SD_BLOCK, RD_X_EVNTS,RD_END); 119 126 type state_write_sd_type is (WRITE_SD_START, WRITE_SD_WAIT, WRITE_SD_END); 120 127 type state_read_sd_type is (READ_SD_START, READ_SD_WAIT, READ_SD_END); … … 163 170 164 171 signal next_packet_data_cnt : integer range 0 to 4095 := 0; 165 signal rx_packets_cnt : std_logic_vector (15 downto 0) ;172 signal rx_packets_cnt : std_logic_vector (15 downto 0) := X"0000"; 166 173 signal new_config_flag : std_logic := '0'; 167 174 … … 182 189 signal local_sd_addr : std_logic_vector (11 downto 0); 183 190 signal local_sd_data : std_logic_vector (15 downto 0); 191 192 signal data_package_type : std_logic_vector (15 downto 0) := X"0000"; 193 signal data_package_length : std_logic_vector (15 downto 0) := X"0000"; 184 194 185 195 … … 574 584 when SFE_START => 575 585 next_state <= SEND_FTU_ERROR; 586 data_package_type <= FTM_PACKAGE_TYPE_FTU_ERR; 587 data_package_length <= FTU_ERROR_LENGTH + 1; -- +1 := package end 576 588 read_addr_state <= READ_FTU_ERROR; 577 589 local_sd_addr <= X"000"; … … 626 638 627 639 when RD_END => 640 if (new_config_flag = '1') then 641 new_config_flag <= '0'; 642 next_state <= CONFIG; 643 else 644 next_state <= MAIN; 645 end if; 628 646 if (internal_cmd = '0') then 629 647 par_addr <= W5300_S0_CR; … … 632 650 else 633 651 internal_cmd <= '0'; 634 end if; 635 if (new_config_flag = '1') then 636 new_config_flag <= '0'; 637 next_state <= CONFIG; 638 else 639 next_state <= MAIN; 652 state_init <= MAIN; 640 653 end if; 641 654 … … 670 683 led_int <= NOT led_int; 671 684 state_read_data <= RD_5; 685 686 when CMD_START => 687 case cmd_array (2) is 688 -- start "normal" run 689 when PAR_START_RUN => 690 start_run <= '1'; 691 start_run_param <= cmd_array (2); 692 if (start_run_ack = '1') then 693 start_run <= '0'; 694 state_read_data <= RD_5; 695 end if; 696 -- start run an take X events 697 when PAR_START_X_EVNTS => 698 next_state_read_data <= RD_X_EVNTS; 699 state_read_data <= RD_5; 700 when others => 701 state_read_data <= RD_5; 702 end case; 703 704 when CMD_STOP => 705 stop_run <= '1'; 706 if (stop_run_ack = '1') then 707 stop_run <= '0'; 708 state_read_data <= RD_5; 709 end if; 710 711 when CMD_CRESET => 712 crate_reset <= '1'; 713 crate_reset_param <= cmd_array (2); 714 if (crate_reset_ack = '1') then 715 crate_reset <= '0'; 716 state_read_data <= RD_5; 717 end if; 672 718 673 719 when CMD_WRITE => … … 739 785 when PING_WRITE_LIST => 740 786 state_read_data <= RD_5; 787 data_package_type <= FTM_PACKAGE_TYPE_FTU_LIST; 788 data_package_length <= FL_BLOCK_SIZE + 1; -- +1 := package end 741 789 read_addr_state <= READ_FROM_FL_ADDR; 742 790 local_sd_addr <= X"000"; --start at address 0x000 … … 767 815 when READ_DD_BLOCK_WRITE => 768 816 if (dd_write_general_ready = '1') then 817 data_package_type <= FTM_PACKAGE_TYPE_DD; 818 data_package_length <= DD_BLOCK_SIZE + 1; -- +1 := package end 769 819 read_addr_state <= READ_FROM_DD_ADDR; 770 820 local_sd_addr <= X"000"; -- start at address 0x000 … … 796 846 -- read static data block and write it to ethernet 797 847 when RD_READ_SD_BLOCK => 848 data_package_type <= FTM_PACKAGE_TYPE_SD; 849 data_package_length <= SD_BLOCK_SIZE + 1; -- +1 := package end 798 850 state_read_data <= RD_5; 799 851 read_addr_state <= READ_FROM_SD_ADDR; … … 806 858 -- read from address in static data ram and write data to ethernet 807 859 when RD_READ_SD_ADDR => 860 data_package_type <= FTM_PACKAGE_TYPE_SD_WORD; 861 data_package_length <= SD_SINGLE_WORD_SIZE + 1; -- +1 := package end 808 862 state_read_data <= RD_5; 809 863 read_addr_state <= READ_FROM_SD_ADDR; … … 841 895 state_init <= WRITE_TO_SD_ADDR; 842 896 end if; 897 898 -- read X events 899 when RD_X_EVNTS => 900 if (next_packet_data_cnt = 0) then 901 start_run_num_events (31 downto 16) <= data_read; 902 else 903 start_run_num_events (15 downto 0) <= data_read; 904 start_run_param <= cmd_array (2); 905 start_run <= '1'; 906 if (start_run_ack = '1') then 907 start_run <= '0'; 908 next_packet_data_cnt <= 0; 909 next_state_read_data <= RD_CMD; 910 state_read_data <= RD_5; 911 end if; 912 end if; 843 913 844 914 end case; -- state_read_data … … 860 930 case header_cnt is 861 931 when X"00" => 932 local_sd_data <= data_package_type; 933 when X"01" => 934 local_sd_data <= data_package_length; 935 when X"02" => 936 local_sd_data <= header_current_state; 937 when X"03" => 862 938 local_sd_data <= header_board_id (63 DOWNTO 48); 863 when X"0 1" =>939 when X"04" => 864 940 local_sd_data <= header_board_id (47 DOWNTO 32); 865 when X"0 2" =>941 when X"05" => 866 942 local_sd_data <= header_board_id (31 DOWNTO 16); 867 when X"0 3" =>943 when X"06" => 868 944 local_sd_data <= header_board_id (15 DOWNTO 0); 869 when X"0 4" =>945 when X"07" => 870 946 local_sd_data <= header_firmware_id; 871 when X"0 5" =>947 when X"08" => 872 948 local_sd_data <= header_trigger_counter (31 DOWNTO 16); 873 when X"0 6" =>949 when X"09" => 874 950 local_sd_data <= header_trigger_counter (15 DOWNTO 0); 875 when X"07" => 951 when X"0A" => 952 local_sd_data <= X"0000"; 953 when X"0B" => 876 954 local_sd_data <= header_timestamp_counter (47 DOWNTO 32); 877 when X"0 8" =>955 when X"0C" => 878 956 local_sd_data <= header_timestamp_counter (31 DOWNTO 16); 879 when X"0 9" =>957 when X"0D" => 880 958 local_sd_data <= header_timestamp_counter (15 DOWNTO 0); 881 when X"0A" =>882 local_sd_data <= X"FFFF"; -- spare883 959 when others => 884 960 null; … … 981 1057 local_socket_nr <= "000"; 982 1058 next_state_tmp <= next_state; 983 write_length_bytes <= (FTM_HEADER_LENGTH + local_write_length (15 downto 0)) & '0'; -- shift left (*2) 1059 -- Write Length: 2 := START and END of package 1060 write_length_bytes <= (2 + FTM_HEADER_LENGTH + local_write_length (15 downto 0)) & '0'; -- shift left (*2) 984 1061 data_cnt <= 0; 985 1062 header_cnt <= X"00"; … … 1004 1081 state_write <= WR_01; 1005 1082 else 1006 state_write <= WR_GET_HEADER; 1007 end if; 1083 state_write <= WR_WRITE_START_DEL; 1084 end if; 1085 1086 -- write package start delimiter 1087 when WR_WRITE_START_DEL => 1088 par_addr <= W5300_S0_TX_FIFOR + local_socket_nr * W5300_S_INC; 1089 par_data <= FTM_PACKAGE_START; 1090 state_init <= WRITE_REG; 1091 next_state <= WRITE_DATA; 1092 state_write <= WR_GET_HEADER; 1008 1093 1009 1094 -- get header data … … 1053 1138 state_write <= WR_FIFO_DATA; 1054 1139 else 1055 state_write <= WR_05; 1056 end if; 1140 state_write <= WR_WRITE_END_DEL; 1141 end if; 1142 1143 -- write package end delimiter 1144 when WR_WRITE_END_DEL => 1145 par_addr <= W5300_S0_TX_FIFOR + local_socket_nr * W5300_S_INC; 1146 par_data <= FTM_PACKAGE_END; 1147 state_init <= WRITE_REG; 1148 next_state <= WRITE_DATA; 1149 state_write <= WR_05; 1057 1150 1058 1151 -- Send FIFO … … 1137 1230 1138 1231 end Behavioral; 1232
Note:
See TracChangeset
for help on using the changeset viewer.