集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 4789|回复: 13

各位看看我这程序怎么不出波形呀???

[复制链接]
竹林听雨早晨 发表于 2010-10-28 21:40:33 | 显示全部楼层 |阅读模式
主程序module counter_10(clock,counter);
    input clock;
    output[3:0] counter;
    reg[3:0] counter;
   
    initial
     begin
         counter=6;
     end
     
     always @(posedge clock)
      begin
          if(counter<16)
            counter <= counter + 1 ;
          else
            counter <= 6;
      end
endmodule
      
测试模块
`include"counter_10.v"
module TESTcounter_10;
    reg clock;
    wire[3:0] counter;
     counter_10 U(clock,counter);
   
    initial
    begin
     clock=0;
    end
     always #50 clock=~clock;
   
   
   
endmodule
 楼主| 竹林听雨早晨 发表于 2010-10-28 21:53:37 | 显示全部楼层
我想设计一个十进制计数器
njithjw 发表于 2010-10-28 22:22:33 | 显示全部楼层
module counter_10(clock,counter);
    input clock;
    output[3:0] counter;
    reg[3:0] counter;
   
//    initial
//     begin
//         counter=6;
//     end
     
//     always @(posedge clock)
//      begin
//          if(counter<16)
//            counter <= counter + 1 ;
//          else
//            counter <= 6;
//      end

always @ (posedge clock)
begin
    if (counter>=4'd9)
        counter <= 4'd0;
    else
        counter <= counter + 4'd1;        
end

endmodule
 楼主| 竹林听雨早晨 发表于 2010-10-28 23:17:25 | 显示全部楼层
回复 3# njithjw


    这是十进制的吗
njithjw 发表于 2010-10-28 23:48:02 | 显示全部楼层
你可以自己仿真一下看看就知道了。

不过不知道你想要的是自然二进制编码下的十进制,还是8421BCD码的十进制。
xuanyuanchen 发表于 2010-10-29 00:43:13 | 显示全部楼层
回复 1# 竹林听雨早晨


    你这个在测试文件的开头没有加`timescale  这一句,这个不能丢
liyujie 发表于 2010-10-29 08:36:49 | 显示全部楼层
6和16是做什么用的?
fullattack 发表于 2010-10-29 19:43:27 | 显示全部楼层
counter_10 U(.clock(clock),.counter(counter));测试文件这句应该这样写吧。
fullattack 发表于 2010-10-29 19:45:41 | 显示全部楼层
counter也不会超过16最多=15
always @(posedge clock)
//      begin
//          if(counter<16)
//            counter <= counter + 1 ;
//          else
//            counter <= 6;

//      end
不会执行的
 楼主| 竹林听雨早晨 发表于 2010-10-31 20:06:50 | 显示全部楼层
回复 6# xuanyuanchen


    他有啥用啊
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-6-21 11:22 , Processed in 0.090914 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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