05-29-2019 01:39 PM
Hello folks,
I'd like some recommendations on how to handle creating an LVFPGA VI that can act as its own simulation source. The DEN requires a timing loop (while or SCTL) in the target VI, but my subVIs don't contain loops - only my top level. Is there a convenient way to incorporate loops such that my DEN works, but without having multiple copies of my controls and indicators so I don't have to rewire the connector pane when switching from TB to synthesis?
I am using LabVIEW 2017 with FPGA module. The Desktop Execution Node (DEN) allows the user to simulate the behavior of LabVIEW FPGA modules, and plot various boolean and numeric signals on a waveform. The DEN expects to point to a VI containing either a While Loop + Timing structures, or a Single Cycle Timed Loop. It then allows you to apply a top level "clock" as a stimulus source, as well as select Inputs to apply stimulus.
Example VI: U16 counter that saturates @ xFFFF rather than rollover.
As you can see, this subVI is meant to be instantiated in a while loop with looptimer, or SCTL.
Testbench: Do not increment for the first 15 clocks. Then increment for 5 clocks. Then reset the count. Then resume incrementing. End the simulation after 40 clocks elapsed.
Here are the issues I see:
So it really looks like my only two options are:
Can you help provide some other suggestions for me to try, or other feedback?
05-29-2019 02:23 PM
EDIT: I just realized that nesting SCTLs is a no-no. I thought perhaps it would recognize and flatten the nests. It does not. Therefore, I don't have any streamlined way to procedurally switch between synthesizable and simulator-compatible subVIs.
Bummer.
05-29-2019 03:48 PM
Yeah, nested SCTLs are not allowed, which definitely doesn't help you. The real issue that you're running into is that the DEN isn't really designed for "unit" testing like this. It's more for higher level "component" testing. That said, you can get the behavior you're looking for by adding in a wrapper VI on the FPGA side (that is really just for this simulation). A project organization would look something like this:
having the additional files in the project is definitely not ideal, but there isn't really a way around it... at least in LabVIEW 20XX.
It doesn't really help your current project, but we actually went the other direction with LabVIEW NXG, and the node similar to the DEN behaves as you would have expected.
05-29-2019 04:58 PM
TJ - good to hear from you. As you know, I'm trying to develop a methodology for unit-testing my VI's. I've been becoming more proficient at the DEN and its intricacies. I've also been working through the Simulated I/O from VI functionality. Specifically, trying out this tutorial: http://zone.ni.com/reference/en-XX/help/371599P-01/lvfpgaconcepts/test_bench_tutorial/
I don't think that's really the greatest method either - it's wildly unreadable, and fairly obscure if you don't already know how to do it. I want to get out of the habit of manual checking of testbenches, but also would like the flexibility to probe deeper into subVIs if possible.
What does the NI staff use for Unit Test and/or regression testing of FPGA VI?
05-30-2019 08:33 AM
Also it's worth mentioning that your first example photo doesn't work in LV2017 for sampling probes.
Specifically, the DEN will only allow probing of the VI that it points to. So having a SCTL wrapper around a SubVI block defeats the purpose of probing. Here's an adder example that illustrates that your example with the 'sim' wrapper doesn't work except as a black-box. This would work for "Verification" against a software model, and for use in a self-checking testbench. Doesn't really work for debugging.
Any visibility for debugging would need to be done with more copying and pasting. IE: the a DUT would need to be debugged, and then copied/pasted into its own non-SCTL VI, as shown here.
06-03-2019 05:00 PM - edited 06-03-2019 05:06 PM
Hi JJMontante,
I think you were already hinting at this in your first post but part of the problem here is that only certain block diagram nodes and structures will advance simulated time (i.e. While Loops and SCTLs) when using DEN. You can see a full list of those nodes here:
Using the LabVIEW FPGA Desktop Execution Node
http://www.ni.com/product-documentation/51859/en/
In addition, I think that your definition of Unit Testing might be slightly different than the way it is defined for LabVIEW 20XX FPGA in our documentation. We recommend that Unit Testing in LabVIEW 20XX FPGA be executed by running code on the Windows PC. The Desktop Execution Node is considered "FPGA Simulation", even though the node itself is being called from the Windows PC. Here is the way Unit Testing is defined in our documentation:
"Execution of a VI in the Windows context is primarily used for unit testing and logic validation. Because a unit does not contain any FPGA-specific I/O or resources, you can execute the VI in the Windows context. To execute an FPGA VI in the Windows context, click and drag the VI from the FPGA target to My Computer in the LabVIEW project.
When you execute an FPGA VI in the Windows context, you can only verify the functionality of the VI. In the Windows context, none of the FPGA timing characteristics of the VI is preserved. To verify timing, you must integrate the unit into a component and test the unit in one of the other execution modes."
Taking this into account I think your unit testing would be running these VIs on the Windows PC to verify the functionality of the unit without DEN and without any timing. When the VI is running on the Windows PC you can use all of your standard LabVIEW debugging tools (breakpoints, highlight execution, probes, etc.). If some of the VIs that you want to unit test can't run on the Windows PC because of FPGA specific nodes or resources then it could be an indication that it needs to be broken down more to be tested at the unit level (as we've defined it). If you need to incorporate timing then it would no longer be unit testing.
My understanding of the intent of DEN is for it to be used at a higher level testing (i.e. component and above).
This tutorial contains the definitions and more detail on the various forms of testing:
Testing and Debugging LabVIEW FPGA Code
http://www.ni.com/tutorial/51862/en/
Finally, regarding organizing and maintaining separate code for simulation and hardware one thing that might be helpful is using a Conditional Disable Structure with the FPGA_EXECUTION_MODE symbol:
Configuring Conditions for Conditional Disable Structures
https://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/creating_cond_disable_struc/
There is a simple LabVIEW example for this structure at:
Help>>Find Examples>>Fundamentals>>Loops and Structures>>Conditional Disable Structure.vi
All of that being said I think that you definitely have some valid concerns here. My intent with the above is to describe what I understand the purpose of DEN to be and what we've defined as unit testing.
Regards,
Kyle S.
06-04-2019 07:42 AM
Kyle -
Long post ahead, most of it is me trying to put my thoughts into writing. I'd like to achieve specific goals, with specific questions all the way at the end. I'd appreciate your input on those questions, and of course, let me know where my assumptions are wrong in what I've written below.
My goal is to try and create an ASIC/FPGA style verification flow with the following goals:
My current design flow basically forces me into a couple of directions I don't want:
So to recap the advice given in this thread for a single VI with no hierarchy.
Which *ideally* requires the following resources:
1. LabVIEW FPGA source code
2. LabVIEW FPGA wrapper for timing
3. Labview Host code for stimulus generation, checking, and execution
4. 3rd-party simulation export
5. VHDL files for stimulus generator, checker
6. LabVIEW FPGA DUT programmer
7. LabVIEW Host testbench programmer (bad practice to trust testing to the author of the code)
8. VHDL testbench programmer (again, bad practice to let the author test their own code).
So here are my specific questions:
Thanks!
Jim