LabVIEW FPGA Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
jkirschner

Single-Cycle Timed For Loop

Status: New

When writing LabVIEW code for an FPGA target, the most important considerations are speed and resource usage.  By using the single-cycle timed loop (SCTL), we can increase the speed of the program by allowing more than one operation to complete per clock cycle.  We also decrease resource usage by removing the flip-flops that would be required to store values between clock cycles for the operations in the SCTL.

 

However, there are limitations of the SCTL.  For some operations, it takes significantly less resources to implement something using a for loop rather than a single-cycle timed loop.  With a for loop, one can auto-index a result at the border of the for loop (if the preallocation of arrays option is selected) to obtain a fixed-size array (valid on the FPGA).  Below is the simplest possible example:

 

AutoIndexed For Loop

 

The equivalent with a single-cycle timed loop would be:

 

SCTL

The replace array/subset VI consumes resources proportional to the size of the array.  Depending on the operation being performed, this can increase resource usage such that it is more practical to use a for loop (as shown above).

 

I propose the creation of a single-cycle timed for loop.  Here is a very rough mock-up (MS Paint is not the most adequate of image processing tools... you will get the idea):

 

SCTFL

 

This solves two problems: 1) It allows for the compiler to know how many times to loop will run at compile time.  It also simplifies the UI by letting the user know how many times the loop will run without having to think through a condition.  2) It allows for the more efficient creation of fixed-size arrays through a SCTL (rather than through a for loop).

2 Comments
Dragis
Active Participant

this has been something i've been wanting to see for some time. actually, i'd just like to be able to have a single-cycle version of any structure, but that's another topic. this along with the "loose the ears" idea would make the diagram nice and compact. 

 

ps. as a compiler guy, i'd love to see LabVIEW support your middle sctl equivalent diagram with the replace array subset just like a for-loop since it knows the exact iteration count at compile time with the compare against a constant. 

ibberger
Member
I'd replace the SCTL by a Single Clock Structrue, which can be placed in any other structure where you need it, or it could be a "Single Clock" VI as well, where the compiler tries to execute that specific VI in a single clock cycle