﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="thpdoc.xsl"?>
<page id="link" suffix=" Keyword">
  <subsection>Declares a signal and creates an implicit process.<code>link TypeName SigName = Expression;</code></subsection>
  The <kw>link</kw> statement is equivalent to a <kw>signal</kw> statement followed by an implicit process. See examples for more details.
  <section name="Remarks">
	<p>If you try to declare a normal <kw>signal</kw> with a non-constant initial value, THDL++ compiler will show an error message and suggest using the <kw>link</kw> statement instead.</p>
	<p>You don't have to specify the type of the signal when using <kw>link</kw> statements. If you use the <kw>auto</kw> or <kw>any</kw> keyword instead, the type will be inferred from the expression on the right.</p>
  </section>
  <examples>
	<example>
  Let's define a signal sum thats value should be always equivalent to X + Y:
  <code>entity Test
{
	port in logic[8] X, Y;
	
	signal logic[8] sum;
	sum = X + Y;
}</code>
	The following VHDL code will be generated:
<code>entity Test is
	Port (
		X : in std_logic_vector(7 downto 0);
		Y : in std_logic_vector(7 downto 0)
	);
	
end entity Test;

architecture Behavioral of Test is
	signal sum : std_logic_vector(7 downto 0);
	
	begin
		sum &lt;= (X + Y);
end architecture Behavioral;</code>
	You could achieve the same result by using <kw>link</kw> statement instead:
<code>entity Test
{
	port in logic[8] X, Y;
	link logic[8] sum = X + Y;
}</code>
	The generated VHDL code will be exactly the same.
	</example>
  <example name="Type inference">
  The following code is equivalent to the previous example:
  <code>entity Test
{
	port in logic[8] X, Y;
	link auto sum = X + Y;
} </code>
	The type of sum will be inferred from the "X + Y" expression.
  </example>
  </examples>
  <seealso id="entity"/>
  <seealso id="port"/>
  <seealso id="signal"/>
</page>