Skip to content

Commit 3094270

Browse files
committed
deploy: 44798a6
1 parent eb90765 commit 3094270

File tree

7 files changed

+607
-77
lines changed

7 files changed

+607
-77
lines changed

pr-10/compiler-user-guide/developing-hardware/limitations.html

Lines changed: 382 additions & 0 deletions
Large diffs are not rendered by default.

pr-10/compiler-user-guide/developing-hardware/primitives.html

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ <h1 id="user-defined-primitives"><a class="header" href="#user-defined-primitive
170170
<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.
171171
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.
172172
There are perhaps 10 (at most) functions which are truly hard-coded into the Clash compiler.
173-
You can take a look at the files in <a href="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 <a href="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 <a href="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
174-
as "regular" primitives.
173+
You can take a look at the files in <a href="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 <a href="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 <a href="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.
175174
The compiler looks for primitives in four locations:</p>
176175
<ul>
177176
<li>
@@ -203,7 +202,7 @@ <h1 id="user-defined-primitives"><a class="header" href="#user-defined-primitive
203202
(S a) *# (S b) = fromInteger_INLINE (a * b)
204203
{-# OPAQUE (*#) #-}
205204
</code></pre>
206-
<p>For which the VHDL /expression/ primitive is:</p>
205+
<p>For which the VHDL <em>expression</em> primitive is:</p>
207206
<pre><code class="language-yaml">BlackBox:
208207
name: Clash.Sized.Internal.Signed.*#
209208
kind: Expression
@@ -212,12 +211,12 @@ <h1 id="user-defined-primitives"><a class="header" href="#user-defined-primitive
212211
</code></pre>
213212
<p>The <code>name</code> of the primitive is the <em>fully qualified</em> name of the function you are creating the primitive for.
214213
Because we are creating an <em>expression</em> primitive the kind must be set to <code>Expression</code>.
215-
As the name suggest, it is a VHDL /template/, meaning that the compiler must fill in the holes heralded by the tilde (~).
214+
As the name suggest, it is a VHDL <em>template</em>, meaning that the compiler must fill in the holes heralded by the tilde (~).
216215
Here:</p>
217216
<ul>
218-
<li><code>~ARG[1]</code> denotes the second argument given to the <code>(*#)</code> function, which corresponds to the LHS of the (<code>*</code>) operator.</li>
219-
<li><code>~ARG[2]</code> denotes the third argument given to the <code>(*#)</code> function, which corresponds to the RHS of the (<code>*</code>) operator.</li>
220-
<li><code>~LIT[0]</code> denotes the first argument given to the <code>(*#)</code> function, withthe extra condition that it must be a <code>LIT</code>eral.
217+
<li><code>~ARG[1]</code> denotes the second argument given to the <code>(*#)</code> function, which corresponds to the LHS of the (<code>*</code>) operator.</li>
218+
<li><code>~ARG[2]</code> denotes the third argument given to the <code>(*#)</code> function, which corresponds to the RHS of the (<code>*</code>) operator.</li>
219+
<li><code>~LIT[0]</code> denotes the first argument given to the <code>(*#)</code> function, with the extra condition that it must be a <code>LIT</code>eral.
221220
If for some reason this first argument does not turn out to be a literal then the compiler will raise an error.
222221
This first arguments corresponds to the <code>KnownNat n</code> class constraint.</li>
223222
</ul>
@@ -347,27 +346,26 @@ <h1 id="user-defined-primitives"><a class="header" href="#user-defined-primitive
347346
Because we are creating a <em>declaration</em> primitive the <em>kind</em> must be set to <code>Declaration</code>.
348347
Instead of discussing what the individual template holes mean in the above context, we will instead just give a general listing of the available template holes:</p>
349348
<ul>
350-
<li><code>~RESULT</code>: Signal to which the result of a primitive must be assigned
351-
to. NB: Only used in a <em>declaration</em> primitive.</li>
349+
<li><code>~RESULT</code>: Signal to which the result of a primitive must be assigned to.
350+
NB: Only used in a <em>declaration</em> primitive.</li>
352351
<li><code>~ARG[N]</code>: <code>(N+1)</code>'th argument to the function.</li>
353-
<li><code>~CONST[N]</code>: <code>(N+1)</code>'th argument to the function. Like <code>~ARG</code>, but Clash will try to reduce this to a literal, even if it would otherwise consider it too expensive.
352+
<li><code>~CONST[N]</code>: <code>(N+1)</code>'th argument to the function.
353+
Like <code>~ARG</code>, but Clash will try to reduce this to a literal, even if it would otherwise consider it too expensive.
354354
And if Clash fails to reduce this argument to a literal it will produce an error.</li>
355-
<li><code>~LIT[N]</code>: <code>(N+1)</code>'th argument to the function. Like <code>~CONST~</code> but values are rendered as a bare literals, without any size or type annotations.
355+
<li><code>~LIT[N]</code>: <code>(N+1)</code>'th argument to the function.
356+
Like <code>~CONST</code> but values are rendered as a bare literals, without any size or type annotations.
356357
This only works for numeric types, and not for BitVector.</li>
357358
<li><code>~TYP[N]</code>: VHDL type of the <code>(N+1)</code>'th argument.</li>
358359
<li><code>~TYPO</code>: VHDL type of the result.</li>
359-
<li><code>~TYPM[N]</code>: VHDL type_name_ of the <code>(N+1)</code>'th argument; used in <em>type qualification</em>.</li>
360-
<li><code>~TYPMO</code>: VHDL type_name_ of the result; used in <em>type qualification</em>.</li>
360+
<li><code>~TYPM[N]</code>: VHDL type<em>name</em> of the <code>(N+1)</code>'th argument; used in <em>type qualification</em>.</li>
361+
<li><code>~TYPMO</code>: VHDL type<em>name</em> of the result; used in <em>type qualification</em>.</li>
361362
<li><code>~ERROR[N]</code>: Error value for the VHDL type of the <code>(N+1)</code>'th argument.</li>
362363
<li><code>~ERRORO</code>: Error value for the VHDL type of the result.</li>
363-
<li><code>~GENSYM[&lt;NAME&gt;][N]</code>: Create a unique name, trying to stay as close to
364-
the given <code>&lt;NAME&gt;</code> as possible. This unique symbol can be referred to in
365-
other places using <code>~SYM[N]</code>.</li>
364+
<li><code>~GENSYM[&lt;NAME&gt;][N]</code>: Create a unique name, trying to stay as close to the given <code>&lt;NAME&gt;</code> as possible.
365+
This unique symbol can be referred to in other places using <code>~SYM[N]</code>.</li>
366366
<li><code>~SYM[N]</code>: a reference to the unique symbol created by <code>~GENSYM[&lt;NAME&gt;][N]</code>.</li>
367-
<li><code>~SIGD[&lt;HOLE&gt;][N]</code>: Create a signal declaration, using <code>&lt;HOLE&gt;</code> as the name
368-
of the signal, and the type of the <code>(N+1)</code>'th argument.</li>
369-
<li><code>~SIGDO[&lt;HOLE&gt;]</code>: Create a signal declaration, using <code>&lt;HOLE&gt;</code> as the name
370-
of the signal, and the type of the result.</li>
367+
<li><code>~SIGD[&lt;HOLE&gt;][N]</code>: Create a signal declaration, using <code>&lt;HOLE&gt;</code> as the name of the signal, and the type of the <code>(N+1)</code>'th argument.</li>
368+
<li><code>~SIGDO[&lt;HOLE&gt;]</code>: Create a signal declaration, using <code>&lt;HOLE&gt;</code> as the name of the signal, and the type of the result.</li>
371369
<li><code>~TYPEL[&lt;HOLE&gt;]</code>: The element type of the vector type represented by <code>&lt;HOLE&gt;</code>.
372370
The content of <code>&lt;HOLE&gt;</code> must either be: <code>~TYP[N]</code>, <code>~TYPO</code>, or <code>~TYPEL[&lt;HOLE&gt;]</code>.</li>
373371
<li><code>~COMPNAME</code>: The name of the component in which the primitive is instantiated.</li>
@@ -376,12 +374,9 @@ <h1 id="user-defined-primitives"><a class="header" href="#user-defined-primitive
376374
The content of <code>&lt;HOLE&gt;</code> must either be: <code>~TYP[N]</code>, <code>~TYPO</code>, or <code>~TYPEL[&lt;HOLE&gt;]</code>.</li>
377375
<li><code>~SIZE[&lt;HOLE&gt;]</code>: The number of bits needed to encode the type represented by <code>&lt;HOLE&gt;</code>.
378376
The content of <code>&lt;HOLE&gt;</code> must either be: <code>~TYP[N]</code>, <code>~TYPO</code>, or <code>~TYPEL[&lt;HOLE&gt;]</code>.</li>
379-
<li><code>~IF &lt;CONDITION&gt; ~THEN &lt;THEN&gt; ~ELSE &lt;ELSE&gt; ~FI</code>: renders the <code>&lt;ELSE&gt;</code>
380-
part when <code>&lt;CONDITION&gt;</code> evaluates to <em>0</em>, and renders the <code>&lt;THEN&gt;</code> in all
381-
other cases.
377+
<li><code>~IF &lt;CONDITION&gt; ~THEN &lt;THEN&gt; ~ELSE &lt;ELSE&gt; ~FI</code>: renders the <code>&lt;ELSE&gt;</code> part when <code>&lt;CONDITION&gt;</code> evaluates to <em>0</em>, and renders the <code>&lt;THEN&gt;</code> in all other cases.
382378
Valid <code>&lt;CONDITION&gt;</code>s are <code>~LENGTH[&lt;HOLE&gt;]</code>, <code>~SIZE[&lt;HOLE&gt;]</code>, <code>~CMPLE[&lt;HOLE1&gt;][&lt;HOLE2&gt;]</code>, <code>~DEPTH[&lt;HOLE&gt;]</code>, <code>~VIVADO</code>, <code>~IW64</code>, <code>~ISLIT[N]</code>, <code>~ISVAR[N]</code>, <code>~ISACTIVEENABLE[N]</code>, <code>~ISSYNC[N]</code>, and <code>~AND[&lt;HOLE1&gt;,&lt;HOLE2&gt;,..]</code>.</li>
383-
<li><code>~VIVADO</code>: <em>1</em> when Clash compiler is invoked with the <code>-fclash-xilinx</code> or
384-
<code>-fclash-vivado</code> flag.
379+
<li><code>~VIVADO</code>: <em>1</em> when Clash compiler is invoked with the <code>-fclash-hdlsyn Vivado</code> (or <code>Xilinx</code> or <code>ISE</code>) flag.
385380
To be used with in an <code>~IF .. ~THEN .. ~ELSE .. ~FI</code> statement.</li>
386381
<li><code>~CMPLE[&lt;HOLE1&gt;][&lt;HOLE2&gt;]</code>: <em>1</em> when <code>&lt;HOLE1&gt; &lt;= &lt;HOLE2&gt;</code>, otherwise <em>0</em></li>
387382
<li><code>~IW64</code>: <em>1</em> when <code>Int</code>/<code>Word</code>/<code>Integer</code> types are represented with 64 bits in HDL.
@@ -401,19 +396,17 @@ <h1 id="user-defined-primitives"><a class="header" href="#user-defined-primitive
401396
In (System)Verilog only <code>Bit</code> and <code>Bool</code> are considered scalar.
402397
In VHDL, in addition to those two, enumeration types and integers are considered scalar.</li>
403398
<li><code>~TAG[N]</code>: Name of given domain.
404-
Errors when called on an argument which is not a 'KnownDomain', 'Reset', or 'Clock'.</li>
399+
Errors when called on an argument which is not a <code>KnownDomain</code>, <code>Reset</code>, or <code>Clock</code>.</li>
405400
<li><code>~PERIOD[N]</code>: Clock period of given domain.
406-
Errors when called on an argument which is not a 'Clock', 'Reset', 'KnownDomain' or 'KnownConf'.</li>
407-
<li><code>~ISACTIVEENABLE[N]</code>: Is the <code>(N+1)</code>'th argument a an Enable line <strong>not</strong> set to a constant True.
408-
Can be used instead of deprecated (and removed) template tag</li>
401+
Errors when called on an argument which is not a <code>Clock</code>, <code>Reset</code>, <code>KnownDomain</code> or <code>KnownConf</code>.</li>
402+
<li><code>~ISACTIVEENABLE[N]</code>: Is the <code>(N+1)</code>'th argument an Enable line <strong>not</strong> set to a constant True.</li>
409403
<li><code>~ISSYNC[N]</code>: Does synthesis domain at the <code>(N+1)</code>'th argument have synchronous resets.
410-
Errors when called on an argument which is not a 'Reset', 'Clock', 'Enable', 'KnownDomain' or 'KnownConf'.</li>
404+
Errors when called on an argument which is not a <code>Reset</code>, <code>Clock</code>, <code>Enable</code>, <code>KnownDomain</code> or <code>KnownConf</code>.</li>
411405
<li><code>~ISINITDEFINED[N]</code>: Does synthesis domain at the <code>(N+1)</code>'th argument have defined initial values.
412-
Errors when called on an argument which is not a 'Clock', 'Reset', 'Enable', 'KnownDomain' or 'KnownConf'.</li>
413-
<li><code>~ACTIVEEDGE[edge][N]</code>: Does synthesis domain at the <code>(N+1)</code>'th argument respond to
414-
<em>edge</em>.
415-
<em>edge</em> must be one of 'Falling' or 'Rising'.
416-
Errors when called on an argument which is not a 'Clock', 'Reset', 'Enable', 'KnownDomain' or 'KnownConf'.</li>
406+
Errors when called on an argument which is not a <code>Clock</code>, <code>Reset</code>, <code>Enable</code>, <code>KnownDomain</code> or <code>KnownConf</code>.</li>
407+
<li><code>~ACTIVEEDGE[edge][N]</code>: Does synthesis domain at the <code>(N+1)</code>'th argument respond to <em>edge</em>.
408+
<em>edge</em> must be one of <code>Falling</code> or <code>Rising</code>.
409+
Errors when called on an argument which is not a <code>Clock</code>, <code>Reset</code>, <code>Enable</code>, <code>KnownDomain</code> or <code>KnownConf</code>.</li>
417410
<li><code>~AND[&lt;HOLE1&gt;,&lt;HOLE2&gt;,..]</code>: Logically <em>and</em> the conditions in the <code>&lt;HOLE&gt;</code>'s</li>
418411
<li><code>~VAR[&lt;NAME&gt;][N]</code>: Like <code>~ARG[N]</code> but binds the argument to a variable named NAME.
419412
The <code>&lt;NAME&gt;</code> can be left blank, then Clash will come up with a (unique) name.</li>
@@ -552,7 +545,7 @@ <h2 id="systemverilog-examples"><a class="header" href="#systemverilog-examples"
552545
<i class="fa fa-angle-left"></i>
553546
</a>
554547

555-
<a rel="next prefetch" href="../hacking-on-clash/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
548+
<a rel="next prefetch" href="../developing-hardware/limitations.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
556549
<i class="fa fa-angle-right"></i>
557550
</a>
558551

@@ -566,7 +559,7 @@ <h2 id="systemverilog-examples"><a class="header" href="#systemverilog-examples"
566559
<i class="fa fa-angle-left"></i>
567560
</a>
568561

569-
<a rel="next prefetch" href="../hacking-on-clash/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
562+
<a rel="next prefetch" href="../developing-hardware/limitations.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
570563
<i class="fa fa-angle-right"></i>
571564
</a>
572565
</nav>

pr-10/compiler-user-guide/hacking-on-clash/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ <h2 id="subprojects"><a class="header" href="#subprojects">Subprojects</a></h2>
264264

265265
<nav class="nav-wrapper" aria-label="Page navigation">
266266
<!-- Mobile navigation buttons -->
267-
<a rel="prev" href="../developing-hardware/primitives.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
267+
<a rel="prev" href="../developing-hardware/limitations.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
268268
<i class="fa fa-angle-left"></i>
269269
</a>
270270

@@ -275,7 +275,7 @@ <h2 id="subprojects"><a class="header" href="#subprojects">Subprojects</a></h2>
275275
</div>
276276

277277
<nav class="nav-wide-wrapper" aria-label="Page navigation">
278-
<a rel="prev" href="../developing-hardware/primitives.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
278+
<a rel="prev" href="../developing-hardware/limitations.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
279279
<i class="fa fa-angle-left"></i>
280280
</a>
281281

0 commit comments

Comments
 (0)