Open edwardalee opened 10 months ago
The reason for this behavior is that the C target has a single PortInstance that represents all the connections, inside and out, and the interleaving changes the order in which mixed radix digits are placed in the number that is used to index into the array of channels. I believe that the behavior could be made the same as the version without hierarchy by just implicitly treating an inside connection as interleaved if the outside connection is interleaved (note that the inside connection cannot be explicitly interleaved... that is prohibited by the validator).
I am not sure if this will work reliably in all cases. What if the connection forks off somewhere in the hierarchy? What if there is another connection on the path that uses the interleaved keyword?
In the C target, @cmnrd has pointed out that the way interleaved connections work with hierarchical programs is arguably incorrect. Consider a test program that looks like this (complete code below):
The connection is interleaved:
We add hierarchy as follows (complete code below):
where the interleaved connection is as follows:
Currently, the the behavior is that the first bank member of C will receive the first two outputs from a[0] followed by the first output from a[1]. This is not the same as above and arguably incorrect because the outside connection should not change how the inside connection is interpreted.
The reason for this behavior is that the C target has a single PortInstance that represents all the connections, inside and out, and the interleaving changes the order in which mixed radix digits are placed in the number that is used to index into the array of channels. I believe that the behavior could be made the same as the version without hierarchy by just implicitly treating an inside connection as interleaved if the outside connection is interleaved (note that the inside connection cannot be explicitly interleaved... that is prohibited by the validator).
Source code for the version without hierarchy:
Source code for the version with hierarchy: