Intel® High Level Design
Support for Intel® High Level Synthesis Compiler, DSP Builder, OneAPI for Intel® FPGAs, Intel® FPGA SDK for OpenCL™
666 Discussions

wrong results for implementation logic gate

nafiseh
Beginner
682 Views

hi
I write a simple code to implement AND gate with pushbuttons and LED on cyclone iv ep4ce6e22c8n.
but it acts like OR gate, it means that when I press one of the pushbuttons or both, the LED turns on. I try to implement OR gate and it acts like AND gate! when I press both of the pushbutton, the LED turns on. what should I do to solve this problem?
Thanks.

0 Kudos
1 Solution
_AK6DN_
Valued Contributor I
671 Views

Very likely because the pushbutton inputs are active low and not active high.
So when you push the button, the FPGA input sees a LOW value.
When the button is not pushed, it defaults to a HIGH value.
Schematically, the pushbutton is connected to GROUND and the FPGA input, which has a pullup to VCC to set the unpushed state.

An active low logic AND function becomes an active high logic OR function, and vice versa.

So simple fix is to invert the sense of the input from each pushbutton (add a NOT function).

Most likely your LED output is active HIGH (meaning when the output is high the LED is ON) but it could be inverted as well.
You may or may not need to add a NOT to the output LED driver, so when the output is HIGH the LED is ON.
It depends upon the design of your board.

 

 

View solution in original post

2 Replies
_AK6DN_
Valued Contributor I
672 Views

Very likely because the pushbutton inputs are active low and not active high.
So when you push the button, the FPGA input sees a LOW value.
When the button is not pushed, it defaults to a HIGH value.
Schematically, the pushbutton is connected to GROUND and the FPGA input, which has a pullup to VCC to set the unpushed state.

An active low logic AND function becomes an active high logic OR function, and vice versa.

So simple fix is to invert the sense of the input from each pushbutton (add a NOT function).

Most likely your LED output is active HIGH (meaning when the output is high the LED is ON) but it could be inverted as well.
You may or may not need to add a NOT to the output LED driver, so when the output is HIGH the LED is ON.
It depends upon the design of your board.

 

 

NazrulNaim_Intel
Employee
595 Views

Hello,

 

I’m glad that your question has been addressed, for now I will set this case to Close-Pending. 

 

Regards,

Nazrul Naim


0 Kudos
Reply