Keller, Jacob E
2015-04-04 00:47:15 UTC
Hey Richard, and others,
I am currently implementing a timecounter setup for a device which
(nominally) represents time as
Field1: 32bits, Seconds
Field2: 32bits, Nanoseconds (never > 999,999,999)
I do the math to convert this to u64 nanoseconds, and provide this to a
cycle counter.
The trouble is that the u64 field "overflows" at an arbitrary number,
not at a potential mask value.
Since seconds value will overflow at 0xFFFFFFFF, the nanoseconds u64
field overflows at
0xFFFFFFFF*(0d1000000000) + 0d999999999 or 3B9AC9FFFFFFFFFF which is not
a mask-able value.
It overflows somewhete between (2^61)-1 and (2^62)-1.. That is, 2^61-1
is a valid value, but (2^62)-1 is not.
I am trying to determine what mask I can use for this. If I use 64,
obviously I will get an incorrect value.
I believe that I have to use the mask as 41 bits, which is the maximum
value that it can actually hold that consistently overflows at the same
location.
I think the timecounter code is actually incorrect, because it doesn't
allow for arbitrary overflow points....
I tried it out at using 61, and it really didn't look right.. But I
don't really like the idea that I have to mask all the way down to 41
bits.
Any suggestions or thoughts on the timecounter stuff?
Regards,
Jake
I am currently implementing a timecounter setup for a device which
(nominally) represents time as
Field1: 32bits, Seconds
Field2: 32bits, Nanoseconds (never > 999,999,999)
I do the math to convert this to u64 nanoseconds, and provide this to a
cycle counter.
The trouble is that the u64 field "overflows" at an arbitrary number,
not at a potential mask value.
Since seconds value will overflow at 0xFFFFFFFF, the nanoseconds u64
field overflows at
0xFFFFFFFF*(0d1000000000) + 0d999999999 or 3B9AC9FFFFFFFFFF which is not
a mask-able value.
It overflows somewhete between (2^61)-1 and (2^62)-1.. That is, 2^61-1
is a valid value, but (2^62)-1 is not.
I am trying to determine what mask I can use for this. If I use 64,
obviously I will get an incorrect value.
I believe that I have to use the mask as 41 bits, which is the maximum
value that it can actually hold that consistently overflows at the same
location.
I think the timecounter code is actually incorrect, because it doesn't
allow for arbitrary overflow points....
I tried it out at using 61, and it really didn't look right.. But I
don't really like the idea that I have to mask all the way down to 41
bits.
Any suggestions or thoughts on the timecounter stuff?
Regards,
Jake