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
<li>Use cached versions of generated HDL, i.e., prevent recompilation of (sub)entities that have not changed since the last run.
175
175
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>
176
176
</ul>
177
-
<p>Functions with a 'Synthesize' annotation must adhere to the following restrictions:</p>
177
+
<p>Functions with a <code>Synthesize</code> annotation must adhere to the following restrictions:</p>
178
178
<ul>
179
179
<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>
180
180
<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>
<p><code>Int</code> and <code>Word</code> are represented by the same number of bits as is native for the architecture of the computer on which the Clash compiler is executed.
306
306
This means that if you are working on a 64-bit machine, <code>Int</code> and <code>Word</code> will be 64-bit.
307
307
This might be problematic when you are working in a team, and one designer has a 32-bit machine, and the other has a 64-bit machine.
308
-
In general, you should be avoiding 'Int' in such cases, but as a band-aid solution, you can force the Clash compiler to use a specific bit-width for <code>Int</code> and <code>Word</code> using the <code>-fclash-intwidth=N</code> flag, where <em>N</em> must either be <em>32</em> or <em>64</em>.</p>
308
+
In general, you should be avoiding <code>Int</code> in such cases, but as a band-aid solution, you can force the Clash compiler to use a specific bit-width for <code>Int</code> and <code>Word</code> using the <code>-fclash-intwidth=N</code> flag, where <em>N</em> must either be <em>32</em> or <em>64</em>.</p>
309
309
</li>
310
310
<li>
311
-
<p>When you use the <code>-fclash-intwidth=32</code> flag on a <em>64-bit</em> machine, the 'Word64' and 'Int64' types <em>cannot</em> be translated. This restriction does <em>not</em> apply to the other three combinations of <code>-fclash-intwidth</code> flag and machine type.</p>
311
+
<p>When you use the <code>-fclash-intwidth=32</code> flag on a <em>64-bit</em> machine, the <code>Word64</code> and <code>Int64</code> types <em>cannot</em> be translated. This restriction does <em>not</em> apply to the other three combinations of <code>-fclash-intwidth</code> flag and machine type.</p>
312
312
</li>
313
313
<li>
314
-
<p>The translation of 'Integer' is not meaning-preserving.
315
-
'Integer' in Haskell is an arbitrary precision integer, something that cannot be represented in a statically known number of bits.
316
-
In the Clash compiler, we chose to represent 'Integer' by the same number of bits as we do for <code>Int</code> and <code>Word</code>.
314
+
<p>The translation of <code>Integer</code> is not meaning-preserving.
315
+
<code>Integer</code> in Haskell is an arbitrary precision integer, something that cannot be represented in a statically known number of bits.
316
+
In the Clash compiler, we chose to represent <code>Integer</code> by the same number of bits as we do for <code>Int</code> and <code>Word</code>.
317
317
As you have read in a previous bullet point, this number of bits is either 32 or 64, depending on the architecture of the machine the Clash compiler is running on, or the setting of the <code>-fclash-intwidth</code> flag.</p>
318
-
<p>Consequently, you should use <code>Integer</code> with due diligence; be especially careful when using <code>fromIntegral</code> as it does a conversion via 'Integer'.
318
+
<p>Consequently, you should use <code>Integer</code> with due diligence; be especially careful when using <code>fromIntegral</code> as it does a conversion via <code>Integer</code>.
319
319
For example:</p>
320
320
<pre><codeclass="language-haskell">signedToUnsigned :: Signed 128 -> Unsigned 128
<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.
171
-
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.
171
+
In these specific cases you can resort to defining your own HDL primitives.
172
+
Actually, most of the primitives in Clash are specified in the same way as you will read about in this section.
172
173
There are perhaps 10 (at most) functions which are truly hard-coded into the Clash compiler.
173
174
You can take a look at the files in <ahref="https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/vhdl">https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/vhdl</a> (or <ahref="https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/verilog">https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/verilog</a> for the Verilog primitives or <ahref="https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/systemverilog">https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/systemverilog</a> for the SystemVerilog primitives) if you want to know which functions are defined as "regular" primitives.
174
175
The compiler looks for primitives in four locations:</p>
<p><strong>Type error: Couldn't match expected type <code>Signal dom (a,b)</code> with actual type <code>(Signal dom a, Signal dom b)</code></strong>:</p>
174
174
<p>Signals of product types and product types of signals are <strong>isomorphic</strong> due to synchronisity principle, but are not (structurally) equal.
175
-
Tuples are a product type. Use the <code>bundle</code> function to convert from a product type to the signal type.
175
+
Tuples are a product type.
176
+
Use the <code>bundle</code> function to convert from a product type to the signal type.
176
177
So if your code which gives the error looks like:</p>
177
178
<pre><codeclass="language-haskell">... = f a b (c,d)
<p><strong>Type error: Couldn't match expected type <code>(Signal dom a, Signal dom b)</code> with actual type <code>Signal dom (a,b)</code></strong>:</p>
190
191
<p>Product types of signals and signals of product types are <strong>isomorphic</strong> due to synchronicity principle, but are not (structurally) equal.
191
-
Tuples are a product type. Use the <code>unbundle</code> function to convert from a signal type to the product type.
192
+
Tuples are a product type.
193
+
Use the <code>unbundle</code> function to convert from a signal type to the product type.
192
194
So if your code which gives the error looks like:</p>
<p><strong><*** Exception: <<loop>> or "blinking cursor"</strong></p>
256
-
<p>You are using value-recursion, but one of the <code>Vec</code>tor functions that you are using is too <em>strict</em> in one of the recursive arguments. For example:</p>
258
+
<p>You are using value-recursion, but one of the <code>Vec</code>tor functions that you are using is too <em>strict</em> in one of the recursive arguments.
259
+
For example:</p>
257
260
<pre><codeclass="language-haskell">-- Bubble sort for 1 iteration
Copy file name to clipboardExpand all lines: pr-10/compiler-user-guide/print.html
+15-11Lines changed: 15 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -794,7 +794,7 @@ <h2 id="undefined-values"><a class="header" href="#undefined-values">Undefined V
794
794
<li>Use cached versions of generated HDL, i.e., prevent recompilation of (sub)entities that have not changed since the last run.
795
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
796
</ul>
797
-
<p>Functions with a 'Synthesize' annotation must adhere to the following restrictions:</p>
797
+
<p>Functions with a <code>Synthesize</code> annotation must adhere to the following restrictions:</p>
798
798
<ul>
799
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
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>
@@ -914,7 +914,8 @@ <h2 id="undefined-values"><a class="header" href="#undefined-values">Undefined V
914
914
<p>See the documentation of <code>Synthesize</code> for the meaning of all its fields.</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.
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.
917
+
In these specific cases you can resort to defining your own HDL primitives.
918
+
Actually, most of the primitives in Clash are specified in the same way as you will read about in this section.
918
919
There are perhaps 10 (at most) functions which are truly hard-coded into the Clash compiler.
919
920
You can take a look at the files in <ahref="https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/vhdl">https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/vhdl</a> (or <ahref="https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/verilog">https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/verilog</a> for the Verilog primitives or <ahref="https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/systemverilog">https://github.com/clash-lang/clash-compiler/tree/master/clash-lib/prims/systemverilog</a> for the SystemVerilog primitives) if you want to know which functions are defined as "regular" primitives.
920
921
The compiler looks for primitives in four locations:</p>
<p><strong>Type error: Couldn't match expected type <code>Signal dom (a,b)</code> with actual type <code>(Signal dom a, Signal dom b)</code></strong>:</p>
1290
1291
<p>Signals of product types and product types of signals are <strong>isomorphic</strong> due to synchronisity principle, but are not (structurally) equal.
1291
-
Tuples are a product type. Use the <code>bundle</code> function to convert from a product type to the signal type.
1292
+
Tuples are a product type.
1293
+
Use the <code>bundle</code> function to convert from a product type to the signal type.
1292
1294
So if your code which gives the error looks like:</p>
1293
1295
<pre><codeclass="language-haskell">... = f a b (c,d)
<p><strong>Type error: Couldn't match expected type <code>(Signal dom a, Signal dom b)</code> with actual type <code>Signal dom (a,b)</code></strong>:</p>
1306
1308
<p>Product types of signals and signals of product types are <strong>isomorphic</strong> due to synchronicity principle, but are not (structurally) equal.
1307
-
Tuples are a product type. Use the <code>unbundle</code> function to convert from a signal type to the product type.
1309
+
Tuples are a product type.
1310
+
Use the <code>unbundle</code> function to convert from a signal type to the product type.
1308
1311
So if your code which gives the error looks like:</p>
<p><strong><*** Exception: <<loop>> or "blinking cursor"</strong></p>
1372
-
<p>You are using value-recursion, but one of the <code>Vec</code>tor functions that you are using is too <em>strict</em> in one of the recursive arguments. For example:</p>
1375
+
<p>You are using value-recursion, but one of the <code>Vec</code>tor functions that you are using is too <em>strict</em> in one of the recursive arguments.
1376
+
For example:</p>
1373
1377
<pre><codeclass="language-haskell">-- Bubble sort for 1 iteration
<p><code>Int</code> and <code>Word</code> are represented by the same number of bits as is native for the architecture of the computer on which the Clash compiler is executed.
1534
1538
This means that if you are working on a 64-bit machine, <code>Int</code> and <code>Word</code> will be 64-bit.
1535
1539
This might be problematic when you are working in a team, and one designer has a 32-bit machine, and the other has a 64-bit machine.
1536
-
In general, you should be avoiding 'Int' in such cases, but as a band-aid solution, you can force the Clash compiler to use a specific bit-width for <code>Int</code> and <code>Word</code> using the <code>-fclash-intwidth=N</code> flag, where <em>N</em> must either be <em>32</em> or <em>64</em>.</p>
1540
+
In general, you should be avoiding <code>Int</code> in such cases, but as a band-aid solution, you can force the Clash compiler to use a specific bit-width for <code>Int</code> and <code>Word</code> using the <code>-fclash-intwidth=N</code> flag, where <em>N</em> must either be <em>32</em> or <em>64</em>.</p>
1537
1541
</li>
1538
1542
<li>
1539
-
<p>When you use the <code>-fclash-intwidth=32</code> flag on a <em>64-bit</em> machine, the 'Word64' and 'Int64' types <em>cannot</em> be translated. This restriction does <em>not</em> apply to the other three combinations of <code>-fclash-intwidth</code> flag and machine type.</p>
1543
+
<p>When you use the <code>-fclash-intwidth=32</code> flag on a <em>64-bit</em> machine, the <code>Word64</code> and <code>Int64</code> types <em>cannot</em> be translated. This restriction does <em>not</em> apply to the other three combinations of <code>-fclash-intwidth</code> flag and machine type.</p>
1540
1544
</li>
1541
1545
<li>
1542
-
<p>The translation of 'Integer' is not meaning-preserving.
1543
-
'Integer' in Haskell is an arbitrary precision integer, something that cannot be represented in a statically known number of bits.
1544
-
In the Clash compiler, we chose to represent 'Integer' by the same number of bits as we do for <code>Int</code> and <code>Word</code>.
1546
+
<p>The translation of <code>Integer</code> is not meaning-preserving.
1547
+
<code>Integer</code> in Haskell is an arbitrary precision integer, something that cannot be represented in a statically known number of bits.
1548
+
In the Clash compiler, we chose to represent <code>Integer</code> by the same number of bits as we do for <code>Int</code> and <code>Word</code>.
1545
1549
As you have read in a previous bullet point, this number of bits is either 32 or 64, depending on the architecture of the machine the Clash compiler is running on, or the setting of the <code>-fclash-intwidth</code> flag.</p>
1546
-
<p>Consequently, you should use <code>Integer</code> with due diligence; be especially careful when using <code>fromIntegral</code> as it does a conversion via 'Integer'.
1550
+
<p>Consequently, you should use <code>Integer</code> with due diligence; be especially careful when using <code>fromIntegral</code> as it does a conversion via <code>Integer</code>.
1547
1551
For example:</p>
1548
1552
<pre><codeclass="language-haskell">signedToUnsigned :: Signed 128 -> Unsigned 128
0 commit comments