forked from VLSI-EDA/PoC
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathipv4_FrameLoopback.vhdl
More file actions
144 lines (127 loc) · 5.4 KB
/
Copy pathipv4_FrameLoopback.vhdl
File metadata and controls
144 lines (127 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
-- =============================================================================
-- Authors: Patrick Lehmann
--
-- Entity: TODO
--
-- Description:
-- -------------------------------------
-- .. TODO:: No documentation available.
--
-- License:
-- =============================================================================
-- Copyright 2007-2015 Technische Universitaet Dresden - Germany
-- Chair of VLSI-Design, Diagnostics and Architecture
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- =============================================================================
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
use work.config.all;
use work.utils.all;
use work.vectors.all;
use work.net.all;
entity ipv4_FrameLoopback is
generic (
MAX_FRAMES : positive := 4
);
port (
Clock : in std_logic;
Reset : in std_logic;
-- IN port
In_Valid : in std_logic;
In_Data : in T_SLV_8;
In_SOF : in std_logic;
In_EOF : in std_logic;
In_Ack : out std_logic;
In_Meta_rst : out std_logic;
In_Meta_SrcIPv4Address_nxt : out std_logic;
In_Meta_SrcIPv4Address_Data : in T_SLV_8;
In_Meta_DestIPv4Address_nxt : out std_logic;
In_Meta_DestIPv4Address_Data : in T_SLV_8;
In_Meta_Length : in T_SLV_16;
-- OUT port
Out_Valid : out std_logic;
Out_Data : out T_SLV_8;
Out_SOF : out std_logic;
Out_EOF : out std_logic;
Out_Ack : in std_logic;
Out_Meta_rst : in std_logic;
Out_Meta_SrcIPv4Address_nxt : in std_logic;
Out_Meta_SrcIPv4Address_Data : out T_SLV_8;
Out_Meta_DestIPv4Address_nxt : in std_logic;
Out_Meta_DestIPv4Address_Data : out T_SLV_8;
Out_Meta_Length : out T_SLV_16
);
end entity;
architecture rtl of ipv4_FrameLoopback is
constant META_STREAMID_SRCADDR : natural := 0;
constant META_STREAMID_DESTADDR : natural := 1;
constant META_STREAMID_LENGTH : natural := 2;
constant META_BITS : T_POSVEC := (
META_STREAMID_SRCADDR => 8,
META_STREAMID_DESTADDR => 8,
META_STREAMID_LENGTH => 16
);
constant META_FIFO_DEPTHS : T_POSVEC := (
META_STREAMID_SRCADDR => 4,
META_STREAMID_DESTADDR => 4,
META_STREAMID_LENGTH => 1
);
signal StmBuf_MetaIn_nxt : std_logic_vector(META_BITS'length - 1 downto 0);
signal StmBuf_MetaIn_Data : std_logic_vector(isum(META_BITS) - 1 downto 0);
signal StmBuf_MetaOut_nxt : std_logic_vector(META_BITS'length - 1 downto 0);
signal StmBuf_MetaOut_Data : std_logic_vector(isum(META_BITS) - 1 downto 0);
begin
StmBuf_MetaIn_Data(high(META_BITS, META_STREAMID_SRCADDR) downto low(META_BITS, META_STREAMID_SRCADDR)) <= In_Meta_SrcIPv4Address_Data;
StmBuf_MetaIn_Data(high(META_BITS, META_STREAMID_DESTADDR) downto low(META_BITS, META_STREAMID_DESTADDR)) <= In_Meta_DestIPv4Address_Data;
StmBuf_MetaIn_Data(high(META_BITS, META_STREAMID_LENGTH) downto low(META_BITS, META_STREAMID_LENGTH)) <= In_Meta_Length;
In_Meta_SrcIPv4Address_nxt <= StmBuf_MetaIn_nxt(META_STREAMID_SRCADDR);
In_Meta_DestIPv4Address_nxt <= StmBuf_MetaIn_nxt(META_STREAMID_DESTADDR);
StmBuf: entity work.stream_FIFO
generic map (
FRAMES => MAX_FRAMES,
DATA_BITS => 8,
DATA_FIFO_DEPTH => 1024,
META_BITS => META_BITS,
META_FIFO_DEPTH => META_FIFO_DEPTHS
)
port map (
Clock => Clock,
Reset => Reset,
In_Valid => In_Valid,
In_Data => In_Data,
In_SOF => In_SOF,
In_EOF => In_EOF,
In_Ack => In_Ack,
In_Meta_rst => In_Meta_rst,
In_Meta_nxt => StmBuf_MetaIn_nxt,
In_Meta_Data => StmBuf_MetaIn_Data,
Out_Valid => Out_Valid,
Out_Data => Out_Data,
Out_SOF => Out_SOF,
Out_EOF => Out_EOF,
Out_Ack => Out_Ack,
Out_Meta_rst => Out_Meta_rst,
Out_Meta_nxt => StmBuf_MetaOut_nxt,
Out_Meta_Data => StmBuf_MetaOut_Data
);
-- unpack StmBuf metadata to signals
Out_Meta_SrcIPv4Address_Data <= StmBuf_MetaOut_Data(high(META_BITS, META_STREAMID_DESTADDR) downto low(META_BITS, META_STREAMID_DESTADDR)); -- Crossover: Source <= Destination
Out_Meta_DestIPv4Address_Data <= StmBuf_MetaOut_Data(high(META_BITS, META_STREAMID_SRCADDR) downto low(META_BITS, META_STREAMID_SRCADDR)); -- Crossover: Destination <= Source
Out_Meta_Length <= StmBuf_MetaOut_Data(high(META_BITS, META_STREAMID_LENGTH) downto low(META_BITS, META_STREAMID_LENGTH));
-- pack metadata nxt signals to StmBuf meta vector
StmBuf_MetaOut_nxt(META_STREAMID_DESTADDR) <= Out_Meta_SrcIPv4Address_nxt;
StmBuf_MetaOut_nxt(META_STREAMID_SRCADDR) <= Out_Meta_DestIPv4Address_nxt;
StmBuf_MetaOut_nxt(META_STREAMID_LENGTH) <= '0';
end architecture;