You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p><code>Synthesize</code> annotations allow us to control hierarchy and naming aspects of the Clash compiler, specifically, they allow us to:</p>
791
+
<ul>
792
+
<li>Assign names to entities (VHDL) / modules ((System)Verilog), and their ports.</li>
793
+
<li>Put generated HDL files of a logical (sub)entity in their own directory.</li>
794
+
<li>Use cached versions of generated HDL, i.e., prevent recompilation of (sub)entities that have not changed since the last run.
795
+
Caching is based on a <code>.manifest</code> which is generated alongside the HDL; deleting this file means deleting the cache; changing this file will result in <em>undefined</em> behavior.</li>
796
+
</ul>
797
+
<p>Functions with a 'Synthesize' annotation must adhere to the following restrictions:</p>
798
+
<ul>
799
+
<li>Although functions with a <code>Synthesize</code> annotation can of course depend on functions with another <code>Synthesize</code> annotation, they must not be mutually recursive.</li>
800
+
<li>Functions with a <code>Synthesize</code> annotation must be completely <em>monomorphic</em> and <em>first-order</em>, and cannot have any <em>non-representable</em> arguments or result.</li>
801
+
</ul>
802
+
<p>Also take the following into account when using <code>Synthesize</code> annotations.</p>
803
+
<ul>
804
+
<li>The Clash compiler is based on the GHC Haskell compiler, and the GHC machinery does not understand <code>Synthesize</code> annotations and it might subsequently decide to inline those functions.
805
+
You should therefor also add a <code>{-# OPAQUE f #-}</code> pragma to the functions which you give a <code>Synthesize</code> functions.</li>
806
+
<li>Functions with a <code>Synthesize</code> annotation will not be specialized on constants.</li>
807
+
</ul>
808
+
<p>Finally, the root module, the module which you pass as an argument to the Clash compiler must either have:</p>
809
+
<ul>
810
+
<li>A function with a <code>Synthesize</code> annotation.</li>
811
+
<li>A function called <em>topEntity</em>.</li>
812
+
</ul>
813
+
<p>You apply <code>Synthesize</code> annotations to functions using an <code>ANN</code> pragma:</p>
<p>There are times when you already have an existing piece of IP, or there are times where you need the HDL to have a specific shape so that the HDL synthesis tool can infer a specific component.
791
917
In these specific cases you can resort to defining your own HDL primitives. Actually, most of the primitives in Clash are specified in the same way as you will read about in this section.
0 commit comments