Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
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.
17268 Discussions

No control Nested If condition ?

Altera_Forum
Honored Contributor II
1,571 Views

Hi All, 

 

I am trying to code an alarm-clock; The problems that I have right now is in setting up the alarm when SW2 is ON 

 

Currently when I run the program, it automatically enters the loop and set LEDS[2] ON,which represent SW2. My goal is to turn LEDS[9] ON, only if I turn ON SW2 ON. The other problem I have, is that, once I am in the SW2 loop, I want to increment the variable by one when I pressed KEY2, but I again KEY2 does not have any response when I press it. The pciture below shows only the setion that I am trying to fix right now. 

 

if you can revise the code and give some pointers will be appreciated. 

 

thanks in advanced 

 

esso
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
719 Views

You'll need to do an edge detect on key2. You do this by comparing a registered version of the key to the current state. If it changes, you have an edge.  

 

// inside synchronous always key2_r <= key2 if(key2 & ~key2_r) begin // edge on key
0 Kudos
Altera_Forum
Honored Contributor II
719 Views

thanks, I will try it

0 Kudos
Reply