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_Spartan3/] [PACKET_RECEIVER_FSM.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 NikosAl
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    03:48:34 02/07/2010 
6
-- Design Name: 
7
-- Module Name:    PACKET_RECEIVER_FSM - 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
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity PACKET_RECEIVER_FSM is
31
    Port (
32
                rst : in  STD_LOGIC;
33
           clk : in  STD_LOGIC;
34
 
35
                          -- Signals from EMAC
36
                          rx_sof: in STD_LOGIC; -- active low input
37
                          rx_eof: in STD_LOGIC; -- active low input
38
 
39
                          -- Signals to Counter and Comparator
40
                          sel_comp_Bval: out STD_LOGIC;
41
                          comp_Bval: out STD_LOGIC_VECTOR(10 downto 0);
42
           rst_count : out  STD_LOGIC;
43
           en_count : out  STD_LOGIC;
44
 
45
                          -- Signal from Comparator
46
                          comp_eq: in STD_LOGIC;
47
 
48
                          -- Signals to Length Register                   
49
                          wren_MSbyte: out STD_LOGIC;
50
                          wren_LSbyte: out STD_LOGIC;
51
 
52
                          -- Signal to user interface
53
                          valid_out_usr_data: out STD_LOGIC);
54
end PACKET_RECEIVER_FSM;
55
 
56
architecture Behavioral of PACKET_RECEIVER_FSM is
57
 
58
TYPE state is (rst_state,
59
                                        idle_state,
60
                                        detect_n_store_usr_length_MSbyte_state,
61
                                        store_usr_length_LSbyte_state,
62
                                        checksum_gap_state,
63
                                        receive_usr_data_state);
64
 
65
signal current_st,next_st: state;
66
 
67
constant  udp_length_match_cycle : std_logic_vector(10 downto 0):="00000100100"; -- UDP length MSbyte - 2
68
constant  udp_checksum_skip : std_logic_vector(10 downto 0):="00000000001";
69
constant  gnd_vec : std_logic_vector(10 downto 0):="00000000000";
70
begin
71
 
72
process(current_st,rx_sof,rx_eof,comp_eq)
73
begin
74
case current_st is
75
 
76
 
77
when rst_state =>
78
 
79
          sel_comp_Bval<='0';
80
          comp_Bval<=gnd_vec;
81
          rst_count<='1';
82
          en_count<='0';
83
 
84
          wren_MSbyte<='0';
85
          wren_LSbyte<='0';
86
 
87
          valid_out_usr_data<='0';
88
 
89
        next_st<=idle_state;
90
 
91
when idle_state =>
92
 
93
        if rx_sof='0' then -- rx_sof is active low
94
          sel_comp_Bval<='0';
95
          comp_Bval<=udp_length_match_cycle;
96
          rst_count<='1';
97
          en_count<='0';
98
 
99
          wren_MSbyte<='0';
100
          wren_LSbyte<='0';
101
 
102
          valid_out_usr_data<='0';
103
 
104
         next_st<=detect_n_store_usr_length_MSbyte_state;
105
 
106
        else
107
          sel_comp_Bval<='0';
108
          comp_Bval<=gnd_vec;
109
          rst_count<='0';
110
          en_count<='0';
111
 
112
          wren_MSbyte<='0';
113
          wren_LSbyte<='0';
114
 
115
          valid_out_usr_data<='0';
116
 
117
         next_st<=idle_state;
118
        end if;
119
 
120
when detect_n_store_usr_length_MSbyte_state =>
121
 
122
        if comp_eq='1' then -- comp_eq is active high
123
          sel_comp_Bval<='0';
124
          comp_Bval<=udp_checksum_skip; -- Just to skip the UDP checksum field
125
          rst_count<='1';
126
          en_count<='0';
127
 
128
          wren_MSbyte<='1';
129
          wren_LSbyte<='0';
130
 
131
          valid_out_usr_data<='0';
132
 
133
         next_st<=store_usr_length_LSbyte_state;
134
 
135
        else
136
          sel_comp_Bval<='0';
137
          comp_Bval<=udp_length_match_cycle;
138
          rst_count<='0';
139
          en_count<='1';
140
 
141
          wren_MSbyte<='0';
142
          wren_LSbyte<='0';
143
 
144
          valid_out_usr_data<='0';
145
 
146
         next_st<=detect_n_store_usr_length_MSbyte_state;
147
        end if;
148
 
149
when store_usr_length_LSbyte_state =>
150
 
151
          sel_comp_Bval<='0';
152
          comp_Bval<=udp_checksum_skip; -- Just to skip the UDP checksum field
153
          rst_count<='0';
154
          en_count<='1';
155
 
156
          wren_MSbyte<='0';
157
          wren_LSbyte<='1';
158
 
159
          valid_out_usr_data<='0';
160
 
161
         next_st<=checksum_gap_state;
162
 
163
when checksum_gap_state =>
164
 
165
        if comp_eq='1' then -- comp_eq is active high
166
          sel_comp_Bval<='1';
167
          comp_Bval<=gnd_vec;
168
          rst_count<='1';
169
          en_count<='0';
170
 
171
          wren_MSbyte<='0';
172
          wren_LSbyte<='0';
173
 
174
          valid_out_usr_data<='0';
175
 
176
         next_st<=receive_usr_data_state;
177
 
178
        else
179
          sel_comp_Bval<='0';
180
          comp_Bval<=udp_checksum_skip;
181
          rst_count<='0';
182
          en_count<='1';
183
 
184
          wren_MSbyte<='0';
185
          wren_LSbyte<='0';
186
 
187
          valid_out_usr_data<='0';
188
 
189
         next_st<=checksum_gap_state;
190
        end if;
191
 
192
when receive_usr_data_state =>
193
 
194
        if (comp_eq='1' or rx_eof='0') then  -- comp_eq is active high rx_eof is active-low
195
          sel_comp_Bval<='0';
196
          comp_Bval<=udp_length_match_cycle;
197
          rst_count<='1';
198
          en_count<='0';
199
 
200
          wren_MSbyte<='0';
201
          wren_LSbyte<='0';
202
 
203
          valid_out_usr_data<='1';
204
 
205
         next_st<=idle_state;
206
 
207
        else
208
          sel_comp_Bval<='1';
209
          comp_Bval<=gnd_vec;
210
          rst_count<='0';
211
          en_count<='1';
212
 
213
          wren_MSbyte<='0';
214
          wren_LSbyte<='0';
215
 
216
          valid_out_usr_data<='1';
217
 
218
         next_st<=receive_usr_data_state;
219
        end if;
220
 
221
 
222
end case;
223
end process;
224
 
225
 
226
 
227
 
228
process(clk)
229
begin
230
if (rst='1') then
231
        current_st<= rst_state;
232
elsif (clk'event and clk='1') then
233
        current_st <= next_st;
234
end if;
235
end process;
236
 
237
end Behavioral;
238
 

powered by: WebSVN 2.1.0

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