AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
Main Page
Design Unit List
Files
File List
All
Classes
Variables
src
CMS_DAQ_if
10Gb
slink
freq_measure.vhd
1
------------------------------------------------------
2
-- Frequency Clock detection
3
--
4
-- Ver
1
.
00
5
--
6
-- Dominique Gigi Jan
2015
7
------------------------------------------------------
8
-- Measure the clock frequency used by FED
9
--
10
--
11
--
12
------------------------------------------------------
13
LIBRARY
ieee
;
14
library
work
;
15
16
USE
ieee.std_logic_1164.
all
;
17
use
ieee.numeric_std.
all
;
18
use
ieee.std_logic_unsigned.
all
;
19
use
work.
mydefs
.
all
;
20
21
22
entity
freq_measure
is
23
port
(
24
reset
:
in
std_logic
;
25
26
sysclk
:
in
std_logic
;
-- clock used by the FED
to
send data
and
to
measure the backpressure
27
base_clk
:
in
std_logic
;
-- clock base used
to
measure the sysclk
28
29
frequency
:
out
std_logic_vector
(
31
downto
0
)
-- measure
of
the frequency)
30
)
;
31
end
freq_measure
;
32
33
architecture
behavioral
of
freq_measure
is
34
35
36
component
reset_resync
is
37
port
(
38
reset :
in
std_logic
;
39
clock :
in
std_logic
;
40
41
Reset_sync :
out
std_logic
42
);
43
end
component
;
44
45
46
signal
counter_base
:
std_logic_vector
(
31
downto
0
)
;
47
signal
counter_measure
:
std_logic_vector
(
31
downto
0
)
;
48
signal
measure
:
std_logic_vector
(
31
downto
0
)
;
49
signal
latch_value
:
std_logic
;
50
signal
reset_cnt
:
std_logic
;
51
signal
reset_cnt_rsyc
:
std_logic
;
52
--*********************************************************
53
--************ CODE START HERE ****************
54
--*********************************************************
55
begin
56
57
-- counter base
58
process
(base_clk)
59
begin
60
if
rising_edge
(
base_clk
)
then
61
-- base
on
the base_clk
of
156
.
25
MHz =>
6
.4ns =>
156250
x
to
reach 1ms
62
latch_value
<=
'
0
'
;
63
if
counter_base
=
freq_used
then
64
counter_base
<=
(
others
=
>
'
0
'
)
;
65
latch_value
<=
'
1
'
;
66
else
67
counter_base
<=
counter_base
+
'
1
'
;
68
end
if
;
69
end
if
;
70
end
process
;
71
72
73
-- counter measure
74
process
(sysclk,reset_cnt_rsyc)
75
begin
76
if
reset_cnt_rsyc
=
'
0
'
then
77
counter_measure
<=
(
others
=
>
'
0
'
)
;
78
elsif
rising_edge
(
sysclk
)
then
79
counter_measure
<=
counter_measure
+
'
1
'
;
80
end
if
;
81
end
process
;
82
83
resync_i1:
reset_resync
84
port
map
(
85
reset => reset_cnt,
86
clock => sysclk,
87
Reset_sync => reset_cnt_rsyc
88
)
;
89
90
-- latch the frequency
91
process
(base_clk)
92
begin
93
if
rising_edge
(
base_clk
)
then
94
reset_cnt
<=
'
1
'
;
-- reset the counter measure
when
the measure
is
latched
95
if
latch_value
=
'
1
'
then
96
measure
<=
counter_measure
;
97
reset_cnt
<=
'
0
'
;
98
end
if
;
99
end
if
;
100
end
process
;
101
102
frequency
<=
measure
;
103
104
end
behavioral
;
105
106
107
Generated on Wed Apr 18 2018 10:55:26 for AMC13 by
1.8.1