LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SPI FPGA debug simulate

How can I debug/test FPGA code?

 

I have done a version of http://www.ni.com/white-paper/9117/en/ but I am getting nothing at the output (measuring with an oscilloscope).

 

I have simulated the main state machine and the sub vi SPI state machine (with Global definitions) on a normal vi to study it. But when I am flashing it in the FPGA (a FPGA version one) I am getting nothing at the output.

 

How to debug the FPGA code? I’ve created some indicator to the states machine but the main FPGA vi seen to work (change states) but nothing happened to SPI vi or the global definitions, as they are in FPGA they will not display the real values?

 

When I run the main FPGA vi the sub SPI vi and Global definition also shown they are engage running. Would they display the real values? Because the states in SPI sub vi does change.

 

The way I am testing it I select the command configure and then I run it (start buttom) and when It get back to idle I select Write/Read command, follow the condition to get back to idle (nothing at the output or in the global definition vi)

 

I have attached the code I am trying.

Message 1 of 4
(2,589 Views)

I recommend using the SPI library from http://sine.ni.com/nips/cds/view/p/lang/en/nid/210637 instead of the one you're using.

 

There are a couple of ways you can debug FPGA code. One is that you can set the FPGA to run on the development computer in simulation (right-click the target, choose Execute On...). This will let you use the standard LabVIEW debugging tools such as probes and execution highlighting.

 

If you are executing on the real FPGA, and you run the FPGA VI, the controls and indicators are live, so if your code sets an indicator value you'll see it on the front panel, and if you update a control, the FPGA will see the new value. You can do this even after you have already started running the host program; the FPGA front panel will connect to the already-running FPGA without resetting it.

 

Before you get into SPI, have you tried a simple program with a boolean on the front panel that turns an output on, to verify that you're measuring properly with your scope?

0 Kudos
Message 2 of 4
(2,562 Views)

nathand wrote:

I recommend using the SPI library from http://sine.ni.com/nips/cds/view/p/lang/en/nid/210637 instead of the one you're using.

 

I cannot use this example library as I need to modify the original example to satisfy requirement.

 

There are a couple of ways you can debug FPGA code. One is that you can set the FPGA to run on the development computer in simulation (right-click the target, choose Execute On...). This will let you use the standard LabVIEW debugging tools such as probes and execution highlighting.

 

Thanks I have done some example simulating input data this way but In this case it will leave FPGA hardware out, which I would like to verify.

 

If you are executing on the real FPGA, and you run the FPGA VI, the controls and indicators are live, so if your code sets an indicator value you'll see it on the front panel, and if you update a control, the FPGA will see the new value. You can do this even after you have already started running the host program; the FPGA front panel will connect to the already-running FPGA without resetting it.

 

In my initial post I think I state this option, the question in about Global Definitions and Sub vi within the FPGA main vi?

 

Before you get into SPI, have you tried a simple program with a boolean on the front panel that turns an output on, to verify that you're measuring properly with your scope?

 

I have done this by loading old simple example and there is nothing wrong with the hardware.


 

Message 3 of 4
(2,535 Views)

When you are running on the FPGA, only the top-level front panel will update. Global variables and subVIs will not display real values.

 

You can modify the other SPI library - I've done it. It took a little while to get a separate copy out of vi.lib, but my modified version works well (for the specific device). In my case I needed to insert a delay between each group of 16 bits, while holding the Chip Select line low the whole time.

 

Some FPGA devices support running the code in the development environment with real IO, is that an option on your device? It will run more slowly, of course, but you can do full debugging with the real signals. Since the code generates the SPI clock, the communication should still work even at a slower rate.

 

 

0 Kudos
Message 4 of 4
(2,518 Views)