Ignore:
Timestamp:
03/04/11 17:42:32 (14 years ago)
Author:
weitzel
Message:
first version of FTM firmware including ethernet and FTU interface; still some debugging needed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • firmware/FTM/ftu_control/FTM_ftu_control.vhd

    r10175 r10227  
    6969    ping_all_done      : out std_logic := '0';
    7070
     71    -- active FTU lists
     72    ftu_active_cr0 : in std_logic_vector (15 downto 0);
     73    ftu_active_cr1 : in std_logic_vector (15 downto 0);
     74    ftu_active_cr2 : in std_logic_vector (15 downto 0);
     75    ftu_active_cr3 : in std_logic_vector (15 downto 0);
     76   
    7177    -- communication with static (config) RAM
    7278    -- this RAM is only read by FTU_control
     
    123129
    124130  -- global signals after multiplexer
    125   signal rx_en_sig    : std_logic;
    126   signal tx_en_sig    : std_logic;
    127   signal rx_valid_sig : std_logic;
    128   signal tx_busy_sig  : std_logic;
    129   signal tx_start_sig : std_logic;
    130   signal tx_data_sig  : std_logic_vector (7 DOWNTO 0);
     131  signal rx_en_sig    : std_logic := '0';
     132  signal tx_en_sig    : std_logic := '0';
     133  signal rx_valid_sig : std_logic := '0';
     134  signal tx_busy_sig  : std_logic := '0';
     135  signal tx_start_sig : std_logic := '0';
     136  signal tx_data_sig  : std_logic_vector (7 DOWNTO 0) := (others => '0');
    131137 
    132138  -- signals for interpreter of FTU communication
     
    190196
    191197  -- various loop counters
    192   signal active_FTU_list_cnt : integer range 0 to NO_OF_CRATES := 0;
     198  --signal active_FTU_list_cnt : integer range 0 to NO_OF_CRATES := 0;
    193199  signal crate_cnt           : integer range 0 to NO_OF_CRATES := 0;
    194200  signal FTU_cnt             : integer range 0 to NO_OF_FTUS_PER_CRATE := 0;
     
    272278  type FTM_ftu_rs485_control_StateType is (INIT, IDLE, ACTIVE_LIST, READ_CONFIG, TRANSMIT_CONFIG,
    273279                                           PING, PING_END, FTU_LIST, RATES,
    274                                            ACTIVE_LIST_1, ACTIVE_LIST_2, ACTIVE_LIST_3,
    275280                                           READ_CONFIG_1, READ_CONFIG_2, READ_CONFIG_3,
    276281                                           TRANSMIT_CONFIG_1, TRANSMIT_CONFIG_2, TRANSMIT_CONFIG_3,
     
    435440          end if;
    436441
    437         when ACTIVE_LIST =>  -- loop over 4 crates to get active FTU list
    438           if (active_FTU_list_cnt < NO_OF_CRATES) then
    439             active_FTU_list_cnt <= active_FTU_list_cnt + 1;
    440             FTM_ftu_rs485_control_State <= ACTIVE_LIST_1;
    441           else
    442             active_FTU_list_cnt <= 0;
    443             FTM_ftu_rs485_control_State <= READ_CONFIG;
    444           end if;
    445 
    446         when ACTIVE_LIST_1 =>
    447           if (static_RAM_busy = '0') then
    448             read_static_RAM <= '1';
    449             addr_static_RAM <= conv_std_logic_vector(STATIC_RAM_ACT_FTU_OFFSET + (active_FTU_list_cnt - 1), STATIC_RAM_ADDR_WIDTH);
    450             FTM_ftu_rs485_control_State <= ACTIVE_LIST_2;
    451           end if;
     442        when ACTIVE_LIST =>  -- copy active FTU list from inputs to array
     443          active_FTU_array_sig(0) <= ftu_active_cr0;
     444          active_FTU_array_sig(1) <= ftu_active_cr1;
     445          active_FTU_array_sig(2) <= ftu_active_cr2;
     446          active_FTU_array_sig(3) <= ftu_active_cr3;
     447          FTM_ftu_rs485_control_State <= READ_CONFIG;
     448         
     449--        when ACTIVE_LIST =>  -- loop over 4 crates to get active FTU list
     450--          if (active_FTU_list_cnt < NO_OF_CRATES) then
     451--            active_FTU_list_cnt <= active_FTU_list_cnt + 1;
     452--            FTM_ftu_rs485_control_State <= ACTIVE_LIST_1;
     453--          else
     454--            active_FTU_list_cnt <= 0;
     455--            FTM_ftu_rs485_control_State <= READ_CONFIG;
     456--          end if;
     457
     458--        when ACTIVE_LIST_1 =>
     459--          if (static_RAM_busy = '0') then
     460--            read_static_RAM <= '1';
     461--            addr_static_RAM <= conv_std_logic_vector(STATIC_RAM_ACT_FTU_OFFSET + (active_FTU_list_cnt - 1), STATIC_RAM_ADDR_WIDTH);
     462--            FTM_ftu_rs485_control_State <= ACTIVE_LIST_2;
     463--          end if;
    452464           
    453         when ACTIVE_LIST_2 =>
    454           if (static_RAM_started = '1') then
    455             FTM_ftu_rs485_control_State <= ACTIVE_LIST_3;
    456           end if;
     465--        when ACTIVE_LIST_2 =>
     466--          if (static_RAM_started = '1') then
     467--            FTM_ftu_rs485_control_State <= ACTIVE_LIST_3;
     468--          end if;
    457469           
    458         when ACTIVE_LIST_3 =>
    459           if (static_RAM_ready = '1') then
    460             active_FTU_array_sig(active_FTU_list_cnt - 1) <= data_static_RAM;
    461             read_static_RAM <= '0';
    462             FTM_ftu_rs485_control_State <= ACTIVE_LIST;
    463           end if;
     470--        when ACTIVE_LIST_3 =>
     471--          if (static_RAM_ready = '1') then
     472--            active_FTU_array_sig(active_FTU_list_cnt - 1) <= data_static_RAM;
     473--            read_static_RAM <= '0';
     474--            FTM_ftu_rs485_control_State <= ACTIVE_LIST;
     475--          end if;
    464476                   
    465477        when READ_CONFIG =>  -- read configuration of FTUs (one by one)
     
    535547                                     & FTU_dac_array_RAM_sig(0)(15 downto 8) & FTU_dac_array_RAM_sig(0)(7 downto 0)
    536548                                     & "00000000" & FIRMWARE_ID & FTM_ADDRESS
    537                                      & "00" & conv_std_logic_vector(FTU_cnt,4) & conv_std_logic_vector(crate_cnt,2)
     549                                     & "00" & conv_std_logic_vector((FTU_cnt - 1),4) & conv_std_logic_vector(crate_cnt,2)
    538550                                     & FTU_RS485_START_DELIM;
    539             FTU_brd_add_sig <= conv_std_logic_vector(FTU_cnt,4) & conv_std_logic_vector(crate_cnt,2);
     551            FTU_brd_add_sig <= conv_std_logic_vector((FTU_cnt - 1),4) & conv_std_logic_vector(crate_cnt,2);
    540552            FTU_command_sig <= "00000000";
    541553            FTM_ftu_rs485_control_State <= TRANSMIT_CONFIG_1;
     
    552564                                     & FTU_enable_array_RAM_sig(0)(15 downto 8) & FTU_enable_array_RAM_sig(0)(7 downto 0)
    553565                                     & "00000011" & FIRMWARE_ID & FTM_ADDRESS
    554                                      & "00" & conv_std_logic_vector(FTU_cnt,4) & conv_std_logic_vector(crate_cnt,2)
     566                                     & "00" & conv_std_logic_vector((FTU_cnt - 1),4) & conv_std_logic_vector(crate_cnt,2)
    555567                                     & FTU_RS485_START_DELIM;
    556             FTU_brd_add_sig <= conv_std_logic_vector(FTU_cnt,4) & conv_std_logic_vector(crate_cnt,2);
     568            FTU_brd_add_sig <= conv_std_logic_vector((FTU_cnt - 1),4) & conv_std_logic_vector(crate_cnt,2);
    557569            FTU_command_sig <= "00000011";
    558570            FTM_ftu_rs485_control_State <= TRANSMIT_CONFIG_1;
     
    567579                                     & FTU_prescaling_RAM_sig(15 downto 8) & FTU_prescaling_RAM_sig(7 downto 0)
    568580                                     & "00000110" & FIRMWARE_ID & FTM_ADDRESS
    569                                      & "00" & conv_std_logic_vector(FTU_cnt,4) & conv_std_logic_vector(crate_cnt,2)
     581                                     & "00" & conv_std_logic_vector((FTU_cnt - 1),4) & conv_std_logic_vector(crate_cnt,2)
    570582                                     & FTU_RS485_START_DELIM;
    571             FTU_brd_add_sig <= conv_std_logic_vector(FTU_cnt,4) & conv_std_logic_vector(crate_cnt,2);
     583            FTU_brd_add_sig <= conv_std_logic_vector((FTU_cnt - 1),4) & conv_std_logic_vector(crate_cnt,2);
    572584            FTU_command_sig <= "00000110";
    573585            FTM_ftu_rs485_control_State <= TRANSMIT_CONFIG_1;
     
    735747            write_FTUlist_RAM <= '1';
    736748            addr_FTUlist_RAM <= conv_std_logic_vector(FTU_LIST_RAM_OFFSET +
    737                                                       FTU_cnt * NO_OF_FTU_LIST_REG +
     749                                                      (FTU_cnt - 1)* NO_OF_FTU_LIST_REG +
    738750                                                      (FTU_list_reg_cnt - 1), FTU_LIST_RAM_ADDR_WIDTH);
    739751            if (retry_cnt < FTU_RS485_NO_OF_RETRY) then
Note: See TracChangeset for help on using the changeset viewer.