Skip to content

Commit 9e3f807

Browse files
author
Oron Port
committed
docs: Reorder sections in design hierarchy documentation for improved flow
1 parent 9a41777 commit 9e3f807

File tree

1 file changed

+74
-74
lines changed
  • docs/user-guide/design-hierarchy

1 file changed

+74
-74
lines changed

docs/user-guide/design-hierarchy/index.md

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -550,80 +550,6 @@ case class Bar() extends DFDesign
550550

551551
All other Scala class modifiers have no special effect or limitation from a DFHDL compiler perspective. Nonetheless, these modifiers can be relevant when defining a more complex design API, as part of the DFHDL meta-programming capabilities through the Scala language (e.g., changing class access to `#!scala protected`).
552552

553-
### Design Class Inheritance
554-
DFHDL leverages Scala inheritance to enable sharing functionality between design classes.
555-
556-
#### `ShiftGen` example {#ShiftGen}
557-
/// admonition | Generic left and right shifters, design class inheritance example
558-
type: example
559-
The DFHDL code below demonstrates how to implement both left and right generic shifters efficiently by using a common `#!scala abstract class` named `ShiftGen`. The `width` parameter is declared as an abstract class field (without an assigned value) inside the `ShiftGen` class body. By extending `ShiftGen`, both `LeftShiftGen` and `RightShiftGen` can utilize the IOs already declared in `ShiftGen`. They only need to explicitly declare the `width` parameter and implement the shift functionality in their respective class bodies.
560-
561-
<div class="grid" markdown>
562-
563-
```scala
564-
--8<-- "lib/src/test/scala/docExamples/ugdemos/demo5/LRShiftDirect.scala:6:35"
565-
```
566-
567-
```hdelk width=100%
568-
stroke-width = 0
569-
children = [
570-
{
571-
id = left
572-
label = LeftShiftGen
573-
inPorts = [iBits, shift]
574-
outPorts = [oBits]
575-
parameters = [width]
576-
children = [
577-
{
578-
id = opLeft
579-
label = "<<"
580-
northPorts = [{id = shift, label = " ", height = 5, width = 1}]
581-
}
582-
]
583-
edges = [
584-
[left.shift, opLeft.shift]
585-
[left.iBits, opLeft]
586-
[opLeft, left.oBits]
587-
]
588-
},
589-
{
590-
id = right
591-
label = RightShiftGen
592-
inPorts = [iBits, shift]
593-
outPorts = [oBits]
594-
parameters = [width]
595-
children = [
596-
{
597-
id = opRight
598-
label = ">>"
599-
northPorts = [{id = shift, label = " ", height = 5, width = 1}]
600-
}
601-
]
602-
edges = [
603-
[right.shift, opRight.shift]
604-
[right.iBits, opRight]
605-
[opRight, right.oBits]
606-
]
607-
}
608-
]
609-
```
610-
611-
</div>
612-
///
613-
614-
615-
616-
## Design Composition & Instantiation
617-
DFHDL supports three mechanisms to form a design hierarchy through design instantiation and composition:
618-
619-
* [Direct Connection Composition][direct-connection-composition] - The recommended mechanism for complex design hierarchies with multiple inputs and outputs. Design instantiation and port connection can be done separately, allowing child design ports to be referenced without intermediate variables.
620-
621-
* [Via Connection Composition][via-connection-composition] - A legacy mechanism that connects ports only within a design instantiation. This exists for compatibility with Verilog module instancing and VHDL component instancing. The DFHDL compiler automatically transforms direct connections into via connections.
622-
623-
* [Functional Composition][functional-composition] - A method-call mechanism for dataflow designs, primarily used for arithmetic/logic functionality with a single output port. The DFHDL compiler automatically transforms functional composition into direct design composition.
624-
625-
The following sections explore these composition mechanisms using our running example of a bit shifter. First, let's examine a more complex shifter with both left and right shift capabilities, implemented as a flat (composition-less) design:
626-
627553
### `LRShiftFlat` example {#LRShiftFlat}
628554
/// admonition | Generic left-right shifter, flat design example
629555
type: example
@@ -711,6 +637,80 @@ children = [
711637
///
712638
///
713639

640+
### Design Class Inheritance
641+
DFHDL leverages Scala inheritance to enable sharing functionality between design classes.
642+
643+
#### `ShiftGen` example {#ShiftGen}
644+
/// admonition | Generic left and right shifters, design class inheritance example
645+
type: example
646+
The DFHDL code below demonstrates how to implement both left and right generic shifters efficiently by using a common `#!scala abstract class` named `ShiftGen`. The `width` parameter is declared as an abstract class field (without an assigned value) inside the `ShiftGen` class body. By extending `ShiftGen`, both `LeftShiftGen` and `RightShiftGen` can utilize the IOs already declared in `ShiftGen`. They only need to explicitly declare the `width` parameter and implement the shift functionality in their respective class bodies.
647+
648+
<div class="grid" markdown>
649+
650+
```scala
651+
--8<-- "lib/src/test/scala/docExamples/ugdemos/demo5/LRShiftDirect.scala:6:35"
652+
```
653+
654+
```hdelk width=100%
655+
stroke-width = 0
656+
children = [
657+
{
658+
id = left
659+
label = LeftShiftGen
660+
inPorts = [iBits, shift]
661+
outPorts = [oBits]
662+
parameters = [width]
663+
children = [
664+
{
665+
id = opLeft
666+
label = "<<"
667+
northPorts = [{id = shift, label = " ", height = 5, width = 1}]
668+
}
669+
]
670+
edges = [
671+
[left.shift, opLeft.shift]
672+
[left.iBits, opLeft]
673+
[opLeft, left.oBits]
674+
]
675+
},
676+
{
677+
id = right
678+
label = RightShiftGen
679+
inPorts = [iBits, shift]
680+
outPorts = [oBits]
681+
parameters = [width]
682+
children = [
683+
{
684+
id = opRight
685+
label = ">>"
686+
northPorts = [{id = shift, label = " ", height = 5, width = 1}]
687+
}
688+
]
689+
edges = [
690+
[right.shift, opRight.shift]
691+
[right.iBits, opRight]
692+
[opRight, right.oBits]
693+
]
694+
}
695+
]
696+
```
697+
698+
</div>
699+
///
700+
701+
702+
703+
## Design Composition & Instantiation
704+
DFHDL supports three mechanisms to form a design hierarchy through design instantiation and composition:
705+
706+
* [Direct Connection Composition][direct-connection-composition] - The recommended mechanism for complex design hierarchies with multiple inputs and outputs. Design instantiation and port connection can be done separately, allowing child design ports to be referenced without intermediate variables.
707+
708+
* [Via Connection Composition][via-connection-composition] - A legacy mechanism that connects ports only within a design instantiation. This exists for compatibility with Verilog module instancing and VHDL component instancing. The DFHDL compiler automatically transforms direct connections into via connections.
709+
710+
* [Functional Composition][functional-composition] - A method-call mechanism for dataflow designs, primarily used for arithmetic/logic functionality with a single output port. The DFHDL compiler automatically transforms functional composition into direct design composition.
711+
712+
The following sections explore these composition mechanisms using our running example of a bit shifter. First, let's examine a more complex shifter with both left and right shift capabilities, implemented as a flat (composition-less) design:
713+
714714
### Direct Connection Composition
715715
Direct connection composition is the recommended approach for building hierarchical designs in DFHDL. It offers several key advantages:
716716

0 commit comments

Comments
 (0)