connectIO method
- Module module,
- Interface srcInterface, {
- Iterable<
DataPortGroup> ? inputTags, - Iterable<
DataPortGroup> ? outputTags, - Iterable<
DataPortGroup> ? inOutTags, - String uniquify(
- String original
override
Connects module's inputs, outputs, and inOuts up to srcInterface and
this Interface.
The srcInterface should be an external instance of the Interface
passed in from outside the module, and connectIO should be called on a
new instance of the Interface to be used by module for all input and
output connectivity. For example:
MyMod(MyIntf srcIntf) {
srcIntf = MyIntf(args)..connectIO(this, srcIntf, inputTags: ... );
}
All signals in the interface with specified TagType will be connected
to the Module via Module.addInput, Module.addOutput, or
Module.addInOut based on inputTags, outputTags, and inOutTags,
respectively. uniquify can be used to uniquifiy port names by
manipulating the original name of the port.
If inputTags, outputTags, or inOutTags is not specified, then,
respectively, no inputs, outputs, or inOuts will be added.
Implementation
@override
void connectIO(Module module, Interface<dynamic> srcInterface,
{Iterable<DataPortGroup>? inputTags,
Iterable<DataPortGroup>? outputTags,
Iterable<DataPortGroup>? inOutTags,
String Function(String original)? uniquify}) {
final inputs = inputTags?.toSet();
final outputs = outputTags?.toSet();
final inOuts = inOutTags?.toSet();
final isInput = inputs?.contains(DataPortGroup.data) ?? false;
final isOutput = outputs?.contains(DataPortGroup.data) ?? false;
final isInOut = inOuts?.contains(DataPortGroup.data) ?? false;
if (isInput || isOutput || isInOut) {
final source = srcInterface.port('data');
if (!compatiblePayloadConnection(data, source)) {
throw PortTypeException.forIntendedName(
'data',
'Memory payload layout does not match '
'${payloadShapeIdentity(data)}.');
}
final dataName = uniquify?.call('data') ?? 'data';
connectTypedPayloadPorts(module,
name: dataName,
local: data,
source: source,
input: isInput,
output: isOutput,
inOut: isInOut);
}
_suppressData = isInput || isOutput || isInOut;
try {
super.connectIO(module, srcInterface,
inputTags: inputs,
outputTags: outputs,
inOutTags: inOuts,
uniquify: uniquify);
} finally {
_suppressData = false;
}
}