打印

新手请教,对时钟进行3分频1/6占空比,怎么实现?

[复制链接]
1414|2
手机看帖
扫描二维码
随时随地手机跟帖
沙发
atchboy|  楼主 | 2012-4-18 14:59 | 只看该作者
本帖最后由 atchboy 于 2012-4-18 15:01 编辑

module sanfenpin(clk,R);
  input clk;
  output R;
  
  reg [1:0]counter=0;
  reg temp1=1;
  reg temp2=1;
  
always @(posedge clk)
  begin
   counter<=counter+1;
   begin
    if(counter==2)
     counter<=0;
   end
  end
always @(posedge clk)
  begin
   if(counter==2)
    temp1=~temp1;
  end

always @(negedge clk)
  begin
   if(counter==0)
    temp2=~temp2;
  end

assign R=temp1~^temp2;
   
endmodule

这样写程序是不是太简单了,但是仿真结果正确,不知道这种方法实现会有什么问题么?

使用特权

评论回复
板凳
wjy1107| | 2012-4-18 17:28 | 只看该作者
counter在同一时刻即做赋值又做比较,我觉得会有问题。
你可以看看布线后的仿真。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

16

主题

55

帖子

0

粉丝