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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gaisler/] [sim/] [phy.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
----------------------------------------------------------------------------
19
-- Entity:      phy
20
-- File:        phy.vhd
21
-- Description: Simulation model of an Ethernet PHY
22
-- Author:      Marko Isomaki
23
------------------------------------------------------------------------------
24
 
25
-- pragma translate_off
26
 
27
library ieee;
28
library grlib;
29
 
30
use ieee.std_logic_1164.all;
31
use grlib.stdlib.all;
32
 
33
entity phy is
34
  generic(
35
    address       : integer range 0 to 31 := 0;
36
    extended_regs : integer range 0 to 1  := 1;
37
    aneg          : integer range 0 to 1  := 1;
38
    base100_t4    : integer range 0 to 1  := 0;
39
    base100_x_fd  : integer range 0 to 1  := 1;
40
    base100_x_hd  : integer range 0 to 1  := 1;
41
    fd_10         : integer range 0 to 1  := 1;
42
    hd_10         : integer range 0 to 1  := 1;
43
    base100_t2_fd : integer range 0 to 1  := 1;
44
    base100_t2_hd : integer range 0 to 1  := 1;
45
    base1000_x_fd : integer range 0 to 1  := 0;
46
    base1000_x_hd : integer range 0 to 1  := 0;
47
    base1000_t_fd : integer range 0 to 1  := 1;
48
    base1000_t_hd : integer range 0 to 1  := 1
49
    );
50
  port(
51
    rstn     : in std_logic;
52
    mdio     : inout std_logic;
53
    tx_clk   : out std_logic;
54
    rx_clk   : out std_logic;
55
    rxd      : out std_logic_vector(7 downto 0);
56
    rx_dv    : out std_logic;
57
    rx_er    : out std_logic;
58
    rx_col   : out std_logic;
59
    rx_crs   : out std_logic;
60
    txd      : in std_logic_vector(7 downto 0);
61
    tx_en    : in std_logic;
62
    tx_er    : in std_logic;
63
    mdc      : in std_logic;
64
    gtx_clk  : in std_logic
65
  );
66
end;
67
 
68
architecture behavioral of phy is
69
  type mdio_state_type is (idle, start_of_frame, start_of_frame2, op, phyad, regad,
70
    ta, rdata, wdata);
71
 
72
  type ctrl_reg_type is record
73
    reset       : std_ulogic;
74
    loopback    : std_ulogic;
75
    speedsel    : std_logic_vector(1 downto 0);
76
    anegen      : std_ulogic;
77
    powerdown   : std_ulogic;
78
    isolate     : std_ulogic;
79
    restartaneg : std_ulogic;
80
    duplexmode  : std_ulogic;
81
    coltest     : std_ulogic;
82
  end record;
83
 
84
  type status_reg_type is record
85
    base100_t4    : std_ulogic;
86
    base100_x_fd  : std_ulogic;
87
    base100_x_hd  : std_ulogic;
88
    fd_10         : std_ulogic;
89
    hd_10         : std_ulogic;
90
    base100_t2_fd : std_ulogic;
91
    base100_t2_hd : std_ulogic;
92
    extstat       : std_ulogic;
93
    mfpreamblesup : std_ulogic;
94
    anegcmpt      : std_ulogic;
95
    remfault      : std_ulogic;
96
    anegability   : std_ulogic;
97
    linkstat      : std_ulogic;
98
    jabdetect     : std_ulogic;
99
    extcap        : std_ulogic;
100
  end record;
101
 
102
  type aneg_ab_type is record
103
    next_page     : std_ulogic;
104
    remote_fault  : std_ulogic;
105
    tech_ability  : std_logic_vector(7 downto 0);
106
    selector      : std_logic_vector(4 downto 0);
107
  end record;
108
 
109
  type aneg_exp_type is record
110
    par_detct_flt : std_ulogic;
111
    lp_np_able    : std_ulogic;
112
    np_able       : std_ulogic;
113
    page_rx       : std_ulogic;
114
    lp_aneg_able  : std_ulogic;
115
  end record;
116
 
117
  type aneg_nextpage_type is record
118
    next_page     : std_ulogic;
119
    message_page  : std_ulogic;
120
    ack2          : std_ulogic;
121
    toggle        : std_ulogic;
122
    message       : std_logic_vector(10 downto 0);
123
  end record;
124
 
125
  type mst_slv_ctrl_type is record
126
    tmode         : std_logic_vector(2 downto 0);
127
    manualcfgen   : std_ulogic;
128
    cfgval        : std_ulogic;
129
    porttype      : std_ulogic;
130
    base1000_t_fd : std_ulogic;
131
    base1000_t_hd : std_ulogic;
132
  end record;
133
 
134
  type mst_slv_status_type is record
135
    cfgfault        : std_ulogic;
136
    cfgres          : std_ulogic;
137
    locrxstate      : std_ulogic;
138
    remrxstate      : std_ulogic;
139
    lpbase1000_t_fd : std_ulogic;
140
    lpbase1000_t_hd : std_ulogic;
141
    idlerrcnt       : std_logic_vector(7 downto 0);
142
  end record;
143
 
144
  type extended_status_reg_type is record
145
    base1000_x_fd : std_ulogic;
146
    base1000_x_hd : std_ulogic;
147
    base1000_t_fd : std_ulogic;
148
    base1000_t_hd : std_ulogic;
149
  end record;
150
 
151
  type reg_type is record
152
    state         : mdio_state_type;
153
    cnt           : integer;
154
    op            : std_logic_vector(1 downto 0);
155
    phyad         : std_logic_vector(4 downto 0);
156
    regad         : std_logic_vector(4 downto 0);
157
    wr            : std_ulogic;
158
    regtmp        : std_logic_vector(15 downto 0);
159
    -- MII management registers
160
    ctrl          : ctrl_reg_type;
161
    status        : status_reg_type;
162
    anegadv       : aneg_ab_type;
163
    aneglp        : aneg_ab_type;
164
    anegexp       : aneg_exp_type;
165
    anegnptx      : aneg_nextpage_type;
166
    anegnplp      : aneg_nextpage_type;
167
    mstslvctrl    : mst_slv_ctrl_type;
168
    mstslvstat    : mst_slv_status_type;
169
    extstatus     : extended_status_reg_type;
170
    rstcnt        : integer;
171
    anegcnt       : integer;
172
  end record;
173
 
174
  signal r, rin   : reg_type;
175
  signal int_clk  : std_ulogic := '0';
176
  signal clkslow  : std_ulogic := '0';
177
  signal rcnt     : integer;
178
  signal anegact  : std_ulogic;
179
begin
180
  --mdio signal pull-up
181
  int_clk <= not int_clk after 8 ns when r.ctrl.speedsel = "01" else
182
             not int_clk after 40 ns when r.ctrl.speedsel = "10" else
183
             not int_clk after 400 ns when r.ctrl.speedsel = "00";
184
 
185
  clkslow <= not clkslow after 40 ns when r.ctrl.speedsel = "10" else
186
             not clkslow after 400 ns;
187
 
188
--   rstdelay : process
189
--   begin
190
--     loop
191
--       rstd <= '0';
192
--       while r.ctrl.reset /= '1' loop
193
--         wait on r.ctrl.reset;
194
--       end loop;
195
--       rstd <= '1';
196
--       while rstn = '0' loop
197
--         wait on rstn;
198
--       end loop;
199
--       wait on rstn for 3 us;
200
--       rstd <= '0';
201
--       wait on rstn until r.ctrl.reset = '0' for 5 us; 
202
--     end loop;
203
--   end process;
204
 
205
  anegproc : process is
206
  begin
207
    loop
208
      anegact <= '0';
209
      while rstn /= '1' loop
210
        wait on rstn;
211
      end loop;
212
      while rstn = '1' loop
213
        if r.ctrl.anegen = '0' then
214
          anegact <= '0';
215
          wait on rstn, r.ctrl.anegen, r.ctrl.restartaneg;
216
        else
217
          if r.ctrl.restartaneg = '1' then
218
            anegact <= '1';
219
            wait on rstn, r.ctrl.restartaneg, r.ctrl.anegen for 2 us;
220
            anegact <= '0';
221
            wait on rstn, r.ctrl.anegen until r.ctrl.restartaneg = '0';
222
            if (rstn and r.ctrl.anegen) = '1' then
223
              wait on rstn, r.ctrl.anegen, r.ctrl.restartaneg;
224
            end if;
225
          else
226
            anegact <= '0';
227
            wait on rstn, r.ctrl.restartaneg, r.ctrl.anegen;
228
          end if;
229
        end if;
230
      end loop;
231
    end loop;
232
  end process;
233
 
234
  mdiocomb : process(rstn, r, anegact, mdio) is
235
    variable v : reg_type;
236
  begin
237
    v := r;
238
    if anegact = '0' then
239
      v.ctrl.restartaneg := '0';
240
    end if;
241
    case r.state is
242
      when idle =>
243
        mdio <= 'Z';
244
        if to_X01(mdio) = '1' then
245
          v.cnt := v.cnt + 1;
246
          if v.cnt = 31 then
247
            v.state := start_of_frame; v.cnt := 0;
248
          end if;
249
        else
250
          v.cnt := 0;
251
        end if;
252
      when start_of_frame =>
253
        if to_X01(mdio) = '0' then
254
          v.state := start_of_frame2;
255
        elsif to_X01(mdio) /= '1' then
256
          v.state := idle;
257
        end if;
258
      when start_of_frame2 =>
259
        if to_X01(mdio) = '1' then
260
          v.state := op;
261
        else
262
          v.state := idle;
263
        end if;
264
      when op =>
265
        v.cnt := v.cnt + 1;
266
        v.op := r.op(0) & to_X01(mdio);
267
        if r.cnt = 1 then
268
          if (v.op = "01") or (v.op = "10") then
269
            v.state := phyad; v.cnt := 0;
270
          else
271
            v.state := idle; v.cnt := 0;
272
          end if;
273
        end if;
274
      when phyad =>
275
        v.phyad := r.phyad(3 downto 0) & to_X01(mdio);
276
        v.cnt := v.cnt + 1;
277
        if r.cnt = 4 then
278
          v.state := regad; v.cnt := 0;
279
        end if;
280
      when regad =>
281
        v.regad := r.regad(3 downto 0) & to_X01(mdio);
282
        v.cnt := v.cnt + 1;
283
        if r.cnt = 4 then
284
          v.cnt := 0;
285
          if conv_integer(r.phyad) = address then
286
            v.state := ta;
287
          else
288
            v.state := idle;
289
          end if;
290
        end if;
291
      when ta =>
292
        v.cnt := r.cnt + 1;
293
        if r.cnt = 0 then
294
          if (r.op = "01") and to_X01(mdio) /= '1' then
295
            v.cnt := 0; v.state := idle;
296
          end if;
297
        else
298
          if r.op = "10" then
299
            mdio <= '0'; v.cnt := 0; v.state := rdata;
300
            case r.regad is
301
              when "00000" => --ctrl (basic)
302
                v.regtmp := r.ctrl.reset & r.ctrl.loopback &
303
                  r.ctrl.speedsel(1) & r.ctrl.anegen & r.ctrl.powerdown &
304
                  r.ctrl.isolate & r.ctrl.restartaneg & r.ctrl.duplexmode &
305
                  r.ctrl.coltest & r.ctrl.speedsel(0) & "000000";
306
              when "00001" => --statuc (basic)
307
                v.regtmp := r.status.base100_t4 & r.status.base100_x_fd &
308
                  r.status.base100_x_hd & r.status.fd_10 & r.status.hd_10 &
309
                  r.status.base100_t2_fd & r.status.base100_t2_hd &
310
                  r.status.extstat & '0' & r.status.mfpreamblesup &
311
                  r.status.anegcmpt & r.status.remfault & r.status.anegability &
312
                  r.status.linkstat & r.status.jabdetect & r.status.extcap;
313
              when "00010" => --PHY ID (extended)
314
                if extended_regs = 1 then
315
                  v.regtmp := X"BBCD";
316
                else
317
                  v.cnt := 0; v.state := idle;
318
                end if;
319
              when "00011" => --PHY ID (extended)
320
                if extended_regs = 1 then
321
                  v.regtmp := X"9C83";
322
                else
323
                  v.cnt := 0; v.state := idle;
324
                end if;
325
              when "00100" => --Auto-neg adv. (extended)
326
                if extended_regs = 1 then
327
                  v.regtmp := r.anegadv.next_page & '0' & r.anegadv.remote_fault &
328
                    r.anegadv.tech_ability & r.anegadv.selector;
329
                else
330
                  v.cnt := 0; v.state := idle;
331
                end if;
332
              when "00101" => --Auto-neg link partner ability (extended)
333
                if extended_regs = 1 then
334
                  v.regtmp := r.aneglp.next_page & '0' & r.aneglp.remote_fault &
335
                    r.aneglp.tech_ability & r.aneglp.selector;
336
                else
337
                  v.cnt := 0; v.state := idle;
338
                end if;
339
              when "00110" => --Auto-neg expansion (extended)
340
                if extended_regs = 1 then
341
                  v.regtmp := "00000000000" & r.anegexp.par_detct_flt &
342
                  r.anegexp.lp_np_able &  r.anegexp.np_able & r.anegexp.page_rx &
343
                  r.anegexp.lp_aneg_able;
344
                else
345
                  v.cnt := 0; v.state := idle;
346
                end if;
347
              when "00111" => --Auto-neg next page (extended)
348
                if extended_regs = 1 then
349
                  v.regtmp := r.anegnptx.next_page & '0' & r.anegnptx.message_page &
350
                  r.anegnptx.ack2 & r.anegnptx.toggle & r.anegnptx.message;
351
                else
352
                  v.cnt := 0; v.state := idle;
353
                end if;
354
              when "01000" => --Auto-neg link partner received next page (extended)
355
                if extended_regs = 1 then
356
                  v.regtmp := r.anegnplp.next_page & '0' & r.anegnplp.message_page &
357
                  r.anegnplp.ack2 & r.anegnplp.toggle & r.anegnplp.message;
358
                else
359
                  v.cnt := 0; v.state := idle;
360
                end if;
361
              when "01001" => --Master-slave control (extended)
362
                if extended_regs = 1 then
363
                  v.regtmp := r.mstslvctrl.tmode & r.mstslvctrl.manualcfgen &
364
                  r.mstslvctrl.cfgval & r.mstslvctrl.porttype &
365
                  r.mstslvctrl.base1000_t_fd &  r.mstslvctrl.base1000_t_hd &
366
                  "00000000";
367
                else
368
                  v.cnt := 0; v.state := idle;
369
                end if;
370
              when "01010" => --Master-slave status (extended)
371
                if extended_regs = 1 then
372
                  v.regtmp := r.mstslvstat.cfgfault & r.mstslvstat.cfgres &
373
                  r.mstslvstat.locrxstate & r.mstslvstat.remrxstate &
374
                  r.mstslvstat.lpbase1000_t_fd & r.mstslvstat.lpbase1000_t_hd &
375
                  "00" & r.mstslvstat.idlerrcnt;
376
                else
377
                  v.cnt := 0; v.state := idle;
378
                end if;
379
              when "01111" =>
380
                if (base1000_x_fd = 1) or (base1000_x_hd = 1) or
381
                   (base1000_t_fd = 1) or (base1000_t_hd = 1) then
382
                  v.regtmp := r.extstatus.base1000_x_fd &
383
                              r.extstatus.base1000_x_hd &
384
                              r.extstatus.base1000_t_fd &
385
                              r.extstatus.base1000_t_hd & X"000";
386
                else
387
                  v.regtmp := (others => '0');
388
                end if;
389
              when others =>
390
                --PHY shall not drive MDIO when unimplemented registers
391
                --are accessed
392
                v.cnt := 0; v.state := idle;
393
                v.regtmp := (others => '0');
394
            end case;
395
            if r.ctrl.reset = '1' then
396
              if r.regad = "00000" then
397
                v.regtmp := X"8000";
398
              else
399
                v.regtmp := X"0000";
400
              end if;
401
            end if;
402
          else
403
            if to_X01(mdio) /= '0'then
404
              v.cnt := 0; v.state := idle;
405
            else
406
              v.cnt := 0; v.state := wdata;
407
            end if;
408
          end if;
409
        end if;
410
      when rdata =>
411
        v.cnt := r.cnt + 1;
412
        mdio <= r.regtmp(15-r.cnt);
413
        if r.cnt = 15 then
414
          v.state := idle; v.cnt := 0;
415
        end if;
416
      when wdata =>
417
        v.cnt := r.cnt + 1;
418
        v.regtmp := r.regtmp(14 downto 0) & to_X01(mdio);
419
        if r.cnt = 15 then
420
          v.state := idle; v.cnt := 0;
421
          if r.ctrl.reset = '0' then
422
            case r.regad is
423
              when "00000" =>
424
                v.ctrl.reset := v.regtmp(15);
425
                v.ctrl.loopback := v.regtmp(14);
426
                v.ctrl.speedsel(1) := v.regtmp(13);
427
                v.ctrl.anegen := v.regtmp(12);
428
                v.ctrl.powerdown := v.regtmp(11);
429
                v.ctrl.isolate := v.regtmp(10);
430
                v.ctrl.restartaneg := v.regtmp(9);
431
                v.ctrl.duplexmode := v.regtmp(8);
432
                v.ctrl.coltest := v.regtmp(7);
433
                v.ctrl.speedsel(0) := v.regtmp(6);
434
              when "00100" =>
435
                if extended_regs = 1 then
436
                  v.anegadv.remote_fault := r.regtmp(13);
437
                  v.anegadv.tech_ability := r.regtmp(12 downto 5);
438
                  v.anegadv.selector := r.regtmp(4 downto 0);
439
                end if;
440
              when "00111" =>
441
                if extended_regs = 1 then
442
                  v.anegnptx.next_page     := r.regtmp(15);
443
                  v.anegnptx.message_page  := r.regtmp(13);
444
                  v.anegnptx.ack2          := r.regtmp(12);
445
                  v.anegnptx.message       := r.regtmp(10 downto 0);
446
                end if;
447
              when "01001" =>
448
                if extended_regs = 1 then
449
                  v.mstslvctrl.tmode         := r.regtmp(15 downto 13);
450
                  v.mstslvctrl.manualcfgen   := r.regtmp(12);
451
                  v.mstslvctrl.cfgval        := r.regtmp(11);
452
                  v.mstslvctrl.porttype      := r.regtmp(10);
453
                  v.mstslvctrl.base1000_t_fd := r.regtmp(9);
454
                  v.mstslvctrl.base1000_t_hd := r.regtmp(8);
455
                end if;
456
              when others =>  --no writable bits for other regs
457
                null;
458
            end case;
459
          end if;
460
        end if;
461
      when others =>
462
        null;
463
    end case;
464
    if r.rstcnt > 19 then
465
      v.ctrl.reset := '0'; v.rstcnt := 0;
466
    else
467
      v.rstcnt := r.rstcnt + 1;
468
    end if;
469
    if (v.ctrl.reset and not r.ctrl.reset) = '1' then
470
      v.rstcnt := 0;
471
    end if;
472
    if r.ctrl.anegen = '1' then
473
      if r.anegcnt < 10 then
474
        v.anegcnt := r.anegcnt + 1;
475
      else
476
        v.status.anegcmpt := '1';
477
        if (base1000_x_fd = 1) or (base1000_x_hd = 1) or
478
           (r.mstslvctrl.base1000_t_fd = '1') or
479
           (r.mstslvctrl.base1000_t_hd = '1') then
480
          v.ctrl.speedsel(1 downto 0) := "01";
481
        elsif (r.anegadv.tech_ability(4) = '1') or
482
              (r.anegadv.tech_ability(3) = '1') or
483
              (r.anegadv.tech_ability(2) = '1') or
484
              (base100_t2_fd = 1) or (base100_t2_hd = 1) then
485
          v.ctrl.speedsel(1 downto 0) := "10";
486
        else
487
          v.ctrl.speedsel(1 downto 0) := "00";
488
        end if;
489
        if ((base1000_x_fd = 1) or (r.mstslvctrl.base1000_t_fd = '1')) or
490
           (((base100_t2_fd = 1) or (r.anegadv.tech_ability(3) = '1')) and
491
           (r.mstslvctrl.base1000_t_hd = '0') and (base1000_x_hd = 0)) or
492
           ((r.anegadv.tech_ability(1) = '1') and (base100_t2_hd = 0) and
493
           (r.anegadv.tech_ability(4) = '0') and
494
           (r.anegadv.tech_ability(2) = '0')) then
495
          v.ctrl.duplexmode := '1';
496
        else
497
          v.ctrl.duplexmode := '0';
498
        end if;
499
      end if;
500
    end if;
501
    if r.ctrl.restartaneg = '1' then
502
      v.anegcnt := 0;
503
      v.status.anegcmpt := '0';
504
      v.ctrl.restartaneg := '0';
505
    end if;
506
    rin <= v;
507
  end process;
508
 
509
  reg : process(rstn, mdc) is
510
  begin
511
    if rising_edge(mdc) then
512
      r <= rin;
513
    end if;
514
--     -- RESET DELAY
515
--     if rstd = '1' then
516
--       r.ctrl.reset <= '1';
517
--     else
518
--       r.ctrl.reset <= '0';
519
--     end if;
520
 
521
    -- RESET
522
    if (r.ctrl.reset or not rstn) = '1' then
523
      r.ctrl.loopback <= '0'; r.anegcnt <= 0;
524
      if (base1000_x_hd = 1) or (base1000_x_fd = 1) or (base1000_t_hd = 1) or
525
         (base1000_t_fd = 1) then
526
        r.ctrl.speedsel <= "01";
527
      elsif (base100_x_hd = 1) or (base100_t2_hd = 1) or (base100_x_fd = 1) or
528
            (base100_t2_fd = 1) or (base100_t4 = 1) then
529
        r.ctrl.speedsel <= "10";
530
      else
531
        r.ctrl.speedsel <= "00";
532
      end if;
533
 
534
      r.ctrl.anegen <= conv_std_logic(aneg = 1);
535
      r.ctrl.powerdown <= '0';
536
      r.ctrl.isolate <= '0';
537
      r.ctrl.restartaneg <= '0';
538
      if (base100_x_hd = 0) and (hd_10 = 0) and (base100_t2_hd = 0) and
539
         (base1000_x_hd = 0) and (base1000_t_hd = 0) then
540
        r.ctrl.duplexmode <= '1';
541
      else
542
        r.ctrl.duplexmode <= '0';
543
      end if;
544
      r.ctrl.coltest <= '0';
545
 
546
      r.status.base100_t4 <= conv_std_logic(base100_t4 = 1);
547
      r.status.base100_x_fd <= conv_std_logic(base100_x_fd = 1);
548
      r.status.base100_x_hd <= conv_std_logic(base100_x_hd = 1);
549
      r.status.fd_10 <= conv_std_logic(fd_10 = 1);
550
      r.status.hd_10 <= conv_std_logic(hd_10 = 1);
551
      r.status.base100_t2_fd <= conv_std_logic(base100_t2_fd = 1);
552
      r.status.base100_t2_hd <= conv_std_logic(base100_t2_hd = 1);
553
      r.status.extstat <= conv_std_logic((base1000_x_fd = 1) or
554
                                         (base1000_x_hd = 1) or
555
                                         (base1000_t_fd = 1) or
556
                                         (base1000_t_hd = 1));
557
      r.status.mfpreamblesup <= '0';
558
      r.status.anegcmpt <= '0';
559
      r.status.remfault <= '0';
560
      r.status.anegability <= conv_std_logic(aneg = 1);
561
      r.status.linkstat <= '0';
562
      r.status.jabdetect <= '0';
563
      r.status.extcap <= conv_std_logic(extended_regs = 1);
564
 
565
      r.anegadv.next_page <= '0';
566
      r.anegadv.remote_fault <= '0';
567
      r.anegadv.tech_ability <= "000" & conv_std_logic(base100_t4 = 1) &
568
        conv_std_logic(base100_x_fd = 1) & conv_std_logic(base100_x_hd = 1) &
569
        conv_std_logic(fd_10 = 1) & conv_std_logic(hd_10 = 1);
570
      r.anegadv.selector <= "00001";
571
 
572
      r.aneglp.next_page <= '0';
573
      r.aneglp.remote_fault <= '0';
574
      r.aneglp.tech_ability <= "000" & conv_std_logic(base100_t4 = 1) &
575
        conv_std_logic(base100_x_fd = 1) & conv_std_logic(base100_x_hd = 1) &
576
        conv_std_logic(fd_10 = 1) & conv_std_logic(hd_10 = 1);
577
      r.aneglp.selector <= "00001";
578
 
579
      r.anegexp.par_detct_flt <= '0';
580
      r.anegexp.lp_np_able    <= '0';
581
      r.anegexp.np_able       <= '0';
582
      r.anegexp.page_rx       <= '0';
583
      r.anegexp.lp_aneg_able  <= '0';
584
 
585
      r.anegnptx.next_page     <= '0';
586
      r.anegnptx.message_page  <= '1';
587
      r.anegnptx.ack2          <= '0';
588
      r.anegnptx.toggle        <= '0';
589
      r.anegnptx.message       <= "00000000001";
590
 
591
      r.anegnplp.next_page     <= '0';
592
      r.anegnplp.message_page  <= '1';
593
      r.anegnplp.ack2          <= '0';
594
      r.anegnplp.toggle        <= '0';
595
      r.anegnplp.message       <= "00000000001";
596
 
597
      r.mstslvctrl.tmode         <= (others => '0');
598
      r.mstslvctrl.manualcfgen   <= '0';
599
      r.mstslvctrl.cfgval        <= '0';
600
      r.mstslvctrl.porttype      <= '0';
601
      r.mstslvctrl.base1000_t_fd <= conv_std_logic(base1000_t_fd = 1);
602
      r.mstslvctrl.base1000_t_hd <= conv_std_logic(base1000_t_fd = 1);
603
 
604
      r.mstslvstat.cfgfault         <= '0';
605
      r.mstslvstat.cfgres           <= '1';
606
      r.mstslvstat.locrxstate       <= '1';
607
      r.mstslvstat.remrxstate       <= '1';
608
      r.mstslvstat.lpbase1000_t_fd  <= conv_std_logic(base1000_t_fd = 1);
609
      r.mstslvstat.lpbase1000_t_hd  <= conv_std_logic(base1000_t_fd = 1);
610
      r.mstslvstat.idlerrcnt        <= (others => '0');
611
 
612
      r.extstatus.base1000_x_fd <= conv_std_logic(base1000_x_fd = 1);
613
      r.extstatus.base1000_x_hd <= conv_std_logic(base1000_x_hd = 1);
614
      r.extstatus.base1000_t_fd <= conv_std_logic(base1000_t_fd = 1);
615
      r.extstatus.base1000_t_hd <= conv_std_logic(base1000_t_hd = 1);
616
 
617
    end if;
618
 
619
    if rstn = '0' then
620
      r.cnt <= 0; r.state <= idle; r.rstcnt <= 0;
621
      r.ctrl.reset <= '1';
622
    end if;
623
  end process;
624
 
625
 
626
  loopback_sel : process(r.ctrl.loopback, int_clk, gtx_clk, r.ctrl.speedsel, txd, tx_en) is
627
  begin
628
    if r.ctrl.loopback = '1' then
629
      rx_col <= '0'; rx_crs <= tx_en; rx_dv <= tx_en; rx_er <= tx_er;
630
      rxd <= txd;
631
      if r.ctrl.speedsel /= "01" then
632
        rx_clk <= int_clk; tx_clk <= int_clk;
633
      else
634
        rx_clk <= gtx_clk; tx_clk <= clkslow;
635
      end if;
636
    else
637
      rx_col <= '0'; rx_crs <= '0'; rx_dv <= '0';
638
      rxd <= (others => '0');
639
      if r.ctrl.speedsel /= "01" then
640
        rx_clk <= int_clk; tx_clk <= int_clk after 3 ns;
641
      else
642
        rx_clk <= gtx_clk; tx_clk <= clkslow;
643
      end if;
644
    end if;
645
  end process;
646
end;
647
-- pragma translate_on

powered by: WebSVN 2.1.0

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