Strange FPGA issue - Page 1
Forum section: electronics / general

author: MattHollands
author_rank: Frequent Contributor
timestamp: May 13, 2018, 08:16:03 pm
content: Hi,I am using an FPGA to drive a display. There are three outputs VGA_RED_O, VGA_BLUE_O, VGA_GREEN_O which are 4-bit outputs, defined as so:Code:output wire[3:0] VGA_RED_O,VGA_BLUE_O,VGA_GREEN_O;I also have a 4-bit wire called TX_VGA_VIDEO which is the output of a submodule.Using these lines, the output is as expected - the video looks correct.Code:assign VGA_RED_O = TX_VGA_VIDEO;assign VGA_GREEN_O = TX_VGA_VIDEO;assign VGA_BLUE_O = TX_VGA_VIDEO;Using these lines, the output is also as expected - the colours are weird but that's intentional:Code:assign VGA_RED_O = (TX_VGA_VIDEO ? 4'b1111 : 4'b0000);assign VGA_GREEN_O = (TX_VGA_VIDEO ? 4'b1111 : 4'b0000);assign VGA_BLUE_O = ((TX_VGA_VIDEO | TX_VGA_VIDEO) ? 4'b1111 : 4'b0000);However, if I combine the two using a switch input to switch between them:Code:assign VGA_RED_O = (SW ? (TX_VGA_VIDEO ? 4'b1111 : 4'b0000) : TX_VGA_VIDEO);assign VGA_GREEN_O = (SW ? (TX_VGA_VIDEO ? 4'b1111 : 4'b0000) : TX_VGA_VIDEO);assign VGA_BLUE_O = (SW ? ((TX_VGA_VIDEO | TX_VGA_VIDEO) ? 4'b1111 : 4'b0000) : TX_VGA_VIDEO);The video signal is always black! in fact, other things are messed up too, like other outputs appearing strange.However, I can fix the situation by adding the line:Code:assign LED = SW;Where LED is an output.Both SW and LED are asynchronous.What could be causing my code to break!? I would simulate it, but this code is in my main module and therefore to simulate it would require simulating a lot of other things.The only thing I can think of is that I have a clock input to the FPGA that is not going through a proper clock input pin of the FPGA (layout oversight) and therefore vivado complains a lot about the routing being bad, could this be causing the issue? Even though it's such a small change...

author: iMo
author_rank: Super Contributor
timestamp: May 13, 2018, 09:28:29 pm
content: Look into the reports, it could be the SW has been optimized out (missing or wrong SW13 pin assignment/location/type in pins constraints for example), thus everything related to it is optimized out too..TheCode:assign LED = SW;returns it back into the game..

author: MattHollands
author_rank: Frequent Contributor
timestamp: May 13, 2018, 10:30:24 pm
content: Nice idea. I can see SW in the schematic.An example of the other weird things that happen: I have basically a passthrough from some inputs called G[9:6] which goes straight to an output called JC (see attached image)... This is the schematic apparently, but the output is always low. I can measure a signal on G but I can't see any signal on the corresponding signals on JC. If I add the LED = SW line, it gets fixed!

author: rstofer
author_rank: Super Contributor
timestamp: May 14, 2018, 04:15:19 pm
content: Signals that don't appear on the top level PORT or create/use those signals, will be optimized away. There's no point in synthesizing logic that doesn't do anything.Regardless of what the code does, it ultimately has to take inputs and deliver outputs. Any signals that don't get involved one of these two things won't be synthesized.

author: MattHollands
author_rank: Frequent Contributor
timestamp: May 14, 2018, 10:52:34 pm
content: Quote from: rstofer on May 14, 2018, 04:15:19 pmWell VGA_RED_O are direct outputs. So they won't be optimised away. SW is a direct input and modifies VGA_RED_O so shouldn't be optimised away.I have bodged my clock input to use a proper clock input pin on the FPGA and this *seems* to have gotten rid of the issue. I'm hesitant to say it has gotten rid of the underlying issue. Is it possible that using a clock on a non-optimal route could be causing this bug? Seems odd that such a small change breaks it.

author: ataradov
author_rank: Super Contributor
timestamp: May 14, 2018, 11:07:51 pm
content: Whether things can be optimized may depend on how those pins were declared in the constraints file, or equivalent for that FPGA.Generally things like this will be noted in the reports.

author: NorthGuy
author_rank: Super Contributor
timestamp: May 15, 2018, 12:13:31 am
content: Quote from: MattHollands on May 14, 2018, 10:52:34 pmYou mean clock on non-CC capable pin? This shouldn't cause anything dramatic. The only difference is that, instead of a straight wire to the buffer, the clock takes (possibly long) route through the FPGA fabric. This increases clock jitter, worsens temperature stability, may be even can affect the ability of MMCM/PLL to lock.But none of this should affect the straight wire through FPGA as you showed in your example, unless your FPGA doesn't get configured at all. Does the DONE pin ever go high?

author: Sparker
author_rank: Regular Contributor
timestamp: May 16, 2018, 10:37:22 pm
content: Do you have the timing constraints set up in your project? Usually weirdest things happen if you don't. Like what appeared to be working right might break because you changed something and now fitter places the logic differently.