Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

Strange switch, cant justify this behaviour

Hi,

I made this differentiated switch. But.. upon usage it turns out to be inverted. Contrary to what i deem to be logical behaviour?

Any thoughts?

else if (switch < register) //* so the result would be like this?

begin

action <= taken;

register <= switch;

end

else if (switch > register)

begin

register <= switch;

end

* There I would expect the switch to be greater than the register when pressed so if (switch > register) the action would be taken at the positive flank of the push button. This is not the case how come?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It depends how your push button is wired. If it is connected so that the push button is between the pin and ground, and there is a pull-up resistor, then when you press the switch it will actually go from high to low.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    It depends how your push button is wired. If it is connected so that the push button is between the pin and ground, and there is a pull-up resistor, then when you press the switch it will actually go from high to low.

    --- Quote End ---

    Yes I wanted to figure that out so I attached a LED to see it it would light up. And it did. I also set the register to be 0.

    None of that had any effect..