multiplication of two 8bit number
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, i want to compare the two multiplier output and count the no. of error output. The multiplier width is 8 bit.One is exact multiplier other one is approximate (inaccurate) multiplier. I created the function for approximate multiplier,under the name MULTIPLIER_APPROXIMATE, i checked its functionality, it works as designed. Next, i have to count the no. of error outputs out of (2^8 x 2^8) outputs. I wrote the matlab code which is given below, am not pretty sure whether it works fine. Can someone suggest is this written script is correct one? I am new to this MATLAB platform, am tried my level best. Thanks in advance.
a=0;
b=0;
i=0;
j=0;
num_correct=0;
num_wrong=0;
check=0;
for a=1:256
for b=1:256
[c]=MULTIPLIER_APPROIMATE(a,b);
end
end
for i=1:256
a=i;
for j=1:256
b=j;
check=a*b;
if c==check
num_correct = num_correct + 1;
else
num_wrong = num_wrong + 1;
%dis = e-check;
end
end
end
0 commentaires
Réponses (1)
Guillaume
le 3 Juin 2017
Well, if you'd tested your code with the debugger you probably would have quickly seen that it does not work.
You have a first set of loop that does nothing but repeatedly overwrite c. At the end c will only contain the value of the last iteration. So your second set of loop after that is not going to do what you want.
I don't particularly understand why you decided to go with two sets of loops. Why can't you do your check at the exact same time you calculate c?
4 commentaires
Reetika Banerjee
le 2 Déc 2020
can anyone tell how to precompute all possible multiplication of two 4 bit binary numbers?
Walter Roberson
le 2 Déc 2020
[a, b] = ndgrid(0:15)
c = a.*b;
A = randi([0,15]);
B = randi([0,15]);
c(A+1,B+1); %lookup answer
Voir également
Catégories
En savoir plus sur Surrogate Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!