The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Aug 16th, 2024, 9:14pm
Pages: 1
Send Topic Print
Rise and  Fall time (Read 3668 times)
zahrein
Junior Member
**
Offline



Posts: 14

Rise and  Fall time
Sep 27th, 2011, 7:14pm
 
HI All,
Copied my checkers. I don’t  understand, why my time_vhi &time_vlo is fluctuating at different signals. Another thing is that my rise and fall time also is not  consistant.  

module measure_riset_fallt (drive_en, pad);


input pad;
input  drive_en;

// need to  declare  variables so that the  equation of the Rise/fall time  can be calculated



parameter real padh =1.05;
real  time_vhi;
real  time_vlo;
real  rise_time;
real  fall_time;



analog  begin




 @(cross(V(pad) - ((padh)*0.3), 1)) begin
  time_vlo= $abstime;
 
               end
               @(cross (V(pad) -((padh)*0.7),1)) begin //3
  time_vhi=$abstime;


               

// For   rising  time . Calculate between 70% and 30% of the peak  Voltage  
   rise_time=time_vhi-time_vlo;              
               `AMS_INFORM($display("Rise Time= %e",rise_time))
   
               end //3



if (drive_en==1'b1) begin //1

@(cross(V(pad) - ((padh)*0.7), -1)) begin  
  time_vhi= $abstime;
 
               end

@ (cross (V(pad) -((padh)*0.3),-1)) begin
  time_vlo=$abstime;
   
   fall_time = time_vhi - time_vlo;
               `AMS_INFORM($display("Fall Time= %e",fall_time))
   
               end



end
end
endmodule
Back to top
 

out.png
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2386
Silicon Valley
Re: Rise and  Fall time
Reply #1 - Sep 27th, 2011, 11:43pm
 
Your code was unreadable and I know it is unlikely that you will get many responses if people cannot easily understand your code, so I took the liberty of reformatting it to make it easier to understand:
Code:
module measure_riset_fallt (drive_en, pad);
input pad;
input drive_en;
parameter real padh = 1.05;
real  time_vhi, time_vlo, rise_time, fall_time;

analog  begin
    @(cross(V(pad) - padh*0.3, 1)) begin
	  time_vlo = $abstime;
    end
    @(cross(V(pad) - padh*0.7, 1)) begin
	  time_vhi =$abstime;
	  // For   rise  time . Calculate between 70% and 30% of the peak  Voltage  
	  rise_time=time_vhi-time_vlo;		  
	  $display("Rise Time= %e",rise_time);
    end

    if (drive_en==1'b1) begin
	  @(cross(V(pad) - padh*0.7, -1)) begin  
		time_vhi= $abstime;
	  end
	  @(cross(V(pad) - padh*0.3, -1)) begin
		time_vlo=$abstime;
		fall_time = time_vhi - time_vlo;
		$display("Fall Time= %e",fall_time);
	  end
    end
end
endmodule 


First a few generic comments:
  • One problem with this code is that you put cross functions inside an if statement. That is a no-no. And it seems unnecessary. After all, you did not put your rise time code inside an if statement.
  • You did not specify tolerances on your cross functions. If your signals are small, your variation may simply be due to loose tolerances.
  • To get better accuracy, you might want to use last_crossing (see "Time interval measurement" on verilogams.com).
None of this explains the problem you are having, which seems to be due to the fact that your vlo rising edge threshold detection simply fails to operate on every fourth edge. The code looks okay to me, so I suspect the problem is elsewhere.

What simulator is this?

-Ken



Back to top
 
 
View Profile WWW   IP Logged
zahrein
Junior Member
**
Offline



Posts: 14

Re: Rise and  Fall time
Reply #2 - Sep 28th, 2011, 6:06pm
 
Hi Ken,
Thanks  for  your  feedback and  rearranging my code so that it is  readable. The simulator i used  is  using the  DVE. I believe  most of the Logic  Guyz  use this.

I will  try modify base  on your recomendations but i dont think tolerance play an issue as we  cross on voltages and not the timing.

Will let you know once its successfull. Thanks.
Back to top
 
 
View Profile   IP Logged
zahrein
Junior Member
**
Offline



Posts: 14

Re: Rise and  Fall time
Reply #3 - Sep 28th, 2011, 10:51pm
 
Manage to fix it.  The "begin" and  "end" have some disorganize. Here are the  Codes and the waveform pics.



module measure_riset_fallt (drive_en, pad);


input pad;
input  drive_en;

// need to  declare  variables so that the  equation of the Rise/fall time  can be calculated



parameter real padh =1.05;
real  time_vhi;
real  time_vlo;
real  rise_time;
real  fall_time;



analog  begin

// For   rising  time . Calculate between 70% and 30% of the peak  Voltage  

@(cross(V(pad) - (padh*0.3), 1)) begin
if (drive_en==1'b1) begin
time_vlo= $abstime;
end
               end

@(cross (V(pad) -(padh*0.7),1)) begin //3
if (drive_en==1'b1) begin
time_vhi=$abstime;

rise_time=time_vhi-time_vlo;              
`AMS_INFORM($display("Rise Time= %e",rise_time))
end
end //3


// For   falling   time . Calculate between 70% and 30% of the peak  Voltage  

@(cross(V(pad) - (padh*0.7), -1)) begin  
if (drive_en==1'b1) begin
time_vhi= $abstime;
                               end
               end

@ (cross (V(pad) -(padh*0.3),-1)) begin
                               if (drive_en==1'b1) begin
time_vlo=$abstime;

fall_time = time_vhi - time_vlo;
`AMS_INFORM($display("Fall Time= %e",fall_time))
end
end

end

endmodule
Back to top
 

out_001.png
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: Rise and  Fall time
Reply #4 - Oct 7th, 2011, 7:45am
 
zahrein wrote on Sep 28th, 2011, 10:51pm:
Manage to fix it.  The "begin" and  "end" have some disorganize.


It always helps me keep begin/end straight if I use proper indentation or formatting, as Ken showed you.  (You need the "code" tag in the forum, so that spaces aren't combined.)
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.