07-28-2009 08:52 AM
Hey Guys,
Simple questions ( I hope ). Say I have some FPGA code running that is outputting 4 different signals, and I want to be able to direct these signals to an output channel of my choice.
Does anyone have an example of how to do this?
I tried one way using an FPGA I/O node and wiring in a control to select an output channel. However, I'm only able to select the output and never change it while its running.
Thanks
Solved! Go to Solution.
07-28-2009 08:53 AM
Sorry....
This is a 7831R Multi-DAQ FPGA. LabVIEW 8.5
Thanks
07-29-2009 12:01 AM
One way to change the outputs while FPGA is running by having a control in the FPGA vi and use the Read/Write Control from Host to do the job. In this case you will have to write the FPGA code to take an appropriate action whenver control is set/reset etc. However this is not very efficient. Other way is to establish some kind of Communication mechanism like a FIFO to send data to FPGA vi, thereby an action can be taken by the FPGA vi based on it.
Hope this helps...
VJ
07-29-2009 12:38 AM
07-29-2009 08:17 AM
I've never used LV FGPA (it's on my todo list), but if I wanted to route multiple signals to a bunch of different outputs in an FPGA, here's a simple way to do it:
Let's say you had 32 output ports (X(31 downto 0)) and one channel A that you wanted to programatically route to one (or more) of the pins. First, you could declare a 32 bit "mask" register in your design, and make it accessible to the top level or whatever you're using to change your route.
Then, AND each bit in this mask with your channel A:
X(i) = A AND MASK(i); --where i is 0 to 31
In software this would be a FOR loop, but since youre in an FPGA this can be done all at the same time (and if you use a FOR loop for this, the fpga gods will kill a kitten).
Now, when you write the value 0x000000001 to your mask register, the least significant bit of X will follow the signal in A and the rest will stay at 0:
X(0) = A AND 1 = A
X(31 downto 1) = A AND 0 = 0
Note that if you wrote 0x00001001 you would get two lines to follow signal A.
What if you also had signals B, C and D? Just declare four masks and OR them all together at the end!
Amasked(i) = A AND A_MASK(i);
Bmasked(i) = B AND B_MASK(i);
Cmasked(i) = C AND C_MASK(i);
Dmasked(i) = D AND D_MASK(i);
X = Amasked OR Bmasked OR Cmasked OR Dmasked;
So if you were to write 0x00000001 to A_MASK, and 0x10000000 to B_MASK, you would end up with your lowest line following A and one of your higher lines following B. Note that if you wrote overlapping masks to the registers you would end up with the OR of your signals (if A_MASK and B_MASK both got 0x00000001, the lowest line would output "A OR B"). You could add some logic that checks for mask collisions and reports back with a boolean if you'd like.
Using that method you can pretty cheaply route around a few signals and change them on the fly.
Hugs,
memoryleak
PS I think there's a structure in LV FPGA that allows you to tell it to not place registers between logic... I think that for a small number of signals this app is a great use for that feature. You can or-mask 8 signals together in two levels of LUT4s (Virtex4 and older) and 18 in two levels of LUT6s (Virtex 5). Two levels of logic should be super duper quick and not cause timing issues at 40mhz. (You're probably safe with more, there is no hard and fast rule)
07-29-2009 11:33 AM
Guys, thanks alot for the tips! At the moment, all I have is 4 different signals than can be routed to 4 different outputs.
I just made a quick and dirty MUX using some 'Boolean Selects'. As my project becomes bigger, Im sure I'll have to come back to this and create a more modular solution.
Does LV FPGA have a MUX VI for use? I was searching around, and could not find one.
07-29-2009 01:35 PM
This just sounds like a case structure to me. Is this essentially what you want to do?
07-29-2009 02:50 PM
<SLAPS Forehead> Yup!! Sorry for the newb mistake.
Another newb question: How do I use strings to control the case selection? So far I only see a way to do it with Integers.
In 'regular' LabVIEW, there were the "Radio Buttons", which you could wire into the case statement. Not seeing those in FPGA LV.
07-29-2009 03:18 PM