用VERILOG做个分频器,输入50MHZ,,要求输出一个4HZ,一个1MHZ的分频器,怎么弄啊 20
3个回答
展开全部
这是个分频的模块
module clk434(clkin,clkout);
input clkin;
output clkout;
reg [8:0]num;
reg clkout;
always @(posedge clkin)
begin
if(num==324)num=0; ----只需要修改这里的324和下面的162就行了
else num=num+1; ----- 比如50M分1MHz,clkin=50M,50000000/1000000=50,就把324改为50,162改为50/2=25.
if(num>162)clkout=1;
else clkout=0;
end
endmodule
module clk434(clkin,clkout);
input clkin;
output clkout;
reg [8:0]num;
reg clkout;
always @(posedge clkin)
begin
if(num==324)num=0; ----只需要修改这里的324和下面的162就行了
else num=num+1; ----- 比如50M分1MHz,clkin=50M,50000000/1000000=50,就把324改为50,162改为50/2=25.
if(num>162)clkout=1;
else clkout=0;
end
endmodule
艾普斯
2024-07-18 广告
2024-07-18 广告
稳频稳压电源哪家好?艾普斯电源(苏州)有限公司开始专业研发、制造及营销交流稳压电源,满足全球电子及信息业对电源设备日益蓬勃的市场需求。迄今为止,业已发展成为交流不间断电源、稳压电源、变频电源、中频航空- 军事专用电源、直流电源、逆变电源等产...
点击进入详情页
本回答由艾普斯提供
2010-12-12
展开全部
module led(rst,clk_50M,clk_4,clk_1M);
input rst,clk_50M;
output clk_4,clk_1M;
reg clk_4,clk_1M;
integer count_4,count_1M;
always @(posedge clk_50M or posedge rst)
begin
if (rst)
begin
clk_4 <= 0;
clk_1M <= 0;
count_4 <= 1;
count_1M <= 1;
end
else
begin
if (count_1M == 25)
begin
count_1M <= 1;
clk_1M <= !clk_1M;
end
else
count_1M <= count_1M + 1;
if (count_4 == 6_250_000)
begin
count_4 <= 1;
clk_4 <= !clk_4;
end
else
count_4 <= count_4 + 1;
end
end
endmodule
input rst,clk_50M;
output clk_4,clk_1M;
reg clk_4,clk_1M;
integer count_4,count_1M;
always @(posedge clk_50M or posedge rst)
begin
if (rst)
begin
clk_4 <= 0;
clk_1M <= 0;
count_4 <= 1;
count_1M <= 1;
end
else
begin
if (count_1M == 25)
begin
count_1M <= 1;
clk_1M <= !clk_1M;
end
else
count_1M <= count_1M + 1;
if (count_4 == 6_250_000)
begin
count_4 <= 1;
clk_4 <= !clk_4;
end
else
count_4 <= count_4 + 1;
end
end
endmodule
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个程序能实现但是要修改一下:将!改为~
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询