首页 > 其他 > 详细

七分频

时间:2020-04-02 20:45:50      阅读:65      评论:0      收藏:0      [点我收藏+]
技术分享图片
module Freq_divide
(
    input clk,
    input rst_n,
    output clk_divide
 );
 
//----------count the posedge---------------------
reg [2:0] cnt_p;
reg clk_p;

always @ (posedge clk or negedge rst_n) 
if(!rst_n) 
    cnt_p <= 3d0;
else if(cnt_p == 3d6)
    cnt_p <= 3d0;
else 
    cnt_p <= cnt_p + 1b1;

always @ (posedge clk or negedge rst_n) 
if(!rst_n)     
    clk_p <= 1b0;
else if((cnt_p == 3d3) || (cnt_p == 3d6))
    clk_p <= ~ clk_p;
//---------------------------------------------

//----------count the negedge------------------
reg [2:0] cnt_n;
reg clk_n;

always @ (negedge clk or negedge rst_n) 
if(!rst_n) 
    cnt_n <= 3d0;
else if(cnt_n == 3d6) 
    cnt_n <= 3d0;
else
    cnt_n <= cnt_n + 1b1;
    
always @ (negedge clk or negedge rst_n) 
if(!rst_n) 
    clk_n <= 1b0;
else if((cnt_n == 3d3) || (cnt_n == 3d6)) 
    clk_n <= ~clk_n;
//----------------------------------------------

assign clk_divide = clk_p | clk_n;

    
endmodule
View Code

技术分享图片

3:4变成3.5:3.5

七分频

原文:https://www.cnblogs.com/ajiaoa/p/12622261.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!