DateTime

Home

This core keeps track of the date and time.

The dateTime core supports both Earthly and Martian time keeping.

One of the problems with date / time tracking is that the date / time update needs to take place all at once within a single cycle. Otherwise what can happen is an incorrect value may be read due to one value being updated already while another one isn't updated yet during the read. This creates a minor control problem which can easily be handled with flags and triggers in hardware. It is much more difficult to handle date / time updates in software than it is with hardware.

The core tracks the date / time values in BCD format. The reason behind this is that it is a lot easier to read BCD values when dumping the dateTime core's registers using some sort of debugger.

In order to read the date / time accurately this chip has a "snapshot" trigger. When the snapshot is triggered, which may be done by writing any value to register #5, the value of internal registers are copied to registers #0, 1 for reading. The date / time values at the time of the snapshot may then be read from registers #0 and 1. In order to update the date / time the clock timing may be disabled prior to the update by writing register #4 with a zero, then re-enabled after writing register #4 one.

*This core has not be tested at all yet, because it is probably subject to change depending on the usage.

Download: BCDateTime.v

Register   Comment
0 [ 7: 0] read / write jiffies a jiffy is 1/60th of a second
[15: 8] read / write seconds  
[23:16] read / write minutes  
[31:24] read / write hours  
1 [ 7: 0] read/write day  
[15: 8] read/write month 12/20 for Earth / Mars
[31:15] read/write year  
2-3   2-3 same as 0-1, but contain alarm setting
4 bit 0 = 1=enable,0=disable timing  
5   writing this register triggers a snapshot
6    
7    
     

 

Notes:

Martian vs. Earth time:

The Martian time keeping uses days 24 hours, 37 minutes, and 22 seconds long (time constant:

32'h24372159).

Earth time keeping uses days 24 hours long. (time constant: 32'h23595959)

Note that rather than alter the current length of seconds or minutes to get the Martian day to work out to an even 24 hours, the Martian day simply isn't 24 hours long. Reminds me of the time there was a power surge, and I got up at night only to find out the clock read 12:65:02 pm. It was time for a new alarm clock.

The Martian Calendar broken up into years of 20 months, with a varying numbers of days per month as shown below. This is similar to the "Pavonian" or "Millennium" (http://www.xs4all.nl/~fwb/kalenders.html) however the days have been re-arranged a little bit so that February is short a day. Hopefully the code is fairly easy to modify.

 

 

Sample Coding:


reg incMarsMonth;
always @(monthH,monthL,dayH,dayL)


begin
case({monthH,monthL}) // synopsys full_case parallel_case
8'h01: incMarsMonth = {dayH,dayL}==8'h34;
8'h02: incMarsMonth = {dayH,dayL}==8'h32;
8'h03: incMarsMonth = {dayH,dayL}==8'h34;
8'h04: incMarsMonth = {dayH,dayL}==8'h33;
8'h05: incMarsMonth = {dayH,dayL}==8'h34;
8'h06: incMarsMonth = {dayH,dayL}==8'h33;
8'h07: incMarsMonth = {dayH,dayL}==8'h34;
8'h08: incMarsMonth = {dayH,dayL}==8'h33;
8'h09: incMarsMonth = {dayH,dayL}==8'h34;
8'h10: incMarsMonth = {dayH,dayL}==8'h33;
8'h11: incMarsMonth = {dayH,dayL}==8'h34;
8'h12: incMarsMonth = {dayH,dayL}==8'h33;
8'h13: incMarsMonth = {dayH,dayL}==8'h33;
8'h14: incMarsMonth = {dayH,dayL}==8'h34;
8'h15: incMarsMonth = {dayH,dayL}==8'h33;
8'h16: incMarsMonth = {dayH,dayL}==8'h34;
8'h17: incMarsMonth = {dayH,dayL}==8'h33;
8'h18: incMarsMonth = {dayH,dayL}==8'h34;
8'h19: incMarsMonth = {dayH,dayL}==8'h33;
8'h20: incMarsMonth = {dayH,dayL}==8'h34;
endcase
end


 

Spartan3

Webpack 9.1i xc3s1000
306 LUTs / 191 slices / 95MHz (incl. mars)