﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="thpdoc.xsl"?>
<page id="import_entity" suffix=" Statement">
  <subsection>Makes an entity described in VHDL visible for THDL++ code.<code>import_entity EntityName("filename.vhd");</code></subsection>
  <section name="Remarks">
    <p>The <kw>import_entity</kw> statement allows instantiating existing VHDL entities inside THDL++ entities. To do the reverse, use the <kw>generate_vhdl</kw> statement.</p>
	<p>Note that the current implementation <kw>import_entity</kw> won't be able to parse an entity declaration if it has generic port widths. To avoid it, please make wrapper entities with fixed-size ports around generic VHDL entities to import them to THDL++ code.</p>
  </section>
  <section name="Attention">
    <p>The <kw>import_entity</kw> statement does not automatically add the referenced file to the project. This behavior is similar to forward declarations in C/C++. Always add the related VHDL files to the project if you want VisualHDL to build them correctly.</p>
  </section>
  <examples>
	<example><code>import_entity Multiplier("multiplier.vhd");

entity Squarer
{
	port in logic[8] X;
	port out logic[16] Y; 

	Multiplier mul
	(
		a = X,
		b = X,
		y = Y
	); 
}

entity MyTestbench
{
	port in logic clk;
	
	Squarer uut(
		X = auto(0),
		Y = auto
	);
	
	process count (clk.rising)
	{
		uut.X += 1;
	}
}

simulate_entity(SimulatedClockProvider&lt;20ns, MyTestbench&gt;);</code>
	</example>
  </examples>
<seealso id="synthesize_hardware"/>
<seealso id="simulate_entity"/>
<seealso id="generate_vhdl"/>
</page>