10-09-2018 06:31 AM
Hi!
Let us say we have a loop with controls outside the loop to be initialized before loop run-time. I have seen applications using shift registers to connect the loop content with outside controls. Are there any advantages of using Shift Registers this way over Tunnels?
Solved! Go to Solution.
10-09-2018 06:55 AM - edited 10-09-2018 06:58 AM
@sskr33 wrote:
Are there any advantages of using Shift Registers this way over Tunnels?
Yes, the values in the shift registers can be set inside the loop. So iteration 0 sets the values for iteration 1. That is in fact the hole point of a shift register. Usually (there are corner cases*) if you don't want that a tunnel is better.
All this stuff is probably in the (free) online courses (although I never did them).
* A 'corner case' (pretty common, but for this context) is when an output of the loop needs to make sense even if the loop iterates 0 times. This is important for instance when references are used. Two tunnels (in and out) would change the output to a 0 reference if the loop runs 0 times. A shift register would output it's input.
10-09-2018 09:23 AM - edited 10-09-2018 09:24 AM
wiebe@CARYA wrote:
@sskr33Yes, the values in the shift registers can be set inside the loop. So iteration 0 sets the values for iteration 1. That is in fact the hole point of a shift register. Usually (there are corner cases*) if you don't want that a tunnel is better.
Having to set the starting value inside the loop sounds like a corner case to me. I can't say I have ever used a feedback node since it inception as I have yet to run into a case where a shift register would not suffice. You know you can "preset" a shift register so iteration 0 starts at any value you want.
10-09-2018 10:00 AM
Feedback nodes are handy especially in larger state machines where you have one case that needs a value from a previous iteration. Rather than having to wire the value to a shift register and wire it through all of your case you can simply put a feedback node in that one case and all is good.
10-09-2018 11:51 AM
@RTSLVU wrote:Having to set the starting value inside the loop sounds like a corner case to me.
I think wiebe was referring to updating the value for the next iteration, not the starting value
@RTSLVU wrote:I can't say I have ever used a feedback node since it inception as I have yet to run into a case where a shift register would not suffice.
A Shift Register and a Feedback Node as essentially the same thing. But I do find Feedback Nodes quite useful for things like comparing a value to its previous iteration. It saves wiring.
10-10-2018 02:47 AM
@crossrulz wrote:
@RTSLVU wrote:Having to set the starting value inside the loop sounds like a corner case to me.
I think wiebe was referring to updating the value for the next iteration, not the starting value
Yes, I was.
@crossrulz
@RTSLVU wrote:I can't say I have ever used a feedback node since it inception as I have yet to run into a case where a shift register would not suffice.
A Shift Register and a Feedback Node as essentially the same thing. But I do find Feedback Nodes quite useful for things like comparing a value to its previous iteration. It saves wiring.
A thing about the feedback loop attached to loops is that you can put it inside a structure (even a loop), while still having the initializer on the loop. The rest of the loop diagram doesn't need to have all the wires that a shift register would need. That sounds like a great feature, but I found the use cases very limited. You often want to use the output of the feedback node as well. So you still end up with a shift register...
For me feedback nodes attached to a loop are mostly obscure and mostly useless. That could be biased by a decade of using the shift register.
Standalone feedback nodes are a different story altogether.
10-10-2018 03:31 AM
Another question:
Do Shift Registers have any advantages over Tunnels in perspective of speed of the execution of the loop or resources consumed when used on FPGA? In case you only use them for initiation, that is (the value doesn't change during the loop run-time).
10-10-2018 03:45 AM
@sskr33 wrote:
Do Shift Registers have any advantages over Tunnels in perspective of speed of the execution of the loop or resources consumed when used on FPGA? In case you only use them for initiation, that is (the value doesn't change during the loop run-time).
I'd put my bet on a tunnel.
With a SR, LV would likely be smart enough to avoid data copies if the value doesn't change in the loop. But it might (I really don't know for sure) add logic for writing values on the right side even if it never changes. So (IMHO) best case it will be as good as a tunnel, worse case it will be less efficient.
Of course if you want execution speed, you'd use a single cycled timed loop. Then you'd know the execution speed, and LV will make it fit or it will fail to compile. I'd say a SR will require more slices though.
So in execution speed (not really applicable on an FPGA), resources and also compilation time, I'd go for the tunnel. In this situation.
10-10-2018 09:28 AM
I would bet that the compiler could do a better job of optimizations when it is a tunnel since it is explicit that it will not change inside the loop. A shift register would indicate that the value might change and therefore some optimizations may not be allowed.
10-10-2018 09:31 AM
@Mark_Yedinak wrote:
I would bet that the compiler could do a better job of optimizations when it is a tunnel since it is explicit that it will not change inside the loop. A shift register would indicate that the value might change and therefore some optimizations may not be allowed.
From what I understand anytime you have a tunnel entering a loop it pretty much negates any optimizations so SR or FN makes no difference in that aspect.