Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 17 additions & 4 deletions lib/src/references/port_reference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ sealed class PortReference extends Reference {
}

if (relativeLocation == _RelativePortLocation.sameModule &&
direction == PortDirection.input) {
direction == PortDirection.input &&
other.direction == PortDirection.input) {
throw RohdBridgeException(
'An port $other on module ${other.module} cannot drive an'
'An input port $other on module ${other.module} cannot drive an'
' input $this on the same module');
}

Expand Down Expand Up @@ -275,7 +276,13 @@ sealed class PortReference extends Reference {
}
}

return (driver: other._internalPort, receiver: _internalPort);
if (direction == PortDirection.input &&
other.direction == PortDirection.output) {
// loop-back
return (driver: other._externalPort, receiver: _externalPort);
} else {
return (driver: other._internalPort, receiver: _internalPort);
}

case _RelativePortLocation.sameLevel:
return (driver: other._externalPort, receiver: _externalPort);
Expand Down Expand Up @@ -322,7 +329,13 @@ sealed class PortReference extends Reference {
}
}

return other._internalPortSubset;
if (direction == PortDirection.input &&
other.direction == PortDirection.output) {
// loop-back
return other._externalPortSubset;
} else {
return other._internalPortSubset;
}

case _RelativePortLocation.sameLevel:
return other._externalPortSubset;
Expand Down
3 changes: 2 additions & 1 deletion test/intf_port_module_port_connections_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ void main() {

if (testCase.relativePosition ==
_RelativePosition.sameModule &&
testCase.dst.direction == PortDirection.input) {
testCase.dst.direction == PortDirection.input &&
testCase.src.direction == PortDirection.input) {
// port cant drive input on same module
expectFailure = true;
}
Expand Down