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
Files
Variables
src
common
IPBUS
ipbus2
ipbus_core
hdl
udp_byte_sum.vhd
1
-- Calculates
16
bit
1's compliment
or
2's compliment sum a byte at a
time
2
--
For
2's compliment first byte
is
the high byte
3
--
4
-- Dave Sankey, June
2012
5
6
library
ieee
;
7
use
ieee.std_logic_1164.
all
;
8
use
ieee.numeric_std.
all
;
9
10
entity
udp_byte_sum
is
11
port
(
12
mac_clk
:
in
std_logic
;
13
do_sum
:
in
std_logic
;
14
clr_sum
:
in
std_logic
;
15
mac_rx_data
:
in
std_logic_vector
(
7
downto
0
)
;
16
mac_rx_valid
:
in
std_logic
;
17
int_data
:
in
std_logic_vector
(
7
downto
0
)
;
18
int_valid
:
in
std_logic
;
19
cksum
:
in
std_logic
;
20
run_byte_sum
:
in
std_logic
;
21
outbyte
:
out
std_logic_vector
(
7
downto
0
)
22
)
;
23
end
udp_byte_sum
;
24
25
architecture
rtl
of
udp_byte_sum
is
26
27
signal
carry_bit
:
std_logic
;
28
signal
hi_byte
,
lo_byte
:
unsigned
(
8
downto
0
)
;
29
30
begin
31
32
outbyte
<=
std_logic_vector
(
hi_byte
(
7
downto
0
)
)
;
33
34
lo_byte_calc:
process
(mac_clk)
35
variable
hi_byte_int
,
lo_byte_int
:
unsigned
(
8
downto
0
)
;
36
variable
int_data_buf
:
std_logic_vector
(
7
downto
0
)
;
37
variable
clr_sum_buf
,
int_valid_buf
:
std_logic
;
38
begin
39
if
rising_edge
(
mac_clk
)
then
40
if
do_sum
=
'
1
'
and
clr_sum
=
'
1
'
then
41
clr_sum_buf
:=
'
1
'
;
42
end
if
;
43
if
do_sum
=
'
1
'
and
int_valid
=
'
1
'
then
44
int_data_buf
:=
int_data
;
45
int_valid_buf
:=
'
1
'
;
46
end
if
;
47
if
mac_rx_valid
=
'
1
'
or
run_byte_sum
=
'
1
'
then
48
if
clr_sum_buf
=
'
1
'
then
49
hi_byte_int
:=
(
Others
=
>
'
0
'
)
;
50
clr_sum_buf
:=
'
0
'
;
51
else
52
hi_byte_int
:=
hi_byte
;
53
end
if
;
54
if
do_sum
=
'
1
'
then
55
if
int_valid_buf
=
'
1
'
then
56
lo_byte_int
:=
unsigned
(
'
0
'
&
int_data_buf
)
;
57
int_valid_buf
:=
'
0
'
;
58
else
59
lo_byte_int
:=
unsigned
(
'
0
'
&
mac_rx_data
)
;
60
end
if
;
61
else
62
lo_byte_int
:=
(
Others
=
>
'
0
'
)
;
63
end
if
;
64
end
if
;
65
lo_byte
<=
hi_byte_int
+
lo_byte_int
66
-- pragma translate_off
67
after
4
ns
68
-- pragma translate_on
69
;
70
end
if
;
71
end
process
;
72
73
hi_byte_calc:
process
(mac_clk)
74
variable
carry_bit_int
,
hi_lo
,
clr_sum_buf
:
std_logic
;
75
variable
hi_byte_int
:
unsigned
(
8
downto
0
)
;
76
begin
77
if
rising_edge
(
mac_clk
)
then
78
if
do_sum
=
'
1
'
and
clr_sum
=
'
1
'
then
79
clr_sum_buf
:=
'
1
'
;
80
end
if
;
81
if
mac_rx_valid
=
'
1
'
or
run_byte_sum
=
'
1
'
then
82
if
clr_sum_buf
=
'
1
'
then
83
hi_byte_int
:=
(
Others
=
>
'
0
'
)
;
84
carry_bit_int
:=
'
0
'
;
85
hi_lo
:=
'
1
'
;
86
clr_sum_buf
:=
'
0
'
;
87
else
88
if
carry_bit
=
'
1
'
and
hi_lo
=
'
1
'
then
89
hi_byte_int
:=
unsigned
(
'
0
'
&
lo_byte
(
7
downto
0
)
)
+
1
;
90
else
91
hi_byte_int
:=
unsigned
(
'
0
'
&
lo_byte
(
7
downto
0
)
)
;
92
end
if
;
93
carry_bit_int
:=
lo_byte
(
8
)
;
94
hi_lo
:=
cksum
or
not
hi_lo
;
95
end
if
;
96
end
if
;
97
carry_bit
<=
carry_bit_int
98
-- pragma translate_off
99
after
4
ns
100
-- pragma translate_on
101
;
102
hi_byte
<=
hi_byte_int
103
-- pragma translate_off
104
after
4
ns
105
-- pragma translate_on
106
;
107
end
if
;
108
end
process
;
109
110
end
rtl
;
Generated on Sun Mar 6 2016 12:24:20 for AMC13 by
1.8.1