No BSD License  

Highlights from
UWB Fixed-Point Model (Multiband OFDM)

image thumbnail

UWB Fixed-Point Model (Multiband OFDM)

by

 

04 Mar 2004 (Updated )

Ultrawideband (UWB) multiband OFDM physical layer with fixed-point transmitter/receiver modeling.

plothist(x, ax, firstcall, a, b, nBits, tol, refCase);
function plothist(x, ax, firstcall, a, b, nBits, tol, refCase);

x = x(:).';
xr = real(x);
xi = imag(x);
[ir1, ir2] = findRange(xr, tol);
[ii1, ii2] = findRange(xi, tol);
isRealSig = (ii1==1 && ii2==1);
if ~isRealSig
    i1 = min(ir1, ii1);
    i2 = min(ir2, ii2);
else
    i1 = ir1;
    i2 = ir2;
end
t = a:b;
eMin = t(i1);
eMax = t(i2);
nBitsRange = eMax - eMin + 2;
E = eMax - nBits + 1;  % for signed fixed point
ep1 = E-a;
ep2 = (E+nBits-1)-a+2;
pUnder = round(1000*0.5*( sum(xr(1:ep1)) + sum(xi(1:ep1)) ))/10;
pOver = round(1000*0.5*sum(xr(ep2:end) + sum(xi(ep2:end)) ))/10;
% str = {...
%         ['Range of e = ', num2str(nBitsRange) ' bits (' ...
%          num2str(eMin) ' to ' num2str(eMax) '; ' ...
%          num2str(round(tol*100)) '% tolerance)'], ...
%         '', ...
%         ['Desired word length = ' num2str(nBits) ' bits'] ...
%         ['log_2(scale factor), E = ' num2str(E)] ...
%         [num2str(pUnder) '% underflow'] ...
%         [num2str(pOver) '% overflow']};
str = {...
        ['Desired word length = ' num2str(nBits) ' bits'] ...
        ['Autocompute scale factor: 2^{' num2str(E) '}'] ...
        [num2str(pUnder) '% underflow'] ...
        [num2str(pOver) '% overflow']};

yAxesMin = 1e-4;
small = yAxesMin/1e6;

if isempty(ax) || firstcall
    t2 = [t; t; t];  
    t2 = t2(:).';
    yr = zeros(1, length(t2)) + small;
    yr(2:3:end) = xr;
    yi = zeros(1, length(t2)) + small;
    yi(2:3:end) = xi;
    if ~isempty(ax) 
        h = get(ax.main, 'userdata');
        if isstruct(h) && isfield(h, 'realRef') && ishandle(h.realRef)
            yRealRef = get(h.realRef, 'ydata');
            yImagRef = get(h.imagRef, 'ydata');
        end
    else
        yRealRef = xr;
        yImagRef = xi;
        % need to set to zeros if no ref case?
    end
%    h.des = semilogy([E E+nBits-1], [0 0]+yAxesMin, 'g-', 'linewidth', 10); 
    %hold on
    %h.binaryPt = plot(0, yAxesMin, 'k.', 'markersize', 25);
    %hold on
    h.real = semilogy(t, xr, 'r.', 'markersize', 20); 
    hold on
    h.realStem = semilogy(t2, yr, 'r-', 'linewidth', 2);
    h.imag = semilogy(t, xi, 'b.', 'markersize', 20);
    h.imagStem = semilogy(t2, yi, 'b-', 'linewidth', 1);
%    if refCase
       h.realRef = semilogy(t, yRealRef, 'r--', 'linewidth', 1);
       h.imagRef = semilogy(t, yImagRef, 'b--', 'linewidth', 1); 
%    end
    hold off
    axis([a b yAxesMin 1]);
    tt = t(mod(a,2)+1:2:end);
    ax = gca;
    set(ax, 'xtick', tt, 'yticklabel', {'0.01%', '0.1%', '1%', '10%', '100%'})
    set(ax, 'fontsize', 8);
    set(ax, 'tag', 'main');
    grid off
    xlabel('e = log_2(Magnitude)', 'fontsize', 10)
    ylabel('Occurrences', 'fontsize', 10);
    %title('Histogram');
    text(a+1, 0.2, str);
    h.text = findobj(gca, 'type', 'text');
    set(h.text, 'fontsize', 10, 'fontweight', 'bold');
%     legend([h.des, h.binaryPt, h.real, h.imag, h.realRef, h.imagRef], ...
%         'Fixed pt range', 'Binary point', 'Real part', 'Imag part', ...
%         'Real ref', 'Imag ref');
     legend([h.real, h.imag, h.realRef, h.imagRef], ...
         'Real part', 'Imag part', ...
         'Real ref', 'Imag ref');

    set(ax, 'userdata', h); 
else
    h = get(ax.main, 'userdata');
    set(h.real, 'ydata', xr);
    set(h.imag, 'ydata', xi);
    yr = get(h.realStem, 'ydata');
    yr(2:3:end) = xr;
    yi = get(h.imagStem, 'ydata');
    yi(2:3:end) = xi;
    set(h.realStem, 'ydata', yr);
    set(h.imagStem, 'ydata', yi);
    if refCase
        set(h.realRef, 'ydata', xr); 
        set(h.imagRef, 'ydata', xi); 
    end
%    set(h.des, 'xdata', [E E+nBits-1]);
    set(h.text, 'string', str)
end


function [i1, i2] = findRange(x, tol);
xWithinTol = (x>tol);
idx1 = find(xWithinTol);
idx2 = find(fliplr(xWithinTol));
i1 = idx1(1);
i2 = length(x) - idx2(1) + 1;

Contact us