The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl Design Languages >> Verilog-AMS >> random PWM https://designers-guide.org/forum/YaBB.pl?num=1171437065 Message started by trond on Feb 13th, 2007, 11:11pm |
Title: random PWM Post by trond on Feb 13th, 2007, 11:11pm Hello, I am trying to generate a signal with constant period, T, but random duty-cycle. Essentially, I would like to obtain a clk-like signal whose "on-time" is random and uniformly distributed between 0 and let's say 0.1T. I can generate random bit streams with: @(timer(start, period)) x = ($random(y) >= 0) ? 1 : 0; but here the period of the signal x will vary and also I cannot set limits on the duty cycle maximum and minimum. Can anyone suggest a way? Thanks for any tips. |
Title: Re: random PWM Post by trond on Feb 14th, 2007, 12:01am I ended up generating a tri-wave with period T and height 1. This i did with using the idtmod function. Also I generate a random amplitude signal with period T using @(timer(0.0, T)) x=$rdist_uniform(seed, 0 ,1 ) % 0.1; Then my desired random duty-cycle signal with constant period T, and in this case, on-time between 0 and 0.1T is generated by: @(cross(tri - 0.5, -1) or cross(tri - x, +1)) n=(tri >=0) && (tri < rand); This works fine. Still, is there an easier way? |
Title: Re: random PWM Post by Andrew Beckett on Feb 22nd, 2007, 11:19am Here's something I wrote a while ago for testing an eye diagram calculator function. Not quite what you want, but it might give you a few clues: Code:
Regards, Andrew. |
Title: Re: random PWM Post by jbdavid on Mar 17th, 2007, 5:11pm you do one timer for the rising edge @timer(start,period) begin duty = period*rnd(0->1); <- multiply period by a random number between 0 and 1 signal = 1 timeout = abstime+duty end and another for the falling edge, @timer(timeout) signal = 0; - untested and not legal syntax, but it seems easier than generating extra signals |
The Designer's Guide Community Forum » Powered by YaBB 2.2.2! YaBB © 2000-2008. All Rights Reserved. |