如何编写多维数组端口的测试平台

时间:2013-03-23 17:07:39

标签: verilog

我有一个用Verilog代码编写的7位向上/向下计数器:

module updowncount_7bit  (clock,reset,hold,up_down,q);
input clock,reset,hold,up_down;
output reg [6:0] q;
integer direction;

    always @(posedge clock)
    begin
        if(up_down)
            direction = 1;
        else
            direction = -1;
        if (!reset)
            q <= 0;                 
        else if (!hold)         
            q <= q + direction;

    end
endmodule

我曾尝试编写测试台代码,但似乎输出不起作用,我不知道为什么!任何人都可以提供帮助!?

测试平台结果:

在Model-sim中:http://i1114.photobucket.com/albums/k533/omegakd/222_zps6d406e8b.png

在Quartus中通过矢量波形:enter image description here

module counter_7bit_tb;
  wire [6:0]f_tb;
  reg  clock_in_tb, reset_tb, hold_tb, up_down_tb;
 updowncount_7bit dut(clock_in_tb, reset_tb,hold_tb, up_down_tb, f_tb);


  initial begin
    clock_in_tb = 0;reset_tb= 1; hold_tb = 0;up_down_tb=1;
    #10; 
    forever begin
     #10 clock_in_tb= ~clock_in_tb ;
    end

  end

endmodule

1 个答案:

答案 0 :(得分:2)

您似乎没有从测试平台将reset应用于您的模块。因此,q始终为X,看起来就像您所看到的那样。