0
votes

Very new to Verilog and FPGA. I can't wrap my head around the processes behind outputting to a Spartan-6 board and could do with a written explanation.

All I'm doing is a simple AND gate which outputs to an LED.

module andgate(
input a, b,
output q
);

assign q = a&b;

endmodule

Input switches are SW1 and SW2 (both set to pull-up), output LED is D1.

The program file runs on the board just fine, except the output is inverted - when no switches are pressed, the LED is on. I understand this is due to the need for pull-up resistors, but I only want the LED to illuminate when both switches are pressed.

How do I re-write my code or reconfigure the board so the desired output is displayed?

I've found that writing

assign q = ~a&~b

gives the result I want, but is there a better way?

1
This might be what your looking for : en.wikipedia.org/wiki/De_Morgan%27s_laws#EngineeringMorgan

1 Answers

0
votes

It depends on your board schematic, either your LED is active high or active low.

From the behavior, you have described looks like you button is pulled up when no pressed. If you press the button you get a low signal on one of the input, as result zero on the result function and led is off.