mahdi3999
Member level 2
- Joined
- May 10, 2013
- Messages
- 49
- Helped
- 13
- Reputation
- 24
- Reaction score
- 11
- Trophy points
- 1,288
- Activity points
- 1,657
hi everybody,
I generate a sinesiod waveform in hspice with freq=384.902954MHz and import the data to Matlab to find its FFT and SNR. In my hspice netlist, I set the time step in .tran to 20psec (so that the generated waveform is a sampled sine with Tsampling=20psec), by the way in Matlab mfile, I choose the number of points for FFT and the prime number of sine cycles equal to 2^17 and 1009 respectively. Therefore coherent sampling is assured. However I find the signal THD equal to -41dB while using the same mfile with a sine wave produced in Matlab itself the THD is -249dB which seems to be reasonble. Has anyone run into a similar experience before? (I should mention that in Hspice I use the .option numdgt=8 to increase the accuracy of the numbers but the resul is still -41dB)
my mfile is as follows:
clc
format long
load vin.mat %loads hspice output
Ts=20e-12;
t1=vin,1);
y1=vin,2);
%%the following two lines are only used when the sine waveform is produced in Matlab
%t1=0:Ts:3e-6;
%y1=20e-3*sin(2*pi*384902954.1015625*t1);
L=2^17;
NFFT=2^17;
len=length(t1);
t=t1(len-L+1:len);
y=y1(len-L+1:len);
subplot(2,1,1)
plot(t,y)
Y=(abs(fft(y,NFFT)/NFFT));
f=(1/(2*Ts))*linspace(0,1,NFFT/2+1);
subplot(2,1,2)
plot(f,2*20*log10(Y(1:NFFT/2+1)))
d=Y.^2;
noise=sum(d(1:1009))+sum(d(1011:NFFT/2+1)) %bin 1010 is the signal power
thd=sqrt(noise/(d(1010)))
thddb=20*log10(thd)
I generate a sinesiod waveform in hspice with freq=384.902954MHz and import the data to Matlab to find its FFT and SNR. In my hspice netlist, I set the time step in .tran to 20psec (so that the generated waveform is a sampled sine with Tsampling=20psec), by the way in Matlab mfile, I choose the number of points for FFT and the prime number of sine cycles equal to 2^17 and 1009 respectively. Therefore coherent sampling is assured. However I find the signal THD equal to -41dB while using the same mfile with a sine wave produced in Matlab itself the THD is -249dB which seems to be reasonble. Has anyone run into a similar experience before? (I should mention that in Hspice I use the .option numdgt=8 to increase the accuracy of the numbers but the resul is still -41dB)
my mfile is as follows:
clc
format long
load vin.mat %loads hspice output
Ts=20e-12;
t1=vin,1);
y1=vin,2);
%%the following two lines are only used when the sine waveform is produced in Matlab
%t1=0:Ts:3e-6;
%y1=20e-3*sin(2*pi*384902954.1015625*t1);
L=2^17;
NFFT=2^17;
len=length(t1);
t=t1(len-L+1:len);
y=y1(len-L+1:len);
subplot(2,1,1)
plot(t,y)
Y=(abs(fft(y,NFFT)/NFFT));
f=(1/(2*Ts))*linspace(0,1,NFFT/2+1);
subplot(2,1,2)
plot(f,2*20*log10(Y(1:NFFT/2+1)))
d=Y.^2;
noise=sum(d(1:1009))+sum(d(1011:NFFT/2+1)) %bin 1010 is the signal power
thd=sqrt(noise/(d(1010)))
thddb=20*log10(thd)