--====================================================================== -- A small back-end emulator for testing purposes. --====================================================================== library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.ipbus.all; use work.ipbus_reg_types.all; use work.constants_tcds2.all; use work.ipbus_decode_backend_emulator.all; use work.tcds2_streams_pkg.all; --================================================== entity backend_emulator is generic ( G_NUM_TTS2_CHANNELS : positive := 1 ); port ( clk_ipb : in std_logic; rst_ipb : in std_logic; ipb_in : in ipb_wbus; ipb_out : out ipb_rbus; clk_40 : in std_logic; ttc2_i : in tcds2_ttc2; tts2_o : out tcds2_tts2_value_array(G_NUM_TTS2_CHANNELS - 1 downto 0) ); end backend_emulator; --================================================== architecture arch of backend_emulator is -- IPBus read/write buses. signal ipbw : ipb_wbus_array(N_SLAVES - 1 downto 0); signal ipbr : ipb_rbus_array(N_SLAVES - 1 downto 0); -- CSR signals. signal ctrl : ipb_reg_v(1 downto 0); signal stat : ipb_reg_v(0 downto 0); -- TCDS2 TTC2/TTS2 signals. signal ttc2 : tcds2_ttc2; signal tts2 : tcds2_tts2_value_array(G_NUM_TTS2_CHANNELS - 1 downto 0); -- Misc. signal is_tts2_forced_tmp : std_logic; signal is_tts2_forced : boolean; signal tts2_value : tcds2_tts2_value; signal tts2_force_value : tcds2_tts2_value; begin ------------------------------------------ -- IPBus address decoder. ------------------------------------------ fabric : entity work.ipbus_fabric_sel generic map ( NSLV => N_SLAVES, SEL_WIDTH => IPBUS_SEL_WIDTH ) port map ( ipb_in => ipb_in, ipb_out => ipb_out, sel => ipbus_sel_backend_emulator(ipb_in.ipb_addr), ipb_to_slaves => ipbw, ipb_from_slaves => ipbr ); ------------------------------------------ -- Control and status register. ------------------------------------------ csr : entity work.ipbus_ctrlreg_v generic map ( N_CTRL => ctrl'length, N_STAT => stat'length ) port map ( clk => clk_ipb, reset => rst_ipb, ipbus_in => ipbw(N_SLV_CSR), ipbus_out => ipbr(N_SLV_CSR), q => ctrl, d => stat ); is_tts2_forced_tmp <= ctrl(0)(0); tts2_force_value <= to_integer(unsigned(ctrl(1)(C_TCDS2_TTS2_VALUE_WIDTH - 1 downto 0))); -- DEBUG DEBUG DEBUG -- Test counter for now. stat(0) <= std_logic_vector(resize(unsigned(ttc2.reserved), C_IPBUS_WORD_WIDTH)); -- DEBUG DEBUG DEBUG end is_tts2_forced <= true when is_tts2_forced_tmp = '1' else false; ------------------------------------------ tts2_value <= tts2_force_value when is_tts2_forced else C_TCDS2_TTS2_VALUE_READY; tts2 <= (0 => tts2_value, others => C_TCDS2_TTS2_VALUE_IGNORED); ttc2 <= ttc2_i; tts2_o <= tts2; end arch; --======================================================================