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

Subversion Repositories gigabit_udp_mac

[/] [gigabit_udp_mac/] [trunk/] [MAC/] [GMII_MII_WRAPPER_V6.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 boa_a_m
-------------------------------------------------------------
2
--      Filename:  GMII_MII_WRAPPER_V5.VHD
3
--      Version: 1
4
--      Date last modified: 10/28/11
5
-- Inheritance:         GMII_MII_WRAPPER.VHD, rev1 4-20-10
6
--
7
-- description:  Wrapper between the MAC and the PHY (GMII/MII interface) 
8
-- 10/100 Mbps: Complies with the MII interface specification in the 802.3 standard clause 22
9
-- 1000 Mbps:  Complies with the GMII interface specification in the 802.3 standard clause 35
10
-- Automatic detection of the rx speed.
11
-- For Virtex-5
12
---------------------------------------------------------------
13
library IEEE;
14
use IEEE.STD_LOGIC_1164.ALL;
15
use IEEE.STD_LOGIC_ARITH.ALL;
16
use IEEE.STD_LOGIC_UNSIGNED.ALL;
17
library UNISIM;
18
use UNISIM.VComponents.all;
19
 
20
entity GMII_MII_WRAPPER_V6 is
21
    Port (
22
                --// CLK, RESET
23
                CLK: in std_logic;
24
                        -- 125 MHz global reference clock (fixed, independent of the tx speed)
25
                IDELAYREFCLK200MHZ: in std_logic;
26
                        -- 190-210 MHz clock required for implementing IO delay(s).
27
                SYNC_RESET: in std_logic;
28
                        -- block the GMII/MII output signals to the PHY during the PHY reset.
29
                        -- minimum width 50ns for Virtex 5 (IDELAYCTRL contraint)
30
                        -- MANDATORY at power up.
31
 
32
                --// PHY GMII/MII Interface ----------------------------------------------------------------
33
                -- Connect directly to FPGA pins
34
                TX_CLK: in std_logic;
35
                        -- MII tx clock from PHY. Continuous clock. (10/100 Mbps only) 
36
                        -- 25 MHz (100 Mbps), or 2.5 MHz (10 Mbps) depending on speed
37
                        -- accuracy: +/- 100ppm (MII)
38
                        -- duty cycle between 35% and 65% inclusive (MII).
39
                GTX_CLK: out std_logic;
40
                        -- GMII tx clock to PHY. Continuous clock. 125MHz (1000 Mbps only)
41
                        -- 2ns delay inside (user adjustable).
42
                TXD: out std_logic_vector(7 downto 0);
43
                        -- tx data (when TX_EN = '1' and TX_ER = '0') or special codes otherwise (carrier extend, 
44
                        -- carrier extend error, transmit error propagation). See 802.3 table 35-1 for definitions.
45
                TX_EN: out std_logic;
46
                        -- 
47
                TX_ER: out std_logic;
48
                        -- to deliberately corrupt the contents of the frame (so as to be detected as such by the receiver)
49
 
50
                RX_CLK: in std_logic;
51
                        -- continuous receive reference clock recovered by the PHY from the received signal
52
                        -- 125/25/2.5 MHz +/- 50 ppm. 
53
                        -- Duty cycle better than 35%/65% (MII)
54
                        -- 125 MHz must be delayed by 1.5 to 2.1 ns to prevent glitches (TBC. true for RGMII, but for GMII TOO???)
55
 
56
                RXD: in std_logic_vector(7 downto 0);
57
                        -- rx data. 8-bit when 1000 Mbps. 4-bit nibble (3:0) when 10/100 Mbps.
58
                RX_DV: in std_logic;
59
                RX_ER: in std_logic;
60
                CRS: in std_logic;
61
                        -- carrier sense
62
                COL: in std_logic;
63
                        -- collision detection
64
 
65
                --// MAC Interface ----------------------------------------------------------------
66
                MAC_RX_CLK: out std_logic;
67
                        -- received clock (already a global clock, no need for any additional BUFG)
68
                        -- 125 MHz (1000 Mbps), 25 MHz (100 Mbps) or 2.5 MHz (10 Mbps)
69
                -- receive signals are synchronous with the MAC_RX_CLK clock recovered by the PHY
70
                MAC_RXD: out std_logic_vector(7 downto 0);
71
                        -- 8-bits of rx data
72
                MAC_RX_DV: out std_logic;
73
                MAC_RX_ER: out std_logic;
74
                MAC_RX_SAMPLE_CLK: out std_logic;
75
                        -- read the above MAC_RX? signals at the rising edge of MAC_RX_CLK when MAC_RX_SAMPLE_CLK = '1'.
76
                        -- Always '1' when the transmit speed is set at 1000 Mbps  
77
                        -- 1-CLK pulse once every (exactly) 2 CLKs when the transmit speed is set at 10 or 100 Mbps 
78
 
79
                -- transmit signals are synchronous with the rising edge of the 125 MHz CLK 
80
                MAC_TXD: in std_logic_vector(7 downto 0);
81
                        -- 8-bits of tx data
82
                        -- tx data (when MAC_TX_EN = '1' and MAC_TX_ER = '0') or special codes otherwise (carrier extend, 
83
                        -- carrier extend error, transmit error propagation). See 802.3 table 35-1 for definitions.
84
                MAC_TX_EN: in std_logic;
85
                        -- The MAC is responsible for holding the tx enable low until it has verified that it
86
                        -- operates at the same speed as the PHY (as reported in the SPEED_STATUS)
87
                MAC_TX_ER: in std_logic;
88
                        -- use (MAC_TX_EN, MAC_TX_ER) as follows:
89
                        -- 0,0  = transmit complete
90
                        -- 0,1 and MAC_TXD = 0x0F = carrier extend
91
                        -- 0,1 and MAC_TXD = 0x1F = carrier extend error
92
                        -- 1,0 = normal transmission
93
                        -- 1,1 = transmit error
94
                MAC_TX_SAMPLE_CLK: in std_logic;
95
                        -- read the above MAC_TX? signals at the rising edge of CLK when MAC_TX_SAMPLE_CLK = '1'.
96
                        -- MAC_TX_SAMPLE_CLK conveys the transmit speed information. 
97
                        -- Always '1' when the transmit speed is set at 1000 Mbps  
98
                        -- 1-CLK pulse once every (exactly) 10 CLKs when the transmit speed is set at 100 Mbps 
99
                        -- 1-CLK pulse once every (exactly) 100 CLKs when the transmit speed is set at 10 Mbps
100
 
101
                -- MAC monitoring and control
102
                MAC_TX_SPEED: in std_logic_vector(1 downto 0);
103
                        -- 00/01/10  for 10/100/1000 Mbps transmit speed (not really a control, but this component
104
                        -- needs to know what speed it should run at).
105
                MAC_CRS: out std_logic;
106
                        -- carrier sense. Directly from PHY over MII.
107
                MAC_COL: out std_logic;
108
                        -- collision detection. Directly from PHY over MII.
109
 
110
                --// PHY status
111
                -- optional in-band status (must be enabled at PHY)
112
                LINK_STATUS: out std_logic ;  -- 0 = link down, 1 = link up
113
                SPEED_STATUS: out std_logic_vector(1 downto 0);
114
                        -- Detected RX_CLK clock speed, 00 = 2.5 MHz, 01 = 25 MHz, 10 = 125 MHz, 11 = reserved
115
                DUPLEX_STATUS: out std_logic
116
                        -- 0 = half duplex, 1 = full duplex
117
 
118
 );
119
end entity;
120
 
121
architecture Behavioral of GMII_MII_WRAPPER_V6 is
122
--------------------------------------------------------
123
--      COMPONENTS
124
--------------------------------------------------------
125
--------------------------------------------------------
126
--     SIGNALS
127
--------------------------------------------------------
128
constant RXC_DELAY: integer range 0 to 31 := 20;  -- adjust as needed. Here: 2ns
129
constant TXC_DELAY: integer range 0 to 31 := 20;  -- adjust as needed. Here: 2ns
130
--
131
--signal RGMII_EN: std_logic;
132
signal RX_CLK_IN: std_logic;
133
signal RX_CLK_IN2: std_logic;
134
signal RX_CLK_DELAYED: std_logic := '0';
135
signal RX_CLKG: std_logic := '0';        -- global clock, delayed 2ns w.r.t. received RXC.
136
signal RX_CLKGA: std_logic := '0';
137
signal RX_DV_D: std_logic;
138
signal RX_DV_D2: std_logic;
139
signal RX_ER_D: std_logic;
140
signal RXD_NIBBLE_TOGGLE: std_logic := '0';
141
signal RXD_D: std_logic_vector(7 downto 0);
142
signal RX_SPEED: std_logic_vector(1 downto 0) := "10";
143
signal RX_CLK_COUNTER1: std_logic_vector(2 downto 0) := "000";
144
signal RX_CLK_COUNTER1_MSB_D: std_logic;
145
signal RX_CLK_COUNTER1_MSB_D2: std_logic;
146
signal RX_CLK_COUNTER2: std_logic_vector(9 downto 0) := "0000000000";
147
signal MAC_RX_ER_LOCAL: std_logic := '0';
148
signal rxd_delay                : std_logic_vector(7 downto 0) := "00000000";
149
signal rx_er_delay      : std_logic;
150
signal rx_dv_delay      : std_logic;
151
signal TXC_COUNTER: std_logic_vector(5 downto 0) := "000010";
152
signal TX_CLK_D: std_logic;
153
signal TX_CLK_D2: std_logic;
154
signal TXC0: std_logic;
155
signal MAC_TXD_D: std_logic_vector(7 downto 0);
156
signal MAC_TX_EN_D: std_logic;
157
signal MAC_TX_ER_D: std_logic;
158
signal TXD_NIBBLE_TOGGLE: std_logic;
159
 
160
--------------------------------------------------------
161
--      IMPLEMENTATION
162
--------------------------------------------------------
163
begin
164
 
165
--RGMII_EN <= not SYNC_RESET;
166
--  -- disable the RGMII outputs while the PHY is being reset.
167
--
168
---------------------------------------------
169
-- RECEIVE SECTION
170
---------------------------------------------
171
-- force IBUF selection (otherwise tools may select the wrong primitive)
172
--IBUF_001: IBUF port map( I => RX_CLK, O => RX_CLK_IN);
173
 
174
---- delay the RX_CLK clock by 2ns so that the clock is always slightly AFTER the signal transition.
175
--   IDELAYCTRL_inst : IDELAYCTRL
176
--   port map (
177
--      RDY => open,       -- 1-bit output indicates validity of the REFCLK
178
--      REFCLK => IDELAYREFCLK200MHZ, -- 1-bit reference clock input 190-210 MHz
179
--      RST => SYNC_RESET        -- 1-bit reset input. Minimum width 50ns
180
--   );
181
 
182
--  IDELAYE2_inst : IDELAYE2
183
--   generic map (
184
--      CINVCTRL_SEL => "FALSE",          -- Enable dynamic clock inversion (FALSE, TRUE)
185
--      DELAY_SRC => "IDATAIN",           -- Delay input (IDATAIN, DATAIN)
186
--      HIGH_PERFORMANCE_MODE => "TRUE", -- Reduced jitter ("TRUE"), Reduced power ("FALSE")
187
--      IDELAY_TYPE => "FIXED",           -- FIXED, VARIABLE, VAR_LOAD, VAR_LOAD_PIPE
188
--      IDELAY_VALUE => 0,                -- Input delay tap setting (0-31)
189
--      PIPE_SEL => "FALSE",              -- Select pipelined mode, FALSE, TRUE
190
--      REFCLK_FREQUENCY => 200.0,        -- IDELAYCTRL clock input frequency in MHz (190.0-210.0).
191
--      SIGNAL_PATTERN => "CLOCK"          -- DATA, CLOCK input signal
192
--   )
193
--   port map (
194
--      CNTVALUEOUT => open, -- 5-bit output: Counter value output
195
--      DATAOUT => RX_CLK_DELAYED,         -- 1-bit output: Delayed data output
196
--      C => '0',                     -- 1-bit input: Clock input
197
--      CE => '0',                   -- 1-bit input: Active high enable increment/decrement input
198
--      CINVCTRL => '0',       -- 1-bit input: Dynamic clock inversion input
199
--      CNTVALUEIN => (OTHERS   =>      '0'),   -- 5-bit input: Counter value input
200
--      DATAIN => '0',           -- 1-bit input: Internal delay data input
201
--      IDATAIN => RX_CLK_IN,         -- 1-bit input: Data input from the I/O
202
--      INC => '0',                 -- 1-bit input: Increment / Decrement tap delay input
203
--      LD => '0',                   -- 1-bit input: Load IDELAY_VALUE input
204
--      LDPIPEEN => '0',       -- 1-bit input: Enable PIPELINE register to load data input
205
--      REGRST => SYNC_RESET            -- 1-bit input: Active-high reset tap-delay input
206
--   );
207
 
208
-- delay_gmii_rx_dv : IODELAYE1
209
--   generic map (
210
--      IDELAY_TYPE    => "FIXED",
211
--      DELAY_SRC      => "I"
212
--   )
213
--   port map (
214
--      IDATAIN        => rx_dv,
215
--      ODATAIN        => '0',
216
--      DATAOUT        => rx_dv_delay,
217
--      DATAIN         => '0',
218
--      C              => '0',
219
--      T              => '1',
220
--      CE             => '0',
221
--      CINVCTRL       => '0',
222
--      CLKIN          => '0',
223
--      CNTVALUEIN     => "00000",
224
--      CNTVALUEOUT    => open,
225
--      INC            => '0',
226
--      RST            => '0'
227
--   );
228
rx_dv_delay     <= rx_dv;
229
--delay_gmii_rx_er : IODELAYE1
230
--   generic map (
231
--      IDELAY_TYPE    => "FIXED",
232
--      DELAY_SRC      => "I"
233
--   )
234
--   port map (
235
--      IDATAIN        => rx_er,
236
--      ODATAIN        => '0',
237
--      DATAOUT        => rx_er_delay,
238
--      DATAIN         => '0',
239
--      C              => '0',
240
--      T              => '1',
241
--      CE             => '0',
242
--      CINVCTRL       => '0',
243
--      CLKIN          => '0',
244
--      CNTVALUEIN     => "00000",
245
--      CNTVALUEOUT    => open,
246
--      INC            => '0',
247
--      RST            => '0'
248
--   );
249
 
250
rx_er_delay     <=      rx_er;
251
--  rxdata_bus: for I in 7 downto 0 generate
252
--   delay_gmii_rxd : IODELAYE1
253
--   generic map (
254
--      IDELAY_TYPE    => "FIXED",
255
--      DELAY_SRC      => "I"
256
--   )
257
--   port map (
258
--      IDATAIN        => rxd(I),
259
--      ODATAIN        => '0',
260
--      DATAOUT        => rxd_delay(I),
261
--      DATAIN         => '0',
262
--      C              => '0',
263
--      T              => '1',
264
--      CE             => '0',
265
--      CINVCTRL       => '0',
266
--      CLKIN          => '0',
267
--      CNTVALUEIN     => "00000",
268
--      CNTVALUEOUT    => open,
269
--      INC            => '0',
270
--      RST            => '0'
271
--   );
272
--   end generate;
273
 
274
---------------
275
rxd_delay       <=      rxd;
276
---------------
277
--IBUFG_inst : IBUF
278
--      generic map (
279
--                                      IOSTANDARD              => "DEFAULT"
280
--                                      )
281
--      port map (
282
--                                      O                                       => RX_CLKGA, -- Clock buffer output
283
--                                      I                                       => RX_CLK -- Clock buffer input (connect directly to top-level port)
284
--                              );
285
RX_CLKGA        <=      RX_CLK;
286
-- delay RX clock, but only in the case of 125 MHz
287
--RX_CLK_IN2 <= RX_CLK_DELAYED;-- when (RX_SPEED = "10") else RX_CLK_IN;
288
 
289
-- TODO.. It may be better to control IODELAY2 delay because the mux above delays the clock.
290
 
291
---- declare the RX clock as a global clock
292
--BUFG_001 : BUF port map (
293
--      O => ,     -- Clock buffer output
294
--      I => RX_CLKGA      -- Clock buffer input
295
--);
296
 
297
RX_CLKG <=      RX_CLKGA;
298
-------------------
299
-- immediately reclock rx input signals 
300
--RECLOCK_RX_001: process(RX_CLKG, RXD, RX_DV, RX_ER)
301
RECLOCK_RX_001: process(RX_CLKG)
302
begin
303
        if rising_edge(RX_CLKG) then
304
                RXD_D   <= rxd_delay;
305
                RX_DV_D         <= rx_dv_delay;
306
                RX_ER_D         <= rx_er_delay;
307
        end if;
308
end process;
309
 
310
-- re-assemble 8-bit rx data (from 4-bit nibbles at 10/100 Mbps)
311
RX8B_001: process(RX_CLKG)
312
begin
313
        if rising_edge(RX_CLKG) then
314
                RX_DV_D2 <= RX_DV_D;
315
 
316
                if(RX_SPEED(1) = '0') and (RX_DV_D = '1') and (RX_DV_D2 = '0') then
317
                        -- 10/100 Mbps. Start of new packet. Reset toggle
318
                        RXD_NIBBLE_TOGGLE <= '1';
319
                else
320
                        RXD_NIBBLE_TOGGLE <= not RXD_NIBBLE_TOGGLE;
321
                end if;
322
        end if;
323
end process;
324
 
325
MAX_RX_OUT_001: process(RX_CLKG)
326
begin
327
        if rising_edge(RX_CLKG) then
328
                MAC_CRS <= CRS;
329
                MAC_COL <= COL;
330
 
331
                if(RX_SPEED = "10") then
332
                        -- 1000 Mbps
333
                        MAC_RXD <= RXD_D;
334
                        MAC_RX_DV <= RX_DV_D;
335
                        MAC_RX_ER_LOCAL <= RX_ER_D;
336
                        MAC_RX_SAMPLE_CLK <= '1';
337
                        LINK_STATUS <= '1';
338
                elsif(RX_SPEED(1) = '0') and (RX_DV_D = '1') and (RX_DV_D2 = '0') then
339
                        -- start of new packet. Reset toggle
340
                        MAC_RXD(3 downto 0) <= RXD_D(3 downto 0);
341
                        MAC_RX_DV <= RX_DV_D;
342
                        MAC_RX_ER_LOCAL <= RX_ER_D;
343
                        MAC_RX_SAMPLE_CLK <= '0';  -- waiting for the other half
344
                        LINK_STATUS <= '1';
345
                elsif(RX_SPEED(1) = '0') and (RXD_NIBBLE_TOGGLE = '0') then
346
                        -- 1st nibble (1/2)
347
                        MAC_RXD(3 downto 0) <= RXD_D(3 downto 0);
348
                        MAC_RX_DV <= RX_DV_D;
349
                        MAC_RX_ER_LOCAL <= RX_ER_D;
350
                        MAC_RX_SAMPLE_CLK <= '0';  -- waiting for the other half
351
                        LINK_STATUS <= '1';
352
                elsif(RX_SPEED(1) = '0') and (RXD_NIBBLE_TOGGLE = '1') then
353
                        -- 2nd nibble (2/2)
354
                        MAC_RXD(7 downto 4) <= RXD_D(3 downto 0);
355
                        MAC_RX_SAMPLE_CLK <= '1';  -- got a complete byte
356
                        MAC_RX_ER_LOCAL <= MAC_RX_ER_LOCAL or RX_ER_D;  -- RX_ER can be as short as one RX_CLKG.
357
                        LINK_STATUS <= '1';
358
                else
359
                        MAC_RX_SAMPLE_CLK <= '0';
360
                LINK_STATUS <= '0';
361
                end if;
362
        end if;
363
end process;
364
 
365
-- outputs to MAC
366
MAC_RX_CLK <= RX_CLKG;
367
MAC_RX_ER <= MAC_RX_ER_LOCAL;
368
 
369
--// RX_SPEED AUTODETECT ------------------------------------------
370
-- Automatically detect rx speed based on the RX_CLK.
371
-- Algorithm: two counters, one based the variable frequency clock (RX_CLKG), the other
372
-- based on the 125 MHz master clock.
373
 
374
-- Modulo-8 counter.
375
RX_CLK_COUNTER1_GEN: process(RX_CLKG)
376
begin
377
        if rising_edge(RX_CLKG) then
378
                RX_CLK_COUNTER1 <= RX_CLK_COUNTER1 + 1;
379
        end if;
380
end process;
381
 
382
RX_CLK_COUNTER2_GEN: process(RX_CLKG)
383
begin
384
        if rising_edge(RX_CLKG) then
385
                RX_CLK_COUNTER1_MSB_D <= RX_CLK_COUNTER1(2);  -- reclock to make RX_CLK_COUNTER1 MSb synchronous with CLK
386
                RX_CLK_COUNTER1_MSB_D2 <= RX_CLK_COUNTER1_MSB_D;
387
 
388
                if(RX_CLK_COUNTER1_MSB_D2 = '0') and (RX_CLK_COUNTER1_MSB_D = '1') then
389
                        -- reset RX_CLK_COUNTER2 every 8 RX_CLK_COUNTER1. 
390
                        RX_CLK_COUNTER2 <= (others => '0');
391
                        if(RX_CLK_COUNTER2(9 downto 4) = 0) then  -- <16
392
                                RX_SPEED <= "10";  -- 1000 Mbps
393
                        elsif(RX_CLK_COUNTER2(9 downto 6) = 0) then  -- < 64
394
                                RX_SPEED <= "01";  -- 100 Mbps
395
                        else
396
                                RX_SPEED <= "00";  -- 10 Mbps
397
                        end if;
398
                else
399
                        RX_CLK_COUNTER2 <= RX_CLK_COUNTER2 + 1;
400
                end if;
401
 
402
        end if;
403
end process;
404
 
405
-- report rx speed to MAC
406
SPEED_STATUS <= RX_SPEED;
407
 
408
---------------------------------------------
409
-- TRANSMIT SECTION
410
---------------------------------------------
411
-- Reclock TX signals so that they are stable during the entire period (we don't
412
-- want any transition within a TXC clock period)
413
RECLOCK_005: process(RX_CLKG)
414
begin
415
        if rising_edge(RX_CLKG) then
416
                if(SYNC_RESET = '1') then
417
                        MAC_TXD_D <= (others => '0');
418
                        MAC_TX_EN_D <= '0';
419
                        MAC_TX_ER_D <= '0';
420
                        TXD_NIBBLE_TOGGLE <= '0';
421
                elsif (MAC_TX_SAMPLE_CLK = '1') then
422
                        MAC_TXD_D <= MAC_TXD;
423
                        MAC_TX_EN_D <= MAC_TX_EN;
424
                        MAC_TX_ER_D <= MAC_TX_ER;
425
                        TXD_NIBBLE_TOGGLE <= '0';  -- point to lower nibble (3:0) first
426
                elsif(MAC_TX_SPEED(1) = '0') and (TXC0 = '1')then  -- 10/100 Mbps
427
                        -- read another nibble. toggle upper/lower nibble pointer
428
                        TXD_NIBBLE_TOGGLE <= not TXD_NIBBLE_TOGGLE;
429
                end if;
430
        end if;
431
end process;
432
 
433
-- two cases: @1000 Mbps, the GTX_CLK is an output. At other speeds, the TX_CLK in an input.
434
 
435
-- Case 10/100 Mbps. Convert the TX_CLK input clock from the PHY into CLK-synchronous 8ns pulses.
436
-- Poor-man's DLL to ensure that the clocks are spaced exactly 5 or 50 CLKs apart.
437
TX_CLK_GEN_001: process(RX_CLKG, TX_CLK)
438
begin
439
        if rising_edge(RX_CLKG) then
440
                TX_CLK_D <= TX_CLK;
441
                TX_CLK_D2 <= TX_CLK_D;
442
 
443
                -- TXC_COUNTER represents the phase of the clock replica.
444
                if(SYNC_RESET = '1') or (MAC_TX_SPEED(1) = '1') then
445
                        TXC_COUNTER <= (others => '0');
446
                elsif(MAC_TX_SPEED = "00") and (TXC_COUNTER = 0) then
447
                        -- 10 Mbps: modulo-50 periodic counter
448
                        TXC_COUNTER <= "110001";  -- 49
449
                elsif(MAC_TX_SPEED = "01") and (TXC_COUNTER = 0) then
450
                        -- 100 Mbps: modulo-5 periodic counter
451
                        TXC_COUNTER <= "000100";  -- 4
452
                elsif (TXC_COUNTER > 2) and (TX_CLK_D2 = '0') and (TX_CLK_D = '1') then
453
                        -- re-adjust phase of clock replica (once at start-up) when phase error is too large
454
                        -- 3 CLK margin. 
455
                        TXC_COUNTER <= "000001";
456
                elsif(TXC_COUNTER > 0) then
457
                        TXC_COUNTER <= TXC_COUNTER - 1;
458
                end if;
459
 
460
                if(TXC_COUNTER = 2) then
461
                        TXC0 <= '1';
462
                else
463
                        TXC0 <= '0';
464
                end if;
465
 
466
        end if;
467
end process;
468
 
469
 
470
TXD_OUTPUT_001: process(RX_CLKG)
471
begin
472
        if rising_edge(RX_CLKG) then
473
                if(SYNC_RESET = '1') then
474
                        -- disable all outputs while the component is being reset.
475
                        TXD <= (others => '0');
476
                        TX_EN <= '0';
477
                        TX_ER <= '0';
478
                elsif(MAC_TX_SPEED(1) = '0') and (TXC0 = '1')then  -- 10/100 Mbps
479
                        if(TXD_NIBBLE_TOGGLE = '0') then
480
                                -- lower nibble (3:0)
481
                                TXD <= MAC_TXD_D(3 downto 0) & MAC_TXD_D(3 downto 0);  -- data
482
                        else
483
                                TXD <= MAC_TXD_D(7 downto 4) & MAC_TXD_D(7 downto 4);  -- data
484
                        end if;
485
                        TX_EN <= MAC_TX_EN_D;
486
                        TX_ER <= MAC_TX_ER_D;
487
                elsif(MAC_TX_SPEED = "10") then  -- 1000 Mbps
488
                        TXD <= MAC_TXD_D;  -- data
489
                        TX_EN <= MAC_TX_EN_D;
490
                        TX_ER <= MAC_TX_ER_D;
491
                end if;
492
        end if;
493
end process;
494
 
495
 
496
-- delay the TX clock by 2ns so that the clock is always slightly AFTER the signal transition.
497
   -- Xilinx Virtex-5 IODELAY: Input and Output Fixed or Variable Delay Element
498
--    IODELAY_001 : IODELAYE2
499
--    generic map (
500
--                       CINVCTRL_SEL   =>      FALSE,
501
--       DELAY_SRC => "O", -- Specify which input port to be used
502
----                        "I"=IDATAIN, "O"=ODATAIN, "DATAIN"=DATAIN, "IO"=Bi-directional
503
--       HIGH_PERFORMANCE_MODE => TRUE, -- TRUE specifies lower jitter
504
----                                     at expense of more power
505
--       IDELAY_TYPE => "FIXED",  -- "FIXED" or "VARIABLE" 
506
--       IDELAY_VALUE => 0,   -- 0 to 63 tap values
507
--                       ODELAY_TYPE    =>      "FIXED",
508
--       ODELAY_VALUE => TXC_DELAY,   -- 0 to 63 tap values
509
--       REFCLK_FREQUENCY => 200.0,   -- Frequency used for IDELAYCTRL
510
----                                    175.0 to 225.0
511
--       SIGNAL_PATTERN => "CLOCK")    -- Input signal type, "CLOCK" or "DATA" 
512
--    port map (
513
--                       CNTVALUEOUT    =>      OPEN,
514
--       DATAOUT => GTX_CLK,  -- 1-bit delayed data output
515
--       C => '0',     -- 1-bit clock input
516
--       CE => '0',   -- 1-bit clock enable input
517
--                       CINVCTRL       =>      '0',
518
--                       CLKIN  =>      'Z',
519
--                       CNTVALUEIN     =>      (OTHERS =>      '0'),
520
--       DATAIN => '0', -- 1-bit internal data input
521
--       IDATAIN => '0',  -- 1-bit input data input (connect to port)
522
--       INC => '0', -- 1-bit increment/decrement input
523
--       ODATAIN => CLK,  -- 1-bit output data input
524
--       RST => '0',  -- 1-bit active high, synch reset input
525
--       T => '0'  -- 1-bit 3-state control input
526
--    );
527
GTX_CLK <= RX_CLKG;
528
end Behavioral;
529
 

powered by: WebSVN 2.1.0

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