Skip to content

Commit 1dbb700

Browse files
author
Oron Port
committed
fix: domain contraint check only when domain clock is not a var
1 parent be89284 commit 1dbb700

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,12 @@ final case class DB(
11051105
foundLoc = true
11061106
case _ =>
11071107
}
1108-
if (!foundLoc)
1108+
val clkIsVar = domainOwnerMemberTable(domainOwner).view.collectFirst {
1109+
case dcl: DFVal.Dcl if dcl.isClkDcl => dcl.isVar
1110+
}.getOrElse(false)
1111+
1112+
// for internal domains (indicated by a clock variable) we don't need to check for location constraints
1113+
if (!foundLoc && !clkIsVar)
11091114
errors += s"${domainOwner.getFullName} is missing a clock location constraint"
11101115
case _ =>
11111116
end match

lib/src/test/scala/ElaborationChecksSpec.scala

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,60 @@ class ElaborationChecksSpec extends DesignSpec:
459459
assertElaborationErrors(Top())(
460460
"No error found"
461461
)
462+
test("no need for clock location constraint check in internal domains"):
463+
object Test:
464+
import hw.constraints.*
465+
@deviceID(deviceID.Vendor.XilinxAMD, "test", "test", "")
466+
@timing.clock(rate = 20.MHz)
467+
@top(false) class Top extends RTDesign:
468+
@io(loc = "locClk")
469+
val clk = Clk <> IN
470+
@io(loc = "locx")
471+
val x = Bit <> IN
472+
@io(loc = "locy")
473+
val y = Bit <> OUT
474+
@timing.clock(rate = 20.MHz)
475+
val dmn = new RTDomain:
476+
val clk = Clk <> VAR
477+
dmn.clk <> clk
478+
y <> x.reg(1, init = 0)
479+
end Top
480+
end Test
481+
import Test.*
482+
assertElaborationErrors(Top())(
483+
"No error found"
484+
)
485+
test("domain constraint check"):
486+
object Test:
487+
import hw.constraints.*
488+
@deviceID(deviceID.Vendor.XilinxAMD, "test", "test", "")
489+
@top(false) class Top extends EDDesign:
490+
@io(loc = "locClk")
491+
@timing.clock(rate = 20.MHz)
492+
val dmn1 = new RTDomain:
493+
@io(loc = "locx")
494+
val x = Bit <> IN
495+
@io(loc = "locy")
496+
val y = Bit <> OUT
497+
y <> x.reg(1, init = 0)
498+
end dmn1
499+
@timing.clock(rate = 20.MHz)
500+
val dmn2 = new RTDomain:
501+
val x = Bit <> IN
502+
val y = Bit <> OUT
503+
y <> x.reg(1, init = 0)
504+
end dmn2
505+
end Top
506+
end Test
507+
import Test.*
508+
assertElaborationErrors(Top())(
509+
"""|Elaboration errors found!
510+
|The following top device design ports or domains are missing location constraints:
511+
| Top.dmn2 is missing a clock location constraint
512+
| Top.dmn2.x
513+
| Top.dmn2.y
514+
|To Fix:
515+
|Add a location constraint to the ports by connecting them to a located resource or
516+
|by using the `@io` constraint.""".stripMargin
517+
)
462518
end ElaborationChecksSpec

0 commit comments

Comments
 (0)