[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[f-cpu] DivMod unit



So as Yann say last week, i was writing a divide/modulo unit for the F-CPU.
I concentrate me on the creation of a component that can do all size of 
division. The principe of it is easy :
 For i form WIDTH-1 to 0
   TmpB := B << i
   TmpResult := substraction(A, TmpB);
   if carry(TmpResult) = true then  (test negativ result)
      Yl(i) := 0;
   else
      Yl(i) := 1;
      A := TmpResult;
   endif
 next i;
 Yh := A;

So you have, in the same pass :
	Yl := A / B;
	Yh := A % B;

As you can see all this unit need is a really good substraction function.
The one that I want to write will normally work for all size of data (if
it's a power of 4). The problem is that it doesn't work actually for a
other size than 8 (I have some porblem with index, it will be solved next
week).
I think, that i will probably rewrite my substraction function. Because 
all the perfomance of this unit depend on it. I read a lot about the way
to jump over 0, do SRT divide, and I think that for F-CPU this type of
algorithm are perhaps not a good idea. Because if some case are accelerated
a lot of others are really slow down. And this type of algorithm are not
previsible, and the average speed of this unit is slower than this unit.
It's why i think it's not a good solution to use them.

Of course this component is not pipelined. And i am sure that we divide
sometimes by something that take 64/32/16 bits, so only in really few case
we need to have a pipelined unit (And in this case they will perhaps write
a new div unit). But for 8bits it's not really the same problem, we use
them in all conversion from changing base, in crypto and in some 2d graphical 
filter. In this case, that only represent a really few part of program, we will
have better result, if we have a pipelined 8bits unit i think. So the question
is : "Did we want to accelerate this application ?"

Finally were division are needed, it's in game. But actually all this game
(OpenGl and Direct3D games) use the FPU for all their number. So if we wan't
a good software implementation of OpenGl, we will need a good FPU (i mean
pipelined). And that's perhaps an other discussion ;-)

A+
  Cedric

PS: I will finalise the divide unit during the next week. So if you have
  some idee to accelerate the soustraction, it will be a good idea to say
  them ;-)
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/