Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
93f19a3
exported tap ir construct
ducky64 May 10, 2026
b4168b8
wip export tap
ducky64 May 13, 2026
baf95e4
Revert "wip export tap"
ducky64 May 13, 2026
5b93edf
restructure export tap
ducky64 May 13, 2026
22df64e
bump proto ver
ducky64 May 13, 2026
ebec9cd
delete unused BCA
ducky64 May 14, 2026
cbf412a
tap test skeleton
ducky64 May 15, 2026
35eeac5
export tap tests
ducky64 May 15, 2026
1c7a95b
add requiredEmpty
ducky64 May 15, 2026
c8d4214
wip array case
ducky64 May 15, 2026
112bb33
fix exported tap case
ducky64 May 16, 2026
f2a827d
Update ExportTapTest.scala
ducky64 May 16, 2026
e63de6e
Update ExportTapTest.scala
ducky64 May 16, 2026
b71904b
add error test case
ducky64 May 16, 2026
d0de53e
add export tap checker
ducky64 May 16, 2026
1ad1fb4
refactoring checks to a pass
ducky64 May 16, 2026
1ed6202
Update ExportTapTest.scala
ducky64 May 16, 2026
c4cdf18
subboard block and variants
ducky64 May 16, 2026
5a9fb0e
Update SubboardBlock.py
ducky64 May 16, 2026
f5aec46
broken test case
ducky64 May 16, 2026
1173797
Update test_netlist_subboard.py
ducky64 May 16, 2026
39ecda1
compiling!
ducky64 May 16, 2026
9ce6f2e
Update test_netlist_subboard.py
ducky64 May 16, 2026
4188fc1
external blocks param
ducky64 May 16, 2026
19d52d7
e2e wrapper subboard
ducky64 May 16, 2026
a056d0c
test with passive (subport) tap
ducky64 May 16, 2026
6aedbd5
wip refactoring
ducky64 May 16, 2026
d4eba68
skeleton ok
ducky64 May 16, 2026
b38f0f2
e2e with examples
ducky64 May 16, 2026
128715f
passing
ducky64 May 16, 2026
df3df1c
Refactor out scope ops
ducky64 May 16, 2026
e42fab4
Update BoradScopedTransform.py
ducky64 May 16, 2026
e70809a
refactoring
ducky64 May 16, 2026
0264e2b
infrastructure
ducky64 May 16, 2026
742e646
fix types
ducky64 May 16, 2026
19a7697
hah
ducky64 May 16, 2026
35b9415
wip
ducky64 May 16, 2026
a3ba346
Create test_netlist_subboard_array.py
ducky64 May 16, 2026
ca5ea30
Update test_netlist_subboard_array.py
ducky64 May 16, 2026
f69be51
fix
ducky64 May 16, 2026
15f9504
fix pololu wrapper
ducky64 May 16, 2026
6920638
Update edg-compiler-precompiled.jar
ducky64 May 16, 2026
e739a43
cleaning
ducky64 May 16, 2026
f08bf5a
Update ExportTapCheck.scala
ducky64 May 17, 2026
a2b1949
cleanup
ducky64 May 17, 2026
384d50c
fix types and imports
ducky64 May 17, 2026
0daa251
fix
ducky64 May 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions compiler/src/main/scala/edg/ElemBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,27 @@ object ElemBuilder {
def Exported(
external: ref.LocalPath,
internal: ref.LocalPath,
expanded: Seq[expr.ValueExpr] = Seq()
expanded: Seq[expr.ValueExpr] = Seq(),
tap: Boolean = false
): expr.ValueExpr = expr.ValueExpr(
expr = expr.ValueExpr.Expr.Exported(expr.ExportedExpr(
exteriorPort = Some(ValueExpr.Ref(external)),
internalBlockPort = Some(ValueExpr.Ref(internal)),
expanded = expanded.map(_.getExported)
expanded = expanded.map(_.getExported),
tap = tap
))
)
def ExportedArray(
external: ref.LocalPath,
internal: ref.LocalPath,
expanded: Seq[expr.ValueExpr] = Seq()
expanded: Seq[expr.ValueExpr] = Seq(),
tap: Boolean = false
): expr.ValueExpr = expr.ValueExpr(
expr = expr.ValueExpr.Expr.ExportedArray(expr.ExportedExpr(
exteriorPort = Some(ValueExpr.Ref(external)),
internalBlockPort = Some(ValueExpr.Ref(internal)),
expanded = expanded.map(_.getExported)
expanded = expanded.map(_.getExported),
tap = tap
))
)
// variation for map_extract
Expand Down
39 changes: 23 additions & 16 deletions compiler/src/main/scala/edg/compiler/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object ElaborateRecord {
// Connection to be elaborated, to set port parameter, IS_CONNECTED, and CONNECTED_LINK equivalences.
// Only elaborates the direct connect, and for bundles, creates sub-Connect tasks since it needs
// connectedLink and linkParams.
case class Connect(toLinkPortPath: DesignPath, toBlockPortPath: DesignPath, root: DesignPath)
case class Connect(toLinkPortPath: DesignPath, toBlockPortPath: DesignPath, root: DesignPath, tap: Boolean = false)
extends ElaborateTask

// Elaborates the contents of a port array, based on the port array's ELEMENTS parameter.
Expand Down Expand Up @@ -117,7 +117,7 @@ class AssignNamer() {
}

object Compiler {
final val kExpectedProtoVersion = 11
final val kExpectedProtoVersion = 12
}

/** Compiler for a particular design, with an associated library to elaborate references from.
Expand Down Expand Up @@ -279,12 +279,14 @@ class Compiler private (
val toLinkPort = resolvePort(connect.toLinkPortPath).asInstanceOf[wir.HasParams]
val connectedParam = toLinkPort.getParams.keys.map(IndirectStep.Element(_))
for (connectedStep <- connectedParam) { // note: can't happen for top level connect!
constProp.addAssignEqual(
connect.toLinkPortPath.asIndirect + connectedStep,
connect.toBlockPortPath.asIndirect + connectedStep,
connect.root,
"connect"
)
if (!connect.tap) { // tap is non-propagating
constProp.addAssignEqual(
connect.toLinkPortPath.asIndirect + connectedStep,
connect.toBlockPortPath.asIndirect + connectedStep,
connect.root,
"connect"
)
}
}

// Add sub-ports to the elaboration dependency graph, as appropriate
Expand All @@ -295,7 +297,8 @@ class Compiler private (
ElaborateRecord.Connect(
connect.toLinkPortPath + portName,
connect.toBlockPortPath + portName,
connect.root
connect.root,
connect.tap
),
Seq()
)
Expand Down Expand Up @@ -499,11 +502,12 @@ class Compiler private (
case (ValueExpr.Ref(extPort), ValueExpr.Ref(intPort)) =>
if (!isInLink) {
elaboratePending.addNode(
ElaborateRecord.Connect(blockPath ++ extPort, blockPath ++ intPort, blockPath),
ElaborateRecord.Connect(blockPath ++ extPort, blockPath ++ intPort, blockPath, tap = exported.tap),
Seq(ElaborateRecord.Port(blockPath ++ extPort))
)
constProp.setConnection(blockPath ++ extPort, blockPath ++ intPort)
} else { // for links, the internal port is towards the inner link, so the args are flipped
require(!exported.tap, "tap not allowed in links")
elaboratePending.addNode(
ElaborateRecord.Connect(blockPath ++ intPort, blockPath ++ extPort, blockPath),
Seq(ElaborateRecord.Port(blockPath ++ intPort))
Expand All @@ -514,6 +518,7 @@ class Compiler private (
case _ => false // anything with allocates is not processed
}
case expr.ValueExpr.Expr.ExportedTunnel(exported) =>
require(!exported.tap, "tap not allowed in tunnel")
(exported.getExteriorPort, exported.getInternalBlockPort) match {
case (ValueExpr.Ref(extPort), ValueExpr.Ref(intPort)) =>
require(!isInLink)
Expand Down Expand Up @@ -845,12 +850,14 @@ class Compiler private (

case expr.ValueExpr.Expr.ExportedArray(exported) => // note internal port is portPostfix
val ValueExpr.Ref(extPostfix) = exported.getExteriorPort
constProp.addAssignEqual(
path.asIndirect ++ extPostfix + IndirectStep.Elements,
path.asIndirect ++ portPostfix + IndirectStep.Elements,
path,
constrName
)
if (!exported.tap) { // elements do not propagate in tap case, but are checked to be equal
constProp.addAssignEqual(
path.asIndirect ++ extPostfix + IndirectStep.Elements,
path.asIndirect ++ portPostfix + IndirectStep.Elements,
path,
constrName
)
}
constProp.addAssignEqual(
path.asIndirect ++ portPostfix + IndirectStep.Allocated,
path.asIndirect ++ extPostfix + IndirectStep.Allocated,
Expand Down
109 changes: 109 additions & 0 deletions compiler/src/main/scala/edg/compiler/ExportTapCheck.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package edg.compiler

import edg.ExprBuilder.ValueExpr
import edg.wir.{DesignPath, IndirectStep}
import edg.wir.ProtoUtil.{ConstraintProtoToSeqMap, ParamProtoToSeqMap}
import edgir.elem.elem
import edgir.expr.expr
import edgir.ref.ref

import scala.collection.SeqMap
import scala.collection.mutable

/** Checks export tap validity, that inner-side parameters are undefined and elements are consistent.
*/
class ExportTapCheck(compiler: Compiler)
extends DesignMap[Unit, Seq[CompilerError], Unit] {
val portParams = mutable.HashMap[DesignPath, Seq[String]]()

def mapExported(
containingPath: DesignPath,
exportName: String,
exported: expr.ExportedExpr
): Seq[CompilerError] = {
val (ValueExpr.Ref(extPort), ValueExpr.Ref(intPort)) = (exported.getExteriorPort, exported.getInternalBlockPort)
portParams(containingPath ++ extPort).flatMap { paramName =>
val paramPath = containingPath.asIndirect ++ intPort + paramName
val exportedErrors = compiler.getValue(paramPath) match {
case Some(_) => Seq(CompilerError.ExprError(
paramPath,
"export tap internal port parameter must be undefined"
))
case None => Seq()
}
exportedErrors ++ exported.expanded.flatMap(expr =>
mapExported(containingPath, exportName, expr)
)
}
}

def mapConstraint(
containingPath: DesignPath,
constrName: String,
constr: expr.ValueExpr
): Seq[CompilerError] = {
constr.expr match {
case expr.ValueExpr.Expr.Exported(exported) if exported.tap =>
mapExported(containingPath, constrName, exported)
case expr.ValueExpr.Expr.ExportedArray(exported) if exported.tap =>
val (ValueExpr.Ref(extPort), ValueExpr.Ref(intPort)) = (exported.getExteriorPort, exported.getInternalBlockPort)
val exportedArrayContainerErrors =
if (
compiler.getValue(containingPath.asIndirect ++ extPort + IndirectStep.Elements) == compiler.getValue(
containingPath.asIndirect ++ intPort + IndirectStep.Elements
)
) {
Seq()
} else {
Seq(CompilerError.ExprError(
containingPath.asIndirect + constrName,
"inconsistent export tap array port elements"
))
}
exportedArrayContainerErrors ++ mapExported(containingPath, constrName, exported)
case _ => Seq() // other constructs ignored
}
}

override def mapPort(path: DesignPath, port: elem.Port, ports: SeqMap[String, Unit]): Unit = {
portParams.put(path, port.params.asPairs.map { case (name, _) => name }.toSeq)
}
override def mapPortArray(path: DesignPath, port: elem.PortArray, ports: SeqMap[String, Unit]): Unit = {
portParams.put(path, Seq())
}
override def mapPortLibrary(path: DesignPath, port: ref.LibraryPath): Unit = {}

override def mapBlock(
path: DesignPath,
block: elem.HierarchyBlock,
ports: SeqMap[String, Unit],
blocks: SeqMap[String, Seq[CompilerError]],
links: SeqMap[String, Unit]
): Seq[CompilerError] = {
block.constraints.asPairs.flatMap {
case (name, constr) => mapConstraint(path, name, constr)
}.toSeq ++ blocks.values.flatten
}
override def mapBlockLibrary(path: DesignPath, block: ref.LibraryPath): Seq[CompilerError] = {
Seq() // block library errors should be checked elsewhere
}

override def mapLink(
path: DesignPath,
link: elem.Link,
ports: SeqMap[String, Unit],
links: SeqMap[String, Unit]
): Unit = {} // export tap not valid in links

override def mapLinkArray(
path: DesignPath,
link: elem.LinkArray,
ports: SeqMap[String, Unit],
links: SeqMap[String, Unit]
): Unit = {} // export tap not valid in links

override def mapLinkLibrary(
path: DesignPath,
link: ref.LibraryPath
): Unit = {} // link library errors should be checked elsewhere
}
6 changes: 5 additions & 1 deletion compiler/src/main/scala/edg/compiler/ExprToString.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ class ExprToString() extends ValueExprMap[String] {
expandedExteriorPort: String,
expandedInterorPort: String
): String = {
s"exported($exteriorPort, $internalBlockPort)"
if (!exported.tap) {
s"exported($exteriorPort, $internalBlockPort)"
} else {
s"exported[tap]($exteriorPort, $internalBlockPort)"
}
}

override def mapExportedTunnel(
Expand Down
Loading
Loading