The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 18th, 2024, 10:24am
Pages: 1
Send Topic Print
How to get a Gaussian source using Verilog-AMS (Read 1670 times)
ahutianyi
New Member
*
Offline



Posts: 5

How to get a Gaussian source using Verilog-AMS
Mar 22nd, 2012, 1:25am
 
Hi,guys
I'm modeling a ADC.However,I meet a problem when to model a random source.I need a 255 outputs Gaussian source,and I find it difficult to realize that using "$rdist_normal(seed,mean,deviation)". Cry
Is there anybody who can help me?
Thanks very much!
Back to top
 

pro.JPG
View Profile   IP Logged
ahutianyi
New Member
*
Offline



Posts: 5

Re: How to get a Gaussian source using Verilog-AMS
Reply #1 - Mar 23rd, 2012, 12:56am
 
ahutianyi wrote on Mar 22nd, 2012, 1:25am:
Hi,guys
I'm modeling a block.However,I meet a problem when to model a random source.I need a 255 outputs Gaussian source,and I find it difficult to realize that using "$rdist_normal(seed,mean,deviation)". Cry
Is there anybody who can help me?
Thanks very much!

Back to top
 
 
View Profile   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: How to get a Gaussian source using Verilog-AMS
Reply #2 - Mar 23rd, 2012, 7:09am
 
Hi,

What do you mean when saying 255 outputs Gaussian source? What do you get using your code?

Is it correct for the code
V(offset[i]) <+ V(result[i]);
result is defined as real. I don't know what the compiler/simulator do with the above statement.

Yawei
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: How to get a Gaussian source using Verilog-AMS
Reply #3 - Mar 26th, 2012, 10:46am
 
I'm sure he meant

V(offset[i]) <+ result[i];
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: How to get a Gaussian source using Verilog-AMS
Reply #4 - Mar 26th, 2012, 10:52am
 
But I think you need two integers, one for the loop index and a second for the seed; as it is,
 V(offset[1]) = $rdist_normal(1, mean, dev)

That is, the call to $rdist_normal that sets output[1] is always made with the seed=1, so it will get the same value for each and every timepoint.

Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
ahutianyi
New Member
*
Offline



Posts: 5

Re: How to get a Gaussian source using Verilog-AMS
Reply #5 - Mar 27th, 2012, 5:01am
 
I meant that I want to get a series of random sources.All the sources follow the Gaussian distribution.I found the sytax error---V(offset[i])<+V(result[i]).However,I can't realize the resources yet.Is there anybody can help me?
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: How to get a Gaussian source using Verilog-AMS
Reply #6 - Mar 27th, 2012, 11:07am
 
We can't help you if we don't understand what you are trying to do.

Are you sure you want a new $rdist value for *every* timepoint?

Perhaps you want to use a clock input, or a timer event, to signal when to generate new random values.

integer i, myseed;
genvar j;
@(initial_step)
 myseed = 0;

@(timer(0,1u)) begin
 for (i=1; i <=256; i++) begin
   result[i] = $rdist_normal(myseed, mean, dev);
 end
end

for (j=1; j <=256; j++) begin
 V(offset[j]) <+ transition(result[j], 0, 1n, 1n);
end
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
ahutianyi
New Member
*
Offline



Posts: 5

Re: How to get a Gaussian source using Verilog-AMS
Reply #7 - Mar 27th, 2012, 11:47pm
 
Thanks a lot.I'm sure I want to realize a series of Gaussian voltages,and the voltages are stable.I use these voltages as the sources of the latter blocks. Smiley
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: How to get a Gaussian source using Verilog-AMS
Reply #8 - Mar 28th, 2012, 4:53am
 
Oh, if the voltages are stable (ie, don't change in time, but are picked randomly at time zero), then

integer i, myseed;
genvar j;
@(initial_step) begin
myseed = 0;
for (i=1; i <=256; i++) begin
  result[i] = $rdist_normal(myseed, mean, dev);
end
end

for (j=1; j <=256; j++) begin
V(offset[j]) <+ result[j];
end
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.