Original [FPGA] Odd division of clock divider (5-way)

Source: Internet
Author: User

Use two count modules to count each, get two waveforms for basic and or complete operation. Directly post the code section below.

1 ModuleDiv_freq (2 ICLK,3 Irst_n,4 OCLK5 );6  7 input    WireICLK;8 input    WireIrst_n;9 OutputOCLK;Ten   One parameterN =4'd5; A   - Regclk_p; - Reg[3:0] cnt_p; the  always@ (PosedgeIclkor NegedgeIrst_n)begin -     if(!irst_n) -Cnt_p <=4'D0; -     Else if(cnt_p = = N-1) +Cnt_p <=4'D0; -     Else +Cnt_p <= cnt_p +1'B1; A End at  always@ (PosedgeIclkor NegedgeIrst_n)begin -     if(!irst_n) -Clk_p <=1'B0; -     Else if(cnt_p = = (N-1) /2) -Clk_p <= ~clk_p; -     Else if(cnt_p = = N-1) inClk_p <= ~clk_p; -     Else toClk_p <=clk_p; + End -   the   * RegClk_n; $ Reg[3:0] Cnt_n;Panax Notoginseng  always@ (NegedgeIclkor NegedgeIrst_n)begin -     if(!irst_n) theCnt_n <=4'D0; +     Else if(Cnt_n = = N-1) ACnt_n <=4'D0; the     Else +Cnt_n <= Cnt_n +1'B1; - End $  always@ (NegedgeIclkor NegedgeIrst_n)begin $     if(!irst_n) -Clk_n <=1'B0; -     Else if(Cnt_n = = (N-1) /2) theClk_n <= ~Clk_n; -     Else if(Cnt_n = = N-1)WuyiClk_n <= ~Clk_n; the     Else -Clk_n <=Clk_n; Wu End -   About AssignOCLK = Clk_p |Clk_n; $   - Endmodule -         

Modelsim simulation results such as

Original [FPGA] Odd division of clock divider (5-way)

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: info-contact@alibabacloud.com 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.