您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 通用的Verilog-HDL-奇数偶数分频器
基于VerilogHDL的分频器设计VerilogHDL的分频器设计作者:nyj文中的第一个模块为通用的偶分频模块,第二个模块为通用的奇分频模块,2个模块分频占空比都为1:1,使用时只需将相应模块中parameterDIV_N=N;中的N改为想要的分频数即可。/**********************************************Filename:Divide_Frequency_module**Author:nyj**Version:**Data:11/7/17**Description:EvendivideFPGACLKfrequency**********************************************/moduleDivide_Frequency_module(inputCLK_In,inputRSTn,outputCLK_Out);/*****************************************/parameterDIV_N=N;/***********************************************/reg[DIV_N:0]count;regclk_N;always@(posedgeCLK_InornegedgeRSTn)beginif(!RSTn)begincount=1'b0;clk_N=1'b0;endelseif(count==DIV_N/2-1'b1)begincount=1'b0;clk_N=~clk_N;endelsecount=count+1'b1;end/***********************************************/assignCLK_Out=clk_N;/*************************************************/endmodulemoduleDivide_Frequency_module(inputCLK_In,inputRSTn,outputCLK_Out);/*****************************************/parameterDIV_N=N;/***********************************************/reg[DIV_N:0]count_p;always@(posedgeCLK_InornegedgeRSTn)beginif(!RSTn)count_p=1'b0;elseif(count_p==DIV_N-1'b1)count_p=1'b0;elsecount_p=count_p+1'b1;end/***********************************************/reg[DIV_N:0]count_n;always@(negedgeCLK_InornegedgeRSTn)beginif(!RSTn)count_n=1'b0;elseif(count_n==DIV_N-1'b1)count_n=1'b0;elsecount_n=count_n+1'b1;end/************************************************/regclk_N_p;always@(posedgeCLK_InornegedgeRSTn)beginif(!RSTn)clk_N_p=1'b0;elseif(count_p=DIV_N/2)clk_N_p=1'b1;elseclk_N_p=1'b0;end/***********************************************/regclk_N_n;always@(negedgeCLK_InornegedgeRSTn)beginif(!RSTn)clk_N_n=1'b0;elseif(count_n=DIV_N/2)clk_N_n=1'b1;elseclk_N_n=1'b0;end/***************************************************/assignCLK_Out=(clk_N_p&clk_N_n)?1'b1:1'b0;/*************************************************/endmodule
本文标题:通用的Verilog-HDL-奇数偶数分频器
链接地址:https://www.777doc.com/doc-5493438 .html