TypedStaticPermutation<TLogic extends Logic, TValue> constructor
- TypedLogicArray<
TLogic, TValue> dataIn, { - required TypedLogicArray<
TLogic, TValue> outputPrototype, - required PermutationDescriptor descriptor,
- String name = 'typed_static_permutation',
Creates static typed-element wiring for descriptor.
Implementation
TypedStaticPermutation(
TypedLogicArray<TLogic, TValue> dataIn, {
required TypedLogicArray<TLogic, TValue> outputPrototype,
required this.descriptor,
super.name = 'typed_static_permutation',
}) : inputShape = LayoutShape(dataIn.dimensions),
outputShape = LayoutShape(outputPrototype.dimensions),
super(
definitionName: 'TypedStaticPermutation_'
'${payloadShapesIdentity([dataIn, outputPrototype])}_'
'P${descriptor.configurationSignature}',
) {
if (inputShape.elementCount != outputShape.elementCount ||
descriptor.length != inputShape.elementCount) {
throw RohdHclException(
'Typed permutation shapes and descriptor must contain the same '
'number of elements.',
);
}
if (dataIn.elementWidth != outputPrototype.elementWidth) {
throw PortWidthMismatchException.equalWidth(dataIn, outputPrototype);
}
if (!identical(dataIn.valueCodec, outputPrototype.valueCodec)) {
throw RohdHclException('Typed permutation value codecs must match.');
}
for (var index = 0; index < descriptor.length; index++) {
if (!rohdPayloadsCompatible([
dataIn.arrayElements[descriptor.sourceIndex(index)],
outputPrototype.arrayElements[index]
], ignoreConstantNames: true)) {
throw RohdHclException(
'Typed permutation source and destination payloads must match.');
}
}
final localData =
addTypedInput<TypedLogicArray<TLogic, TValue>>('dataIn', dataIn);
result = addTypedPayloadOutput(this, 'result', outputPrototype);
final localResult = result;
for (var outputIndex = 0; outputIndex < descriptor.length; outputIndex++) {
localResult.arrayElements[outputIndex] <=
localData.arrayElements[descriptor.sourceIndex(outputIndex)];
}
}