IPO 发表于 2010-11-3 08:41:37

请教各位大虾 做一个可变模值的计数器 啥思路

请教各位大虾 做一个可变模值的计数器 啥思路

weibode01 发表于 2010-11-4 10:32:39

这个很简单啊
module cont10(clk,clr,en,c,q);
input clk,clr,en;
output c,q;
reg c;
reg q;
always @(posedge clr or posedge clk)   
if (clr)
    q<=0;
else
   if(en)
   if(q==9)
       begin
                  q<=0;
                  c<=1;
            end
          else   
       begin
                  q<=q+1;
                  c<=0;
            end               
endmodule
只要改变IF(Q==9)语句,就可以实现你所要的模值了啊
页: [1]
查看完整版本: 请教各位大虾 做一个可变模值的计数器 啥思路