Changeset 10418 for firmware/FTM/ftu_control
- Timestamp:
- 04/20/11 12:37:39 (14 years ago)
- Location:
- firmware/FTM/ftu_control
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/FTM/ftu_control/FTM_ftu_control.vhd
r10328 r10418 74 74 ftu_active_cr2 : in std_logic_vector (15 downto 0); 75 75 ftu_active_cr3 : in std_logic_vector (15 downto 0); 76 77 --error message interface to ethernet control 78 ftu_error_calls : out std_logic_vector (15 DOWNTO 0) := (others => '0'); 79 ftu_error_data : out std_logic_vector ((FTU_RS485_BLOCK_WIDTH - 1) downto 0) := (others => '0'); 80 ftu_error_send : out std_logic := '0'; 81 ftu_error_send_ack : in std_logic; 82 ftu_error_send_ready : in std_logic; 76 83 77 84 -- communication with static (config) RAM … … 146 153 signal FTU_enable_array_sig : FTU_enable_array_type; -- initialized in interpreter 147 154 signal FTU_rate_array_sig : FTU_rate_array_type; -- initialized in interpreter 155 signal FTU_overflow_sig : std_logic_vector(7 downto 0); -- initialized in interpreter 148 156 signal FTU_prescaling_sig : std_logic_vector(7 downto 0); -- initialized in interpreter 149 157 signal FTU_crc_error_cnt_sig : std_logic_vector(7 downto 0); -- initialized in interpreter … … 199 207 signal enable_crc_from_interpreter_sig : std_logic; 200 208 signal crc_data_from_FSM_sig : std_logic_vector (FTU_RS485_BLOCK_WIDTH - 9 downto 0) := (others => '0'); 209 signal crc_data_from_FSM_sig_cp : std_logic_vector (FTU_RS485_BLOCK_WIDTH - 9 downto 0) := (others => '0'); 201 210 signal crc_sig : std_logic_vector(CRC_POLYNOMIAL'length - 1 downto 0); 202 211 signal crc_sig_inv : std_logic_vector(CRC_POLYNOMIAL'length - 1 downto 0); … … 211 220 signal FTU_list_reg_cnt : integer range 0 to NO_OF_FTU_LIST_REG := 0; 212 221 signal FTU_list_header_cnt : integer range 0 to FTU_LIST_RAM_OFFSET := 0; 213 222 signal DD_RAM_reg_cnt : integer range 0 to NO_OF_DD_RAM_REG := 0; 223 214 224 -- counter to define timeout and number of retries 215 225 signal timeout_cnt : integer range 0 to FTU_RS485_TIMEOUT := 0; 216 226 signal retry_cnt : integer range 0 to FTU_RS485_NO_OF_RETRY := 0; 227 228 --Zwischenrechnungen 229 signal FTU_cnt_offset_sig : integer range 0 to (NO_OF_DD_RAM_REG * NO_OF_FTUS_PER_CRATE) := 0; 230 signal crate_cnt_offset_sig : integer range 0 to (NO_OF_CRATES * NO_OF_FTUS_PER_CRATE * NO_OF_DD_RAM_REG) := 0; 217 231 218 232 component FTM_ftu_rs485_interface … … 260 274 FTU_enable_array : OUT FTU_enable_array_type; 261 275 FTU_rate_array : OUT FTU_rate_array_type; 276 FTU_overflow : OUT std_logic_vector(7 downto 0); 262 277 FTU_prescaling : OUT std_logic_vector(7 downto 0); 263 278 FTU_crc_error_cnt : OUT std_logic_vector(7 downto 0); … … 285 300 type FTM_ftu_rs485_control_StateType is (INIT, IDLE, ACTIVE_LIST, READ_CONFIG, TRANSMIT_CONFIG, 286 301 PING, PING_END, FTU_LIST, 302 SEND_ERROR_1, SEND_ERROR_2, 287 303 RATES, RATES_1, RATES_2, RATES_3, 304 DD_RAM, DD_RAM_1, DD_RAM_2, DD_RAM_3, 288 305 READ_CONFIG_1, READ_CONFIG_2, READ_CONFIG_3, 289 306 TRANSMIT_CONFIG_1, TRANSMIT_CONFIG_2, TRANSMIT_CONFIG_3, … … 291 308 FTU_LIST_1, FTU_LIST_2, FTU_LIST_3); 292 309 signal FTM_ftu_rs485_control_State : FTM_ftu_rs485_control_StateType; 310 signal after_error_State : FTM_ftu_rs485_control_StateType; 293 311 294 312 begin 295 313 296 Inst_FTM_f TU_rs485_interface_0 : FTM_ftu_rs485_interface -- crate 0314 Inst_FTM_ftu_rs485_interface_0 : FTM_ftu_rs485_interface -- crate 0 297 315 port map( 298 316 clk => clk_50MHz, … … 311 329 ); 312 330 313 Inst_FTM_f TU_rs485_interface_1 : FTM_ftu_rs485_interface -- crate 1331 Inst_FTM_ftu_rs485_interface_1 : FTM_ftu_rs485_interface -- crate 1 314 332 port map( 315 333 clk => clk_50MHz, … … 328 346 ); 329 347 330 Inst_FTM_f TU_rs485_interface_2 : FTM_ftu_rs485_interface -- crate 2348 Inst_FTM_ftu_rs485_interface_2 : FTM_ftu_rs485_interface -- crate 2 331 349 port map( 332 350 clk => clk_50MHz, … … 345 363 ); 346 364 347 Inst_FTM_f TU_rs485_interface_3 : FTM_ftu_rs485_interface -- crate 3365 Inst_FTM_ftu_rs485_interface_3 : FTM_ftu_rs485_interface -- crate 3 348 366 port map( 349 367 clk => clk_50MHz, … … 387 405 FTU_enable_array => FTU_enable_array_sig, 388 406 FTU_rate_array => FTU_rate_array_sig, 407 FTU_overflow => FTU_overflow_sig, 389 408 FTU_prescaling => FTU_prescaling_sig, 390 409 FTU_crc_error_cnt => FTU_crc_error_cnt_sig, … … 602 621 when TRANSMIT_CONFIG_1 => -- wait one cycle for CRC calculation 603 622 enable_crc_from_FSM_sig <= '0'; 623 crc_data_from_FSM_sig_cp <= crc_data_from_FSM_sig; 604 624 FTM_ftu_rs485_control_State <= TRANSMIT_CONFIG_2; 605 625 … … 614 634 elsif (frame_cnt = 27) then 615 635 frame_cnt <= frame_cnt + 1; 636 ftu_error_data <= crc_sig & crc_data_from_FSM_sig_cp; 616 637 tx_data_sig <= crc_sig; 617 638 tx_start_sig <= '1'; … … 633 654 retry_cnt <= 0; 634 655 sel_crc_input_source_sig <= '0'; 635 FTM_ftu_rs485_control_State <= TRANSMIT_CONFIG; 656 if (retry_cnt = 0) then -- no errors 657 FTM_ftu_rs485_control_State <= TRANSMIT_CONFIG; 658 else -- send error message and move to next command; 659 ftu_error_calls <= conv_std_logic_vector((retry_cnt + 1), 16); 660 after_error_State <= TRANSMIT_CONFIG; 661 FTM_ftu_rs485_control_State <= SEND_ERROR_1; 662 end if; 636 663 else 637 664 if (timeout_cnt < FTU_RS485_TIMEOUT) then … … 649 676 else 650 677 retry_cnt <= 0; 651 FTU_command_cnt <= FTU_command_cnt; -- move to next command; 652 FTM_ftu_rs485_control_State <= TRANSMIT_CONFIG; 678 FTU_command_cnt <= FTU_command_cnt; -- send error message and move to next command 679 ftu_error_calls <= (others => '0'); 680 after_error_State <= TRANSMIT_CONFIG; 681 FTM_ftu_rs485_control_State <= SEND_ERROR_1; 653 682 end if; 654 683 end if; 655 684 end if; 656 685 686 when SEND_ERROR_1 => -- send an error message 687 ftu_error_send <= '1'; 688 if (ftu_error_send_ack = '1') then 689 ftu_error_send <= '0'; 690 FTM_ftu_rs485_control_State <= SEND_ERROR_2; 691 end if; 692 693 when SEND_ERROR_2 => 694 if (ftu_error_send_ready = '1') then 695 FTM_ftu_rs485_control_State <= after_error_state; 696 end if; 697 657 698 when PING => -- ping all FTUs 658 699 rec_reset_sig <= '0'; … … 759 800 write_FTUlist_RAM <= '1'; 760 801 addr_FTUlist_RAM <= conv_std_logic_vector(FTU_LIST_RAM_OFFSET + 761 (FTU_cnt - 1)* NO_OF_FTU_LIST_REG + 802 (crate_cnt * NO_OF_FTUS_PER_CRATE * NO_OF_FTU_LIST_REG) + 803 ((FTU_cnt - 1) * NO_OF_FTU_LIST_REG) + 762 804 (FTU_list_reg_cnt - 1), FTU_LIST_RAM_ADDR_WIDTH); 763 805 if (retry_cnt < FTU_RS485_NO_OF_RETRY) then … … 871 913 when RATES_1 => -- wait one cycle for CRC calculation 872 914 enable_crc_from_FSM_sig <= '0'; 915 crc_data_from_FSM_sig_cp <= crc_data_from_FSM_sig; 873 916 FTM_ftu_rs485_control_State <= RATES_2; 874 917 … … 883 926 elsif (frame_cnt = 27) then 884 927 frame_cnt <= frame_cnt + 1; 928 ftu_error_data <= crc_sig & crc_data_from_FSM_sig_cp; 885 929 tx_data_sig <= crc_sig; 886 930 tx_start_sig <= '1'; … … 901 945 timeout_cnt <= 0; 902 946 sel_crc_input_source_sig <= '0'; 903 FTM_ftu_rs485_control_State <= RATES; 947 --FTM_ftu_rs485_control_State <= RATES; 948 if (retry_cnt = 0) then -- no errors 949 FTM_ftu_rs485_control_State <= DD_RAM; 950 else -- send error message and move to next command; 951 ftu_error_calls <= conv_std_logic_vector((retry_cnt + 1), 16); 952 after_error_State <= DD_RAM; 953 FTM_ftu_rs485_control_State <= SEND_ERROR_1; 954 end if; 904 955 else 905 956 if (timeout_cnt < FTU_RS485_TIMEOUT) then … … 916 967 FTM_ftu_rs485_control_State <= RATES; 917 968 else 918 retry_cnt <= 0;969 --retry_cnt <= 0; 919 970 FTU_cnt <= FTU_cnt; -- move on 920 FTM_ftu_rs485_control_State <= RATES; 971 ftu_error_calls <= (others => '0'); 972 after_error_State <= DD_RAM; 973 FTM_ftu_rs485_control_State <= SEND_ERROR_1; 921 974 end if; 922 975 end if; 976 end if; 977 978 when DD_RAM => -- write rates of actual FTU to DD RAM 979 rec_reset_sig <= '0'; 980 if (DD_RAM_reg_cnt < NO_OF_DD_RAM_REG) then 981 DD_RAM_reg_cnt <= DD_RAM_reg_cnt + 1; 982 FTU_cnt_offset_sig <= ((FTU_cnt - 1) * NO_OF_DD_RAM_REG); 983 crate_cnt_offset_sig <= (crate_cnt * NO_OF_FTUS_PER_CRATE * NO_OF_DD_RAM_REG); 984 FTM_ftu_rs485_control_State <= DD_RAM_1; 985 else 986 DD_RAM_reg_cnt <= 0; 987 retry_cnt <= 0; 988 FTM_ftu_rs485_control_State <= RATES; 989 end if; 990 991 when DD_RAM_1 => 992 if (dynamic_RAM_busy = '0') then 993 write_dynamic_RAM <= '1'; 994 addr_dynamic_RAM <= conv_std_logic_vector(DD_BLOCK_SIZE_GENERAL + 995 crate_cnt_offset_sig + 996 --(crate_cnt * NO_OF_FTUS_PER_CRATE * NO_OF_DD_RAM_REG) + 997 --((FTU_cnt - 1) * NO_OF_DD_RAM_REG) + 998 FTU_cnt_offset_sig + 999 (DD_RAM_reg_cnt - 1), DYNAMIC_RAM_ADDR_WIDTH); 1000 if ( (retry_cnt < FTU_RS485_NO_OF_RETRY) 1001 and (FTU_cnt_offset_sig < (NO_OF_FTUS_PER_CRATE * NO_OF_DD_RAM_REG)) 1002 and (crate_cnt_offset_sig < (NO_OF_CRATES * NO_OF_FTUS_PER_CRATE * NO_OF_DD_RAM_REG)) ) then 1003 if ((DD_RAM_reg_cnt - 1) = 0) then 1004 data_dynamic_RAM <= FTU_rate_array_sig(0)(31 downto 16); 1005 elsif ((DD_RAM_reg_cnt - 1) = 1) then 1006 data_dynamic_RAM <= FTU_rate_array_sig(0)(15 downto 0); 1007 elsif ((DD_RAM_reg_cnt - 1) = 2) then 1008 data_dynamic_RAM <= FTU_rate_array_sig(1)(31 downto 16); 1009 elsif ((DD_RAM_reg_cnt - 1) = 3) then 1010 data_dynamic_RAM <= FTU_rate_array_sig(1)(15 downto 0); 1011 elsif ((DD_RAM_reg_cnt - 1) = 4) then 1012 data_dynamic_RAM <= FTU_rate_array_sig(2)(31 downto 16); 1013 elsif ((DD_RAM_reg_cnt - 1) = 5) then 1014 data_dynamic_RAM <= FTU_rate_array_sig(2)(15 downto 0); 1015 elsif ((DD_RAM_reg_cnt - 1) = 6) then 1016 data_dynamic_RAM <= FTU_rate_array_sig(3)(31 downto 16); 1017 elsif ((DD_RAM_reg_cnt - 1) = 7) then 1018 data_dynamic_RAM <= FTU_rate_array_sig(3)(15 downto 0); 1019 elsif ((DD_RAM_reg_cnt - 1) = 8) then 1020 data_dynamic_RAM <= FTU_rate_array_sig(4)(31 downto 16); 1021 elsif ((DD_RAM_reg_cnt - 1) = 9) then 1022 data_dynamic_RAM <= FTU_rate_array_sig(4)(15 downto 0); 1023 elsif ((DD_RAM_reg_cnt - 1) = 10) then 1024 data_dynamic_RAM <= "00000000" & FTU_overflow_sig; 1025 elsif ((DD_RAM_reg_cnt - 1) = 11) then 1026 data_dynamic_RAM <= "00000000" & FTU_crc_error_cnt_sig; 1027 -- elsif ((DD_RAM_reg_cnt - 1) = 10) then 1028 -- data_dynamic_RAM <= "0000" & conv_std_logic_vector(DD_BLOCK_SIZE_GENERAL + 1029 -- --((FTU_cnt - 1) * NO_OF_DD_RAM_REG) + 1030 -- FTU_cnt_offset_sig + 1031 -- (DD_RAM_reg_cnt - 1), DYNAMIC_RAM_ADDR_WIDTH); 1032 -- elsif ((DD_RAM_reg_cnt - 1) = 11) then 1033 -- --data_dynamic_RAM <= "0000" & conv_std_logic_vector(FTU_cnt_offset_sig, DYNAMIC_RAM_ADDR_WIDTH); 1034 -- data_dynamic_RAM <= "0000" & conv_std_logic_vector(DD_BLOCK_SIZE_GENERAL + 1035 -- --((FTU_cnt - 1) * NO_OF_DD_RAM_REG) + 1036 -- FTU_cnt_offset_sig + 1037 -- (DD_RAM_reg_cnt - 1), DYNAMIC_RAM_ADDR_WIDTH); 1038 end if; 1039 else 1040 data_dynamic_RAM <= (others => '0'); 1041 end if; 1042 FTM_ftu_rs485_control_State <= DD_RAM_2; 1043 end if; 1044 1045 when DD_RAM_2 => 1046 if (dynamic_RAM_started = '1') then 1047 write_dynamic_RAM <= '0'; 1048 FTM_ftu_rs485_control_State <= DD_RAM_3; 1049 end if; 1050 1051 when DD_RAM_3 => 1052 if (dynamic_RAM_ready = '1') then 1053 FTM_ftu_rs485_control_State <= DD_RAM; 923 1054 end if; 924 1055 -
firmware/FTM/ftu_control/FTM_ftu_rs485_interpreter.vhd
r10232 r10418 47 47 FTU_enable_array : OUT FTU_enable_array_type := ((others => '0'), (others => '0'), (others => '0'), (others => '0')); 48 48 FTU_rate_array : OUT FTU_rate_array_type := ((others => '0'), (others => '0'), (others => '0'), (others => '0'), (others => '0')); 49 FTU_overflow : OUT std_logic_vector(7 downto 0) := (others => '0'); 49 50 FTU_prescaling : OUT std_logic_vector(7 downto 0) := (others => '0'); 50 51 FTU_crc_error_cnt : OUT std_logic_vector(7 downto 0) := (others => '0'); … … 144 145 data_block(199 downto 168) 145 146 ); 147 FTU_overflow <= data_block(207 downto 200); 146 148 FTU_crc_error_cnt <= data_block(215 downto 208); 147 149 FTM_ftu_rs485_interpreter_State <= WAIT_FOR_DATA; … … 165 167 elsif (data_block(39 downto 32) = "00000111") then -- read counter mode 166 168 FTU_prescaling <= data_block(47 downto 40); 169 FTU_overflow <= data_block(55 downto 48); 167 170 FTM_ftu_rs485_interpreter_State <= WAIT_FOR_DATA; 168 171 elsif (data_block(39 downto 32) = "00000101") then -- ping pong
Note:
See TracChangeset
for help on using the changeset viewer.