Forum Discussion

nafiseh's avatar
nafiseh
Icon for New Contributor rankNew Contributor
3 years ago
Solved

wrong results for implementation logic gate

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.

  • 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.

2 Replies

  • _AK6DN_'s avatar
    _AK6DN_
    Icon for Frequent Contributor rankFrequent Contributor

    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's avatar
    NazrulNaim_Intel
    Icon for Regular Contributor rankRegular Contributor

    Hello,

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

    Regards,

    Nazrul Naim