﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="thpdoc.xsl"?>
<page id="ite" suffix=" Function">
  <subsection>Performs the if-then-else function.</subsection>
  <code>auto ite(bool condition, auto val1, auto val2);</code>
  The <kw>ite</kw>() function in THDL++ is equivalent to the "a ? b : c" operator in C++.
  <examples>
	<example>
		<code>entity Test
{
	signal logic[8] a;
	signal logic[16] b;

	process test (any)
	{
		b = ite(a == 5, logic[16](0), -1);
	}
}</code>
	Generated VHDL code:
<code>architecture Behavioral of Test is
	signal a : std_logic_vector(7 downto 0);
	signal b : std_logic_vector(15 downto 0);
	
	begin
		test : process (a) is
		begin
			b &lt;= thp_ite_1((a = X"05"), X"0000", X"FFFF")(15 downto 0);
		end process test;
		
end architecture Behavioral;</code>
	</example>
  </examples>
  <seealso id="extend_zero"/>
</page>