﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="thpdoc.xsl"?>
<page id="process" suffix=" Statement">
  <subsection>Defines a process.<code>process ProcessName(sensitivity_list)
{
	Process_contents;
}</code>
	THDL++ processes have full semantics of VHDL processes. Moreover, every THDL++ process will be compiled, line-by-line, into a corresponding VHDL process. The syntax of THDL++ process bodies is similar to <link>functions</link>.
</subsection>
<subsection name="Sensitivity lists">
	THDL++ processes can have explicit sensitivity lists, just like in VHDL. Additionally to that, there are two special syntax forms that simplify most of the use cases:
	<ul>
		<li>Sensitivity to all inputs. To make a process sensitive to all inputs, specify <kw>any</kw> keyword inside the sensitivity list.</li>
		<li>Sensitivity to a clock. To make a process sensitive to rising/falling edge of a clock, specify clock_name.<kw>rising</kw> or clock_name.<kw>falling</kw> in the sensitivity list.</li>
	</ul>
</subsection>
<subsection name="Implicit processes">
	An entity can also have implicit processes similar to VHDL ones. An implicit process has the following syntax:
	<code>sig_name = expression;</code>
</subsection>
<section name="Automatic reset block generation">
	<p>If a process is sensitive to a clock, you can use the <kw>autoreset</kw> keyword to generate a block that will assign default values to all signals modified by the process in case the reset signal goes high or low. See the <kw>autoreset</kw> page for more details.</p>
</section>
  <examples>
	<example name="Automatic sensitivity">
  <code>entity Test
{
	signal logic[8] a, b, c;
	
	process test (any)
	{
		a = b + c;
	}
}</code>
	The following VHDL code will be generated:
<code>entity Test is
end entity Test;

architecture Behavioral of Test is
	signal a : std_logic_vector(7 downto 0);
	signal b : std_logic_vector(7 downto 0);
	signal c : std_logic_vector(7 downto 0);
	
	begin
		test : process (b, c) is
		begin
			a &lt;= (b + c);
		end process test;
		
end architecture Behavioral;</code>
	</example>
  <example name="Sensitivity to a clock">
  <code>entity Test
{
	signal logic[8] a, b, c;
	port in logic clk;
	
	process test (clk.rising)
	{
		a = b + c;
	}
}</code>
	Generated VHDL code:
<code>entity Test is
	Port (
		clk : in std_logic
	);
	
end entity Test;

architecture Behavioral of Test is
	signal a : std_logic_vector(7 downto 0);
	signal b : std_logic_vector(7 downto 0);
	signal c : std_logic_vector(7 downto 0);
	
	begin
		test : process (clk) is
		begin
			if rising_edge(clk) then
				a &lt;= (b + c);
			end if;
		end process test;
		
end architecture Behavioral;</code>
  </example>
  <example name="Clock generation">
  <code>entity Test
{
	signal logic clk = '0';
	
	process test ()
	{
		clk = !clk;
		wait(10ns);
	}
}</code>
	Generated VHDL code:
<code>entity Test is
end entity Test;

architecture Behavioral of Test is
	signal clk : std_logic := '0';
	
	begin
		test : process  is
		begin
			clk &lt;= (not clk);
			wait for 10ns;
		end process test;
		
end architecture Behavioral;</code>
  </example>
  </examples>
  <seealso id="entity"/>
  <seealso id="functions"/>
  <seealso id="autoreset"/>
  <seealso id="wait"/>
</page>