Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Dec 4th, 2020, 5:52am
 Pages: 1
 finding voltage peaks and size varying array (Read 2343 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 IP Logged
 Ken Kundert Global Moderator Offline Posts: 2294 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 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 IP Logged
 Ken Kundert Global Moderator Offline Posts: 2294 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 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 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 IP Logged
 Pages: 1