Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

help please.......how to catch number

Altera_Forum
Honored Contributor II
1,434 Views

can someone help me how to design coding that catch number 8 and it will increment the counter..i've done the coding but cannot catch number 8..it will catch random number....

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
746 Views

 

--- Quote Start ---  

can someone help me how to design coding that catch number 8 and it will increment the counter..i've done the coding but cannot catch number 8..it will catch random number.... 

--- Quote End ---  

Why don't you post what you've tried so far. 

 

In VHDL the code would look something like; 

 

constant WIDTH : integer := 4; signal match : std_logic; signal match_value : std_logic_vector(WIDTH-1 downto 0) := X"8"; ... match <= '1' when (count = match_value) else '0'; Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
746 Views

if Reset='0' then  

level<="0000";else  

 

if PUSH'event and PUSH='1' then if X=8 then 

 

if (level < 10) then 

level <= level +1; 

 

else 

level <= "0000";  

end if; 

end if; 

 

 

 

 

--can i do like this?
0 Kudos
Altera_Forum
Honored Contributor II
746 Views

 

--- Quote Start ---  

 

--can i do like this? 

--- Quote End ---  

No, probably not. 

 

You need to use a proper clock and separate the logic into functional blocks; 

 

1) Push button interface, with debounce logic 

* synchronize the push-button to the clock 

* detect an edge, and then ignore the input for a while 

 

2) A counter 

 

3) Synchronized push-button and match control logic 

 

Create a testbench for your logic, eg., something that contains a clock and a noisy push-button press, and use that to confirm that you only see one button press. 

 

If you don't know how 'noisy' to make your button press, create a simple design and download it into your hardware. Add a SignalTap II instance and capture a trace from a push-button press. You will see that the signal generates multiple transitions when you click on the button. Your debounce logic needs to convert the ugly push-button signal into a nice clean logic level. 

 

Cheers, 

Dave
0 Kudos
Reply