2013-11-26 3 views
0

lab7tb()에서 생성 된 50Mhz 클럭을 6 마이크로 초 또는 그 근사치로 변환하려고합니다. 파형 클럭 아웃을 실행하면 빨간색이며 이유를 알 수 없습니다.Verilog Base 2 클럭 분배기

`timescale 1 ns/1 ns //time scale for the test bench 


module p2divider(clockin, clockout); 
    input clockin; 
    output wire clockout; 

    parameter n = 9; 
    reg [n:0] count; 

    [email protected](posedge clockin) 
    begin 
     count <= count + 1; 
    end 

    assign clockout = count[n]; 
endmodule 


module lab7tb(); // the test bench module 

    reg clock_sig; 
    wire clock_out; 



    // Instantiate the Unit Under Test (UUT) 
    p2divider a (clock_sig, clock_out); 


    integer i; 
    initial begin 
     for(i=0; i<100; i=i+1) 
     begin 
      clock_sig <=1; 
      #10; 
      clock_sig <=0; 
      #10; 
     end 
    end 

endmodule 

답변

1

레지스터 count 필요는 시뮬레이션의 시작 부분에 재설정합니다.

모듈의 전원을 켜면 카운트 값을 알 수 없습니다. 알 수없는 값에 1을 계속 추가하면 영원히 알려지지 않습니다.

FPGA를 대상으로하는 경우 초기 문을 사용하여 카운트를 0으로 설정하거나, 리셋 신호가 블록에 들어오고 리셋이 설정되면 카운트를 0으로 설정할 수 있습니다.