--====================================================================== -- TTS2 intelligent OR. --====================================================================== library ieee; use ieee.std_logic_1164.all; use work.tcds2_streams_pkg.all; --====================================================================== entity tts2_prioritised_or is generic ( G_NUMBER_OF_INPUTS : integer ); port ( tts2_i : in tcds2_tts2_array(G_NUMBER_OF_INPUTS - 1 downto 0); tts2_or_o : out tcds2_tts2 ); end tts2_prioritised_or; --====================================================================== architecture arch of tts2_prioritised_or is subtype priority is integer range 0 to 5; type priority_array_type is array (0 to G_NUMBER_OF_INPUTS - 1) of priority; signal tts2_or : tcds2_tts2_value; begin priority_encoder : process(tts2_i) variable temp_or : priority; variable priority_array : priority_array_type; begin -- Translate all input states into priorities. for i in 0 to G_NUMBER_OF_INPUTS - 1 loop -- BUG BUG BUG -- This is a very temporary version! case tts2_i(i).values(0) is -- BUG BUG BUG end when C_TCDS2_TTS2_VALUE_IGNORED => priority_array(i) := 0; when C_TCDS2_TTS2_VALUE_READY => priority_array(i) := 1; when C_TCDS2_TTS2_VALUE_WARNING => priority_array(i) := 2; when C_TCDS2_TTS2_VALUE_BUSY => priority_array(i) := 3; when C_TCDS2_TTS2_VALUE_ERROR => priority_array(i) := 4; when others => priority_array(i) := 5; end case; end loop; -- Find the highest priority. temp_or := 0; for i in priority_array'range loop if priority_array(i) > temp_or then temp_or := priority_array(i); else temp_or := temp_or; end if; end loop; -- Translate back from priority to a TTS value. case temp_or is when 0 => tts2_or <= C_TCDS2_TTS2_VALUE_IGNORED; when 1 => tts2_or <= C_TCDS2_TTS2_VALUE_READY; when 2 => tts2_or <= C_TCDS2_TTS2_VALUE_WARNING; when 3 => tts2_or <= C_TCDS2_TTS2_VALUE_BUSY; when 4 => tts2_or <= C_TCDS2_TTS2_VALUE_ERROR; when 5 => tts2_or <= C_TCDS2_TTS2_VALUE_INVALID; when others => tts2_or <= C_TCDS2_TTS2_VALUE_FAILED; end case; end process priority_encoder; tts2_or_o.reserved <= (others => '0'); -- BUG BUG BUG -- This is a very temporary version! tts2_or_o.values(0) <= tts2_or; -- BUG BUG BUG end end arch; --======================================================================