10M的分频

10 篇文章 0 订阅
1 篇文章 0 订阅

源码:

module FenPing
#(
parameter N=10,
parameter M=N/2

)
(
    input clk,
	input rst_n,
	
	output ad_o,
	output [3:0]ad_o1

);

reg [3:0] cont;
reg vs;
always@(posedge clk)
begin
 if(~rst_n)
   cont<=0;
  else if(cont==N-1)
   cont<=0;
  else
    cont<=cont+1'b1;
end

always@(posedge clk)
begin
  if(~rst_n)
    vs<=1;
 else if(cont==0)
    vs<=1;
else if(cont==M)
	 vs<=0;
end
 assign ad_o=vs;
 assign ad_o1=cont;
endmodule

激励:
`timescale 1ns/1ns
module FenPing_tp();
reg clk;
reg rst_n;
wire ad_o;
wire ad_o1;
parameter N=10;
parameter M=N/2;
initial 
begin
 rst_n=0;
 
 #1000 rst_n=1;
 
 #10000 $stop;
end

initial 
begin
  clk=0;
end
always  #10 clk<=~clk;



FenPing #(
.N(N),
.M(M)
)FenPing_out(
 .clk(clk),
 .rst_n(rst_n),
 .ad_o(ad_o),
 .ad_o1(ad_o1)

);
endmodule

分频要记得一点是要把频率设置成参数。10M是频率,不是容量。1MHz=100_0000Hz
1s=1000ms=1000_000ns=1_000_000_000us

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值