Zipster?
From,
Nice coder
Binary method for calculating hardware/Software mults/divs.
Mr zipster, i think that you said that you would post it.....
Anybody else?
....
Anybody?
From,
Nice coder
Anybody else?
....
Anybody?
From,
Nice coder
Dmitry [lol]. Thats a little... off-center.
Is anything better then the multi-add-with-shift design for multiplication? (currently, this would be huge, in the 100clock range.)
From,
Nice coder
Is anything better then the multi-add-with-shift design for multiplication? (currently, this would be huge, in the 100clock range.)
From,
Nice coder
Ok, my best is using the binary method.
basically if i can get the last bit nicely, then i'm set.
B0 = a & e
B1 = (a & f) | (b & e)
Ect.
But how would i quickly work out the parity of a group of bits? (ie. if the number of bits is odd or even?)
From,
Nice coder
basically if i can get the last bit nicely, then i'm set.
B0 = a & e
B1 = (a & f) | (b & e)
Ect.
But how would i quickly work out the parity of a group of bits? (ie. if the number of bits is odd or even?)
From,
Nice coder
Quote:Original post by Nice Coder
Dmitry [lol]. Thats a little... off-center.
Is anything better then the multi-add-with-shift design for multiplication? (currently, this would be huge, in the 100clock range.)
From,
Nice coder
don't think there's better ways of doing multiplication. You can have small multiplication table for 4bit multiplications, and use them instead. Basically same thing as multiplying decimal numbers manually.
As about division, from that thread,
//subtraction is needed for division. Of course i can do cool subtraction via cool addition,but it's...inelegantint coolsub(int a,int b){ int c,result, tmp; c=((~a)&b)<<1; result=a^b; while(c!=0){ tmp=result^c; c=((~result)&c)<<1; result=tmp; }; return result;};const high_bit=( ~((unsigned int)(0)) ^ (~((unsigned int)(0))>>1) );int cooldivide(int a,int b){ if(b==0)return 0;//division by zero. What i should return.... if(b==1)return a; int s=0; //note that general >,<,<=,>= do subtraction :) if(a&high_bit){a=coolsub(0,a);s=1;} if(b&high_bit){b=coolsub(0,b);s^=1;} int c,d,m=1,r=0; c=b; d=c<<1; while(d>c){ c=d; d<<=1; m<<=1; } int e=a; int k=0; do{ k=coolsub(e,c); if((k&high_bit)==0){e=k;r+=m;}; m>>=1; c>>=1; }while((m!=0)&&(e!=0)); if(s){return coolsub(0,r);}else{return r;}}
you can replace coolsub with "-" if you like.
Ok, say i have 4 bits, a,b,c and d.
Maybe someone else can work this out.... Its stumping me.
From,
Nice coder
Truth table0000 = 00001 = 10010 = 10011 = 00100 = 10101 = 00110 = 00111 = 11000 = 11001 = 01010 = 01011 = 11100 = 01101 = 11110 = 11111 = 0
Maybe someone else can work this out.... Its stumping me.
From,
Nice coder
Dmitry - Considering that i'm doing all this on hardware, (for one of the banks).
From,
Nice coder
From,
Nice coder
Ok. Parity = a ^ b ^ c ^ d
Picking a line
0111 = 1
0 ^ 1 = 1
1 ^ 1 = 0
Result = 1 ^ 0 = 1
Now, its cumative, sao i can use a tree based approach. Log2 n time (even though most of it is done beforehand.)
From,
Nice coder
Picking a line
0111 = 1
0 ^ 1 = 1
1 ^ 1 = 0
Result = 1 ^ 0 = 1
Now, its cumative, sao i can use a tree based approach. Log2 n time (even though most of it is done beforehand.)
From,
Nice coder
Now the algorithm reads:
B0 = ae
B1 = af ^ be
B2 = ag ^ af ^ ce
B3 = ah ^ bg ^ cf ^ de
B4 = bh ^ cg ^ df
B5 = ch ^ dg
B6 = dh
Now, this is 4 bit arithmatic
so we go up to B3 which is
B0 = ae
B1 = af ^ be
B2 = ag ^ af ^ ce
B3 = ah ^ bg ^ cf ^ de
Now, we have overflow which is
Overflow = (bh ^ cg ^ df) | (ch ^ dg) | (dh)
Thats 4 bit mult + overflow. Also very fast.
From,
Nice coder
B0 = ae
B1 = af ^ be
B2 = ag ^ af ^ ce
B3 = ah ^ bg ^ cf ^ de
B4 = bh ^ cg ^ df
B5 = ch ^ dg
B6 = dh
Now, this is 4 bit arithmatic
so we go up to B3 which is
B0 = ae
B1 = af ^ be
B2 = ag ^ af ^ ce
B3 = ah ^ bg ^ cf ^ de
Now, we have overflow which is
Overflow = (bh ^ cg ^ df) | (ch ^ dg) | (dh)
Thats 4 bit mult + overflow. Also very fast.
From,
Nice coder
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement