找回密码
 注册
搜索
查看: 916|回复: 2

[讨论] 锯齿波的verilog HDL

[复制链接]
发表于 2006-12-23 15:43:06 | 显示全部楼层 |阅读模式
不知道对不对,有问题请指出来!3Q
module test(clk,rst,q);
input clk,rst;
output [1:0] q;
reg [1:0] q;
reg [3:0] cnt;
parameter N=3;
parameter M=6;
parameter L=9;
parameter H=12;
always @(posedge clk or negedge rst)
  begin
     if(~rst)
       begin
            q<=0;
            cnt<=0;
       end
     else  if (cnt<=N)  
                  begin q<=q+1;
                        cnt<=cnt+1;
                  end
           else if((cnt>N)&(cnt<=M))
                  begin q<=q-1;
                        cnt<=cnt+1;
                  end
                 else if((cnt>M)&(cnt<=L))
                      begin  cnt<=cnt+1;
                             q<=0-(q+1);
                      end
                       else if((cnt>L)&(cnt<H))
                           begin q<=0-(q-1);
                                 cnt<=cnt+1;
                           end
                            else begin
                                  q<=0;
                                  cnt<=0;
                                 end
  end
endmodule
发表于 2006-12-25 13:53:45 | 显示全部楼层
扫盲, 很好
点评回复

使用道具 举报

发表于 2006-12-26 13:15:30 | 显示全部楼层
[em01]简单呀
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-9-29 18:22 , Processed in 0.060958 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表