From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm: add 64-64 bit divider
Date: Tue, 20 Sep 2011 20:45:14 +1000 [thread overview]
Message-ID: <4E786EBA.5040805@gmail.com> (raw)
In-Reply-To: <20110907211411.2C91C140875D@gemini.denx.de>
Hi Wolfgang,
On 08/09/11 07:14, Wolfgang Denk wrote:
> Dear Che-liang Chiou,
>
> In message <CANJuy2+BB7tA70vHoTq3LJA-o4ymGCSdP9PnFzrx-uWret7nqQ@mail.gmail.com> you wrote:
>>
>> So I guess we can agree that a 64-bit divider is feature that is nice
>> to have, and we should decide:
>> * Do we need a 64-64 bit divider or a 64-32 bit one?
>> * Do we write it in C or assembly?
>
> The situation is simple: there is no code in U-Boot that needs this
> feature, and we try to avoid adding dead code.
>
> If you don;t have a use case at hand that actually requires this, then
> please let's drop it.
You'll laugh at this - the Intel High Performance Event Timers (HPET) are
defined to a resolution of femto-seconds and you end up with code in
get_timer() like:
u32 count_low;
u32 count_high;
u32 fs_per_tick;
u64 ticks;
u64 fs;
u32 ms;
count_low = readl(&hpet_registers->main_count_low);
count_high = readl(&hpet_registers->main_count_high);
fs_per_tick = readl(&hpet_registers->counter_clk_period);
ticks = ((u64)count_high << 32) | ((u64)count_low);
fs = fs_per_tick * ticks;
ms = (u32)lldiv(ticks, 1000000000000);
But I can right shift both divisor and dividend by 12 bits without loosing
any significant precision which turns it into:
ms = (u32)lldiv(ticks >> 12, 244140625);
So I almost needed a 64 bit divisor.
Regards,
Graeme
next prev parent reply other threads:[~2011-09-20 10:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-31 10:38 [U-Boot] [PATCH] arm: add 64-64 bit divider Che-Liang Chiou
2011-08-31 11:56 ` Marek Vasut
2011-08-31 14:32 ` Mike Frysinger
2011-08-31 15:11 ` Marek Vasut
2011-08-31 15:27 ` Mike Frysinger
2011-08-31 15:33 ` Marek Vasut
2011-08-31 16:05 ` Mike Frysinger
2011-08-31 16:30 ` Marek Vasut
2011-08-31 17:13 ` Mike Frysinger
2011-08-31 20:03 ` Wolfgang Denk
2011-09-01 10:09 ` Che-liang Chiou
2011-09-01 10:16 ` Marek Vasut
2011-09-01 10:30 ` Che-liang Chiou
2011-09-01 10:42 ` Marek Vasut
2011-09-01 12:06 ` Che-liang Chiou
2011-09-01 13:07 ` Wolfgang Denk
2011-09-02 3:12 ` Che-liang Chiou
2011-09-07 21:14 ` Wolfgang Denk
2011-09-20 10:45 ` Graeme Russ [this message]
2011-09-20 11:28 ` Wolfgang Denk
2011-09-20 11:40 ` Graeme Russ
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E786EBA.5040805@gmail.com \
--to=graeme.russ@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox