The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Simulators >> Circuit Simulators >> Help Regarding DFT Calculation using Cadence Calculator
https://designers-guide.org/forum/YaBB.pl?num=1245144421

Message started by saket on Jun 16th, 2009, 2:27am

Title: Help Regarding DFT Calculation using Cadence Calculator
Post by saket on Jun 16th, 2009, 2:27am

Hi,

I am trying to plot the DFT of an all Verilog A model of a sigma delta modulator. The problem arises when I try to plot the DFT.

I do understand the concept of coherent sampling and this is how I have chosen my DFT output.

Input frequency:523.681640625 KHz for Sampling Frequency (Fs) 260 MHz

# of samples = 16384 and No of input cycles = 33

Now I use a zvcvs at the output of the ADC and I set the delay time = 10.8/Fs (0.8 for output to settle)

The problem arises when I try to plot the DFT for different start points and corresponding end points (viz 19.8/Fs or 100.8/Fs) and I get different results for different start points. Sometimes the DFT output is flat at low frequencies whereas in some cases I see proper noise shaping (due to Sigma Delta Mod behavior).

Can anybody explain why this is occuring? I have set the spectre tran sim accuracy to "moderate" and my max step is 50 pS.

Any help will be greatly appreciated. Thanks!

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by currant on Jun 16th, 2009, 5:21am

Hi, saket.

Did You set strobperiod=1/260M?
Although, I think, it is essential to begin DFT after end of all transients.
Show Your DFT statement.

Best regards.

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by sheldon on Jun 16th, 2009, 7:08am

Saket,

  You did not mention the window function that you are using for
the DFT. It sounds like you are using the Rectangular window,
try using the Hann window function. You will manually need to
set the window to Hanning by editing the window type in the calculator.
There is more discussion about this topic in, "Understanding Delta-
Sigma Data Converters", R. Schrier and Gabor Temes, Appendix A,
Spectral Estimation

                                                          Best Regards,

                                                              Sheldon

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by pancho_hideboo on Jun 16th, 2009, 7:23am

The following might be helpful.
http://www.designers-guide.org/Forum/YaBB.pl?num=1213204643

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by saket on Jun 16th, 2009, 9:40pm

Thanks all for the responses!

Currant: I am using a zvcvs at the output. Hence there is no need to set strobing. It's an all Verilog A model that I am using, hence the transients are also quite small i.e the output settles within 10 clock cycles.

Sheldon: Much thanks. Haven't tried the Hann window yet. Will try it and see if that makes a difference.

pancho_hideboo: Thanks!

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by saket on Jun 16th, 2009, 10:35pm

Sheldon: I can't find the Hann Window function in my Cadence Calculator. There are a bunch of windows available, but no Hann window!

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by pancho_hideboo on Jun 16th, 2009, 11:51pm


saket wrote on Jun 16th, 2009, 10:35pm:
Sheldon: I can't find the Hann Window function in my Cadence Calculator. There are a bunch of windows available, but no Hann window!
"Cosine2" is equivalent to "Hanning".
And also you can express almost all windows including "Hanning" by using "Kaiser" with smoothing factor.

http://en.wikipedia.org/wiki/Window_function

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by saket on Jun 17th, 2009, 5:07am

pancho_hideboo: Thanks for the clarification.

Now I need another one ;D

The input signal in the Hanning window is spread over 3 bins. I'm assuming that in order to calculate the SNR, the signal power in all the 3 bins has to be added up. Is this a correct assumption?

In a rectangular window, the signal power is spread over only one bin. These 2 values will be different if I were to add up the 3 bin values in the Hanning window option.

Thanks in advance!

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by pancho_hideboo on Jun 17th, 2009, 6:06am


saket wrote on Jun 17th, 2009, 5:07am:
The input signal in the Hanning window is spread over 3 bins.
I'm assuming that in order to calculate the SNR, the signal power in all the 3 bins has to be added up.
Is this a correct assumption?

Again see M-File of http://www.designers-guide.org/Forum/YaBB.pl?num=1213204643/8#8
The followings are extractions from them.

Quote:
%Parameters
order = 2;
nLev = 2;
opt = 2;
H_inf = 1.6;

fs = 1e6;

%f0 = 1/4;
f0 = 20e3/fs; % Normalized by fs

%OSR = 128;
BW = 4e3;
OSR = fs/(2*BW);
fprintf(stdout, 'OSR=%d\n', OSR);

Nfft = 2^13;

Tstep = 1; % Normalized by (1/fs)
Textra = 100*Tstep;
Tstop = Nfft*Tstep + Textra;
delta_f = 1/(Tstop-Textra);

%tone_bin=57;
tone_bin = fix(f0/delta_f + 0.5);
if mod(tone_bin, 2) == 0
  tone_bin = tone_bin + 1;
end
fprintf(stdout, 'tone_bin=%d\n', tone_bin);

t1 = fix(Textra/Tstep);
t2 = t1 + Nfft-1;
t = 0:t2;
u = 0.5*(nLev-1)*sin(2*pi*(tone_bin)/Nfft*t);
n = 1:150;
n = n + t1;

%Calculating the Spectral Contents of the modulator
%Determining the SNR
figure(4), hold on
spec = fft( v(t1:t2) .* hann(Nfft) ) / (Nfft*(nLev-1)/4);
snr = calculateSNR(spec(1:ceil(Nfft/(2*OSR))+1), tone_bin);
NBW = 1.5/Nfft;
f = linspace(0, 0.5, Nfft/2+1);
plot(f, dbv(spec(1:Nfft/2+1)), 'b')
%z = exp(2i*pi*f); Sqq = 4*( evalTF(H, z) / (nLev-1) ) .^ 2/3;
Sqq = 4*( freqresp(H, 2*pi*f) / (nLev-1) ) .^ 2/3;
plot(f, dbp(squeeze(Sqq)*NBW), 'm', 'Linewidth', 1);
grid on

If you see "delsig/calculateSNR.m" and "delsig/hann.m" of http://www.mathworks.com/matlabcentral/fileexchange/19,
you will be able to find out answer to your questions.

The followings are extractions from "delsig/DSToolbox.pdf".

Quote:
Delta-Sigma Utility
snr = calculateSNR(hwfft, f)
Estimate the SNR given the in-band bins of a Hann-windowed FFT and the location of the input signal.

window = hann(N)
A Hann window of length N. Unlike MATLAB’s original hanning function,
hann does not smear tones which are located exactly in an FFT bin (i.e. tones having an integral number of cycles in the given block of data).
MATLAB 6’s hanning(N, ’periodic’) function is the same as hann(N).


Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by saket on Jun 17th, 2009, 10:23pm

function snr = calculateSNR(hwfft,f,nsig)
% snr = calculateSNR(hwfft,f,nsig=1) Estimate the signal-to-noise ratio,
% given the in-band bins of a (Hann-windowed) fft and
% the location of the input signal (f>0).
% For nsig=1, the input tone is contained in hwfft(f:f+2);
%  this range is appropriate for a Hann-windowed fft.
% Each increment in nsig adds a bin to either side.
% The SNR is expressed in dB.
if nargin<3
   nsig = 1;
end
signalBins = [f-nsig+1:f+nsig+1];
signalBins = signalBins(signalBins>0);
signalBins = signalBins(signalBins<=length(hwfft));
s = norm(hwfft(signalBins));            % *4/(N*sqrt(3)) for true rms value;
noiseBins = 1:length(hwfft);
noiseBins(signalBins) = [];
n = norm(hwfft(noiseBins));
if n==0
   snr = Inf;
else
   snr = dbv(s/n);
end

Hi pancho_hideboo, I can't understand the highlighted code! Please do explain what it means.

It looks like the 3 signal bins are added together but I still need to confirm it. (I'm not that proficient with Matlab!)

Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by pancho_hideboo on Jun 18th, 2009, 5:07am

Array index starts from "1" in MATALB. It is not "0".
So if I specify tone_bin(0<=tone_bin<=Nfft-1), it is located at tone_bin+1 of hwfft.


saket wrote on Jun 17th, 2009, 10:23pm:
I can't understand the highlighted code! Please do explain what it means.
(I'm not that proficient with Matlab!)
Read documentations of MATLAB which are available in http://www.mathworks.com.

These use "Logical Indexing".

Case-1
Quote:
clear, close all, clc
hwfft = [971 : 980];
nsig = 1;

tone_bin = 5;
signalBins = [(tone_bin+1)-nsig : (tone_bin+1)+nsig]
ix1 = signalBins > 0
signalBins = signalBins(ix1)
ix2 = signalBins <= length(hwfft)
signalBins = signalBins(ix2)
hwfft(signalBins)

signalBins = 5    6    7

ix1 = 1     1     1
signalBins = 5    6    7

ix2 = 1     1     1
signalBins = 5    6    7

ans = 975   976   977


Case-2
Quote:
clear, close all, clc
hwfft = [971 : 980];
nsig = 1;

tone_bin = 9;
signalBins = [(tone_bin+1)-nsig : (tone_bin+1)+nsig]
ix1 = signalBins > 0
signalBins = signalBins(ix1)
ix2 = signalBins <= length(hwfft)
signalBins = signalBins(ix2)
hwfft(signalBins)

signalBins = 9    10    11

ix1 = 1     1     1
signalBins = 9    10    11

ix2 = 1     1     0
signalBins = 9    10

ans = 979   980


Case-3
Quote:
clear, close all, clc
hwfft = [971 : 980];
nsig = 1;

tone_bin = 0;
signalBins = [(tone_bin+1)-nsig : (tone_bin+1)+nsig]
ix1 = signalBins > 0
signalBins = signalBins(ix1)
ix2 = signalBins <= length(hwfft)
signalBins = signalBins(ix2)
hwfft(signalBins)

signalBins = 0     1     2

ix1 = 0     1     1
signalBins = 1     2

ix2 = 1     1
signalBins = 1     2

ans = 971   972


Title: Re: Help Regarding DFT Calculation using Cadence Calculator
Post by saket on Jun 18th, 2009, 10:51pm

Thanks a ton, pancho_hideboo! You've been extremely helpful and patient with me  :)

Thanks once again!

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