[time-nuts] FreeBSD, NetBSD, or Minix-III?

Lux, James P james.p.lux at jpl.nasa.gov
Mon May 18 13:28:09 UTC 2009




On 5/18/09 6:18 AM, "Lux, James P" <james.p.lux at jpl.nasa.gov> wrote:

> 
> 
> 
> 
> On 5/18/09 1:12 AM, "Hal Murray" <hmurray at megapathdsl.net> wrote:
> 
>> 
>> 
>> stanley_reynolds at yahoo.com said:
>>> I need to go back and read what you are trying to measure with your
>>> clock. Is it internal to the computer or an external event ?
>> 
>> I was thinking of a FPGA on a PCI bus.  It has to be PCI rather than USB in
>> order to get reasonable timings.
>> 
>> I was going to put the Unix clock in the FPGA.  It's a pair of 32 bit words.
>> The high word is seconds since some magic date/time.  The low word is
>> nano-seconds within this second.
>> 
> 
> I would make that "magic time" the time when power was applied.  Do the
> transformation from "hardware time" to "Unix time" in software (since it
> requires just arithmetic.. An add (offset between the two time zeros) and a
> multiply (for the scale factor between "unix time" and your hardware
> counter)



I also wouldn't have the low order counter count nanoseconds, or even set it
up as seconds/subseconds.  Use one long counter that counts whatever
frequency you want to count.  An integer divide in software is quite fast
(unless you're working with something like a Z80).

There's no real advantage in having "hardware" count seconds.. It takes more
gates to count by arbitrary N than 2^M.  Also, say you set your counters up
to divide by 10E6..assuming you have a 10MHz source.  And then you find that
your source is really 10,000,001 Hz (I know... A 0.1 ppm error is anathema
in this crowd).. Now, if you want to convert your (estimated seconds,
estimated nanoseconds) into "real" time, you've got tricky arithmetic to do
(with all the roundoff and arithmetic issues to deal with).

Ticks = secondscounter*nominaltickrate + subsecondscounter;
Realseconds = floor(ticks/actualtickrate)
Realsubseconds = remainder/actualtickrate;






More information about the time-nuts mailing list