x393
1.0
FPGAcodeforElphelNC393camera
timestamp_snapshot.v
Go to the documentation of this file.
1
39
`timescale 1ns/1ps
40
41
module
timestamp_snapshot
(
42
// input rst,
43
input
tclk
,
// clock that drives time counters
44
input
[
31
:
0
]
sec
,
// @tclk: current time seconds
45
input
[
19
:
0
]
usec
,
// @tclk: current time microseconds
46
// snapshot destination clock domain
47
input
sclk
,
48
input
srst
,
// @ posedge sclk - sync reset
49
input
snap
,
50
output
reg
pre_stb
,
// one clock pulse before sending TS data
51
output
reg
[
7
:
0
]
ts_data
// timestamp data (s0,s1,s2,s3,u0,u1,u2,u3==0)
52
);
53
wire
snap_tclk
;
54
reg
[
51
:
0
]
sec_usec_snap
;
55
wire
pulse_busy
;
56
reg
pulse_busy_r
;
57
reg
[
2
:
0
]
cntr
;
58
reg
snd
;
59
wire
pre_stb_w
;
60
61
assign
pre_stb_w
= !
pulse_busy
&&
pulse_busy_r
;
62
63
always
@ (
posedge
tclk
)
begin
64
if
(
snap_tclk
)
sec_usec_snap
<= {
usec
,
sec
};
65
end
66
67
always
@(
posedge
sclk
)
begin
68
if
(
srst
)
snd
<=
0
;
69
else
if
(!
pulse_busy
&&
pulse_busy_r
)
snd
<=
1
;
70
else
if
((&
cntr
) ||
snap
)
snd
<=
0
;
71
pre_stb
<=
pre_stb_w
;
72
end
73
74
always
@(
posedge
sclk
)
begin
75
76
pulse_busy_r
<=
pulse_busy
;
77
78
if
(!
snd
)
cntr
<=
0
;
79
else
cntr
<=
cntr
+
1
;
80
81
if
(
snd
)
case
(
cntr
)
82
3'h0
:
ts_data
<=
sec_usec_snap
[
7
:
0
];
83
3'h1
:
ts_data
<=
sec_usec_snap
[
15
:
8
];
84
3'h2
:
ts_data
<=
sec_usec_snap
[
23
:
16
];
85
3'h3
:
ts_data
<=
sec_usec_snap
[
31
:
24
];
86
3'h4
:
ts_data
<=
sec_usec_snap
[
39
:
32
];
87
3'h5
:
ts_data
<=
sec_usec_snap
[
47
:
40
];
88
3'h6
:
ts_data
<= {
4'b0
,
sec_usec_snap
[
51
:
48
]};
89
3'h7
:
ts_data
<=
8'b0
;
90
endcase
91
end
92
93
pulse_cross_clock
#(
94
.
EXTRA_DLY
(
1
)
95
)
snap_tclk_i
(
96
.
rst
(
srst
),
// input
97
.
src_clk
(
sclk
),
// input
98
.
dst_clk
(
tclk
),
// input
99
.
in_pulse
(
snap
),
// input
100
.
out_pulse
(
snap_tclk
),
// output
101
.
busy
(
pulse_busy
)
// output
102
);
103
104
105
endmodule
106
pulse_cross_clock.10722rst
10722rst
Definition:
pulse_cross_clock.v:46
timestamp_snapshot
Definition:
timestamp_snapshot.v:41
timestamp_snapshot.9626srst
9626srst
Definition:
timestamp_snapshot.v:48
pulse_cross_clock.10724dst_clk
10724dst_clk
Definition:
pulse_cross_clock.v:48
pulse_cross_clock.10727busy
10727busy
Definition:
pulse_cross_clock.v:51
timestamp_snapshot.9628pre_stb
reg 9628pre_stb
Definition:
timestamp_snapshot.v:50
pulse_cross_clock.10725in_pulse
10725in_pulse
Definition:
pulse_cross_clock.v:49
timestamp_snapshot.9630snap_tclk
9630snap_tclkwire
Definition:
timestamp_snapshot.v:53
timestamp_snapshot.9634cntr
9634cntrreg[2:0]
Definition:
timestamp_snapshot.v:57
timestamp_snapshot.9633pulse_busy_r
9633pulse_busy_rreg
Definition:
timestamp_snapshot.v:56
pulse_cross_clock.10723src_clk
10723src_clk
Definition:
pulse_cross_clock.v:47
timestamp_snapshot.9623sec
[31:0] 9623sec
Definition:
timestamp_snapshot.v:44
pulse_cross_clock.10726out_pulse
10726out_pulse
Definition:
pulse_cross_clock.v:50
timestamp_snapshot.9624usec
[19:0] 9624usec
Definition:
timestamp_snapshot.v:45
timestamp_snapshot.9631sec_usec_snap
9631sec_usec_snapreg[51:0]
Definition:
timestamp_snapshot.v:54
timestamp_snapshot.9635snd
9635sndreg
Definition:
timestamp_snapshot.v:58
timestamp_snapshot.9629ts_data
reg [7:0] 9629ts_data
Definition:
timestamp_snapshot.v:51
timestamp_snapshot.9636pre_stb_w
9636pre_stb_wwire
Definition:
timestamp_snapshot.v:59
timestamp_snapshot.pulse_cross_clock
snap_tclk_i pulse_cross_clock
Definition:
timestamp_snapshot.v:93
timestamp_snapshot.9632pulse_busy
9632pulse_busywire
Definition:
timestamp_snapshot.v:55
timestamp_snapshot.9622tclk
9622tclk
Definition:
timestamp_snapshot.v:43
timestamp_snapshot.9625sclk
9625sclk
Definition:
timestamp_snapshot.v:47
timestamp_snapshot.9627snap
9627snap
Definition:
timestamp_snapshot.v:49
timing
timestamp_snapshot.v
Generated by
1.8.12