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
common
check_event.vhd
1
----------------------------------------------------------------------------------
2
-- Company:
3
-- Engineer:
4
--
5
-- Create Date:
12
:
37
:
54
11/04/2015
6
-- Design Name:
7
-- Module Name: check_event - Behavioral
8
-- Project Name:
9
-- Target Devices:
10
-- Tool versions:
11
-- Description:
12
--
13
-- Dependencies:
14
--
15
-- Revision:
16
-- Revision
0
.
01
-
File
Created
17
-- Additional Comments:
18
--
19
----------------------------------------------------------------------------------
20
library
IEEE
;
21
use
IEEE.STD_LOGIC_1164.
ALL
;
22
use
IEEE.STD_LOGIC_ARITH.
ALL
;
23
use
IEEE.STD_LOGIC_UNSIGNED.
ALL
;
24
use
IEEE.std_logic_misc.
all
;
25
use
work.
amc13_pack
.
all
;
26
27
-- Uncomment the following
library
declaration
if
using
28
-- arithmetic functions
with
Signed
or
Unsigned
values
29
--use IEEE.NUMERIC_STD.
ALL
;
30
31
-- Uncomment the following
library
declaration
if
instantiating
32
-- any Xilinx primitives
in
this code.
33
--library UNISIM;
34
--use UNISIM.VComponents.
all
;
35
36
entity
check_event
is
37
Port
(
clk
:
in
STD_LOGIC
;
38
reset
:
in
STD_LOGIC
;
39
en_stop
:
in
STD_LOGIC_VECTOR
(
4
downto
0
)
;
40
cmsCRC_err
:
in
STD_LOGIC_VECTOR
(
2
downto
0
)
;
41
EventData_in
:
in
array3X67
;
42
EventData_we
:
in
std_logic_VECTOR
(
2
downto
0
)
;
43
inc_err
:
out
array3X5
;
44
stop
:
out
STD_LOGIC
)
;
45
end
check_event
;
46
47
architecture
Behavioral
of
check_event
is
48
signal
EvtLengthCntr
:
array3X24
:=
(
others
=
>
(
others
=
>
'
0
'
)
)
;
49
signal
nAMC
:
array3X4
:=
(
others
=
>
(
others
=
>
'
0
'
)
)
;
50
signal
EvtLength_err
:
std_logic_vector
(
2
downto
0
)
:=
(
others
=
>
'
0
'
)
;
51
signal
AMClength_err
:
std_logic_vector
(
2
downto
0
)
:=
(
others
=
>
'
0
'
)
;
52
signal
AMCvalid_err
:
std_logic_vector
(
2
downto
0
)
:=
(
others
=
>
'
0
'
)
;
53
signal
AMCcrc_err
:
std_logic_vector
(
2
downto
0
)
:=
(
others
=
>
'
0
'
)
;
54
signal
IsBoE
:
std_logic_vector
(
2
downto
0
)
:=
(
others
=
>
'
0
'
)
;
55
signal
IsBoB
:
std_logic_vector
(
2
downto
0
)
:=
(
others
=
>
'
0
'
)
;
56
begin
57
inc_err
(
0
)
<=
AMCcrc_err
(
0
)
&
AMCvalid_err
(
0
)
&
AMClength_err
(
0
)
&
EvtLength_err
(
0
)
&
cmsCRC_err
(
0
)
;
58
inc_err
(
1
)
<=
AMCcrc_err
(
1
)
&
AMCvalid_err
(
1
)
&
AMClength_err
(
1
)
&
EvtLength_err
(
1
)
&
cmsCRC_err
(
1
)
;
59
inc_err
(
2
)
<=
AMCcrc_err
(
2
)
&
AMCvalid_err
(
2
)
&
AMClength_err
(
2
)
&
EvtLength_err
(
2
)
&
cmsCRC_err
(
2
)
;
60
process
(clk)
61
begin
62
if
(
clk
'
event
and
clk
=
'
1
'
)
then
63
for
i
in
0
to
2
loop
64
if
(
reset
=
'
1
'
)
then
65
EvtLengthCntr
(
i
)
<=
x
"000001"
;
66
IsBoE
(
i
)
<=
'
1
'
;
67
IsBoB
(
i
)
<=
'
0
'
;
68
elsif
(
EventData_we
(
i
)
=
'
1
'
)
then
69
if
(
EventData_in
(
i
)
(
65
)
=
'
1
'
)
then
70
EvtLengthCntr
(
i
)
<=
x
"000001"
;
71
else
72
EvtLengthCntr
(
i
)
<=
EvtLengthCntr
(
i
)
+
1
;
73
end
if
;
74
if
(
EventData_in
(
i
)
(
65
)
=
'
1
'
)
then
75
IsBoE
(
i
)
<=
'
1
'
;
76
elsif
(
EventData_in
(
i
)
(
64
)
=
'
1
'
)
then
77
IsBoB
(
i
)
<=
'
1
'
;
78
else
79
IsBoE
(
i
)
<=
'
0
'
;
80
IsBoB
(
i
)
<=
IsBoE
(
i
)
;
81
end
if
;
82
end
if
;
83
if
(
reset
=
'
1
'
)
then
84
nAMC
(
i
)
<=
(
others
=
>
'
0
'
)
;
85
elsif
(
EventData_we
(
i
)
=
'
1
'
)
then
86
if
(
IsBoB
(
i
)
=
'
1
'
)
then
87
nAMC
(
i
)
<=
EventData_in
(
i
)
(
55
downto
52
)
;
88
elsif
(
or_reduce
(
nAMC
(
i
)
)
=
'
1
'
)
then
89
nAMC
(
i
)
<=
nAMC
(
i
)
-
1
;
90
end
if
;
91
end
if
;
92
if
(
EventData_we
(
i
)
=
'
1
'
and
or_reduce
(
nAMC
(
i
)
)
=
'
1
'
and
EventData_in
(
i
)
(
62
)
=
'
1
'
)
then
93
AMClength_err
(
i
)
<=
'
1
'
;
94
else
95
AMClength_err
(
i
)
<=
'
0
'
;
96
end
if
;
97
if
(
EventData_we
(
i
)
=
'
1
'
and
or_reduce
(
nAMC
(
i
)
)
=
'
1
'
and
EventData_in
(
i
)
(
61
)
=
'
0
'
and
EventData_in
(
i
)
(
57
)
=
'
0
'
)
then
98
AMCvalid_err
(
i
)
<=
'
1
'
;
99
else
100
AMCvalid_err
(
i
)
<=
'
0
'
;
101
end
if
;
102
if
(
EventData_we
(
i
)
=
'
1
'
and
or_reduce
(
nAMC
(
i
)
)
=
'
1
'
and
EventData_in
(
i
)
(
61
)
=
'
0
'
and
EventData_in
(
i
)
(
56
)
=
'
0
'
)
then
103
AMCcrc_err
(
i
)
<=
'
1
'
;
104
else
105
AMCcrc_err
(
i
)
<=
'
0
'
;
106
end
if
;
107
if
(
EventData_we
(
i
)
=
'
1
'
and
EventData_in
(
i
)
(
65
)
=
'
1
'
and
EventData_in
(
i
)
(
55
downto
32
)
/=
EvtLengthCntr
(
i
)
)
then
108
EvtLength_err
(
i
)
<=
'
1
'
;
109
else
110
EvtLength_err
(
i
)
<=
'
0
'
;
111
end
if
;
112
end
loop
;
113
stop
<=
(
or_reduce
(
cmsCRC_err
)
and
en_stop
(
0
)
)
or
(
or_reduce
(
EvtLength_err
)
and
en_stop
(
1
)
)
or
(
or_reduce
(
AMClength_err
)
and
en_stop
(
2
)
)
or
114
(
or_reduce
(
AMCvalid_err
)
and
en_stop
(
3
)
)
or
(
or_reduce
(
AMCcrc_err
)
and
en_stop
(
4
)
)
;
115
end
if
;
116
end
process
;
117
118
end
Behavioral
;
119
Generated on Wed Apr 18 2018 10:55:27 for AMC13 by
1.8.1