Forum Discussion
Altera_Forum
Honored Contributor
12 years agoThe main problem with your code is that it isn't synchronous. A VHDL simulator may simulate your code correctly because it will only execute the first process when one of your GPIO signals will change, but a VHDL synthesizer will not know what to do with your code.
I suggest to use a clock and make the first process a regular clocked process. The DE0 kit should have an on-board oscillator that you can use. Then you will need to change your process a bit. The part with the reset pin can be used as is, but for the clock signal you will need to detect a rising edge. The recommended way of doing that is to create an extra signal that will hold the previous value of GPIO_0(5). Then if that signal is '0' and GPIO_0(5) is '1', it means you have a rising edge and you can increase bitnumber. Also it isn't recommended to use IEEE.STD_LOGIC_UNSIGNED.ALL because it isn't a standard library, and it will cause problems if you try to mix unsigned and signed values, or try to use other libraries. The recommended way is to use IEEE.NUMERIC_STD.ALL instead, and make your bitnumber an "unsigned" type instead of "std_logic_vector". You can use the rest of the code as is, except for LED, as you will need to cast bitnumber back to the vector type:LED <= std_logic_vector(bitnumber);