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

Subversion Repositories esoc

[/] [esoc/] [trunk/] [Sources/] [altera/] [esoc_port_mac/] [testbench/] [model/] [ethmon2.vhd] - Blame information for rev 42

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 42 lmaarsen
-- -------------------------------------------------------------------------
2
-- -------------------------------------------------------------------------
3
--
4
-- Revision Control Information
5
--
6
-- $RCSfile: ethmon2.vhd,v $
7
-- $Source: /ipbu/cvs/sio/projects/TriSpeedEthernet/src/testbench/models/vhdl/ethernet_model/mon/ethmon2.vhd,v $
8
--
9
-- $Revision: #1 $
10
-- $Date: 2008/08/09 $
11
-- Check in by : $Author: sc-build $
12
-- Author      : SKNg/TTChong
13
--
14
-- Project     : Triple Speed Ethernet - 10/100/1000 MAC
15
--
16
-- Description : (Simulation only)
17
--
18
-- MII Interface Ethernet Traffic Monitor/Decoder
19
--
20
-- 
21
-- ALTERA Confidential and Proprietary
22
-- Copyright 2006 (c) Altera Corporation
23
-- All rights reserved
24
--
25
-- -------------------------------------------------------------------------
26
-- -------------------------------------------------------------------------
27
 
28
 
29
library ieee ;
30
use ieee.std_logic_1164.all ;
31
use ieee.std_logic_arith.all ;
32
use ieee.std_logic_unsigned.all ;
33
use std.textio.all ;
34
 
35
entity ETHMONITOR2 is
36
 
37
    port (
38
 
39
      reset         : in  std_logic ;     -- active high
40
 
41
        -- GMII transmit interface: To be connected to MAC TX
42
 
43
      tx_clk        : in  std_logic ;
44
      txd           : in  std_logic_vector(7 downto 0);
45
      tx_dv         : in  std_logic;
46
      tx_er         : in  std_logic;
47
      tx_sop        : in  std_logic;
48
      tx_eop        : in  std_logic;
49
 
50
       -- Mode of Operation
51
      ethernet_speed: in  std_logic;
52
      mii_mode      : in  std_logic;   -- 4-bit Nibbles (Fast Ethernet)
53
      rgmii_mode    : in  std_logic;   -- 4-bit DDR (Reduced Gigabit)
54
 
55
        -- Frame Contents definitions
56
 
57
      dst           : out std_logic_vector(47 downto 0); -- destination address
58
      src           : out std_logic_vector(47 downto 0); -- source address
59
 
60
      prmble_len    : out integer range 0 to 10000;         -- length of preamble
61
      pquant        : out std_logic_vector(15 downto 0); -- Pause Quanta value
62
      vlan_ctl      : out std_logic_vector(15 downto 0); -- VLAN control info
63
      len           : out std_logic_vector(15 downto 0); -- Length of payload
64
      frmtype       : out std_logic_vector(15 downto 0); -- if non-null: type field instead length
65
 
66
      payload       : out std_logic_vector(7 downto 0);
67
      payload_vld   : out std_logic;
68
 
69
        -- Indicators
70
 
71
      is_vlan       : out std_logic;
72
      is_stack_vlan : out std_logic;
73
      is_pause      : out std_logic;
74
      crc_err       : out std_logic;
75
      prmbl_err     : out std_logic;
76
      len_err       : out std_logic;
77
      payload_err   : out std_logic;
78
      frame_err     : out std_logic;
79
      pause_op_err  : out std_logic;
80
      pause_dst_err : out std_logic;
81
      mac_err       : out std_logic;
82
      end_err       : out std_logic;
83
 
84
       -- Control
85
 
86
      jumbo_en      : in std_logic;
87
      data_only     : in std_logic;
88
 
89
        -- Receive indicator
90
 
91
      frm_rcvd     : out std_logic );
92
 
93
end ETHMONITOR2 ;
94
 
95
architecture behave of ETHMONITOR2 is
96
 
97
        -- GMII Monitor
98
 
99
        component ETHMONITOR port (
100
 
101
              reset         : in std_logic ;     -- active high
102
              tx_clk        : in std_logic ;
103
              txd           : in std_logic_vector(7 downto 0);
104
              tx_dv     : in std_logic;
105
              tx_er         : in std_logic;
106
              tx_sop        : in std_logic;
107
              tx_eop        : in std_logic;
108
              dst           : out std_logic_vector(47 downto 0); -- destination address
109
              src           : out std_logic_vector(47 downto 0); -- source address
110
              prmble_len    : out integer range 0 to 10000;         -- length of preamble
111
              pquant        : out std_logic_vector(15 downto 0); -- Pause Quanta value
112
              vlan_ctl      : out std_logic_vector(15 downto 0); -- VLAN control info
113
              len           : out std_logic_vector(15 downto 0); -- Length of payload
114
              frmtype       : out std_logic_vector(15 downto 0); -- if non-null: type field instead length
115
              payload       : out std_logic_vector(7 downto 0);
116
              payload_vld   : out std_logic;
117
              is_vlan       : out std_logic;
118
              is_stack_vlan : out std_logic;
119
              is_pause      : out std_logic;
120
              crc_err       : out std_logic;
121
              prmbl_err     : out std_logic;
122
              len_err       : out std_logic;
123
              payload_err   : out std_logic;
124
              frame_err     : out std_logic;
125
              pause_op_err  : out std_logic;
126
              pause_dst_err : out std_logic;
127
              mac_err       : out std_logic;
128
              end_err       : out std_logic;
129
              jumbo_en      : in std_logic;
130
              data_only     : in std_logic;
131
              frm_rcvd      : out std_logic );
132
 
133
        end component;
134
 
135
        signal clk_div2 : std_logic;
136
 
137
        -- Signals for GMII Monitor
138
 
139
        signal gmii_clk      : std_logic ;
140
        signal gmii_d        : std_logic_vector(7 downto 0);
141
        signal gmii_en       : std_logic;
142
        signal gmii_er       : std_logic;
143
 
144
        -- RGMII demultiplexed
145
 
146
        signal rgmii_d_f     : std_logic_vector(3 downto 0);
147
        signal rgmii_d       : std_logic_vector(7 downto 0);
148
        signal rgmii_en_int  : std_logic;
149
        signal rgmii_en      : std_logic;
150
        signal rgmii_er      : std_logic;
151
        signal rgmii_10_100_d   : std_logic_vector(7 downto 0);
152
        signal rgmii_10_100_d_lo: std_logic_vector(3 downto 0);
153
        signal rgmii_hi         : std_logic;
154
                signal rgmii_en_10_100_d: std_logic;
155
 
156
        -- MII demultiplexed
157
 
158
        signal mii_d_lo    : std_logic_vector(3 downto 0);  -- low nibble
159
        signal mii_d       : std_logic_vector(7 downto 0);
160
        signal mii_en      : std_logic;
161
        signal mii_er      : std_logic;
162
        signal mii_hi      : std_logic; -- hi nibble is on bus
163
 
164
        signal frm_rcvd_mon : std_logic;
165
        signal frm_rcvd_i   : std_logic;
166
 
167
 
168
begin
169
 
170
        -- demultiplex RGMII 
171
 
172
        process(reset, tx_clk )
173
        begin
174
                if(reset='1') then
175
 
176
                        rgmii_d_f     <= (others => '0');  -- falling edge
177
                        rgmii_d       <= (others => '0');  -- rising edge
178
                        rgmii_en      <= '0';
179
                        rgmii_en_int  <= '0';
180
                        rgmii_er      <= '0';
181
 
182
                elsif(tx_clk'event) then -- DDR
183
 
184
                        if( tx_clk='0') then
185
 
186
                                rgmii_d_f    <= txd(3 downto 0);     -- low nibble 
187
                                rgmii_en_int <= tx_dv;               -- dv in 1st half of clock
188
 
189
                        else
190
 
191
                                rgmii_d(7 downto 0) <= txd(3 downto 0) & rgmii_d_f;  -- high nibble on rising edge
192
                                rgmii_er  <= tx_dv xor rgmii_en_int;
193
                                rgmii_en  <= rgmii_en_int;            -- produce all on rising edge only
194
 
195
                        end if;
196
 
197
                end if;
198
 
199
        end process;
200
 
201
        --demultiplex rgmii 10/100  
202
        process(reset, tx_clk )
203
        begin
204
                if(reset='1') then
205
 
206
                        rgmii_10_100_d     <= (others => '0');  -- falling edge
207
                        rgmii_10_100_d_lo  <= (others => '0');  -- rising edge
208
                        rgmii_hi           <= '0';
209
                                rgmii_en_10_100_d  <= '0';
210
                elsif(tx_clk'event and tx_clk='1') then -- DDR
211
                   -- prepare that we can have a start at any clock cycle.
212
                                   rgmii_en_10_100_d <= rgmii_en;
213
 
214
                   if( tx_dv='0' and rgmii_en='0' ) then
215
 
216
                          rgmii_hi <= '0';
217
 
218
                   else
219
                          rgmii_hi <= not(rgmii_hi);
220
 
221
                   end if;
222
 
223
                   -- read two nibbles
224
 
225
                   if( rgmii_hi='0') then
226
 
227
                           rgmii_10_100_d_lo <= txd(3 downto 0);   -- low nibble first
228
 
229
                   else
230
 
231
                           rgmii_10_100_d(7 downto 0) <= (txd(3 downto 0) & rgmii_10_100_d_lo);-- after 0.5 ns;   -- hi nibble and all internal dv
232
 
233
                   end if;
234
                end if;
235
 
236
        end process;
237
 
238
        -- demultiplex MII 
239
 
240
        process(reset, tx_clk )
241
        begin
242
                if(reset='1') then
243
 
244
                        mii_d   <= (others => '0');
245
                        mii_d_lo<= (others => '0');  -- low nibble
246
                        mii_en  <= '0';
247
                        mii_er  <= '0';
248
                        mii_hi  <= '0';
249
 
250
                        frm_rcvd_i <= '0';
251
                        clk_div2   <= '0';
252
 
253
                elsif(tx_clk'event and tx_clk='1') then
254
 
255
                        clk_div2 <= not(clk_div2);
256
 
257
 
258
                        -- prepare that we can have a start at any clock cycle.
259
 
260
                        if( tx_dv='0' and mii_en='0' ) then
261
 
262
                               mii_hi <= '0';
263
 
264
                        else
265
                               mii_hi <= not(mii_hi);
266
 
267
                        end if;
268
 
269
                        -- read two nibbles
270
 
271
                        if( mii_hi='0') then
272
 
273
                                mii_d_lo <= txd(3 downto 0);   -- low nibble first
274
 
275
                        else
276
 
277
                                mii_d(7 downto 0) <= (txd(3 downto 0) & mii_d_lo) after 0.5 ns;   -- hi nibble and all internal dv
278
 
279
                                mii_en <= tx_dv after 0.5 ns;
280
                                mii_er <= tx_er after 0.5 ns;
281
 
282
                        end if;
283
 
284
                        -- frame received indication only for 1 clock cycle
285
 
286
                        if( frm_rcvd_mon='1' and frm_rcvd_i='0') then
287
 
288
                                frm_rcvd_i <= '1';
289
 
290
                        else
291
 
292
                                frm_rcvd_i <= '0';
293
 
294
                        end if;
295
 
296
 
297
                end if;
298
 
299
        end process;
300
 
301
    -- connect Model Signals
302
 
303
--    gmii_clk <= tx_clk  when mii_mode='0' else clk_div2;
304
 
305
        process (rgmii_mode, mii_mode,ethernet_speed,clk_div2, tx_clk )
306
          begin
307
 
308
          if( ethernet_speed ='0') then
309
                  if (rgmii_mode ='1'or mii_mode ='1') then
310
                  gmii_clk <= clk_div2;
311
                  end if;
312
          else
313
              if (rgmii_mode ='1' and  mii_mode ='0') then
314
                  gmii_clk <= tx_clk;
315
                  end if;
316
          end if;
317
 
318
    end process;
319
 
320
 
321
    gmii_d   <= rgmii_d when (rgmii_mode='1' and ethernet_speed ='1') else
322
                rgmii_10_100_d when (rgmii_mode='1' and ethernet_speed ='0') else
323
                mii_d   when mii_mode='1' else
324
                txd;
325
 
326
    gmii_en  <= rgmii_en when (rgmii_mode='1' and ethernet_speed ='1') else
327
                rgmii_en_10_100_d when (rgmii_mode='1' and ethernet_speed ='0') else
328
                mii_en   when (mii_mode='1' and ethernet_speed ='0') else
329
                tx_dv;
330
 
331
    gmii_er  <= rgmii_er when rgmii_mode='1' else
332
                mii_er   when mii_mode='1' else
333
                tx_er;
334
 
335
 
336
    frm_rcvd <= frm_rcvd_i when (mii_mode='1' or ethernet_speed ='0') else frm_rcvd_mon;
337
 
338
    -- connect GMII Monitor
339
    -- --------------------
340
 
341
   GMII_MON: ETHMONITOR port map (
342
 
343
      reset        => reset,         -- active high
344
      tx_clk       => gmii_clk,
345
      txd          => gmii_d,
346
      tx_dv        => gmii_en,
347
      tx_er        => gmii_er,
348
      tx_sop       => tx_sop,
349
      tx_eop       => tx_eop,
350
      dst          => dst  ,
351
      src          => src  ,
352
      prmble_len   => prmble_len,
353
      pquant       => pquant ,
354
      vlan_ctl     => vlan_ctl ,
355
      len          => len,
356
      frmtype      => frmtype,
357
      payload      => payload,
358
      payload_vld  => payload_vld,
359
      is_vlan      => is_vlan,
360
      is_stack_vlan=> is_stack_vlan,
361
      is_pause     => is_pause,
362
      crc_err      => crc_err,
363
      prmbl_err    => prmbl_err,
364
      len_err      => len_err,
365
      payload_err  => payload_err,
366
      frame_err    => frame_err,
367
      pause_op_err => pause_op_err,
368
      pause_dst_err=> pause_dst_err,
369
      mac_err      => mac_err,
370
      end_err      => end_err,
371
      jumbo_en     => jumbo_en,
372
      data_only    => data_only,
373
      frm_rcvd     => frm_rcvd_mon );
374
 
375
end behave;
376
 
377
 

powered by: WebSVN 2.1.0

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