云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 基于Verilog的数字频率计的设计包含代码及仿真

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

  • 62 次阅读
  • 3 次下载
  • 2025/7/13 10:26:18

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

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

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)

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com