The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> Noise table using CASE statement
https://designers-guide.org/forum/YaBB.pl?num=1112809322

Message started by Nathan on Apr 6th, 2005, 10:41am

Title: Noise table using CASE statement
Post by Nathan on Apr 6th, 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?

Title: Re: Noise table using CASE statement
Post by Andrew Beckett on 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.


Title: Re: Noise table using CASE statement
Post by Nathan on 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...

Title: Re: Noise table using CASE statement
Post by Andrew Beckett on 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.

Title: Re: Noise table using CASE statement
Post by Nathan on 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

Title: Re: Noise table using CASE statement
Post by Andrew Beckett on 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.

Title: Re: Noise table using CASE statement
Post by Geoffrey_Coram on 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.

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.