Simple button Stabilization

Source: Internet
Author: User

ModuleDS (inputCLK,input[3:0] Key,Output Reg[3:0] led);Reg[3:0] Key_r; Wire[3:0] key_p; always@ (PosedgeCLK)beginKey_r<={key[3],key[2],key[1],key[0]};EndAssignKey_p=key & ~Key_r; always@ (PosedgeCLK)begin    Case(key_p)4'b0001:led=4'b0001; 4'b0010:led=4'b0010; 4'b0100:led=4'b0100; 4'b1000:led=4'b1000; EndcaseEndEndmodule

Core in assign Key_p=key & ~key_r; Once there is a change, the key_p is 1 and only the falling edge is detected.

Key_r is a clock cycle with key difference.

Do not directly put key into always, always best only put CLK or reg variables, other wire variables do not easily put inside.

Simple key Stabilization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.