Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Distributed arithmetic: 2BAAT hardware with a single LUT

Status
Not open for further replies.

Joshyan

Newbie
Joined
Nov 28, 2022
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
15
I'm trying to create 2BAAT 4 taps FIR filter with single LUT table: created model for 1 BATT - works as expected.

enter image description here

Below is a model in matlab:

Code:
N = 16;
ids = dec2bin(([0:N-1]));

k0 = fi(0.72, true, N, N-1);
k1 = fi(-0.3, true, N, N-1);
k2 = fi(0.95, true, N, N-1);
k3 = fi(0.11, true, N, N-1);

multiplicand = @(k) bin2dec(k);
mem = zeros(N, 1);

for i=1:N
    mask = ids(i, :);
    k = k0 * multiplicand(mask(1)) + k1 * multiplicand(mask(2)) + ...
    k2 * multiplicand(mask(3)) + k3 * multiplicand(mask(4));
    mem(i, 1) = k;
end

x0 = fi(0.5, true, N, N-1);
x1 = fi(0.25, true, N, N-1);
x2 = fi(0.5, true, N, N-1);
x3 = fi(0.25, true, N, N-1);

y = x0*k0 + x1*k1 + x2 * k2 + x3 * k3;

acc = 0;

for i=N:-1:1
    bid1 = bin(x0);
    id1 = bid1(i);
    bid1 = bin(x1);
    id2 = bid1(i);
    bid1 = bin(x2);
    id3 = bid1(i);
    bid1 = bin(x3);
    id4 = bid1(i);
    id = bin2dec([id1 id2 id3 id4]) + 1;
    if i > 1
        acc = (acc + mem(id))/2;
    else
        if i == 0
            acc = acc - mem(id);
        end
    end
end
    disp(['acc = ' num2str(acc)])
    disp(['y = ' num2str(y)])

2 BATT model: enter image description here Formula for memory calculation: enter image description here Model doesn't work as expected:

Code:
clc;
clear;
n = 4;
N = 2^(n*2);
ids = dec2bin(([0:N-1]));

k0 = fi(0.72, true, N, N-1);

k1 = fi(-0.3, true, N, N-1);

k2 = fi(0.95, true, N, N-1);

k3 = fi(0.11, true, N, N-1);

multiplicand = @(k) bin2dec(k);
mem = zeros(N, 1);

for i=1:N
    mask = ids(i, :);
    k = ( (k0 * multiplicand(mask(1))) + (k0 * multiplicand(mask(2))) * 0.5 ) + ...
        ( (k1 * multiplicand(mask(3))) + (k1 * multiplicand(mask(4))) * 0.5 ) + ...
        ( (k2 * multiplicand(mask(5))) + (k2 * multiplicand(mask(6))) * 0.5 ) + ...
        ( (k3 * multiplicand(mask(7))) + (k3 * multiplicand(mask(8))) * 0.5 );
    mem(i, 1) = k;
end

mem_q15 = fi(mem, true, 16, 15);
%%
s = 0;
% x0 - 0.100 (0.5)
% x1 - 0.010 (0.25)
% x2 - 0.100
% x3 - 0.010

adr1 = bin2dec('00010001') + 1;
adr2 = bin2dec('10001000') + 1;

v1 = mem(adr1);
v2 = mem(adr2);
s = (s + v1) / 2;
s = s - v2;

disp(s)

The answer isn't correct.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top