Skip to content

Commit 23c23f3

Browse files
author
Oron Port
committed
some more annotation prep
1 parent 0592380 commit 23c23f3

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ object ConfigN:
3535
def flatMap[R](f: T => ConfigN[R]): ConfigN[R] = x match
3636
case None => None
3737
case value: T @unchecked => f(value)
38+
def toList: List[T] = x match
39+
case None => Nil
40+
case value: T @unchecked => List(value)
41+
end extension
42+
extension [T <: DFRefAny](x: ConfigN[T])
43+
def =~(that: ConfigN[T])(using MemberGetSet): Boolean = (x, that) match
44+
case (None, None) => true
45+
case (t: T @unchecked, that: T @unchecked) => t =~ that
46+
case _ => false
3847
end ConfigN
3948

4049
/** Sets the policy for inclusing the clock or reset signals when they are not needed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package dfhdl.compiler.ir
2-
import dfhdl.compiler.printing.{Printer, HasCodeString}
2+
import dfhdl.compiler.printing.{Printer, HasCodeString, refCodeString}
33
import dfhdl.internals.*
44
import upickle.default.*
55
import dfhdl.internals.StableEnum
@@ -73,12 +73,13 @@ object constraints:
7373

7474
private def csParam[T](name: String, value: ConfigN[T])(using printer: Printer): String =
7575
value match
76-
case None => ""
77-
case cs: HasCodeString => s"$name = ${cs.codeString}"
78-
case str: String => s"$name = \"$str\""
79-
case num: FreqNumber => s"$name = ${printer.csDFFreqData(num)}"
80-
case num: TimeNumber => s"$name = ${printer.csDFTimeData(num)}"
81-
case _ => s"$name = ${value}"
76+
case None => ""
77+
case ref: DFRef.TwoWayAny @unchecked => s"$name = ${ref.refCodeString}"
78+
case cs: HasCodeString => s"$name = ${cs.codeString}"
79+
case str: String => s"$name = \"$str\""
80+
case num: FreqNumber => s"$name = ${printer.csDFFreqData(num)}"
81+
case num: TimeNumber => s"$name = ${printer.csDFTimeData(num)}"
82+
case _ => s"$name = ${value}"
8283

8384
final case class IO(
8485
bitIdx: ConfigN[Int] = None,

core/src/main/scala/dfhdl/hw/annotation.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import dfhdl.compiler.printing.{Printer, HasCodeString}
66
import scala.annotation.StaticAnnotation
77
import dfhdl.internals.*
88
import scala.annotation.Annotation
9-
import dfhdl.internals.StableEnum
109
import dfhdl.compiler.ir
10+
import dfhdl.core.*
1111

1212
object annotation:
1313
sealed abstract class HWAnnotation extends StaticAnnotation:

0 commit comments

Comments
 (0)