|
发表于 2011-5-13 19:23:45
|
显示全部楼层
回复 16# fhchen2002
附上一個 behavioral analysis of (INL and DNL) MATLAB script
clear
clf
format long e
MSB = 6;
LSB = 4;
N = MSB + LSB;
iFull = 1;
iUnit = iFull / (2 ^ N);
iMSB = iFull / (2 ^ MSB);
Stdev = 0.03; % Standard deviation of the unit current source
% \Delta(I_%) = sqrt(2) * Stdev;
for sample = 1: 100
% The standard deviation of the normal distribution
% (pseudo) random numbers should be very close to 1.
errLSB = randn(1, (2 ^ LSB) - 1);
iArrayLSB = 1 + Stdev * errLSB;
errMSB = randn(1, (2^MSB) - 1) / sqrt(2^LSB);
StdMSB = std(errMSB);
iArrayMSB = 1 + Stdev * errMSB;
% Real voltage output
v(1) = 0;
for i = 1: 2^MSB
for j = 1: 2^LSB - 1
v((i-1) * 2^LSB + j + 1) = v((i-1)*(2^LSB) + j) + iUnit * iArrayLSB(j);
end
if i < 2^MSB
v(i * 2^LSB + 1) = v((i-1) * 2^LSB + 1) + iMSB * iArrayMSB(i);
end
end
% ideal voltage output
i = 1: 2^N;
p = polyfit(i, v, 1);
v_ideal(i) = p(1) * i + p(2);
vlsb = (v_ideal(2^N) - v_ideal(1)) / (2^N-1);
INL(i) = (v_ideal(i) - v(i)) / vlsb;
INL_max(sample) = max(abs(INL));
i = 1: 2^N -1;
DNL(i) = (v(i+1) - v(i)) / vlsb - 1;
DNL_max(sample) = max(DNL);
end
% hist(INL_max,0:0.05:1), xlabel('INL'), ylabel('Sample count'), title('INL Histogram (\sigma = 0.3%), 10-bit DAC'), grid
% axis([0 1 0 15]);
hist(DNL_max, 0: 0.05: 1), xlabel('DNL'), ylabel('Sample count'), title('DNL Histogram (\sigma = 0.3%), 10-bit DAC'), grid |
|