The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Apr 26th, 2024, 2:20pm
Pages: 1
Send Topic Print
Noise table using CASE statement (Read 5479 times)
Nathan
Guest




Noise table using CASE statement
Apr 06th, 2005, 10:41am
 
I am trying to set up my VCO phase noise using noise table. No issue there.

However, I am trying to set the code so depending on the corner (typical, slow, fast) it will pick different include files. The CASE statement seems like a good way to do this. This is how I set it up:

case (typ)

0:`include "/home/yom/WA/PLL_TOOL/VCO_PHASE_DOMAIN/vco_tt.txt"

1:`include "/home/yom/WA/PLL_TOOL/VCO_PHASE_DOMAIN/vco_ff.txt"

This caused the files to be added to each other instead of selected. I figured that I needed ";" at the end of each. See below:
 
case (typ)

0:`include "/home/yom/WA/PLL_TOOL/VCO_PHASE_DOMAIN/vco_tt.txt";

1:`include "/home/yom/WA/PLL_TOOL/VCO_PHASE_DOMAIN/vco_ff.txt";

However, this caused a syntax error. Is there a way to make this work?
Back to top
 
 
  IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: Noise table using CASE statement
Reply #1 - Apr 7th, 2005, 1:08pm
 
What's in the files you're including? That's probably the cause of the error, I'd guess.

I can't remember the exact syntax of the case statement - I didn't check to see whether what you've done is correct, but knowing what's in the include files is also important.

Andrew.

Back to top
 
 
View Profile WWW   IP Logged
Nathan
Guest




Re: Noise table using CASE statement
Reply #2 - Apr 7th, 2005, 4:03pm
 
In my .txt file
       Theta(out) <+ noise_table({
1.00E+04,       1.3467E-05,
1.26E+04,       7.01811E-06,
1.58E+04,       3.6637E-06,


etc...
Back to top
 
 
  IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: Noise table using CASE statement
Reply #3 - Apr 7th, 2005, 10:33pm
 
Well, I don't think you should have the semi-colon after the include statement. Here's what I just tried:

Code:
`include "discipline.h"
`include "constants.h"

module myres (a,b);

inout  a,b;
electrical  a,b;
branch (a,b) resbr,noisebr;
parameter real r=1000,typ=0;

analog begin

  case (typ)
    0: `include "noise1.txt"
    1: `include "noise2.txt"
  endcase
  V(resbr) <+ r*I(resbr);

end

endmodule
 



And the noise1.txt file contained:

Code:
I(noisebr) <+ noise_table({
1e+4, 1.3e-5,
1.26e+4, 7.0e-6,
1.6e+4, 3.6e-6
});

 



for testing, I just made noise2.txt the same.

This compiled with no errors.

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
Nathan
Guest




Re: Noise table using CASE statement
Reply #4 - Apr 8th, 2005, 8:48am
 
This is how I originally had it, and yes I did not get an error (original mail).

BUT the noise from the different .txt file were added on ignoring the CASE statement. Basically, it seems that the lack of ";" caused the two noise tables to be added.

To confirm try this:
1) Call only noise1.txt. Plot results.

2) Then try totally removing the noise2.txt file from your test bench, and I would guess that you will different results.  

In test 1, I would expect you to get the added value of noise1.txt and noise2.txt because as I see it, the CASE statement gets ignored without the ";".

This was my specific problem.

Thanks

Nathan
Back to top
 
 
  IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: Noise table using CASE statement
Reply #5 - Apr 11th, 2005, 1:36am
 
I don't have time to try this right now - but you might need to store the results of the noise_table into a variable, and then have the contribution outside the case.

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Noise table using CASE statement
Reply #6 - Jun 6th, 2005, 8:10am
 
Does conditional noise work?  Try this:

Code:
module if_noi(a,c);
output a, c;
electrical a, c;
branch (a,c) res;
parameter real rs = 100 from (0:inf];
analog begin
    I(res) <+ V(res)/rs ;
    if (0)
	  I(res) <+ white_noise( 1.0 , "thermal" ) ;
end
endmodule
 



Code:
*
simulator lang = spectre
ahdl_include "if_noi.va"
x1 (top 0) if_noi
noi1 (top 0) noise start=1e3 stop=1e6 dec=2
 



If you get noise from noi1, then you may need to get a new version of the simulator.  Andrew's work-around would also suffice.
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.