1 |
15 |
wzab |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : L3 FADE protocol demo for Digilent Atlys board
|
3 |
|
|
-- Project :
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : atlys_eth_top.vhd
|
6 |
|
|
-- Author : Wojciech M. Zabolotny <wzab@ise.pw.edu.pl>
|
7 |
|
|
-- License : BSD License
|
8 |
|
|
-- Company :
|
9 |
|
|
-- Created : 2010-08-03
|
10 |
26 |
wzab |
-- Last update: 2014-11-15
|
11 |
15 |
wzab |
-- Platform :
|
12 |
|
|
-- Standard : VHDL
|
13 |
|
|
-------------------------------------------------------------------------------
|
14 |
|
|
-- Description:
|
15 |
|
|
-- This file implements the top entity, integrating all component
|
16 |
|
|
-------------------------------------------------------------------------------
|
17 |
|
|
-- Copyright (c) 2012
|
18 |
|
|
-- This is public domain code!!!
|
19 |
|
|
-------------------------------------------------------------------------------
|
20 |
|
|
-- Revisions :
|
21 |
|
|
-- Date Version Author Description
|
22 |
|
|
-- 2010-08-03 1.0 wzab Created
|
23 |
|
|
-------------------------------------------------------------------------------
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
library ieee;
|
27 |
|
|
use ieee.std_logic_1164.all;
|
28 |
|
|
use ieee.numeric_std.all;
|
29 |
|
|
library work;
|
30 |
|
|
use work.pkt_ack_pkg.all;
|
31 |
|
|
use work.desc_mgr_pkg.all;
|
32 |
|
|
|
33 |
|
|
entity atlys_eth is
|
34 |
26 |
wzab |
|
35 |
15 |
wzab |
port (
|
36 |
|
|
cpu_reset : in std_logic;
|
37 |
|
|
-- -- DDR2 interface
|
38 |
|
|
-- ddr2_a : out std_logic_vector(12 downto 0);
|
39 |
|
|
-- ddr2_ba : out std_logic_vector(2 downto 0);
|
40 |
|
|
-- ddr2_cas_b : out std_logic;
|
41 |
|
|
-- ddr2_cke : out std_logic;
|
42 |
|
|
-- ddr2_clk_n : out std_logic;
|
43 |
|
|
-- ddr2_clk_p : out std_logic;
|
44 |
|
|
-- ddr2_dq : inout std_logic_vector(15 downto 0);
|
45 |
|
|
-- ddr2_ldm : out std_logic;
|
46 |
|
|
-- ddr2_ldqs_n : out std_logic;
|
47 |
|
|
-- ddr2_ldqs_p : out std_logic;
|
48 |
|
|
-- ddr2_odt : out std_logic;
|
49 |
|
|
-- ddr2_ras_b : out std_logic;
|
50 |
|
|
-- ddr2_udm : out std_logic;
|
51 |
|
|
-- ddr2_udqs_n : out std_logic;
|
52 |
|
|
-- ddr2_udqs_p : out std_logic;
|
53 |
|
|
-- ddr2_we_b : out std_logic;
|
54 |
|
|
-- -- FLASH interface
|
55 |
|
|
-- flash_a : out std_logic_vector(24 downto 0);
|
56 |
|
|
-- flash_ce_b : out std_logic;
|
57 |
|
|
-- flash_d : inout std_logic_vector(7 downto 0);
|
58 |
|
|
-- flash_oe_b : out std_logic;
|
59 |
|
|
-- flash_we_b : out std_logic;
|
60 |
|
|
-- -- FMC interface
|
61 |
|
|
-- fmc_la28_n : out std_logic;
|
62 |
|
|
-- fmc_la28_p : out std_logic;
|
63 |
|
|
-- fmc_la29_n : out std_logic;
|
64 |
|
|
-- fmc_la29_p : out std_logic;
|
65 |
|
|
-- fmc_la30_n : out std_logic;
|
66 |
|
|
-- fmc_la30_p : out std_logic;
|
67 |
|
|
-- fmc_la31_n : out std_logic;
|
68 |
|
|
-- fmc_la31_p : out std_logic;
|
69 |
|
|
-- iic_scl_main : out std_logic;
|
70 |
|
|
-- iic_sda_main : out std_logic;
|
71 |
|
|
|
72 |
|
|
--gpio_hdr : in std_logic_vector(7 downto 0);
|
73 |
|
|
|
74 |
|
|
-- fmc_clk0_m2c_n : out std_logic;
|
75 |
|
|
-- fmc_clk0_m2c_p : out std_logic;
|
76 |
|
|
-- fmc_clk1_m2c_n : out std_logic;
|
77 |
|
|
-- fmc_clk1_m2c_p : out std_logic;
|
78 |
|
|
-- fmc_la00_cc_n : out std_logic;
|
79 |
|
|
-- fmc_la00_cc_p : out std_logic;
|
80 |
|
|
-- fmc_la01_cc_n : out std_logic;
|
81 |
|
|
-- fmc_la01_cc_p : out std_logic;
|
82 |
|
|
-- fmc_la02_n : out std_logic;
|
83 |
|
|
-- fmc_la02_p : out std_logic;
|
84 |
|
|
-- fmc_la03_n : out std_logic;
|
85 |
|
|
-- fmc_la03_p : out std_logic;
|
86 |
|
|
-- fmc_la04_n : out std_logic;
|
87 |
|
|
-- fmc_la04_p : out std_logic;
|
88 |
|
|
-- led : out std_logic_vector(3 downto 0);
|
89 |
|
|
switches : in std_logic_vector(7 downto 0);
|
90 |
|
|
-- flash_oen : out std_logic;
|
91 |
|
|
-- flash_wen : out std_logic;
|
92 |
|
|
-- flash_cen : out std_logic;
|
93 |
|
|
gpio_led : out std_logic_vector(7 downto 0);
|
94 |
|
|
-- PHY interface
|
95 |
|
|
phy_col : in std_logic;
|
96 |
|
|
phy_crs : in std_logic;
|
97 |
|
|
phy_int : in std_logic;
|
98 |
|
|
phy_mdc : out std_logic;
|
99 |
|
|
phy_mdio : inout std_logic;
|
100 |
|
|
phy_reset : out std_logic;
|
101 |
|
|
phy_rxclk : in std_logic;
|
102 |
|
|
phy_rxctl_rxdv : in std_logic;
|
103 |
|
|
phy_rxd : in std_logic_vector(7 downto 0);
|
104 |
|
|
phy_rxer : in std_logic;
|
105 |
|
|
phy_txclk : in std_logic;
|
106 |
|
|
phy_txctl_txen : out std_logic;
|
107 |
|
|
phy_txc_gtxclk : out std_logic;
|
108 |
|
|
phy_txd : out std_logic_vector(7 downto 0);
|
109 |
|
|
phy_txer : out std_logic;
|
110 |
|
|
sysclk : in std_logic
|
111 |
|
|
);
|
112 |
|
|
|
113 |
|
|
end atlys_eth;
|
114 |
|
|
|
115 |
|
|
architecture beh of atlys_eth is
|
116 |
|
|
|
117 |
|
|
component dp_ram_scl
|
118 |
|
|
generic (
|
119 |
|
|
DATA_WIDTH : integer;
|
120 |
|
|
ADDR_WIDTH : integer);
|
121 |
|
|
port (
|
122 |
|
|
clk_a : in std_logic;
|
123 |
|
|
we_a : in std_logic;
|
124 |
|
|
addr_a : in std_logic_vector(ADDR_WIDTH-1 downto 0);
|
125 |
|
|
data_a : in std_logic_vector(DATA_WIDTH-1 downto 0);
|
126 |
|
|
q_a : out std_logic_vector(DATA_WIDTH-1 downto 0);
|
127 |
|
|
clk_b : in std_logic;
|
128 |
|
|
we_b : in std_logic;
|
129 |
|
|
addr_b : in std_logic_vector(ADDR_WIDTH-1 downto 0);
|
130 |
|
|
data_b : in std_logic_vector(DATA_WIDTH-1 downto 0);
|
131 |
|
|
q_b : out std_logic_vector(DATA_WIDTH-1 downto 0));
|
132 |
|
|
end component;
|
133 |
|
|
|
134 |
|
|
component ack_fifo
|
135 |
|
|
port (
|
136 |
|
|
rst : in std_logic;
|
137 |
|
|
wr_clk : in std_logic;
|
138 |
|
|
rd_clk : in std_logic;
|
139 |
|
|
din : in std_logic_vector(pkt_ack_width-1 downto 0);
|
140 |
|
|
wr_en : in std_logic;
|
141 |
|
|
rd_en : in std_logic;
|
142 |
|
|
dout : out std_logic_vector(pkt_ack_width-1 downto 0);
|
143 |
|
|
full : out std_logic;
|
144 |
|
|
empty : out std_logic);
|
145 |
|
|
end component;
|
146 |
|
|
|
147 |
|
|
component dcm1
|
148 |
|
|
port (
|
149 |
|
|
CLK_IN1 : in std_logic;
|
150 |
|
|
CLK_OUT1 : out std_logic;
|
151 |
|
|
CLK_OUT2 : out std_logic;
|
152 |
|
|
CLK_OUT3 : out std_logic;
|
153 |
|
|
RESET : in std_logic;
|
154 |
|
|
LOCKED : out std_logic);
|
155 |
|
|
end component;
|
156 |
|
|
|
157 |
|
|
component desc_manager is
|
158 |
|
|
generic (
|
159 |
|
|
LOG2_N_OF_PKTS : integer;
|
160 |
|
|
N_OF_PKTS : integer);
|
161 |
|
|
port (
|
162 |
|
|
dta : in std_logic_vector(63 downto 0);
|
163 |
|
|
dta_we : in std_logic;
|
164 |
18 |
wzab |
dta_eod : in std_logic;
|
165 |
15 |
wzab |
dta_ready : out std_logic;
|
166 |
|
|
pkt_number : out unsigned(31 downto 0);
|
167 |
|
|
seq_number : out unsigned(15 downto 0);
|
168 |
|
|
cmd_response_out : out std_logic_vector(12*8-1 downto 0);
|
169 |
|
|
snd_cmd_start : out std_logic;
|
170 |
|
|
snd_start : out std_logic;
|
171 |
18 |
wzab |
flushed : out std_logic;
|
172 |
15 |
wzab |
snd_ready : in std_logic;
|
173 |
|
|
dmem_addr : out std_logic_vector(LOG2_NWRDS_IN_PKT+LOG2_N_OF_PKTS-1 downto 0);
|
174 |
|
|
dmem_dta : out std_logic_vector(63 downto 0);
|
175 |
|
|
dmem_we : out std_logic;
|
176 |
|
|
ack_fifo_empty : in std_logic;
|
177 |
|
|
ack_fifo_rd_en : out std_logic;
|
178 |
|
|
ack_fifo_dout : in std_logic_vector(pkt_ack_width-1 downto 0);
|
179 |
|
|
cmd_code : out std_logic_vector(15 downto 0);
|
180 |
|
|
cmd_seq : out std_logic_vector(15 downto 0);
|
181 |
|
|
cmd_arg : out std_logic_vector(31 downto 0);
|
182 |
|
|
cmd_run : out std_logic;
|
183 |
|
|
cmd_retr_s : out std_logic;
|
184 |
|
|
cmd_ack : in std_logic;
|
185 |
|
|
cmd_response_in : in std_logic_vector(8*12-1 downto 0);
|
186 |
26 |
wzab |
retr_count : out std_logic_vector(31 downto 0);
|
187 |
15 |
wzab |
transmit_data : in std_logic;
|
188 |
|
|
transm_delay : out unsigned(31 downto 0);
|
189 |
|
|
dbg : out std_logic_vector(3 downto 0);
|
190 |
|
|
clk : in std_logic;
|
191 |
|
|
rst_n : in std_logic);
|
192 |
|
|
end component desc_manager;
|
193 |
18 |
wzab |
|
194 |
15 |
wzab |
component cmd_proc is
|
195 |
|
|
port (
|
196 |
|
|
cmd_code : in std_logic_vector(15 downto 0);
|
197 |
|
|
cmd_seq : in std_logic_vector(15 downto 0);
|
198 |
|
|
cmd_arg : in std_logic_vector(31 downto 0);
|
199 |
|
|
cmd_run : in std_logic;
|
200 |
|
|
cmd_ack : out std_logic;
|
201 |
|
|
cmd_response : out std_logic_vector(8*12-1 downto 0);
|
202 |
|
|
clk : in std_logic;
|
203 |
26 |
wzab |
rst_p : in std_logic;
|
204 |
|
|
retr_count : in std_logic_vector(31 downto 0)
|
205 |
|
|
);
|
206 |
15 |
wzab |
end component cmd_proc;
|
207 |
|
|
|
208 |
18 |
wzab |
component eth_sender is
|
209 |
15 |
wzab |
port (
|
210 |
|
|
peer_mac : in std_logic_vector(47 downto 0);
|
211 |
|
|
my_mac : in std_logic_vector(47 downto 0);
|
212 |
|
|
my_ether_type : in std_logic_vector(15 downto 0);
|
213 |
|
|
pkt_number : in unsigned(31 downto 0);
|
214 |
18 |
wzab |
seq_number : in unsigned(15 downto 0);
|
215 |
15 |
wzab |
transm_delay : in unsigned(31 downto 0);
|
216 |
|
|
clk : in std_logic;
|
217 |
|
|
rst_n : in std_logic;
|
218 |
|
|
ready : out std_logic;
|
219 |
18 |
wzab |
flushed : in std_logic;
|
220 |
15 |
wzab |
start : in std_logic;
|
221 |
18 |
wzab |
cmd_start : in std_logic;
|
222 |
15 |
wzab |
tx_mem_addr : out std_logic_vector(LOG2_N_OF_PKTS+LOG2_NWRDS_IN_PKT-1 downto 0);
|
223 |
|
|
tx_mem_data : in std_logic_vector(63 downto 0);
|
224 |
18 |
wzab |
cmd_response : in std_logic_vector(12*8-1 downto 0);
|
225 |
15 |
wzab |
Tx_Clk : in std_logic;
|
226 |
|
|
Tx_En : out std_logic;
|
227 |
|
|
TxD : out std_logic_vector(7 downto 0));
|
228 |
18 |
wzab |
end component eth_sender;
|
229 |
15 |
wzab |
|
230 |
|
|
component eth_receiver
|
231 |
|
|
port (
|
232 |
|
|
peer_mac : out std_logic_vector(47 downto 0);
|
233 |
|
|
my_mac : in std_logic_vector(47 downto 0);
|
234 |
|
|
my_ether_type : in std_logic_vector(15 downto 0);
|
235 |
|
|
transmit_data : out std_logic;
|
236 |
|
|
restart : out std_logic;
|
237 |
|
|
ack_fifo_full : in std_logic;
|
238 |
|
|
ack_fifo_wr_en : out std_logic;
|
239 |
|
|
ack_fifo_din : out std_logic_vector(pkt_ack_width-1 downto 0);
|
240 |
|
|
clk : in std_logic;
|
241 |
|
|
rst_n : in std_logic;
|
242 |
|
|
dbg : out std_logic_vector(3 downto 0);
|
243 |
|
|
Rx_Clk : in std_logic;
|
244 |
|
|
Rx_Er : in std_logic;
|
245 |
|
|
Rx_Dv : in std_logic;
|
246 |
|
|
RxD : in std_logic_vector(7 downto 0));
|
247 |
|
|
end component;
|
248 |
|
|
|
249 |
|
|
component jtag_bus_ctl
|
250 |
|
|
generic (
|
251 |
|
|
d_width : integer;
|
252 |
|
|
a_width : integer);
|
253 |
|
|
port (
|
254 |
|
|
din : in std_logic_vector((d_width-1) downto 0);
|
255 |
|
|
dout : out std_logic_vector((d_width-1) downto 0);
|
256 |
|
|
addr : out std_logic_vector((a_width-1) downto 0);
|
257 |
|
|
nwr : out std_logic;
|
258 |
|
|
nrd : out std_logic);
|
259 |
|
|
end component;
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
signal my_mac : std_logic_vector(47 downto 0);
|
263 |
|
|
constant my_ether_type : std_logic_vector(15 downto 0) := x"fade";
|
264 |
|
|
signal transm_delay : unsigned(31 downto 0);
|
265 |
|
|
signal restart : std_logic;
|
266 |
|
|
signal dta : std_logic_vector(63 downto 0);
|
267 |
|
|
signal dta_we : std_logic := '0';
|
268 |
|
|
signal dta_ready : std_logic;
|
269 |
|
|
signal snd_start : std_logic;
|
270 |
|
|
signal snd_ready : std_logic;
|
271 |
18 |
wzab |
signal flushed : std_logic := '0';
|
272 |
|
|
signal dta_eod : std_logic := '0';
|
273 |
15 |
wzab |
signal dmem_addr : std_logic_vector(LOG2_NWRDS_IN_PKT+LOG2_N_OF_PKTS-1 downto 0);
|
274 |
|
|
signal dmem_dta : std_logic_vector(63 downto 0);
|
275 |
|
|
signal dmem_we : std_logic;
|
276 |
|
|
signal addr_a, addr_b : integer;
|
277 |
|
|
signal test_dta : unsigned(63 downto 0);
|
278 |
|
|
signal tx_mem_addr : std_logic_vector(LOG2_NWRDS_IN_PKT+LOG2_N_OF_PKTS-1 downto 0);
|
279 |
|
|
signal tx_mem_data : std_logic_vector(63 downto 0);
|
280 |
|
|
|
281 |
|
|
signal arg1, arg2, res1 : unsigned(7 downto 0);
|
282 |
|
|
signal res2 : unsigned(15 downto 0);
|
283 |
|
|
signal sender : std_logic_vector(47 downto 0);
|
284 |
|
|
signal peer_mac : std_logic_vector(47 downto 0);
|
285 |
|
|
signal inputs, din, dout : std_logic_vector(7 downto 0);
|
286 |
|
|
signal addr, leds : std_logic_vector(3 downto 0);
|
287 |
|
|
signal nwr, nrd, rst_p, rst_n, dcm_locked : std_logic;
|
288 |
|
|
signal not_cpu_reset, rst_del : std_logic;
|
289 |
|
|
|
290 |
|
|
signal set_number : unsigned(15 downto 0);
|
291 |
|
|
signal pkt_number : unsigned(31 downto 0);
|
292 |
18 |
wzab |
signal seq_number : unsigned(15 downto 0) := (others => '0');
|
293 |
15 |
wzab |
signal start_pkt, stop_pkt : unsigned(7 downto 0) := (others => '0');
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
signal ack_fifo_din, ack_fifo_dout : std_logic_vector(pkt_ack_width-1 downto 0);
|
297 |
|
|
signal ack_fifo_wr_en, ack_fifo_rd_en, ack_fifo_empty, ack_fifo_full : std_logic;
|
298 |
18 |
wzab |
signal transmit_data, td_del0, td_del1 : std_logic := '0';
|
299 |
15 |
wzab |
|
300 |
|
|
signal read_addr : std_logic_vector(15 downto 0);
|
301 |
|
|
signal read_data : std_logic_vector(15 downto 0);
|
302 |
|
|
signal read_done, read_in_progress : std_logic;
|
303 |
|
|
|
304 |
|
|
signal dbg : std_logic_vector(3 downto 0);
|
305 |
|
|
|
306 |
|
|
signal led_counter : integer := 0;
|
307 |
|
|
signal tx_counter : integer := 10000;
|
308 |
|
|
signal Reset : std_logic;
|
309 |
|
|
signal Clk_125M : std_logic;
|
310 |
|
|
signal Clk_user : std_logic;
|
311 |
|
|
signal Clk_reg : std_logic;
|
312 |
|
|
signal Speed : std_logic_vector(2 downto 0);
|
313 |
|
|
signal Rx_mac_ra : std_logic;
|
314 |
|
|
signal Rx_mac_rd : std_logic;
|
315 |
|
|
signal Rx_mac_data : std_logic_vector(31 downto 0);
|
316 |
|
|
signal Rx_mac_BE : std_logic_vector(1 downto 0);
|
317 |
|
|
signal Rx_mac_pa : std_logic;
|
318 |
|
|
signal Rx_mac_sop : std_logic;
|
319 |
|
|
signal Rx_mac_eop : std_logic;
|
320 |
|
|
signal Tx_mac_wa : std_logic;
|
321 |
|
|
signal Tx_mac_wr : std_logic;
|
322 |
|
|
signal Tx_mac_data : std_logic_vector(31 downto 0);
|
323 |
|
|
signal Tx_mac_BE : std_logic_vector(1 downto 0);
|
324 |
|
|
signal Tx_mac_sop : std_logic;
|
325 |
|
|
signal Tx_mac_eop : std_logic;
|
326 |
|
|
signal Pkg_lgth_fifo_rd : std_logic;
|
327 |
|
|
signal Pkg_lgth_fifo_ra : std_logic;
|
328 |
|
|
signal Pkg_lgth_fifo_data : std_logic_vector(15 downto 0);
|
329 |
|
|
signal Gtx_clk : std_logic;
|
330 |
|
|
signal Rx_clk : std_logic;
|
331 |
|
|
signal Tx_clk : std_logic;
|
332 |
|
|
signal Tx_er : std_logic;
|
333 |
|
|
signal Tx_en : std_logic;
|
334 |
|
|
signal Txd : std_logic_vector(7 downto 0);
|
335 |
|
|
signal Rx_er : std_logic;
|
336 |
|
|
signal Rx_dv : std_logic;
|
337 |
|
|
signal Rxd : std_logic_vector(7 downto 0);
|
338 |
|
|
signal Crs : std_logic;
|
339 |
|
|
signal Col : std_logic;
|
340 |
|
|
signal CSB : std_logic := '1';
|
341 |
|
|
signal WRB : std_logic := '1';
|
342 |
|
|
signal CD_in : std_logic_vector(15 downto 0) := (others => '0');
|
343 |
|
|
signal CD_out : std_logic_vector(15 downto 0) := (others => '0');
|
344 |
|
|
signal CA : std_logic_vector(7 downto 0) := (others => '0');
|
345 |
|
|
signal s_Mdo : std_logic;
|
346 |
|
|
signal s_MdoEn : std_logic;
|
347 |
|
|
signal s_Mdi : std_logic;
|
348 |
|
|
|
349 |
|
|
signal s_dta_we : std_logic;
|
350 |
18 |
wzab |
|
351 |
|
|
-- signals related to user commands handling
|
352 |
15 |
wzab |
signal cmd_response_in, cmd_response_out : std_logic_vector(12*8-1 downto 0) := (others => '0');
|
353 |
|
|
signal cmd_start : std_logic := '0';
|
354 |
|
|
signal cmd_run : std_logic := '0';
|
355 |
18 |
wzab |
signal cmd_retr_s : std_logic := '0';
|
356 |
15 |
wzab |
signal cmd_ack : std_logic := '0';
|
357 |
|
|
signal cmd_code : std_logic_vector(15 downto 0) := (others => '0');
|
358 |
|
|
signal cmd_seq : std_logic_vector(15 downto 0) := (others => '0');
|
359 |
|
|
signal cmd_arg : std_logic_vector(31 downto 0) := (others => '0');
|
360 |
|
|
|
361 |
26 |
wzab |
signal retr_count : std_logic_vector(31 downto 0);
|
362 |
|
|
|
363 |
15 |
wzab |
begin -- beh
|
364 |
|
|
|
365 |
|
|
-- Allow selection of MAC with the DIP switch to allow testing
|
366 |
|
|
-- with multiple boards!
|
367 |
|
|
with switches(1 downto 0) select
|
368 |
|
|
my_mac <=
|
369 |
|
|
x"de_ad_ba_be_be_ef" when "00",
|
370 |
|
|
x"de_ad_ba_be_be_e1" when "01",
|
371 |
|
|
x"de_ad_ba_be_be_e2" when "10",
|
372 |
|
|
x"de_ad_ba_be_be_e3" when "11";
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
-- iic_sda_main <= 'Z';
|
376 |
|
|
-- iic_scl_main <= 'Z';
|
377 |
|
|
|
378 |
|
|
not_cpu_reset <= not cpu_reset;
|
379 |
|
|
rst_p <= not rst_n;
|
380 |
|
|
|
381 |
|
|
-- flash_oe_b <= '1';
|
382 |
|
|
-- flash_we_b <= '1';
|
383 |
|
|
-- flash_ce_b <= '1';
|
384 |
|
|
|
385 |
|
|
tx_clk <= Clk_125M;
|
386 |
|
|
rx_clk <= phy_rxclk;
|
387 |
|
|
|
388 |
|
|
Pkg_lgth_fifo_rd <= Pkg_lgth_fifo_ra;
|
389 |
|
|
|
390 |
|
|
addr_a <= to_integer(unsigned(dmem_addr));
|
391 |
|
|
addr_b <= to_integer(unsigned(tx_mem_addr));
|
392 |
|
|
|
393 |
|
|
dp_ram_scl_1 : dp_ram_scl
|
394 |
|
|
generic map (
|
395 |
|
|
DATA_WIDTH => 64,
|
396 |
|
|
ADDR_WIDTH => LOG2_N_OF_PKTS+LOG2_NWRDS_IN_PKT)
|
397 |
|
|
port map (
|
398 |
|
|
clk_a => clk_user,
|
399 |
|
|
we_a => dmem_we,
|
400 |
|
|
addr_a => dmem_addr,
|
401 |
|
|
data_a => dmem_dta,
|
402 |
|
|
q_a => open,
|
403 |
|
|
clk_b => Tx_clk,
|
404 |
|
|
we_b => '0',
|
405 |
|
|
addr_b => tx_mem_addr,
|
406 |
|
|
data_b => (others => '0'),
|
407 |
|
|
q_b => tx_mem_data);
|
408 |
|
|
|
409 |
|
|
desc_manager_1 : desc_manager
|
410 |
|
|
generic map (
|
411 |
|
|
LOG2_N_OF_PKTS => LOG2_N_OF_PKTS,
|
412 |
18 |
wzab |
N_OF_PKTS => N_OF_PKTS)
|
413 |
15 |
wzab |
port map (
|
414 |
18 |
wzab |
dta => dta,
|
415 |
|
|
dta_we => dta_we,
|
416 |
|
|
dta_ready => dta_ready,
|
417 |
|
|
pkt_number => pkt_number,
|
418 |
|
|
seq_number => seq_number,
|
419 |
15 |
wzab |
cmd_response_out => cmd_response_out,
|
420 |
18 |
wzab |
snd_start => snd_start,
|
421 |
|
|
flushed => flushed,
|
422 |
|
|
snd_cmd_start => cmd_start,
|
423 |
|
|
snd_ready => snd_ready,
|
424 |
|
|
dta_eod => dta_eod,
|
425 |
|
|
dmem_addr => dmem_addr,
|
426 |
|
|
dmem_dta => dmem_dta,
|
427 |
|
|
dmem_we => dmem_we,
|
428 |
|
|
ack_fifo_empty => ack_fifo_empty,
|
429 |
|
|
ack_fifo_rd_en => ack_fifo_rd_en,
|
430 |
|
|
ack_fifo_dout => ack_fifo_dout,
|
431 |
|
|
cmd_code => cmd_code,
|
432 |
|
|
cmd_seq => cmd_seq,
|
433 |
|
|
cmd_arg => cmd_arg,
|
434 |
|
|
cmd_run => cmd_run,
|
435 |
|
|
cmd_retr_s => cmd_retr_s,
|
436 |
|
|
cmd_ack => cmd_ack,
|
437 |
|
|
cmd_response_in => cmd_response_in,
|
438 |
26 |
wzab |
retr_count => retr_count,
|
439 |
18 |
wzab |
transmit_data => transmit_data,
|
440 |
|
|
transm_delay => transm_delay,
|
441 |
|
|
dbg => dbg,
|
442 |
|
|
clk => clk_user,
|
443 |
|
|
rst_n => rst_n);
|
444 |
15 |
wzab |
|
445 |
18 |
wzab |
cmd_proc_1 : cmd_proc
|
446 |
15 |
wzab |
port map (
|
447 |
|
|
cmd_code => cmd_code,
|
448 |
|
|
cmd_seq => cmd_seq,
|
449 |
|
|
cmd_arg => cmd_arg,
|
450 |
|
|
cmd_run => cmd_run,
|
451 |
|
|
cmd_ack => cmd_ack,
|
452 |
|
|
cmd_response => cmd_response_in,
|
453 |
|
|
clk => clk_user,
|
454 |
26 |
wzab |
rst_p => rst_p,
|
455 |
|
|
retr_count => retr_count
|
456 |
|
|
);
|
457 |
15 |
wzab |
|
458 |
|
|
eth_sender_1 : eth_sender
|
459 |
|
|
port map (
|
460 |
|
|
peer_mac => peer_mac,
|
461 |
|
|
my_mac => my_mac,
|
462 |
|
|
my_ether_type => my_ether_type,
|
463 |
|
|
pkt_number => pkt_number,
|
464 |
18 |
wzab |
seq_number => seq_number,
|
465 |
15 |
wzab |
transm_delay => transm_delay,
|
466 |
|
|
clk => clk_user,
|
467 |
|
|
rst_n => rst_n,
|
468 |
|
|
ready => snd_ready,
|
469 |
18 |
wzab |
flushed => flushed,
|
470 |
15 |
wzab |
start => snd_start,
|
471 |
18 |
wzab |
cmd_start => cmd_start,
|
472 |
15 |
wzab |
tx_mem_addr => tx_mem_addr,
|
473 |
|
|
tx_mem_data => tx_mem_data,
|
474 |
18 |
wzab |
cmd_response => cmd_response_out,
|
475 |
15 |
wzab |
Tx_Clk => tx_clk,
|
476 |
|
|
Tx_En => phy_txctl_txen,
|
477 |
|
|
TxD => PHY_Txd);
|
478 |
|
|
|
479 |
|
|
eth_receiver_2 : eth_receiver
|
480 |
|
|
port map (
|
481 |
|
|
peer_mac => peer_mac,
|
482 |
|
|
my_mac => my_mac,
|
483 |
|
|
my_ether_type => my_ether_type,
|
484 |
|
|
transmit_data => transmit_data,
|
485 |
|
|
restart => restart,
|
486 |
|
|
ack_fifo_full => ack_fifo_full,
|
487 |
|
|
ack_fifo_wr_en => ack_fifo_wr_en,
|
488 |
|
|
ack_fifo_din => ack_fifo_din,
|
489 |
|
|
clk => clk_user,
|
490 |
|
|
rst_n => rst_n,
|
491 |
|
|
dbg => open, --dbg,
|
492 |
|
|
Rx_Clk => rx_clk,
|
493 |
|
|
Rx_Er => PHY_Rxer,
|
494 |
|
|
Rx_Dv => phy_rxctl_rxdv,
|
495 |
|
|
RxD => PHY_Rxd);
|
496 |
|
|
|
497 |
|
|
dcm1_1 : dcm1
|
498 |
|
|
port map (
|
499 |
|
|
CLK_IN1 => sysclk,
|
500 |
|
|
CLK_OUT1 => Clk_125M,
|
501 |
|
|
CLK_OUT2 => Clk_user,
|
502 |
|
|
CLK_OUT3 => Clk_reg,
|
503 |
|
|
RESET => not_cpu_reset,
|
504 |
|
|
LOCKED => dcm_locked);
|
505 |
|
|
|
506 |
|
|
process (Clk_user, not_cpu_reset)
|
507 |
|
|
begin -- process
|
508 |
|
|
if not_cpu_reset = '1' then -- asynchronous reset (active low)
|
509 |
|
|
rst_n <= '0';
|
510 |
|
|
rst_del <= '0';
|
511 |
|
|
elsif Clk_user'event and Clk_user = '1' then -- rising clock edge
|
512 |
|
|
if restart = '1' then
|
513 |
|
|
rst_n <= '0';
|
514 |
|
|
rst_del <= '0';
|
515 |
|
|
else
|
516 |
|
|
if dcm_locked = '1' then
|
517 |
|
|
rst_del <= '1';
|
518 |
|
|
rst_n <= rst_del;
|
519 |
|
|
end if;
|
520 |
|
|
end if;
|
521 |
|
|
end if;
|
522 |
|
|
end process;
|
523 |
|
|
|
524 |
|
|
-- reset
|
525 |
|
|
|
526 |
|
|
phy_reset <= rst_n;
|
527 |
|
|
|
528 |
|
|
-- Connection of MDI
|
529 |
|
|
--s_Mdi <= PHY_MDIO;
|
530 |
|
|
--PHY_MDIO <= 'Z' when s_MdoEn = '0' else s_Mdo;
|
531 |
|
|
|
532 |
|
|
phy_txer <= '0';
|
533 |
|
|
phy_mdio <= 'Z';
|
534 |
|
|
phy_mdc <= '0';
|
535 |
|
|
|
536 |
|
|
phy_txc_gtxclk <= tx_clk;
|
537 |
|
|
|
538 |
|
|
ack_fifo_1 : ack_fifo
|
539 |
|
|
port map (
|
540 |
|
|
rst => rst_p,
|
541 |
|
|
wr_clk => rx_clk,
|
542 |
|
|
rd_clk => Clk_user,
|
543 |
|
|
din => ack_fifo_din,
|
544 |
|
|
wr_en => ack_fifo_wr_en,
|
545 |
|
|
rd_en => ack_fifo_rd_en,
|
546 |
|
|
dout => ack_fifo_dout,
|
547 |
|
|
full => ack_fifo_full,
|
548 |
|
|
empty => ack_fifo_empty);
|
549 |
|
|
|
550 |
|
|
--E_TXD <= s_Txd(3 downto 0);
|
551 |
|
|
--s_Rxd <= "0000" & E_RXD;
|
552 |
|
|
|
553 |
|
|
-- signal generator
|
554 |
|
|
|
555 |
|
|
dta <= std_logic_vector(test_dta);
|
556 |
|
|
s_dta_we <= '1' when dta_ready = '1' and transmit_data = '1' else '0';
|
557 |
|
|
dta_we <= s_dta_we;
|
558 |
|
|
|
559 |
|
|
process (Clk_user, rst_n)
|
560 |
18 |
wzab |
begin -- process
|
561 |
26 |
wzab |
|
562 |
18 |
wzab |
if rst_n = '0' then -- asynchronous reset (active low)
|
563 |
|
|
td_del0 <= '0';
|
564 |
|
|
td_del1 <= '0';
|
565 |
15 |
wzab |
test_dta <= (others => '0');
|
566 |
18 |
wzab |
elsif Clk_user'event and Clk_user = '1' then -- rising clock edge
|
567 |
15 |
wzab |
if s_dta_we = '1' then
|
568 |
18 |
wzab |
test_dta <= test_dta + x"1234567809abcdef";
|
569 |
15 |
wzab |
end if;
|
570 |
18 |
wzab |
-- Generate the dta_eod pulse after transmit_data
|
571 |
|
|
-- goes low
|
572 |
|
|
td_del0 <= transmit_data;
|
573 |
|
|
td_del1 <= td_del0;
|
574 |
|
|
if (td_del1 = '1') and (td_del0 = '0') then
|
575 |
|
|
dta_eod <= '1';
|
576 |
|
|
else
|
577 |
|
|
dta_eod <= '0';
|
578 |
|
|
end if;
|
579 |
15 |
wzab |
end if;
|
580 |
|
|
end process;
|
581 |
|
|
|
582 |
|
|
-- gpio_led(1 downto 0) <= std_logic_vector(to_unsigned(led_counter, 2));
|
583 |
|
|
gpio_led(0) <= snd_ready;
|
584 |
|
|
gpio_led(1) <= transmit_data;
|
585 |
18 |
wzab |
gpio_led(2) <= flushed;
|
586 |
15 |
wzab |
gpio_led(3) <= Tx_mac_wa;
|
587 |
|
|
gpio_led(7 downto 4) <= dbg;
|
588 |
|
|
--gpio_led(6) <= ack_fifo_full;
|
589 |
|
|
--gpio_led(7) <= not ack_fifo_empty;
|
590 |
|
|
end beh;
|