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/] [eth/] [wrapper/] [greth_gen.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:      greth_gen
20
-- File:        greth_gen.vhd
21
-- Author:      Marko Isomaki 
22
-- Description: Generic Ethernet MAC 
23
------------------------------------------------------------------------------
24
library ieee;
25
library grlib;
26
use ieee.std_logic_1164.all;
27
use grlib.stdlib.all;
28
library techmap;
29
use techmap.gencomp.all;
30
library eth;
31
use eth.ethcomp.all;
32
 
33
entity greth_gen is
34
  generic(
35
    memtech        : integer := 0;
36
    ifg_gap        : integer := 24;
37
    attempt_limit  : integer := 16;
38
    backoff_limit  : integer := 10;
39
    mdcscaler      : integer range 0 to 255 := 25;
40
    enable_mdio    : integer range 0 to 1 := 0;
41
    fifosize       : integer range 4 to 64 := 8;
42
    nsync          : integer range 1 to 2 := 2;
43
    edcl           : integer range 0 to 1 := 0;
44
    edclbufsz      : integer range 1 to 64 := 1;
45
    macaddrh       : integer := 16#00005E#;
46
    macaddrl       : integer := 16#000000#;
47
    ipaddrh        : integer := 16#c0a8#;
48
    ipaddrl        : integer := 16#0035#;
49
    phyrstadr      : integer range 0 to 31 := 0;
50
    rmii           : integer range 0 to 1  := 0;
51
    oepol          : integer range 0 to 1  := 0;
52
    scanen         : integer range 0 to 1  := 0);
53
  port(
54
    rst            : in  std_ulogic;
55
    clk            : in  std_ulogic;
56
    --ahb mst in
57
    hgrant         : in  std_ulogic;
58
    hready         : in  std_ulogic;
59
    hresp          : in  std_logic_vector(1 downto 0);
60
    hrdata         : in  std_logic_vector(31 downto 0);
61
    --ahb mst out
62
    hbusreq        : out  std_ulogic;
63
    hlock          : out  std_ulogic;
64
    htrans         : out  std_logic_vector(1 downto 0);
65
    haddr          : out  std_logic_vector(31 downto 0);
66
    hwrite         : out  std_ulogic;
67
    hsize          : out  std_logic_vector(2 downto 0);
68
    hburst         : out  std_logic_vector(2 downto 0);
69
    hprot          : out  std_logic_vector(3 downto 0);
70
    hwdata         : out  std_logic_vector(31 downto 0);
71
    --apb slv in 
72
    psel           : in   std_ulogic;
73
    penable        : in   std_ulogic;
74
    paddr          : in   std_logic_vector(31 downto 0);
75
    pwrite         : in   std_ulogic;
76
    pwdata         : in   std_logic_vector(31 downto 0);
77
    --apb slv out
78
    prdata         : out  std_logic_vector(31 downto 0);
79
    --irq
80
    irq            : out  std_logic;
81
    --ethernet input signals
82
    rmii_clk       : in   std_ulogic;
83
    tx_clk         : in   std_ulogic;
84
    rx_clk         : in   std_ulogic;
85
    rxd            : in   std_logic_vector(3 downto 0);
86
    rx_dv          : in   std_ulogic;
87
    rx_er          : in   std_ulogic;
88
    rx_col         : in   std_ulogic;
89
    rx_crs         : in   std_ulogic;
90
    mdio_i         : in   std_ulogic;
91
    phyrstaddr     : in   std_logic_vector(4 downto 0);
92
    --ethernet output signals
93
    reset          : out  std_ulogic;
94
    txd            : out  std_logic_vector(3 downto 0);
95
    tx_en          : out  std_ulogic;
96
    tx_er          : out  std_ulogic;
97
    mdc            : out  std_ulogic;
98
    mdio_o         : out  std_ulogic;
99
    mdio_oe        : out  std_ulogic;
100
    --scantest
101
    testrst        : in   std_ulogic;
102
    testen         : in   std_ulogic
103
  );
104
end entity;
105
 
106
architecture rtl of greth_gen is
107
  function getfifosize(edcl, fifosize, ebufsize : in integer) return integer is
108
  begin
109
    if (edcl = 1) then
110
      return ebufsize;
111
    else
112
      return fifosize;
113
    end if;
114
  end function;
115
 
116
  constant fabits     : integer := log2(fifosize);
117
 
118
  type szvct is array (0 to 6) of integer;
119
  constant ebuf       : szvct   := (64, 128, 128, 256, 256, 256, 256);
120
  constant eabits     : integer := log2(edclbufsz) + 8;
121
  constant bufsize    : std_logic_vector(2 downto 0) :=
122
                       conv_std_logic_vector(log2(edclbufsz), 3);
123
  constant ebufsize   : integer := ebuf(log2(edclbufsz));
124
  constant txfifosize : integer := getfifosize(edcl, fifosize, ebufsize);
125
  constant txfabits   : integer := log2(txfifosize);
126
 
127
  --rx ahb fifo
128
  signal rxrenable    : std_ulogic;
129
  signal rxraddress   : std_logic_vector(10 downto 0);
130
  signal rxwrite      : std_ulogic;
131
  signal rxwdata      : std_logic_vector(31 downto 0);
132
  signal rxwaddress   : std_logic_vector(10 downto 0);
133
  signal rxrdata      : std_logic_vector(31 downto 0);
134
  --tx ahb fifo
135
  signal txrenable    : std_ulogic;
136
  signal txraddress   : std_logic_vector(10 downto 0);
137
  signal txwrite      : std_ulogic;
138
  signal txwdata      : std_logic_vector(31 downto 0);
139
  signal txwaddress   : std_logic_vector(10 downto 0);
140
  signal txrdata      : std_logic_vector(31 downto 0);
141
  --edcl buf     
142
  signal erenable     : std_ulogic;
143
  signal eraddress    : std_logic_vector(15 downto 0);
144
  signal ewritem      : std_ulogic;
145
  signal ewritel      : std_ulogic;
146
  signal ewaddressm   : std_logic_vector(15 downto 0);
147
  signal ewaddressl   : std_logic_vector(15 downto 0);
148
  signal ewdata       : std_logic_vector(31 downto 0);
149
  signal erdata       : std_logic_vector(31 downto 0);
150
 
151
begin
152
  ethc0: grethc
153
    generic map(
154
      ifg_gap        => ifg_gap,
155
      attempt_limit  => attempt_limit,
156
      backoff_limit  => backoff_limit,
157
      mdcscaler      => mdcscaler,
158
      enable_mdio    => enable_mdio,
159
      fifosize       => fifosize,
160
      nsync          => nsync,
161
      edcl           => edcl,
162
      edclbufsz      => edclbufsz,
163
      macaddrh       => macaddrh,
164
      macaddrl       => macaddrl,
165
      ipaddrh        => ipaddrh,
166
      ipaddrl        => ipaddrl,
167
      phyrstadr      => phyrstadr,
168
      rmii           => rmii,
169
      oepol          => oepol,
170
      scanen         => scanen)
171
    port map(
172
      rst            => rst,
173
      clk            => clk,
174
      --ahb mst in
175
      hgrant         => hgrant,
176
      hready         => hready,
177
      hresp          => hresp,
178
      hrdata         => hrdata,
179
      --ahb mst out
180
      hbusreq        => hbusreq,
181
      hlock          => hlock,
182
      htrans         => htrans,
183
      haddr          => haddr,
184
      hwrite         => hwrite,
185
      hsize          => hsize,
186
      hburst         => hburst,
187
      hprot          => hprot,
188
      hwdata         => hwdata,
189
      --apb slv in 
190
      psel           => psel,
191
      penable        => penable,
192
      paddr          => paddr,
193
      pwrite         => pwrite,
194
      pwdata         => pwdata,
195
      --apb slv out
196
      prdata         => prdata,
197
      --irq
198
      irq            => irq,
199
      --rx ahb fifo
200
      rxrenable      => rxrenable,
201
      rxraddress     => rxraddress,
202
      rxwrite        => rxwrite,
203
      rxwdata        => rxwdata,
204
      rxwaddress     => rxwaddress,
205
      rxrdata        => rxrdata,
206
      --tx ahb fifo  
207
      txrenable      => txrenable,
208
      txraddress     => txraddress,
209
      txwrite        => txwrite,
210
      txwdata        => txwdata,
211
      txwaddress     => txwaddress,
212
      txrdata        => txrdata,
213
      --edcl buf     
214
      erenable       => erenable,
215
      eraddress      => eraddress,
216
      ewritem        => ewritem,
217
      ewritel        => ewritel,
218
      ewaddressm     => ewaddressm,
219
      ewaddressl     => ewaddressl,
220
      ewdata         => ewdata,
221
      erdata         => erdata,
222
      --ethernet input signals
223
      rmii_clk       => rmii_clk,
224
      tx_clk         => tx_clk,
225
      rx_clk         => rx_clk,
226
      rxd            => rxd(3 downto 0),
227
      rx_dv          => rx_dv,
228
      rx_er          => rx_er,
229
      rx_col         => rx_col,
230
      rx_crs         => rx_crs,
231
      mdio_i         => mdio_i,
232
      phyrstaddr     => phyrstaddr,
233
      --ethernet output signals
234
      reset          => reset,
235
      txd            => txd(3 downto 0),
236
      tx_en          => tx_en,
237
      tx_er          => tx_er,
238
      mdc            => mdc,
239
      mdio_o         => mdio_o,
240
      mdio_oe        => mdio_oe,
241
      --scantest     
242
      testrst        => testrst,
243
      testen         => testen);
244
 
245
-------------------------------------------------------------------------------
246
-- FIFOS ----------------------------------------------------------------------
247
-------------------------------------------------------------------------------
248
  tx_fifo0 : syncram_2p generic map(tech => memtech, abits => txfabits,
249
    dbits => 32, sepclk => 0)
250
    port map(clk, txrenable, txraddress(txfabits-1 downto 0), txrdata, clk,
251
    txwrite, txwaddress(txfabits-1 downto 0), txwdata);
252
 
253
  rx_fifo0 : syncram_2p generic map(tech => memtech, abits => fabits,
254
    dbits => 32, sepclk => 0)
255
    port map(clk, rxrenable, rxraddress(fabits-1 downto 0), rxrdata, clk,
256
    rxwrite, rxwaddress(fabits-1 downto 0), rxwdata);
257
 
258
-------------------------------------------------------------------------------
259
-- EDCL buffer ram ------------------------------------------------------------
260
-------------------------------------------------------------------------------
261
  edclram : if (edcl = 1) generate
262
    rloopm : for i in 0 to 1 generate
263
      r0 : syncram_2p generic map (memtech, eabits, 8) port map(
264
        clk, erenable, eraddress(eabits-1 downto 0), erdata(i*8+23 downto i*8+16), clk,
265
        ewritem, ewaddressm(eabits-1 downto 0), ewdata(i*8+23 downto i*8+16));
266
    end generate;
267
    rloopl : for i in 0 to 1 generate
268
      r0 : syncram_2p generic map (memtech, eabits, 8) port map(
269
        clk, erenable, eraddress(eabits-1 downto 0), erdata(i*8+7 downto i*8), clk,
270
        ewritel, ewaddressl(eabits-1 downto 0), ewdata(i*8+7 downto i*8));
271
    end generate;
272
  end generate;
273
 
274
end architecture;

powered by: WebSVN 2.1.0

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