﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="thpdoc.xsl"?>
<page id="autoreset" suffix=" Keyword">
  <subsection>Generates a reset block for a process<code>process ProcessName(clk.rising) autoreset(reset_signal_name)
{
	Process_contents;
}</code>
	THDL++ compiler can automatically generate reset blocks for processes. A reset block will activate when the reset signal becomes high (or low if "!" was specified). The reset block will assign initial values (specified in signal declarations) to all signals written by the process.
</subsection>
<subsection name="Remarks">
	<p>If a process has an autoreset statement, it should be sensitive to a rising/falling edge of a clock signal and all signals written by the process should have initial values in the declarations. Otherwise, an error message will be shown.</p>
	<p>If a process contains range assignment statements (e.g. sig1[0] = '0'), the autoreset block will not be generated and an error message will be shown.</p>
</subsection>
  <examples>
	<example name="Counter"><code>entity Counter
{
	port in logic clk, reset;
	port out logic[8] Value = 0;
	
	process sync (clk.rising) autoreset(reset)
	{
		Value++;
	}
}</code>
	The following VHDL code will be generated:
<code>entity Counter is
	Port (
		clk : in std_logic;
		reset : in std_logic;
		Value : out std_logic_vector(7 downto 0)
	);
	
end entity Counter;

architecture Behavioral of Counter is
	signal thp_shadow_Value : std_logic_vector(7 downto 0) := X"00";
	
	begin
		Value &lt;= thp_shadow_Value;
		
		sync : process (clk, reset) is
		begin
			if reset = '1' then
				Value &lt;= X"00";
			elsif rising_edge(clk) then
				thp_shadow_Value &lt;= (thp_shadow_Value + X"01");
			end if;
		end process sync;
		
end architecture Behavioral;</code>
	To make the reset signal active-low, simply prefix it with "!" in the <kw>autoreset</kw> statement:
	<code>process sync (clk.rising) autoreset(!reset)</code>
</example>
  </examples>
  <seealso id="entity"/>
  <seealso id="process"/>
</page>