逻辑分析仪内存不足?“拼”出解决之道

摘要:matlab®是一个强有力的工具,可用来快速分析从模数转换器(adc)输出所捕获的数据。本应用笔记演示了如何使用matlab来突破逻辑分析仪存储深度的局限。描述并比较了三种数码拼接方式(基本,超前和反转)。并给出了三种方法所得的结果。
介绍要评估一个高速模数转换器(adc)的性能,就需要捕获其数字输出码,然后进行分析。逻辑分析仪的存储深度常常成为一个重要局限,妨碍系统捕获足够的数据点,以生成高分辨率fft,或者精确的inl/dnl图。解决该问题的一个简单办法是使用某种数学工具,例如matlab® (图1),将多组数据连接起来。连接数据的一个缺点是,通常会在两组数据之间的连接点出现很大的不连续性。尽管不连续性对inl/dnl图的影响极小,但对高分辨率fft而言,几乎是毁灭性的(图2)。
图1. 连接后的数据在两组数据之间出现不连续。
图2. a) 捕获单组16384点数据并分析;b) 捕获两组8192点数据,连接,然后分析“拼接”技术。
有一种办法可以消除不连续性,就是在各组数据中寻找相同的点簇(一般为3到4个点),然后在这些点将两组数据“拼接”在一起(图3)。最简单的“拼接”方法是,记录下第一组数据中的最后四个点,然后在第二组数据里寻找相同的点簇。相同点簇出现在第二组数据中的位置称为“拼接点”。第二组数据中在拼接点之前的所有数据均被舍弃;第二组数据中的剩余部分与第一组数据合并。这种技术即所谓的基本数码拼接,实现起来非常简单,可以在matlab中非常快地运行。
图3. 基本数码拼接后得到的最终“拼接”数组。
采用基本拼接方法拼接数据时,有时必须丢掉第二组数据中的近一半,才能找到与第一组数据最后四个点相匹配的一簇点。作为另一种选择,丢掉第一组数据尾部的几个点,常常有助于找到更靠近第二组数据起点的拼接点(图4)。然而,通过丢掉第一组数据尾部、第二组数据头部的部分采样点来寻找匹配点的方法实现起来比较困难。这种处理被称为超前数码拼接。理想拼接点应该能够保留尽可能多的数据点,寻找这样的拼接点需要认真的考虑和一定的编程技巧。正确地实现之后,超前拼接技术通常能够得到两组小数组所含数据点总数的至少90%。
图4. 采用超前拼接技术寻找理想拼接点,最终得到“拼接”后的数组。
将第二组数据(数组b)拼接到第一组数据(数组a)之前被称为反转拼接,这种方式有可能得到更大的拼接数组(图5)。但是,这种技术会使处理时间翻倍,因为必须在a领先于b和b领先于a两种情况下寻找拼接点。此外,当与其他拼接技术一起使用时,反转拼接方式所带来的好处通常很少。因此,对于较慢的pc,反转拼接技术大幅度增加的处理时间开销较之它所带来的好处而言并不太值。表1详细比较了这三种代码拼接方法。
图5. 反转拼接的处理时间加倍,但常常收效甚微。
表1. 三种拼接技术对比*
stitch technique size of final data set description
data set numbers # of codes
(averaged) % of two data sets
(averaged)
1 + 2 3 + 4 1 + 4
concatenate† n/a 16384 100% will produce erroneous fft; however, inl/dnl can be extracted from this data.
basic 11060 8192‡ 14384 11212 68.4% fft is useable for calculating figures of merit.
reverse 11060 8192‡ 14384 11212 68.4%
advanced 13790 16046 16022 15286 93.3%
advanced
+
reverse 15427 16176 16022 15875 96.9%
*采用上述拼接技术对两组8k (8192个)数据进行拼接。为确保准确性,采用四组8192点数据(分别编号为1至4)重复本测试。每组测试所合成的数据取平均后列于测试数据的右侧。
† 直接连接总能得到100%的数据。
‡ 无法拼接数据。 matlab函数说明本文后附的matlab代码(附录a和b中的stitchmatrices和findstitchpoint)将上述论点结合到一个易于使用的函数中。这些函数可接受两组数据(matlab中的单列矩阵)和几个输入变量(用来选择超前/反转拼接功能)。findstitchpoint例程用来确定拼接点在数组a和b中的偏移量。stitchmatrices例程则根据findstitchpoint例程给出的偏移量对两组数据a和b进行舍弃和组合。同时,最终数据的拼接点被记录在prevstitchbins数组中,以便于后续处理。当拼接多组数据时,prevstitchbins可保存老的拼接点。 结论拼接两组数据可以得到一组理想的结果。图6给出了三组8192点数据使用上述拼接技术拼接起来(使用5个拼接点)后的fft图。所得的fft几乎与前面图2a所示,基于16384个连续点所得结果相同。
图6. 数码拼接后得到精确的fft图。
附录a:stitchmatrices例程(stitchmatrices.m)
function [stitchedmatrix, stitchbins] = stitchmatrices(matrixa, ... matrixb, stitchnumber, prevstitchbins, ... advcodestitchenabled, reversestitchenabled); %stitch matrices function %revision 1.0 % %by donald schelle, may 2005 %maxim integrated products %120 san gabriel drive %sunnyvale, ca, 94086 % %this function will take two matrices (matrixa and matrixb), find a %given number (stitchnumber) of identical points in each and %concatenate the two matrices into one. % %inputs = matrixa, matrixb (data matrices) % stitchnumber (number of points to match) % prevstitchbins (bins of previous stitches in matrixa) % advstitchenabled (0 = no, 1 = yes) % reversestitchenabled (0 = no, 1 = yes) %output = stitchedmatrix (matrixa + matrixb) % stitchbins (bins of stitchedmatrix where the two % matrices were joined.) % %if the matrices can not be joined the function will output a nan %for both the stitchedmatrix variable and the stitchbins variable %-------------------------------------------------------------------------- %check to see that there are at least two stitchnumber points if stitchnumber = reversestitchedsize)| ... isnan(reversestitchedsize) == 1, %stitch matrixb to the end of matrixa stitchedmatrix = cat(1, matrixa(1:normala), matrixb(normalb:sizeb)); %update stitch bins if isnan(prevstitchbins) == 1, %there are no previous stitch bins stitchbins = [normala, normala + stitchnumber - 1]; else %there are previous stitch bins %check for snipped stitches [sizestitchbins, junk] = size(prevstitchbins); while (prevstitchbins(sizestitchbins, 2) > (normala - 1)), %second bin is snipped from matrix. check if first bin is snipped. if (prevstitchbins(sizestitchbins, 1) > (normala - 1)), %first bin is snipped too. delete bin pair prevstitchbins = prevstitchbins(1:(sizestitchbins-1),:); else %first bin is not snipped but second bin is snipped %shrink stitch size prevstitchbins(sizestitchbins, 2) = normala - 1; end; %calculate size of new prevstitchbin matrix [sizestitchbins, junk] = size(prevstitchbins); end; %insert new stitchbins [sizestitchbins, junk] = size(prevstitchbins); stitchbins = prevstitchbins; stitchbins(sizestitchbins + 1, :) = ... [normala, normala + stitchnumber - 1]; %check to see if the last two stitches need to be combined [sizestitchbins, junk] = size(stitchbins); if stitchbins(sizestitchbins,1) == ... (stitchbins((sizestitchbins - 1),2) + 1), %combine stitches stitchbins((sizestitchbins - 1),2) = stitchbins((sizestitchbins),2); %shorten stitchbin matrix stitchbins = stitchbins(1:(sizestitchbins - 1),:); end; end; end; %--------------------- reverse matrix stitching routine --------------- if (reversestitchedsize >= normalstitchedsize)| ... isnan(normalstitchedsize) == 1, %stitch matrixa to the end of matrixb stitchedmatrix = cat(1,matrixb(1:reverseb), matrixa(reversea:sizea)); %update stitch bins if isnan(prevstitchbins) == 1, %there are no previous stitch bins stitchbins = [reverseb, reverseb + stitchnumber - 1]; else %there are previous stitch bins %check for snipped stitches while (prevstitchbins(1,1) < (reversea + stitchnumber - 1)), %first bin is snipped from matrix. check if second is snipped if (prevstitchbins(1,2) < (reversea + stitchnumber - 1)), %second bin is snipped too. delete bad pair [sizestitchbins, junk] = size(prevstitchbins); prevstitchbins = prevstitchbins(2:sizestitchbins, :); else %second bin is not snipped, but first bin is snipped %shrink old stitch size prevstitchbins(1,1) = reversea + stitchnumber - 1; end; end; %offset stitch bins by inserted amount stitchbins = prevstitchbins + reverseb - reversea + 1; %make room for new stitchbins [sizestitchbins, junk] = size(prevstitchbins); stitchbins(2:sizestitchbins+1, :) = stitchbins; %insert new stitch bins stitchbins(1,:) = [reverseb, reverseb + stitchnumber - 1]; %combine close stitches if stitchbins(1,2) == stitchbins(2,1) - 1, %combine stitches stitchbins(2,1) = stitchbins(1,1); %shrink stitch bins matrix [sizestitchbins, junk] = size(stitchbins); stitchbins = stitchbins(2:sizestitchbins,:); end; end; end; 附录b:findstitchpoint例程(findstitchpoint.m)
function [outputbina, outputbinb]=findstitchpoint(matrixa, matrixb, ... matchnumber, advancedstitchfindenabled) %find stitch points function %revision 1.0 % %by donald schelle, may 2005 %maxim integrated products %120 san gabriel drive %sunnyvale, ca, 94086 % %this function will find the ideal stitch point in matrix b given %the number of data points to match % %inputs = matrixa % matrixb % number of records to match % advanced stitch find enabled (0 = no, 1 = yes) %output = (outputbina) end bin of matrixa to stitch data % (outputbinb) start bin of matrix b to stitch data % %if no bins are found, the function will output a nan %-------------------------------------------------------------------------- %do argument error checking to see if there is enough arguments if nargin col, matrixb = matrixb'; end; %determine size of matrices [junk, sizea] = size(matrixa); [junk, sizeb] = size(matrixb); %initialize outputbinb to nan (which means that no stitch points are found) outputbinb = nan; %set initial size of bina bina = sizea - matchnumber + 1; %initialize binstop variable binstop = sizea-100; %loop to search through matrix b numerous times. this loop is only %excuted once if advanced stitch find is disabled. the loop will stop when %the 'ideal' stitch point is found while bina > binstop, %stuff the match numbers into a separate matrix matchmatrix = matrixa(bina:bina+matchnumber - 1); %find all bins in matrixb that match the first number of the match matrix matchedbins = find(matrixb == matchmatrix(1)); %compare the 2nd through nth number of the match matrix with the %prospective series of numbers in matrixb %calculate the size of the matched bins matrix [junk, sizematchedbins] = size(matchedbins); %the advanced stitch mode optimizes search time by eliminating %bad stitch points that would result in the final concatenated %matrix being smaller than the last set of stitch points if isnan(outputbinb) == 0, %a stitch point exists from a previous run. elimiate bad stitch points %calculate critical stitch point matrixsize = outputbina + (sizeb-outputbinb) + 1; criticalbin = bina + sizeb - matrixsize - 1; %find maximum number in the matchmatrix badbin = find(matchedbins > criticalbin); %eliminate bad bins (if there are any) if isempty(badbin) == 0, matchedbins = matchedbins(1:badbin(1) - 1); end; %calculate size of new matched bins matrix [junk, sizematchedbins] = size(matchedbins); end; %loop to cycle through initial matched bins for i=1:sizematchedbins, %check to make sure that there isn't a matrixb overrun if (matchedbins(i) + matchnumber - 1) > sizeb, break; end; %assume that next few codes will match and set stitchbingood = true stitchbingood = 1; %initialize matchmatrixcounter count = 1; %cycle through matrixb and compare numbers with the matchmatrix for j=matchedbins(i):(matchedbins(i) + matchnumber - 1), if matchmatrix(count)==matrixb(j), %number is good, continue and check next number count = count + 1; else %number is bad, break loop and try next sequence stitchbingood = 0; break; end; end; if stitchbingood == 1, %the optimal (first) stitch has been found %record the end bin of matrixa %record the start bin of matrixb outputbina = bina; outputbinb = matchedbins(i) + 1; %calculate the size of the joined matrix and a new binstop# binstop = outputbina-outputbinb+1; break; end; end; if advancedstitchfindenabled == 1, %advanced stitch find is enabled and we should make a new match %matrix and search for these numbers bina = bina - 1; else %advanced stitch find is disabled and we should end the loop break; end; end; %check to see if no bins matched if isnan(outputbinb) == 1, %no bins matched outputbina = nan; end;

基于SPCE061A的通用示波器存储功能扩展设计
威频科技获2000万元A++轮融资
Pioneer开发3D LiDAR系统,携手NVIDIA促进自驾车的实现
高频逆变器是什么,它都有哪些特性
2022年全球芯片紧缺的原因是什么
逻辑分析仪内存不足?“拼”出解决之道
中国平板电脑市场将面临重新洗牌
德豪上半年收入8.74亿元 LED下滑下滑77.64%
rainysky陪你一起在zedboard上移植qt+opencv(四):在zedboard运行QT
功放参数指标(上)
小米MIX2评测:有四大缺点,遭米粉吐槽:外观没有新鲜感
物联网如何利用的5G的发展来迎风腾飞
重磅!军工传感器龙头收购C919机头研发公司!8连涨停不排除内幕交易!
默克和通用显示宣布在OLED领域开展研发合作
南存辉:B20峰会将成中国制造业走向国家化重要契机
IPO上市关注丨OBC市场份额进一步向弗迪动力、威迈斯等企业集中
MIT芯片将语音识别功耗降低99% 荣耀V9将于5天后发布
果蔬机哪些牌子好,众多家庭用户都选用了它
为医疗保健开发NLP应用程序
高通、NVIDIA投入无人机芯片平台