第一范文网 - 专业文章范例文档资料分享平台

基于Verilog的数字频率计的设计包含代码及仿真

来源:用户分享 时间:2025/6/3 16:37:15 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

begin count2<=0;clk_10hz<=~clk_10hz;end else count2<=count2+1; if(count3==240000)

begin count3<=0;clk_100hz<=~clk_100hz;end else count3<=count3+1; if(count4==24000)

begin count4<=0;clk_1khz<=~clk_1khz;end else count4<=count4+1; end end endmodule

仿真图

仿真模块

,门控电路和清零,锁存,阀门信号产生程序 二

module chose(rest,clk_10hz,clk_100hzhz,clk_1khz,key1,key10,key100, gate_out1,ff,clk_latch,clk_clear);

input rest ,clk_10hz,clk_100hz,clk_1khz,key1,key10,key100; output gate_out1,clk_latch,clk_clear; output reg [2:1] ff;

reg gate_out1,clk_latch,clk_clear,gate; reg [4:1]count;

initial begin gate_out1=0;ff=0;clk_latch=0;clk_clear=0;gate=0;count=0;end always@( posedge clk_1khz) begin

if(!rest) begin gate_out1<=0; ff<=2'b00;end else begin

if(key1==1&&key10==0&&key100==0) begin gate<=clk_10hz; ff<=2'b01;end

else if(key1==0&&key10==1&&key100==0) begin gate<=clk_100hz;ff<=2'b10;end

else if(key1==0&&key10==0&&key100==1) begin gate<=clk_1khz;ff<=2'b11;end

else begin ff<=0;end end end

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

always @(posedge gate) begin

count<=count+1; if (count<=9)

begin gate_out1<=1;clk_clear<=0;clk_latch<=0;end else if (count==11)

begin gate_out1<=0;clk_clear<=0;clk_latch<=1;end else if (count==13)

begin gate_out1<=0;clk_clear<=1;clk_latch<=0;count<=0;end else

begin gate_out1<=0;clk_clear<=0;clk_latch<=0;end end

endmodule

仿真图

仿真模块

三, 计数器程序

module counter(rest,start,clk_in,cnt1,cnt2,cnt3,cnt4,cnt5,cnt6,yichu,clk_clear); input rest,start,clk_in,clk_clear;

output yichu; reg yichu;

output reg [4:1]cnt1,cnt2,cnt3,cnt4,cnt5,cnt6;

initial begin yichu=1;

cnt1<=4'b0000;cnt2<=4'b0000;cnt3<=4'b0000;cnt4<=4'b0000; cnt5<=4'b0000; cnt6<=4'b0000;

end

always@(posedge clk_in ) begin

if(!rest) begin

cnt1<=4'b0000;cnt2<=4'b0000;cnt3<=4'b0000; cnt4<=4'b0000;cnt5<=4'b0000;cnt6<=4'b0000; end else begin

if(clk_clear==1) begin

cnt1<=4'b0000;cnt2<=4'b0000;cnt3<=4'b0000;

cnt4<=4'b0000;cnt5<=4'b0000;cnt6<=4'b0000;yichu<=1; end else if(start==1) begin

基于Verilog的数字频率计的设计包含代码及仿真.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c4qz7a3cow69d31q9p63i6j6mw9sjhs00drl_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top