Verilog 编写的8分频模块,32分频模块求高手详细解释一下,我是新手 急用。。谢谢
8分频modulebafenpin(clk,reset,clk1);inputclk;inputreset;outputclk1;regclk1;reg[2:0]coun...
8分频
module bafenpin(clk,reset,clk1);
input clk;
input reset;
output clk1;
reg clk1;
reg[2:0] count;
always @ (posedge clk)
if (reset==0)
count<=0;
else
count<=count+3'b001;
always@(posedge clk)
clk1<=count[2];
//if (reset==0)
//clk1<=0;
//else
// clk1<=!clk1;
endmodule
32分频
module thrfenpin(clk,reset,clk2);
input clk;
input reset;
output clk2;
reg clk2;
reg[4:0] count;
always @ (posedge clk)
if (reset==0)
count<=0;
else
count<=count+5'b00001;
always@(posedge clk)
clk2<=count[4];
endmodule 展开
module bafenpin(clk,reset,clk1);
input clk;
input reset;
output clk1;
reg clk1;
reg[2:0] count;
always @ (posedge clk)
if (reset==0)
count<=0;
else
count<=count+3'b001;
always@(posedge clk)
clk1<=count[2];
//if (reset==0)
//clk1<=0;
//else
// clk1<=!clk1;
endmodule
32分频
module thrfenpin(clk,reset,clk2);
input clk;
input reset;
output clk2;
reg clk2;
reg[4:0] count;
always @ (posedge clk)
if (reset==0)
count<=0;
else
count<=count+5'b00001;
always@(posedge clk)
clk2<=count[4];
endmodule 展开
2个回答
展开全部
第一个程序:clk1输出占空比为50%,当count=000~011(0到3)的时候,clk1=count[2]=0;当count=100~111(4~7)的时候,clk1=count[2]=1;count从0~7循环,即完成8分频
第二个程序:clk2输出占空比为50%,当count=00000~01111(0~15)的时候,clk1=count[2]=0;当count=10000~11111(16~31)的时候,clk1=count[2]=1;count从0~31循环即完成32分频
第二个程序:clk2输出占空比为50%,当count=00000~01111(0~15)的时候,clk1=count[2]=0;当count=10000~11111(16~31)的时候,clk1=count[2]=1;count从0~31循环即完成32分频
追问
谢谢啦。。我想问下你当初始CLK 为多少的时候才会用到8分频和32分频
追答
这个要根据你的实际需求,比如说你的板子上只有50mhz的晶振,但是你需要的频率是50/8=6.25mhz的,那么你就需要这个8分频的电路去分频啦
艾普斯
2024-07-18 广告
2024-07-18 广告
稳频稳压电源哪家好?艾普斯电源(苏州)有限公司开始专业研发、制造及营销交流稳压电源,满足全球电子及信息业对电源设备日益蓬勃的市场需求。迄今为止,业已发展成为交流不间断电源、稳压电源、变频电源、中频航空- 军事专用电源、直流电源、逆变电源等产...
点击进入详情页
本回答由艾普斯提供
展开全部
module freq_divider #
(
parameter DIV_FACTOR = 32
)
(
input clk ,
input rst ,
output reg div_clk
);
reg [7 0] div_cnt ;
always @(posedge clk or posedge rst)
if (rst)
div_cnt <= 0;
else
div_cnt <= (div_cnt == DIV_FACTOR ) ? 0 :div_cnt + 1;
always@(posedge clk or posedge rst)
if (rst)
div_clk <= 1'b0;
else
div_clk <= (div_cnt < DIV_FACTOR/2);
endmodule
例化时配置一下参数DIV_FACTOR就OK了!!
(
parameter DIV_FACTOR = 32
)
(
input clk ,
input rst ,
output reg div_clk
);
reg [7 0] div_cnt ;
always @(posedge clk or posedge rst)
if (rst)
div_cnt <= 0;
else
div_cnt <= (div_cnt == DIV_FACTOR ) ? 0 :div_cnt + 1;
always@(posedge clk or posedge rst)
if (rst)
div_clk <= 1'b0;
else
div_clk <= (div_cnt < DIV_FACTOR/2);
endmodule
例化时配置一下参数DIV_FACTOR就OK了!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询