Programando FPGAs Con LabVIEW
Programando FPGAs Con LabVIEW
Outline
1. Implementing a Boolean function in LabVIEW FPGA on the Xilinx SPARTAN Boards (LAB 01). 2. Embedding VHDL code in a Xilinx SPARTAN FPGA (LAB 02).
5/11/2011
5/11/2011
LAB01
5/11/2011
LAB01
5/11/2011
LAB01
5/11/2011
LAB01
5/11/2011
LAB01
If we go back to the Project Explorer view we see the FPGA I/O that we have added. With this I/O we will implement an Exclusive-OR function.
5/11/2011
LabVIEW FPGA VI
LAB01
1. The next step is the creation of a hardware program that runs on the Xilinx Spartan hardware target. 2. For this we do again a right mouse click on the FPGA target in the Project Explorer view. Select New VI
5/11/2011
LabVIEW FPGA VI
We created :
LAB01
5/11/2011
10
LAB01
5/11/2011
11
LAB01
To add another FPGA I/O. For this do a right click on the FPGA I/O you just filled with SW0. Select Add Element.
5/11/2011
12
LAB01
5/11/2011
13
LAB01
Now we will as an example implement an exclusive-OR Boolean function into the FPGA. From the Functions Palette select Programming Boolean and look for the Exclusive OR function. Place this one on the Block diagram.
5/11/2011
14
LAB01
5/11/2011
15
LAB01
When we implement the function like presented above the function will run only once. We would like to implement it that it runs continuously.
For this we place a While Loop around it and we wire a Boolean False constant to the stop condition of this loop.
5/11/2011
16
LAB01
5/11/2011
17
LAB01
Now it is time to save ourVI that we created for the FPGA. We do this by selecting File Save As... in either the Front Panel or the Block Diagram.
5/11/2011
18
LAB01
For starting the executing of this VI we have to press the Run arrow on either the Block Diagram or on the Front Panel.
5/11/2011
19
LAB01
LabVIEW does Generating Intermediate Files. This files will be send to the Xilinx Synthesis Tools. But this is not important for us as application developers.
5/11/2011
20
LAB01
5/11/2011
21
LAB01
5/11/2011
22
LAB01
When the Bitstream generation is complete message appears and the server status is set to Idle the Xilinx synthesis tools have done their job.
5/11/2011
23
LAB01
You get a Successful Compile Report where you can see the implementation details of your code. You have to Press Ok.
5/11/2011
24
LAB01
After you have pressed the Ok button your VI starts running on the FPGA target. It is indicated on your screen by the black Run arrow.
5/11/2011
25
LAB01
Playing with the switches SW0 and SW1 on the SPARTAN starter board you will see they have an XOR function. The led LD0 will be ON when one of those switches is turned ON.
The problem with this implementation is that when you stop the VI, the function is erased on the LabVIEW FPGA board.
If you dont want this effect you can download this VI to the FLASH of the Xilinx SPARTAN starter board.
5/11/2011
26
LAB01
5/11/2011
27
LAB01
For implementing your VI into the FLASH on the SPARTAN Starter board you have to do some things. 1. Run when loaded to FPGA on. For this you have to go to Project Explorer. 2.Right Mouse click on your FPGA target. Select the Properties option.
5/11/2011
28
LAB01
5/11/2011
29
LAB01
5/11/2011
30
LAB01
We must recompile the VI because we made a change. Do this by going to the Project Explorer view. Click with the Right Mouse button on the FPGA VI you have created for this project. Select the Compile option.
5/11/2011
31
LAB01
When the Successful Compile Report shows up you have to press the OK button.
LAB01
Outline
1. Implementing a Boolean function in LabVIEW FPGA on the Xilinx SPARTAN Boards (LAB 01). 2. Embedding VHDL code in a Xilinx SPARTAN FPGA (LAB 02).
5/11/2011
34
LAB02
The first things we have skipped because it is the same as in LAB01. In this LAB we are going to create a parity checker.
(Parity checking is a rudimentary method of detecting simple, single-bit errors in a memory system. In ncommunications, parity checking refers to the use of parity bits to check that data has been transmitted accurately. The parity bit is added to every data unit (typically 7 or 8 bits) that are transmitted. The parity bit for each unit is set so that all bytes have either an odd number or an even number of set bits).
We will put LED0 of the Spartan3E Starter board on when the input of the checker system (by use of SW0, SW1, SW2 and SW3) has even bits.
5/11/2011 35
LAB02
5/11/2011
36
LAB02
5/11/2011
37
LAB02
5/11/2011
38
LAB02
5/11/2011
39
LAB02
In the first screen we try to add the following 2 parameters: Name inp Direction in, Type TF [ ] Length 4 Name outp Direction out Type TF. Length --
1st SET
2nd SET
TypeDefines the data type of the parameter. LabVIEW displays only a subset of the data types supported in FPGA VIs. LengthDefines the size of the Boolean array if you select the Boolean array data type in the Type column.
5/11/2011
40
LAB02
In the code screen we replace hdlnode (name of the entity) to even_parity. The field below architecture implementation of even_parity is has to been filled with the following VHDL rule: signal s1, s2, s3, s4, s5, s6, s7, s8: std_logic;
5/11/2011 41
LAB02
The field below the VHDL keyword begin has to been filled with the following VHDL code:
outp(0) <=((s1 or s2) or (s3 or s4)) or ((s5 or s6) or (s7 or s8)); s1 s2 s3 s4 s5 s6 s7 s8 <=(not inp(3)) and (not inp(2)) and (not inp(1)) and (not inp(0)); <=(not inp(3)) and (not inp(2)) and inp(1) and inp(0); <=(not inp(3)) and inp(2) and (not inp(1)) and inp(0); <=(not inp(3)) and inp(2) and inp(1) and (not inp(0)); <=inp(3) and (not inp(2)) and (not inp(1)) and inp(0); <=inp(3) and (not inp(2)) and inp(1) and (not inp(0)); <=inp(3) and inp(2) and (not inp(1)) and (not inp(0)); <=inp(3) and inp(2) and inp(1) and inp(0);
enable_out<='1';
5/11/2011
42
LAB02
5/11/2011
43
LAB02
We connect the output of this build array function to the input of the HDLNode called inp. Connect now LED0 to outp of the HDLNode.
5/11/2011
44
LAB02
Now go to the Project Explorer. Right mouse click on FPGA Target then select Properties.
5/11/2011
45
LAB02
Be sure to check in this window Run when loaded to FPGA before compiling the VI.
5/11/2011
46
LAB02
Go back to Project Explorer. Do a right mouse click on FPGA_VI_VHDL. Select Compiler and let the LabVIEW FPGA code compile.
5/11/2011
47
LabVIEW FPGA
Now you can pull out the USB cable out of the Xilinx Spartan3E board and press the PROG button on this board. You will see that the function is implemented in it.
5/11/2011
48
5/11/2011
49