[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [f-cpu] Status quo



Le 2015-03-28 14:03, Ralf Jonas a ÃcritÂ:
Hi Yann,
Hi Ralf,

No BCD there either, it's pure binary again.
whatever.
please name ?

well, let me explain: The last 15 years we programmed a large java
application for an advertising company. Our programms have to plan
advertising campaigns and the distribution of budgets. Budgets in size
up to 1.500.000.000,-- â

1.500.000.000 < 2^32

let's now consider the cents : <2^40

Oh BTW F-CPU is meant to be a 64 bits design.
This leaves about 16 millions of margin ;-)

Because our programm was strictly forbidden to have any rounding
differences, our main datatype was java.lang.BigDecimal. To avoid any
side effects from the database, we even stored the values as strings.
I confess I'm inexperienced in Java...

I already told you, I'm a programmer, not a cpu designer. So I just
thought I might be handy, if the cpu could calculate decimal values
directly. You're right: Of course it's possible to do all that decimal
stuff with standard integer arithmetic. 100% agree.
you see the decimal digits only during display.
it is commonly converted with divide/modulo operations.
Fortunately, it's a pretty common consideration and it's not *that* speed-critical,
and people have come up with pretty smart methods, particularly
for constant conversions such as this.

The "Alpha RISC Architecture" book (p137)
gives this conversion as an example. For each least significant
decimal digit, multiply the number by a special constant
(0xCCCCCCCCCCCCCCCD, the reciprocal of ten)
then shift the result by another specific amount, and there, you
have your value divided by then. That's the next value.

The digit is obtained with another multiply (by the constant ten)
then substract the result from the original : you have now your digit.

I haven't seen the following in the wild but you can go faster with
a recursive/parallel tree approach instead of the iterative
approach. Instead of dividing by 10 all the time,
divide your number by 100000000, then each result
(dividend and modulo) are divided by 10000,
then each result gets divided by 100, and finally 10.
This performs many operations that are inherently parallel
and that lets us fill the pipeline. It can even fit SIMD units.

Converting BCD to binary is even faster, no need of modulo.

But I couldn't imagine, that a decimal arithmetic unit would be that
complicated. It's just from my point of view as a programmer...
It always starts like this ;-)
F-CPU started because some Linux kernel programmers were fed up of
many stupid x86 idiosynchrasies...
However RISC is not a feature, it's a philosophy and you can't make
a computer simply by piling up "ideas" :-/

Regards,

Ralf
Yg
*************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxx with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/