OpenCores
URL https://opencores.org/ocsvn/pc_fpga_com/pc_fpga_com/trunk

Subversion Repositories pc_fpga_com

[/] [pc_fpga_com/] [trunk/] [UDP_IP_CORE_FLEX_Virtex5/] [IPv4_PACKET_RECEIVER.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 NikosAl
-----------------------------------------------------------------------------------------
2
-- Copyright (C) 2010 Nikolaos Ch. Alachiotis                                                                                                           --
3
--                                                                                                                                                                                                                                      --
4
-- Engineer:                            Nikolaos Ch. Alachiotis                                                                                                         --
5
--                                                                                                                                                                                                                                      --
6
-- Contact:                                     alachiot@cs.tum.edu                                                                                                                     --
7
--                                                              n.alachiotis@gmail.com                                                                                                          --
8
--                                                                                                                                                                                                                              --
9
-- Create Date:                 14:32:06 02/07/2010                                                                                                             --
10
-- Module Name:                 IPv4_PACKET_RECEIVER                                                                                                       --
11
-- Target Devices:              Virtex 5 FPGAs                                                                                                                          --
12
-- Tool versions:               ISE 10.1                                                                                                                                                        --
13
-- Description:                         This component can be used to receive IPv4 Ethernet Packets.    --
14
-- Additional Comments:                                                                                                                                                                         --
15
--                                                                                                                                                                                                                                      --
16
--              The receiver does not operate properly for data section of 1 or 2 bytes only.    --
17
--                                                                                                                                                                                                                                      --
18
-----------------------------------------------------------------------------------------
19
 
20
 
21
library IEEE;
22
use IEEE.STD_LOGIC_1164.ALL;
23
use IEEE.STD_LOGIC_ARITH.ALL;
24
use IEEE.STD_LOGIC_UNSIGNED.ALL;
25
 
26
---- Uncomment the following library declaration if instantiating
27
---- any Xilinx primitives in this code.
28
--library UNISIM;
29
--use UNISIM.VComponents.all;
30
 
31
entity IPv4_PACKET_RECEIVER is
32
    Port ( rst : in  STD_LOGIC;
33
           clk_125Mhz : in  STD_LOGIC;
34
           rx_sof : in  STD_LOGIC;
35
           rx_eof : in  STD_LOGIC;
36
           input_bus : in  STD_LOGIC_VECTOR(7 downto 0);
37
           valid_out_usr_data : out  STD_LOGIC;
38
           usr_data_output_bus : out  STD_LOGIC_VECTOR (7 downto 0));
39
end IPv4_PACKET_RECEIVER;
40
 
41
architecture Behavioral of IPv4_PACKET_RECEIVER is
42
 
43
component PACKET_RECEIVER_FSM is
44
    Port (
45
                rst : in  STD_LOGIC;
46
           clk : in  STD_LOGIC;
47
 
48
                          -- Signals from EMAC
49
                          rx_sof: in STD_LOGIC; -- active low input
50
                          rx_eof: in STD_LOGIC; -- active low input
51
 
52
                          -- Signals to Counter and Comparator
53
                          sel_comp_Bval: out STD_LOGIC;
54
                          comp_Bval: out STD_LOGIC_VECTOR(10 downto 0);
55
           rst_count : out  STD_LOGIC;
56
           en_count : out  STD_LOGIC;
57
 
58
                          -- Signal from Comparator
59
                          comp_eq: in STD_LOGIC;
60
 
61
                          -- Signals to Length Register                   
62
                          wren_MSbyte: out STD_LOGIC;
63
                          wren_LSbyte: out STD_LOGIC;
64
 
65
                          -- Signal to user interface
66
                          valid_out_usr_data : out  STD_LOGIC);
67
end component;
68
 
69
component REG_8b_wren is
70
    Port ( rst : in  STD_LOGIC;
71
           clk : in  STD_LOGIC;
72
           wren : in  STD_LOGIC;
73
           input_val : in  STD_LOGIC_VECTOR (7 downto 0);
74
                          output_val : inout STD_LOGIC_VECTOR(7 downto 0));
75
end component;
76
 
77
component COUNTER_11B_EN_RECEIV is
78
    Port ( rst : in  STD_LOGIC;
79
           clk : in  STD_LOGIC;
80
           count_en : in  STD_LOGIC;
81
           value_O : inout  STD_LOGIC_VECTOR (10 downto 0));
82
end component;
83
 
84
component comp_11b_equal is
85
  port (
86
    qa_eq_b : out STD_LOGIC;
87
    clk : in STD_LOGIC := 'X';
88
    a : in STD_LOGIC_VECTOR ( 10 downto 0 );
89
    b : in STD_LOGIC_VECTOR ( 10 downto 0 )
90
  );
91
end component;
92
 
93
signal sel_comp_Bval,
94
                 rst_count,
95
                 en_count,
96
                 comp_eq,
97
                 wren_MSbyte,
98
                 wren_LSbyte: STD_LOGIC;
99
 
100
signal MSbyte_reg_val_out,
101
                 LSbyte_reg_val_out  : STD_LOGIC_VECTOR(7 downto 0);
102
 
103
signal counter_val,
104
       match_val,
105
       comp_Bval,
106
                 comp_sel_val_vec,
107
                 comp_n_sel_val_vec,
108
                 length_val: STD_LOGIC_VECTOR(10 downto 0);
109
 
110
constant length_offest : STD_LOGIC_VECTOR(7 downto 0):="00001010";
111
-- This value is formed as 2 (1 clock the latency of comparator and 1 clock fro changing the FSM state) + 8 (number of bytes of UDP header section) 
112
 
113
begin
114
 
115
usr_data_output_bus<=input_bus;
116
 
117
PACKET_RECEIVER_FSM_port_map: PACKET_RECEIVER_FSM Port Map
118
(
119
          rst => rst,
120
          clk => clk_125MHz,
121
 
122
          rx_sof => rx_sof,
123
          rx_eof => rx_eof,
124
 
125
          sel_comp_Bval => sel_comp_Bval,
126
          comp_Bval => comp_Bval,
127
          rst_count => rst_count,
128
          en_count => en_count,
129
 
130
          comp_eq => comp_eq,
131
 
132
          wren_MSbyte => wren_MSbyte,
133
          wren_LSbyte => wren_LSbyte,
134
 
135
          valid_out_usr_data => valid_out_usr_data
136
);
137
 
138
MSbyte_REG: REG_8b_wren Port Map
139
(
140
                rst => rst,
141
                clk => clk_125MHz,
142
                wren => wren_MSbyte,
143
                input_val => input_bus,
144
                output_val =>MSbyte_reg_val_out
145
);
146
 
147
LSbyte_REG: REG_8b_wren Port Map
148
(
149
                rst => rst,
150
                clk => clk_125MHz,
151
                wren => wren_LSbyte,
152
                input_val => input_bus,
153
                output_val =>LSbyte_reg_val_out
154
);
155
 
156
COUNTER_11B_EN_port_map: COUNTER_11B_EN_RECEIV Port Map
157
(
158
          rst => rst_count,
159
          clk => clk_125MHz,
160
          count_en => en_count,
161
          value_O => counter_val
162
);
163
 
164
Comp_11b_equal_port_map: Comp_11b_equal Port Map
165
(
166
    qa_eq_b => comp_eq,
167
    clk => clk_125MHz,
168
    a => counter_val,
169
    b => match_val
170
  );
171
 
172
length_val(7 downto 0)<= LSbyte_reg_val_out-length_offest;
173
length_val(10 downto 8)<= MSbyte_reg_val_out (2 downto 0);
174
 
175
comp_sel_val_vec<=(others=> sel_comp_Bval);
176
comp_n_sel_val_vec<= (others=> not sel_comp_Bval);
177
 
178
match_val<= (comp_sel_val_vec and length_val) or (comp_n_sel_val_vec and comp_Bval);
179
 
180
 
181
end Behavioral;
182
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.