Skip to content

Commit 52fb878

Browse files
authored
Merge pull request #237 from DFiantHDL/docsupdate8
FSM WIP + Documentation update
2 parents afb3989 + b042c2c commit 52fb878

File tree

111 files changed

+4802
-669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+4802
-669
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ project/metals.sbt
3131
node_modules/
3232
package.json
3333
package-lock.json
34+
*.drawio.bkp
35+

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 3.8.3
1+
version = 3.9.3
22
runner.dialect = scala3
33

44
maxColumn = 100

build.sbt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ commands += DFHDLCommands.docExamplesRefUpdate
33

44
// format: off
55
val projectName = "dfhdl"
6-
val compilerVersion = "3.6.3"
6+
val compilerVersion = "3.6.4"
77

88
inThisBuild(
99
List(
@@ -41,7 +41,8 @@ lazy val root = (project in file("."))
4141
compiler_ir,
4242
core,
4343
compiler_stages,
44-
lib
44+
lib,
45+
devices
4546
)
4647

4748
lazy val internals = project
@@ -125,6 +126,21 @@ lazy val lib = project
125126
compiler_stages
126127
)
127128

129+
lazy val devices = (project in file("devices"))
130+
.settings(
131+
name := s"$projectName-devices",
132+
settings,
133+
pluginUseSettings,
134+
libraryDependencies ++= commonDependencies
135+
)
136+
.dependsOn(
137+
plugin,
138+
internals,
139+
compiler_ir,
140+
core,
141+
lib
142+
)
143+
128144
// DEPENDENCIES
129145

130146
lazy val dependencies =

compiler/ir/src/main/scala/dfhdl/compiler/analysis/DFValAnalysis.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ import DFDesignBlock.InstMode
1212
import scala.util.boundary, boundary.break
1313
import scala.annotation.targetName
1414

15+
object IteratorDcl:
16+
def unapply(dcl: DFVal.Dcl)(using MemberGetSet): Boolean =
17+
dcl.hasTagOf[DFVal.Dcl.IteratorTag.type]
18+
1519
object Ident:
1620
def unapply(alias: DFVal.Alias.AsIs)(using MemberGetSet): Option[DFVal] =
17-
if (alias.hasTagOf[DFVal.Alias.IdentTag.type])
18-
Some(alias.relValRef.get)
21+
if (alias.hasTagOf[DFVal.Alias.IdentTag.type]) Some(alias.relValRef.get)
1922
else None
2023

2124
//A design parameter is an as-is alias that:

compiler/ir/src/main/scala/dfhdl/compiler/ir/Config.scala

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,34 @@ object ConfigN:
1111
given [T]: CanEqual[None.type, ConfigN[T]] = CanEqual.derived
1212
given [L, R]: CanEqual[ConfigN[L], ConfigN[R]] = CanEqual.derived
1313

14+
/** Sets the policy for inclusing the clock or reset signals when they are not needed
15+
*/
16+
enum ClkRstInclusionPolicy derives CanEqual:
17+
/** Don't include if not needed
18+
*/
19+
case AsNeeded
20+
21+
/** Always include at the top and silence with `@unused` annotation
22+
*/
23+
case AlwaysAtTop
24+
1425
type ClkCfg = ConfigN[ClkCfg.Explicit]
1526
object ClkCfg:
1627
enum Edge derives CanEqual:
1728
case Rising, Falling
1829

1930
final case class Explicit(
2031
edge: Edge,
21-
rate: Rate,
22-
portName: String
23-
) derives CanEqual
32+
rate: DFVal,
33+
portName: String,
34+
inclusionPolicy: ClkRstInclusionPolicy
35+
) extends HasRefCompare[Explicit] derives CanEqual:
36+
override protected def prot_=~(that: Explicit)(using MemberGetSet): Boolean =
37+
this.edge == that.edge && this.rate =~ that.rate && this.portName == that.portName &&
38+
this.inclusionPolicy == that.inclusionPolicy
39+
lazy val getRefs: List[DFRef.TwoWayAny] = rate.getRefs
40+
def copyWithNewRefs: this.type = copy(rate = rate.copyWithNewRefs).asInstanceOf[this.type]
41+
end ClkCfg
2442

2543
type RstCfg = ConfigN[RstCfg.Explicit]
2644
object RstCfg:
@@ -32,7 +50,8 @@ object RstCfg:
3250
final case class Explicit(
3351
mode: Mode,
3452
active: Active,
35-
portName: String
53+
portName: String,
54+
inclusionPolicy: ClkRstInclusionPolicy
3655
) derives CanEqual
3756
end RstCfg
3857

@@ -56,15 +75,23 @@ enum RTDomainCfg extends HasRefCompare[RTDomainCfg] derives CanEqual:
5675
protected def `prot_=~`(that: RTDomainCfg)(using MemberGetSet): Boolean =
5776
(this, that) match
5877
case (Related(thisRef), Related(thatRef)) => thisRef =~ thatRef
59-
case _ => this == that
78+
case (
79+
Explicit(thisName, thisClkCfg: ClkCfg.Explicit, thisRstCfg),
80+
Explicit(thatName, thatClkCfg: ClkCfg.Explicit, thatRstCfg)
81+
) =>
82+
thisName == thatName && thisClkCfg =~ thatClkCfg && thisRstCfg == thatRstCfg
83+
case _ => this == that
6084

6185
lazy val getRefs: List[DFRef.TwoWayAny] = this match
62-
case Related(relatedDomainRef) => List(relatedDomainRef)
63-
case _ => Nil
86+
case Related(relatedDomainRef) => List(relatedDomainRef)
87+
case Explicit(_, clkCfg: ClkCfg.Explicit, rstCfg) => clkCfg.getRefs
88+
case _ => Nil
6489

6590
def copyWithNewRefs: this.type = this match
6691
case Related(relatedDomainRef) => Related(relatedDomainRef.copyAsNewRef).asInstanceOf[this.type]
67-
case _ => this
92+
case Explicit(name, clkCfg: ClkCfg.Explicit, rstCfg) =>
93+
Explicit(name, clkCfg.copyWithNewRefs, rstCfg).asInstanceOf[this.type]
94+
case _ => this
6895
end RTDomainCfg
6996

7097
object RTDomainCfg:

compiler/ir/src/main/scala/dfhdl/compiler/ir/DB.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,17 @@ final case class DB(
190190
case MemberView.Folded =>
191191
ownerMemberTable(owner)
192192
case MemberView.Flattened =>
193+
def recur(owner: DFOwner, includeOwner: Boolean = true): List[DFMember] =
194+
val members = ownerMemberTable(owner)
195+
members.flatMap {
196+
case d: DFDesignBlock => Some(d)
197+
case o: DFOwner => if (includeOwner) o :: recur(o) else recur(o)
198+
case m => Some(m)
199+
}
200+
end recur
193201
owner match
194202
case d: DFDesignBlock => designMemberTable(d)
195-
case b: DFBlock => blockMemberTable(b)
196-
case _ => ownerMemberTable(owner)
203+
case _ => recur(owner, includeOwner = false)
197204

198205
// holds a hash table that lists members of each owner. The member list order is maintained.
199206
lazy val ownerMemberTable: Map[DFOwner, List[DFMember]] =

0 commit comments

Comments
 (0)