//設(shè)計分頻器 將50MHZ信號分頻產(chǎn)生1HZ的秒脈沖,輸出信號占空比為50%。
//設(shè)計思路:用計數(shù)器設(shè)計,N分頻:當(dāng)計數(shù)到(N/2)-1個數(shù)時,輸出時鐘翻轉(zhuǎn)一次
//50*10^6次分頻:計數(shù)到24 999 999(需要25bit)時,輸出信號翻轉(zhuǎn)。
//無法用vmf仿真,因為endtime最大為10us,實際最少需要1000000us文章來源:http://www.zghlxwxcb.cn/news/detail-766927.html
module Divider50Mhz#(
?? ?parameter clk_freq=50000000,
?? ?parameter out_freq=1)
?? ?(
?? ?input cr,clk_50M,
?? ?output reg clk_1
?? ?);
?? ?reg[24:0]count_div;
?? ?
?? ?always@(posedge clk_50M or negedge cr)
?? ?begin
?? ??? ?if(!cr)
?? ??? ??? ?begin
?? ??? ??? ?clk_1<=0; //輸出被清0
?? ??? ??? ?count_div<=0;//計數(shù)被清0
?? ??? ??? ?end
?? ??? ??? ?
?? ??? ?else
?? ??? ??? ?begin
?? ??? ??? ?if (count_div<(clk_freq/(2*out_freq)-1))//沒計夠數(shù)時,保持+1
?? ??? ??? ??? ?count_div<=count_div+1'b1;
?? ??? ??? ?else
?? ??? ??? ??? ?begin
?? ??? ??? ??? ?clk_1<=~clk_1;//計夠數(shù)時,輸出信號翻轉(zhuǎn),計數(shù)器清零
?? ??? ??? ??? ?count_div<=0;
?? ??? ??? ??? ?end
?? ??? ??? ?end
?? ??? ??? ?
?? ?end
endmodule文章來源地址http://www.zghlxwxcb.cn/news/detail-766927.html
到了這里,關(guān)于verilog---分頻器設(shè)計的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!