| 
 | 
 
 楼主 |
发表于 2012-10-31 09:07:16
|
显示全部楼层
 
 
 
 本帖最后由 wyardt 于 2012-10-31 09:13 编辑  
 
回复 4# gao_peng  
 
要求要达到那么高,因为在400MHz下误差较小,所以才这样的,我的ENA模块貌似不是很完善,我贴出来给你看看哈同学说不要用initial语句,不用的话,因为我这里没有使能信号,所以不能不用吧。。 
 
////////This block is aimed at generating reset signal for the CLK_DIV10  
////////and passing the original Trig to the output port 
module ENA(clk1,clk2,trig,reset); 
input clk1,clk2,trig; 
output reset; 
 
reg start; 
reg [12:0] c; 
assign reset = start; 
 
initial begin 
c <= 13'd0; 
reset <= 0; 
start <= 0; 
end 
 
///////////////////////////I THINK THIS ALWAYS IS NOT THAT GOOD 
always @(posedge clk1) 
begin                //clk1(400MHz) as the beginner of the counter 
if(trig)                //once the trig is true,set the flag signal START becomes true. 
  start <= 1; 
else  
 
if(c==4096) start <= 0;//after the trig is being low and the number of the pulse(40MHz clk) is 
end                            //big enough(we need at least 1024 pulses of output clk 40MHz),we reset 
                                // the START signal to be false. 
 
////////////////////////////////////////////////////////// 
always @(posedge clk2) 
begin//clk2(50MHz) as the trigger of the counter 
case(start) 
     1:c <= c+1;        //when the START signal is true,we start to count the counter 
     0:c <= 13'd0;     //if start is low,which means we should stop generating 40MHz clk, 
endcase                  // so we reset the counter 
end 
endmodule |   
 
 
 
 |