Forum Discussion
Altera_Forum
Honored Contributor
14 years agoneed some VHDL code help
I am trying to program my board so when you press the ARM and Launch button it will start up my motor. The code not done yet, but I am stuck on getting the counter to work. here what I have ...
Altera_Forum
Honored Contributor
14 years ago --- Quote Start --- The biggest part now that I can not seem to figure out, is how do I get it to count down on it own when I press one button. --- Quote End --- That isn't a VHDL problem, I think. --- Quote Start --- It still showing me numbers above 11, not sure why. --- Quote End --- What's your expectation for code behaviour with q = 0? An integer range 0 to 11 synthesizes as unsigned[3 downto 0]. Decrementing from 0 rolls over to 15. You need to handle the behaviour for q= 0 explicitely, whatever you want, either roll over to 11, or stop decrementing.
IF q = 0 THEN
q <= ...
ELSE
q <= q - 1;
END IF;