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
TCPIP_if
RTO_CALC.vhd
1
----------------------------------------------------------------------------------
2
-- Company:
3
-- Engineer:
4
--
5
-- Create Date:
11
:
26
:
24
09/13/2013
6
-- Design Name:
7
-- Module Name: RTO_CALC - 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
IEEE.numeric_std.
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
RTO_CALC
is
37
Port
(
clk
:
in
STD_LOGIC
;
38
RTT
:
in
STD_LOGIC_VECTOR
(
15
downto
0
)
;
39
RTOmin
:
in
STD_LOGIC_VECTOR
(
15
downto
0
)
;
40
RTO_backoff
:
in
STD_LOGIC
;
41
LISTEN
:
in
STD_LOGIC
;
42
sample_RTT
:
in
STD_LOGIC
;
43
RTO
:
out
STD_LOGIC_VECTOR
(
15
downto
0
)
;
44
debug
:
out
STD_LOGIC_VECTOR
(
135
downto
0
)
45
)
;
46
end
RTO_CALC
;
47
48
architecture
Behavioral
of
RTO_CALC
is
49
--constant RTOmin :
std_logic_vector
(
15
downto
0
) := x"00f4"; --
1
second
50
--constant RTOmin :
std_logic_vector
(
15
downto
0
) := x"0005"; --
20
millisecond
51
constant
RTOmax
:
std_logic_vector
(
15
downto
0
)
:=
x
"3938"
;
--
60
seconds
52
signal
first_RTT
:
std_logic
:=
'
1
'
;
53
signal
latch_RTO
:
std_logic
:=
'
1
'
;
54
signal
sample_RTT_dl
:
std_logic_vector
(
2
downto
0
)
:=
(
others
=
>
'
0
'
)
;
55
signal
RTO_i
:
std_logic_vector
(
16
downto
0
)
:=
(
others
=
>
'
0
'
)
;
56
signal
RTO_backoffed
:
std_logic_vector
(
16
downto
0
)
:=
(
others
=
>
'
0
'
)
;
57
signal
RTTVAR
:
std_logic_vector
(
16
downto
0
)
:=
(
others
=
>
'
0
'
)
;
58
signal
SRTT
:
std_logic_vector
(
15
downto
0
)
:=
(
others
=
>
'
0
'
)
;
59
signal
OneSubAlphaSRTT
:
std_logic_vector
(
15
downto
0
)
:=
(
others
=
>
'
0
'
)
;
60
signal
OneSubBetaRTTVAR
:
std_logic_vector
(
15
downto
0
)
:=
(
others
=
>
'
0
'
)
;
61
signal
BetaSRTT_SUB_RTT
:
std_logic_vector
(
14
downto
0
)
:=
(
others
=
>
'
0
'
)
;
62
begin
63
debug
(
135
downto
84
)
<=
(
others
=
>
'
0
'
)
;
64
debug
(
83
)
<=
first_RTT
;
65
debug
(
82
)
<=
sample_RTT
;
66
debug
(
81
downto
65
)
<=
RTO_i
;
67
debug
(
64
downto
48
)
<=
RTTVAR
;
68
debug
(
47
downto
32
)
<=
'
0
'
&
BetaSRTT_SUB_RTT
;
69
debug
(
31
downto
16
)
<=
SRTT
;
70
debug
(
15
downto
0
)
<=
RTT
;
71
process
(clk)
72
begin
73
if
(
clk
'
event
and
clk
=
'
1
'
)
then
74
if
(
RTO_backoffed
(
16
)
=
'
1
'
or
RTO_backoffed
(
15
downto
0
)
>
RTOmax
)
then
75
RTO
<=
RTOmax
;
76
elsif
(
RTO_backoffed
(
15
downto
0
)
<
RTOmin
)
then
77
RTO
<=
RTOmin
;
78
else
79
RTO
<=
RTO_backoffed
(
15
downto
0
)
;
80
end
if
;
81
if
(
RTO_backoff
=
'
1
'
)
then
82
latch_RTO
<=
'
1
'
;
83
elsif
(
sample_RTT
=
'
1
'
)
then
84
latch_RTO
<=
'
0
'
;
85
end
if
;
86
if
(
RTO_backoff
=
'
1
'
)
then
87
RTO_backoffed
(
16
)
<=
RTO_backoffed
(
16
)
or
RTO_backoffed
(
15
)
;
88
RTO_backoffed
(
15
downto
0
)
<=
RTO_backoffed
(
14
downto
0
)
&
'
0
'
;
89
elsif
(
latch_RTO
=
'
0
'
)
then
90
RTO_backoffed
<=
RTO_i
;
91
end
if
;
92
if
(
first_RTT
=
'
1
'
)
then
93
RTO_i
<=
'
0
'
&
x
"02dc"
;
--
3
second
94
elsif
(
RTTVAR
(
16
downto
14
)
/=
"000"
)
then
95
RTO_i
(
16
)
<=
'
1
'
;
96
else
97
RTO_i
<=
(
'
0
'
&
SRTT
)
+
(
'
0
'
&
RTTVAR
(
13
downto
2
)
&
"01"
)
;
98
end
if
;
99
if
(
LISTEN
=
'
1
'
or
(
RTO_backoff
=
'
1
'
and
latch_RTO
=
'
1
'
)
)
then
100
first_RTT
<=
'
1
'
;
101
elsif
(
sample_RTT
=
'
1
'
)
then
102
first_RTT
<=
'
0
'
;
103
end
if
;
104
OneSubAlphaSRTT
<=
SRTT
-
(
"000"
&
SRTT
(
15
downto
3
)
)
;
105
if
(
RTTVAR
(
16
)
=
'
1
'
)
then
106
OneSubBetaRTTVAR
<=
x
"c000"
;
107
else
108
OneSubBetaRTTVAR
<=
RTTVAR
(
15
downto
0
)
-
(
"00"
&
RTTVAR
(
15
downto
2
)
)
;
109
end
if
;
110
BetaSRTT_SUB_RTT
<=
(
'
0
'
&
SRTT
(
15
downto
2
)
)
-
(
'
0
'
&
RTT
(
15
downto
2
)
)
;
111
sample_RTT_dl
<=
sample_RTT_dl
(
1
downto
0
)
&
sample_RTT
;
112
if
(
sample_RTT_dl
(
2
)
=
'
1
'
)
then
113
if
(
first_RTT
=
'
1
'
)
then
114
RTTVAR
<=
"00"
&
RTT
(
15
downto
1
)
;
115
SRTT
<=
RTT
;
116
else
117
if
(
BetaSRTT_SUB_RTT
(
14
)
=
'
0
'
)
then
118
RTTVAR
<=
(
'
0
'
&
OneSubBetaRTTVAR
)
+
(
"00"
&
BetaSRTT_SUB_RTT
)
;
119
else
120
RTTVAR
<=
(
'
0
'
&
OneSubBetaRTTVAR
)
+
(
"00"
&
not
BetaSRTT_SUB_RTT
)
;
121
end
if
;
122
SRTT
<=
OneSubAlphaSRTT
+
(
"000"
&
RTT
(
15
downto
3
)
)
;
123
end
if
;
124
end
if
;
125
end
if
;
126
end
process
;
127
128
end
Behavioral
;
129
Generated on Wed Apr 18 2018 10:55:28 for AMC13 by
1.8.1