﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="thpdoc.xsl"?>
<page id="namespace" suffix=" Keyword">
  <subsection>Defines a namespace.<code>namespace NamespaceName
{
	Namespace_contents;
}</code></subsection>
  <p>The <kw>namespace</kw> statement allows arranging classes, entities and functions hierarchically to simplify finding them with using autocompletion mechanism. The namespace concept in THDL++ is equivalent to C# namespaces. You can reference namespaces inside source files with the help of the <kw>using</kw> statement.</p>
  <section name="Remarks">
	<p>Namespaces can contain the following primitives: <kw>class</kw>, <kw>entity</kw>, <kw>typedef</kw>, <kw>const</kw>, <kw>enum</kw>, <kw>import_entity</kw>. Namespaces can also be nested and can contain function declarations.</p>
	<p>THDL++ compiler comes with built-in library (corelib.vhl) that defines namespaces <link>Core</link> and <link>System</link>.</p>
  </section>
	<examples>
		<example name="Nested namespaces">
		<code>namespace RAMs
{
	namespace Synchronous
	{
		entity SinglePort {...};
		entity DualPort {...};
	}
	
	namespace Asynchronous
	{
		entity SinglePort {...};
		entity DualPort {...};
	}
}

entity Test
{
	RAMs.Synchronous.SinglePort RAM1(...);
}
</code>
		</example>
		<example name="Using statement">
		<code>
namespace SpeedOptimized
{
	int Divide(int a, int b) {...}
}

namespace AreaOptimized
{
	int Divide(int a, int b) {...}
}

using namespace SpeedOptimized;

entity Test
{
	...
	process proc1(...)
	{
		z = Divide(x, y);
	}
}</code>
		</example>
	</examples>
  <seealso id="using"/>
  <seealso id="Core"/>
  <seealso id="System"/>
</page>