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:
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.
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:
assign VGA_RED_O = (TX_VGA_VIDEO[3] ? 4'b1111 : 4'b0000);
assign VGA_GREEN_O = (TX_VGA_VIDEO[2] ? 4'b1111 : 4'b0000);
assign VGA_BLUE_O = ((TX_VGA_VIDEO[1] | TX_VGA_VIDEO[0]) ? 4'b1111 : 4'b0000);
However, if I combine the two using a switch input to switch between them:
assign VGA_RED_O = (SW[13] ? (TX_VGA_VIDEO[3] ? 4'b1111 : 4'b0000) : TX_VGA_VIDEO);
assign VGA_GREEN_O = (SW[13] ? (TX_VGA_VIDEO[2] ? 4'b1111 : 4'b0000) : TX_VGA_VIDEO);
assign VGA_BLUE_O = (SW[13] ? ((TX_VGA_VIDEO[1] | TX_VGA_VIDEO[0]) ? 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:
assign LED[4] = SW[13];
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...