The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines. Nov 19th, 2017, 4:27am
  HomeHelpSearchLoginRegisterPM to admin  
 
Pages: 1
Send Topic Print
finding voltage peaks and size varying array (Read 348 times)
jjnkxb
New Member
*
Offline



Posts: 7

finding voltage peaks and size varying array
Sep 07th, 2017, 6:43am
 
I am implementing a history dependent model in verilog a. I had some problems which I hope you could provide help.

I need to locate the input voltage peaks and store them in an array. Since the input voltage waveform is arbitrary, the array size is also varying. Is there any way to implement such array?

In addition, to find the peak, I am considering to use d/dt function. When the time derivative changes sign, the peak is found. But right at the peak (for a linear voltage waveform), the time derivative is not defined. I am not clear how that is handled in circuit simulation. Or do you have any other idea to find the peak?

Would you please provide me some insight?

Thanks.
Kai
Back to top
 

Picture2_001.jpg
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline

The Spectre

Posts: 2079
Silicon Valley
Re: finding voltage peaks and size varying array
Reply #1 - Sep 7th, 2017, 8:34am
 
Quote:
I need to locate the input voltage peaks and store them in an array. Since the input voltage waveform is arbitrary, the array size is also varying. Is there any way to implement such array?


No, not that I know of, not within Verilog-A. You could write the peaks to a file.


Quote:
In addition, to find the peak, I am considering to use d/dt function. When the time derivative changes sign, the peak is found. But right at the peak (for a linear voltage waveform), the time derivative is not defined. I am not clear how that is handled in circuit simulation. Or do you have any other idea to find the peak?


Try it and see.

If you don't like the result, consider simply saving two points back and determine the peaks that way.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
jjnkxb
New Member
*
Offline



Posts: 7

Re: finding voltage peaks and size varying array
Reply #2 - Sep 7th, 2017, 8:51am
 
Thanks Ken. About your last sentence, I am not sure how I can save the previous voltage value. To my knowledge, the voltage is instantaneous. Would you please elaborate on that?

Best,
Kai



Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline

The Spectre

Posts: 2079
Silicon Valley
Re: finding voltage peaks and size varying array
Reply #3 - Sep 7th, 2017, 11:09pm
 
Code:
real vprev, vprev2;
analog begin
    if ((vprev2 < vprev) && (vprev > V(in)) begin
	   # vprev is peak
	   ...
    end
    vprev2 = vprev;
    vprev = V(in);
end
 



-Ken
Back to top
 
 
View Profile WWW   IP Logged
jjnkxb
New Member
*
Offline



Posts: 7

Re: finding voltage peaks and size varying array
Reply #4 - Sep 8th, 2017, 1:14pm
 
Ken, Thanks a lot. I will try this method and see how it works.

Best,
Kai
Back to top
 
 
View Profile   IP Logged
jjnkxb
New Member
*
Offline



Posts: 7

Re: finding voltage peaks and size varying array
Reply #5 - Sep 13th, 2017, 8:58am
 
Ken, I tried to use the d/dt approach and also save the previous voltage and compare. Both approaches worked fine. Thank you very much for your help.

Best,
Kai
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Trouble viewing this site? Copyright © 2002-2014 Designer's Guide Consulting. 'Designer's Guide' is a registered trademark of Designer's Guide LLC. All rights reserved.

Our colleges are not as safe as they seem. Sexual assault is pervasive and the treatment of the victim by the adminstration is often as damaging as the assault: Campus Survivors, Campus Survivors Forum.

Some of our other sites that you might find useful: QuantiPhy.