﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="thpdoc.xsl"?>
<page id="__ports" suffix=" Function">
  <subsection>Returns a list of entity's ports or a list of auto signals related to an instance.</subsection>
  <code>list __ports(any entity);
list __ports(any entity, any attributeClass);</code>
	You can limit the output of the <kw>__ports</kw> function to ports having a specified attribute. To do so, specify the attribute as the second argument to <kw>__ports</kw>.
  <examples>
	<example>
		<code>entity Test
{
	port in logic[8] X;
	port out logic[8] Y;
	port in logic clk;

	process step (clk.rising)
	{
		foreach(any p in __ports(Test))
			if (__writable(p))
				p++;
	}	
}</code>
	Generated VHDL code:
<code>entity Test is
	Port (
		X : in std_logic_vector(7 downto 0);
		Y : out std_logic_vector(7 downto 0);
		clk : in std_logic
	);
	
end entity Test;

architecture Behavioral of Test is
	signal thp_shadow_Y : std_logic_vector(7 downto 0);
	
	begin
		Y &lt;= thp_shadow_Y;
		
		step : process (clk) is
		begin
			if rising_edge(clk) then
				thp_shadow_Y &lt;= (thp_shadow_Y + X"01");
			end if;
		end process step;
		
		
end architecture Behavioral;</code></example>
  </examples>
  <seealso id="port"/>
  <seealso id="__writable"/>
  <seealso id="lists"/>
  <seealso id="foreach"/>
  <seealso id="generate"/>
</page>