programando fpgas con labview

49
Programming FPGAs using LabVIEW “How to program FPGAs without VHDL knowledge” Dr. Vlassis Petousis Ruđer Bošković Institut (RBI)

Upload: junior-figueroa

Post on 01-Dec-2015

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programando FPGAs Con LabVIEW

Programming FPGAs

using LabVIEW“How to program FPGAs

without VHDL knowledge”

Dr. Vlassis Petousis

Ruđer Bošković Institut (RBI)

Page 2: Programando FPGAs Con LabVIEW

5/11/2011 22

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).

Outline

Page 3: Programando FPGAs Con LabVIEW

LabVIEW + Basic FPGA

5/11/2011 3

F = (A+B)CD

Implementing Logic on FPGA

Page 4: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Project

5/11/2011 4

We have to create an Empty Project

LAB01

Page 5: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Project

5/11/2011 5

“Right click” on “My Computer” in the

Project Explorer view. We select “New”

and then “Targets and Devices”.

LAB01

Page 6: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Target

5/11/2011 6

“New target or device”

LAB01

Page 7: Programando FPGAs Con LabVIEW

LabVIEW – FPGA I/O

5/11/2011 7

For this we have to “right click” the FPGA Target

LAB01

Page 8: Programando FPGAs Con LabVIEW

LabVIEW – FPGA I/O

5/11/2011 8

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.

LAB01

Page 9: Programando FPGAs Con LabVIEW

LabVIEW – FPGA VI

5/11/2011 9

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

LAB01

Page 10: Programando FPGAs Con LabVIEW

LabVIEW – FPGA VI

5/11/2011 10

We created :

LAB01

Page 11: Programando FPGAs Con LabVIEW

LabVIEW – FPGA create Nodes

5/11/2011 11

We place 2 I/O Nodes on the Block Diagram of the LabVIEW FPGA VI

LAB01

Page 12: Programando FPGAs Con LabVIEW

LabVIEW – FPGA add Nodes

5/11/2011 12

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”.

LAB01

Page 13: Programando FPGAs Con LabVIEW

LabVIEW – FPGA add Nodes

5/11/2011 13

We can do the same to

add another FPGA I/O

LAB01

Page 14: Programando FPGAs Con LabVIEW

LabVIEW – FPGA exclusive OR

5/11/2011 14

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.

LAB01

XOR Truth Table

011

101

110

000

BAOutput

Input

Page 15: Programando FPGAs Con LabVIEW

LabVIEW – FPGA exclusive OR

5/11/2011 15

Wire the “SW1” and “SW0”

FPGA I/O to the Exclusive-OR

inputs.

Wire the output of the

function to “LED0”.

LAB01

Page 16: Programando FPGAs Con LabVIEW

LabVIEW – FPGA “While Loop”

5/11/2011 16

• 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.

• The “While Loop” you find on the “Functions Palette”.

LAB01

Page 17: Programando FPGAs Con LabVIEW

LabVIEW – FPGA “While Loop”

5/11/2011 17

LAB01

Page 18: Programando FPGAs Con LabVIEW

LabVIEW – FPGA “Save as”

5/11/2011 18

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”.

Page 19: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Running VIs

5/11/2011 19

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”.

Page 20: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Running VIs

5/11/2011 20

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.

Page 21: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Running VIs

5/11/2011 21

LAB01

LabVIEW starting the “Compile Server”.

Page 22: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Running VIs

5/11/2011 22

LAB01

Page 23: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Running VIs

5/11/2011 23

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.

Page 24: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Running VIs

5/11/2011 24

LAB01

You get a “Successful Compile Report” where you can see the implementation details of

your code. You have to Press “Ok”.

Page 25: Programando FPGAs Con LabVIEW

LabVIEW – FPGA Target Run

5/11/2011 25

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.

Page 26: Programando FPGAs Con LabVIEW

LabVIEW – FPGA @ SPARTAN 3E

5/11/2011 26

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 don’t want this effect you can download this VI to the

FLASH of the Xilinx SPARTAN starter board.

Page 27: Programando FPGAs Con LabVIEW

LabVIEW – FPGA @ SPARTAN 3E

5/11/2011 27

LAB01

Page 28: Programando FPGAs Con LabVIEW

LabVIEW – FPGA into “FLASH”

5/11/2011 28

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.

Page 29: Programando FPGAs Con LabVIEW

LabVIEW – FPGA into “FLASH”

5/11/2011 29

LAB01

“Run when loaded to FPGA”.

Make sure you select this option. Then press the “OK” button.

Page 30: Programando FPGAs Con LabVIEW

LabVIEW – FPGA into “FLASH”

5/11/2011 30

LAB01

Page 31: Programando FPGAs Con LabVIEW

LabVIEW – FPGA into “FLASH”

5/11/2011 31

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.

Page 32: Programando FPGAs Con LabVIEW

LabVIEW – FPGA into “FLASH”

5/11/2011 32

LAB01

• We will see that there are some previous steps executed.

• When the “Successful Compile Report” shows up you have to

press the “OK” button.

Now we will download it to the Flash.

• For this you have to go to the “Project Explorer” view and do a

“right mouse click” on the FPGA VI you created.

• Then choosing the “Download VI to Flash Memory” option will

start downloading it to the SPARTAN starter board flash.

Page 33: Programando FPGAs Con LabVIEW

LabVIEW – FPGA into “FLASH”

5/11/2011 33

LAB01

LabVIEW FPGA VI is downloaded to the Flash.

Page 34: Programando FPGAs Con LabVIEW

5/11/2011 3434

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).

Outline

Page 35: Programando FPGAs Con LabVIEW

Embedding VHDL in a FPGA

5/11/2011 35

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.

Page 36: Programando FPGAs Con LabVIEW

Step 1: Adding FPGA I/O

5/11/2011 36

LAB02

Page 37: Programando FPGAs Con LabVIEW

Step 2: Creating the VI

5/11/2011 37

LAB02

Do a “right mouse click” on the “FPGA Target” in the “Project Explorer”.

From the pull down menu select “New” => “VI”.

Page 38: Programando FPGAs Con LabVIEW

Step 2: Creating the VI

5/11/2011 38

LAB02

On the “block diagram” of this VI we have to put a “Timed Loop”

Page 39: Programando FPGAs Con LabVIEW

Step 2: Creating the VI

5/11/2011 39

LAB02

In this “Timed Loop” you have to place a “HDL Interface Node”

Page 40: Programando FPGAs Con LabVIEW

Step 2: Creating the VI

5/11/2011 40

LAB02

Now double click the “HDL Node”; you will get the following screen:

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

Type—Defines the data type of the

parameter. LabVIEW displays only a subset

of the data types supported in FPGA VIs.

Length—Defines the size of the Boolean array if

you select the Boolean array data type in the

Type column.

Page 41: Programando FPGAs Con LabVIEW

Step 2: Creating the VI

5/11/2011 41

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;

Page 42: Programando FPGAs Con LabVIEW

Step 2: Creating the VI

5/11/2011 42

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 <=(not inp(3)) and (not inp(2)) and (not inp(1)) and (not inp(0));

s2 <=(not inp(3)) and (not inp(2)) and inp(1) and inp(0);

s3 <=(not inp(3)) and inp(2) and (not inp(1)) and inp(0);

s4 <=(not inp(3)) and inp(2) and inp(1) and (not inp(0));

s5 <=inp(3) and (not inp(2)) and (not inp(1)) and inp(0);

s6 <=inp(3) and (not inp(2)) and inp(1) and (not inp(0));

s7 <=inp(3) and inp(2) and (not inp(1)) and (not inp(0));

s8 <=inp(3) and inp(2) and inp(1) and inp(0);

enable_out<='1';

Page 43: Programando FPGAs Con LabVIEW

Step 2: Creating the VI

5/11/2011 43

LAB02

In the tab “Execution Control” check the option “Single-Cycle Timed Loop

Allowed” and click the “OK” button.

Page 44: Programando FPGAs Con LabVIEW

Step 2: Creating the VI

5/11/2011 44

LAB02

Now we place two “FPGA I/O Node’s” on the block diagram of your VI.

Build an array with “SW0”, “SW1”, “SW2” and “SW3” as inputs.

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”.

Page 45: Programando FPGAs Con LabVIEW

Step 3: Running the VI

5/11/2011 45

LAB02

Now go to the “Project Explorer”. Right mouse click on “FPGA Target” then

select “Properties”.

Page 46: Programando FPGAs Con LabVIEW

Step 3: Running the VI

5/11/2011 46

LAB02

Be sure to check in this window “Run when loaded to FPGA” before compiling

the VI.

Page 47: Programando FPGAs Con LabVIEW

Step 3: Running the VI

5/11/2011 47

LAB02

Go back to “Project Explorer”. Do a right mouse click on “FPGA_VI_VHDL”.

Select Compiler and let the LabVIEW FPGA code compile.

When the compilation completed

go to

“Project Explorer” and do

a right mouse click on

“FPGA_VI_VHDL” and select

“Download VI to Flash Memory”

Page 48: Programando FPGAs Con LabVIEW

LabVIEW – FPGA

5/11/2011 48

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.

Page 49: Programando FPGAs Con LabVIEW

Take away home

5/11/2011 49

1st LabVIEW today is a very powerful tool in Science.

2nd Contains an easy way to embed VHDL code in FPGA’s.

3rd http://www.youtube.com/watch?v=-ulWxOyOfgM

Using LabVIEW FPGA with the Xilinx SPARTAN-3E XUP

Thank You for Your Attention