通用的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

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功