diff options
Diffstat (limited to 'timing')
-rw-r--r-- | timing/time_64bit.v | 12 | ||||
-rw-r--r-- | timing/time_compare.v | 23 |
2 files changed, 28 insertions, 7 deletions
diff --git a/timing/time_64bit.v b/timing/time_64bit.v index c0a846e74..ab0c12be6 100644 --- a/timing/time_64bit.v +++ b/timing/time_64bit.v @@ -9,10 +9,13 @@ module time_64bit output [63:0] vita_time ); - localparam NEXT_TICKS = 0; - localparam NEXT_SECS = 1; + localparam NEXT_TICKS = 1; + localparam NEXT_SECS = 0; localparam ROLLOVER = TICKS_PER_SEC - 1; + reg [31:0] seconds; + reg [31:0] ticks; + wire end_of_second; assign vita_time = {seconds,ticks}; wire [31:0] next_ticks_preset; @@ -28,11 +31,6 @@ module time_64bit (.clk(clk),.rst(rst),.strobe(set_stb),.addr(set_addr), .in(set_data),.out(next_seconds_preset),.changed(set_on_pps_trig)); - reg [31:0] seconds; - reg [31:0] ticks; - - wire end_of_second; - always @(posedge clk) if(rst) set_on_next_pps <= 0; diff --git a/timing/time_compare.v b/timing/time_compare.v new file mode 100644 index 000000000..a21c9f8e0 --- /dev/null +++ b/timing/time_compare.v @@ -0,0 +1,23 @@ + +// Top 32 bits are integer seconds, bottom 32 are clock ticks within a second + +module time_compare + (input [63:0] time_now, + input [63:0] trigger_time, + output now, + output early, + output late, + output too_early); + + wire sec_match = (time_now[63:32] == trigger_time[63:32]); + wire sec_late = (time_now[63:32] > trigger_time[63:32]); + + wire tick_match = (time_now[31:0] == trigger_time[31:0]); + wire tick_late = (time_now[31:0] > trigger_time[31:0]); + + assign now = sec_match & tick_match; + assign late = sec_late | (sec_match & tick_late); + assign early = ~now & ~late; + assign too_early = (trigger_time[63:32] > (time_now[63:32] + 4)); // Don't wait too long + +endmodule // time_compare |