otsdaq_prepmodernization  v2_04_02
arp_reply.vhd
1 -------------------------------------------------------------------------------
2 --
3 -- Title : Arp Reply
4 -- Design : ethernet_controller
5 -- Author : Ryan Rivera
6 -- Company : FNAL
7 --
8 -------------------------------------------------------------------------------
9 --
10 -- File : c:\HDL_Designs\dig_gec\ethernet_controller\compile\arp_reply.vhd
11 -- Generated : 03/20/09 15:19:29
12 -- From : c:/HDL_Designs/dig_gec/ethernet_controller/src/arp_reply.asf
13 -- By : FSM2VHDL ver. 5.0.5.6
14 --
15 -------------------------------------------------------------------------------
16 --
17 -- Description :
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 entity arp_reply is
27  port (
28  addrs: in STD_LOGIC_VECTOR (7 downto 0);
29  clk: in STD_LOGIC;
30  reset: in STD_LOGIC;
31  tip: in STD_LOGIC_VECTOR (31 downto 0);
32  tmac: in STD_LOGIC_VECTOR (47 downto 0);
33  trigger: in STD_LOGIC;
34  udp_busy: in STD_LOGIC;
35  arp_busy: out STD_LOGIC;
36  crc_gen_en: out STD_LOGIC;
37  crc_gen_init: out STD_LOGIC;
38  crc_gen_rd: out STD_LOGIC;
39  dataout: out STD_LOGIC_VECTOR (7 downto 0);
40  tx_en: out STD_LOGIC;
41  tx_er: out STD_LOGIC);
42 end arp_reply;
43 
44 architecture arp_reply_arch of arp_reply is
45 
46 -- diagram signals declarations
47 signal delay_count: INTEGER range 0 to 65535;
48 signal old_trig: STD_LOGIC;
49 signal trigger_sig: STD_LOGIC;
50 
51 -- SYMBOLIC ENCODED state machine: Sreg0
52 type Sreg0_type is (
53  idle, delay, ArpResponse_ARP_Payload_PType2, ArpResponse_ARP_Payload_HLen, ArpResponse_ARP_Payload_PLen, ArpResponse_ARP_Payload_SMac1,
54  ArpResponse_ARP_Payload_SMac2, ArpResponse_ARP_Payload_SMac3, ArpResponse_ARP_Payload_SMac4, ArpResponse_ARP_Payload_SMac5, ArpResponse_ARP_Payload_SMac6,
55  ArpResponse_ARP_Payload_Sip1, ArpResponse_ARP_Payload_Sip2, ArpResponse_ARP_Payload_Sip3, ArpResponse_ARP_Payload_Sip4, ArpResponse_ARP_Payload_TMac1,
56  ArpResponse_ARP_Payload_TMac2, ArpResponse_ARP_Payload_TMac3, ArpResponse_ARP_Payload_TMac4, ArpResponse_ARP_Payload_TMac5, ArpResponse_ARP_Payload_TMac6,
57  ArpResponse_ARP_Payload_Tip1, ArpResponse_ARP_Payload_Tip2, ArpResponse_ARP_Payload_Tip3, ArpResponse_Type_S1, ArpResponse_Type_S48,
58  ArpResponse_Dest_S22, ArpResponse_Dest_S11, ArpResponse_Dest_S12, ArpResponse_Dest_S13, ArpResponse_Dest_S14, ArpResponse_Dest_S15,
59  ArpResponse_ARP_Payload_HType1, ArpResponse_ARP_Payload_Tip4, ArpResponse_ARP_Payload_HType2, ArpResponse_ARP_Payload_PType1, ArpResponse_Src_S50,
60  ArpResponse_Src_S51, ArpResponse_Src_S52, ArpResponse_Src_S53, ArpResponse_Src_S54, ArpResponse_ARP_Payload_Op1, ArpResponse_Src_S55,
61  ArpResponse_ARP_Payload_Op2, delay1, CheckBusy, ArpResponse_Preamble_S57, ArpResponse_Preamble_S58, ArpResponse_CRC_crc1, ArpResponse_CRC_crc2,
62  ArpResponse_CRC_crc3, ArpResponse_CRC_crc4, ArpResponse_CRC_S59
63 );
64 -- attribute enum_encoding of Sreg0_type: type is ... -- enum_encoding attribute is not supported for symbolic encoding
65 
66 signal Sreg0: Sreg0_type;
67 
68 begin
69 
70 -- concurrent signals assignments
71 
72 -- Diagram ACTION
73 trig_proc : process (clk) -- make trigger sig a single clock width pulse
74 begin
75 if rising_edge(clk) then
76  trigger_sig <= '0';
77  old_trig <= trigger;
78  if trigger = '1' and old_trig = '0' then
79  trigger_sig <= '1';
80  end if;
81 end if;
82 end process;
83 
84 ----------------------------------------------------------------------
85 -- Machine: Sreg0
86 ----------------------------------------------------------------------
87 Sreg0_machine: process (clk)
88 begin
89  if clk'event and clk = '1' then
90  if reset = '1' then
91  Sreg0 <= idle;
92  -- Set default values for outputs, signals and variables
93  -- ...
94  delay_count <= 200;
95  -- number of ticks after trigger to delay sending of packet
96 -- also used for loops within packet
97  arp_busy <= '0';
98  -- indicates to udp to not take over transmit line
99  dataout <= (others => '0');
100  tx_er <= '0';
101  tx_en <= '0';
102  crc_gen_en <= '0';
103  crc_gen_init <= '0';
104  crc_gen_rd <= '0';
105  else
106  -- Set default values for outputs, signals and variables
107  -- ...
108  case Sreg0 is
109  when idle =>
110  delay_count <= 200;
111  -- number of ticks after trigger to delay sending of packet
112  -- also used for loops within packet
113  arp_busy <= '0';
114  -- indicates to udp to not take over transmit line
115  dataout <= (others => '0');
116  tx_er <= '0';
117  tx_en <= '0';
118  crc_gen_en <= '0';
119  crc_gen_init <= '0';
120  crc_gen_rd <= '0';
121  if trigger_sig = '1' then
122  Sreg0 <= CheckBusy;
123  arp_busy <= '1';
124  end if;
125  when delay =>
126  delay_count <= delay_count - 1;
127  if delay_count = 1 then
128  Sreg0 <= ArpResponse_Preamble_S57;
129  crc_gen_init <= '0';
130  dataout <= x"55";
131  tx_en <= '1';
132  delay_count <= 7;
133  end if;
134  when delay1 =>
135  delay_count <= delay_count - 1;
136  if delay_count = 1 then
137  Sreg0 <= idle;
138  end if;
139  when CheckBusy =>
140  if udp_busy = '0' then
141  Sreg0 <= delay;
142  crc_gen_init <= '1';
143  end if;
144  when ArpResponse_Dest_S22 =>
145  Sreg0 <= ArpResponse_Dest_S11;
146  dataout <= tmac(39 downto 32);
147  when ArpResponse_Dest_S11 =>
148  Sreg0 <= ArpResponse_Dest_S12;
149  dataout <= tmac(31 downto 24);
150  when ArpResponse_Dest_S12 =>
151  Sreg0 <= ArpResponse_Dest_S13;
152  dataout <= tmac(23 downto 16);
153  when ArpResponse_Dest_S13 =>
154  Sreg0 <= ArpResponse_Dest_S14;
155  dataout <= tmac(15 downto 8);
156  when ArpResponse_Dest_S14 =>
157  Sreg0 <= ArpResponse_Dest_S15;
158  dataout <= tmac(7 downto 0);
159  when ArpResponse_Dest_S15 =>
160  Sreg0 <= ArpResponse_Src_S51;
161  dataout <= x"00";
162  when ArpResponse_Src_S50 =>
163  Sreg0 <= ArpResponse_Src_S55;
164  dataout <= x"55";
165  when ArpResponse_Src_S51 =>
166  Sreg0 <= ArpResponse_Src_S50;
167  dataout <= x"80";
168  when ArpResponse_Src_S52 =>
169  Sreg0 <= ArpResponse_Type_S48;
170  dataout <= x"08";
171  when ArpResponse_Src_S53 =>
172  Sreg0 <= ArpResponse_Src_S52;
173  dataout <= addrs;
174  when ArpResponse_Src_S54 =>
175  Sreg0 <= ArpResponse_Src_S53;
176  dataout <= x"00";
177  when ArpResponse_Src_S55 =>
178  Sreg0 <= ArpResponse_Src_S54;
179  dataout <= x"EC";
180  when ArpResponse_Type_S1 =>
181  Sreg0 <= ArpResponse_ARP_Payload_HType1;
182  dataout <= x"00";
183  when ArpResponse_Type_S48 =>
184  Sreg0 <= ArpResponse_Type_S1;
185  dataout <= x"06";
186  when ArpResponse_ARP_Payload_PType2 =>
187  Sreg0 <= ArpResponse_ARP_Payload_HLen;
188  dataout <= x"06";
189  when ArpResponse_ARP_Payload_HLen =>
190  Sreg0 <= ArpResponse_ARP_Payload_PLen;
191  dataout <= x"04";
192  when ArpResponse_ARP_Payload_PLen =>
193  Sreg0 <= ArpResponse_ARP_Payload_Op1;
194  dataout <= x"00";
195  -- ARP reply
196  when ArpResponse_ARP_Payload_SMac1 =>
197  Sreg0 <= ArpResponse_ARP_Payload_SMac2;
198  dataout <= x"80";
199  when ArpResponse_ARP_Payload_SMac2 =>
200  Sreg0 <= ArpResponse_ARP_Payload_SMac3;
201  dataout <= x"55";
202  when ArpResponse_ARP_Payload_SMac3 =>
203  Sreg0 <= ArpResponse_ARP_Payload_SMac4;
204  dataout <= x"EC";
205  when ArpResponse_ARP_Payload_SMac4 =>
206  Sreg0 <= ArpResponse_ARP_Payload_SMac5;
207  dataout <= x"00";
208  when ArpResponse_ARP_Payload_SMac5 =>
209  Sreg0 <= ArpResponse_ARP_Payload_SMac6;
210  dataout <= addrs;
211  when ArpResponse_ARP_Payload_SMac6 =>
212  Sreg0 <= ArpResponse_ARP_Payload_Sip1;
213  dataout <= x"C0";
214  when ArpResponse_ARP_Payload_Sip1 =>
215  Sreg0 <= ArpResponse_ARP_Payload_Sip2;
216  dataout <= x"A8";
217  when ArpResponse_ARP_Payload_Sip2 =>
218  Sreg0 <= ArpResponse_ARP_Payload_Sip3;
219  dataout <= x"85";
220  when ArpResponse_ARP_Payload_Sip3 =>
221  Sreg0 <= ArpResponse_ARP_Payload_Sip4;
222  dataout <= addrs;
223  when ArpResponse_ARP_Payload_Sip4 =>
224  Sreg0 <= ArpResponse_ARP_Payload_TMac1;
225  dataout <= tmac(47 downto 40);
226  when ArpResponse_ARP_Payload_TMac1 =>
227  Sreg0 <= ArpResponse_ARP_Payload_TMac2;
228  dataout <= tmac(39 downto 32);
229  when ArpResponse_ARP_Payload_TMac2 =>
230  Sreg0 <= ArpResponse_ARP_Payload_TMac3;
231  dataout <= tmac(31 downto 24);
232  when ArpResponse_ARP_Payload_TMac3 =>
233  Sreg0 <= ArpResponse_ARP_Payload_TMac4;
234  dataout <= tmac(23 downto 16);
235  when ArpResponse_ARP_Payload_TMac4 =>
236  Sreg0 <= ArpResponse_ARP_Payload_TMac5;
237  dataout <= tmac(15 downto 8);
238  when ArpResponse_ARP_Payload_TMac5 =>
239  Sreg0 <= ArpResponse_ARP_Payload_TMac6;
240  dataout <= tmac(7 downto 0);
241  when ArpResponse_ARP_Payload_TMac6 =>
242  Sreg0 <= ArpResponse_ARP_Payload_Tip1;
243  dataout <= tip(31 downto 24);
244  when ArpResponse_ARP_Payload_Tip1 =>
245  Sreg0 <= ArpResponse_ARP_Payload_Tip2;
246  dataout <= tip(23 downto 16);
247  when ArpResponse_ARP_Payload_Tip2 =>
248  Sreg0 <= ArpResponse_ARP_Payload_Tip3;
249  dataout <= tip(15 downto 8);
250  when ArpResponse_ARP_Payload_Tip3 =>
251  Sreg0 <= ArpResponse_ARP_Payload_Tip4;
252  dataout <= tip(7 downto 0);
253  when ArpResponse_ARP_Payload_HType1 =>
254  Sreg0 <= ArpResponse_ARP_Payload_HType2;
255  dataout <= x"01";
256  --ethernet
257  when ArpResponse_ARP_Payload_Tip4 =>
258  Sreg0 <= ArpResponse_CRC_S59;
259  dataout <= (others => '0');
260  -- crc may need buffered 0 input
261  delay_count <= 18;
262  when ArpResponse_ARP_Payload_HType2 =>
263  Sreg0 <= ArpResponse_ARP_Payload_PType1;
264  dataout <= x"08";
265  --IPv4
266  when ArpResponse_ARP_Payload_PType1 =>
267  Sreg0 <= ArpResponse_ARP_Payload_PType2;
268  dataout <= x"00";
269  when ArpResponse_ARP_Payload_Op1 =>
270  Sreg0 <= ArpResponse_ARP_Payload_Op2;
271  dataout <= x"02";
272  -- ARP reply
273  when ArpResponse_ARP_Payload_Op2 =>
274  Sreg0 <= ArpResponse_ARP_Payload_SMac1;
275  dataout <= x"00";
276  when ArpResponse_Preamble_S57 =>
277  delay_count <= delay_count - 1;
278  if delay_count = 1 then
279  Sreg0 <= ArpResponse_Preamble_S58;
280  dataout <= x"D5";
281  end if;
282  when ArpResponse_Preamble_S58 =>
283  Sreg0 <= ArpResponse_Dest_S22;
284  dataout <= tmac(47 downto 40);
285  crc_gen_en <= '1';
286  when ArpResponse_CRC_crc1 =>
287  Sreg0 <= ArpResponse_CRC_crc2;
288  when ArpResponse_CRC_crc2 =>
289  Sreg0 <= ArpResponse_CRC_crc3;
290  when ArpResponse_CRC_crc3 =>
291  Sreg0 <= ArpResponse_CRC_crc4;
292  when ArpResponse_CRC_crc4 =>
293  Sreg0 <= delay1;
294  crc_gen_rd <= '0';
295  tx_en <= '0';
296  delay_count <= 20;
297  -- number of ticks after sending packet to keep line dead from udp
298  when ArpResponse_CRC_S59 =>
299  delay_count <= delay_count - 1;
300  if delay_count = 1 then
301  Sreg0 <= ArpResponse_CRC_crc1;
302  crc_gen_rd <= '1';
303  crc_gen_en <= '0';
304  end if;
305 --vhdl_cover_off
306  when others =>
307  null;
308 --vhdl_cover_on
309  end case;
310  end if;
311  end if;
312 end process;
313 
314 end arp_reply_arch;