multiplication of two 8bit number
6 views (last 30 days)
Show older comments
SHOBA MOHAN on 3 Jun 2017
Commented: Walter Roberson on 2 Dec 2020
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.
num_correct = num_correct + 1;
num_wrong = num_wrong + 1;
%dis = e-check;
Guillaume on 3 Jun 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?
Walter Roberson on 2 Dec 2020
[a, b] = ndgrid(0:15)
c = a.*b;
A = randi([0,15]);
B = randi([0,15]);
c(A+1,B+1); %lookup answer
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!