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

powered by: WebSVN 2.1.0

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