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_gbit.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_gbit
20
-- File:        greth_gbit.vhd
21
-- Author:      Marko Isomaki 
22
-- Description: Gigabit 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_gbit 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
    nsync          : integer range 1 to 2 := 2;
54
    edcl           : integer range 0 to 1 := 0;
55
    edclbufsz      : integer range 1 to 64 := 1;
56
    burstlength    : integer range 4 to 128 := 32;
57
    macaddrh       : integer := 16#00005E#;
58
    macaddrl       : integer := 16#000000#;
59
    ipaddrh        : integer := 16#c0a8#;
60
    ipaddrl        : integer := 16#0035#;
61
    phyrstadr      : integer range 0 to 32 := 0;
62
    sim            : integer range 0 to 1 := 0;
63
    oepol          : integer range 0 to 1 := 0;
64
    scanen         : integer range 0 to 1 := 0);
65
  port(
66
    rst            : in  std_ulogic;
67
    clk            : in  std_ulogic;
68
    ahbmi          : in  ahb_mst_in_type;
69
    ahbmo          : out ahb_mst_out_type;
70
    apbi           : in  apb_slv_in_type;
71
    apbo           : out apb_slv_out_type;
72
    ethi           : in  eth_in_type;
73
    etho           : out eth_out_type
74
  );
75
end entity;
76
 
77
architecture rtl of greth_gbit is
78
  --host constants
79
  constant fifosize        : integer := 512;
80
  constant fabits          : integer := log2(fifosize);
81
  constant fsize           : std_logic_vector(fabits downto 0) :=
82
    conv_std_logic_vector(fifosize, fabits+1);
83
 
84
  constant REVISION : amba_version_type := 0;
85
 
86
  constant pconfig : apb_config_type := (
87
 
88
  1 => apb_iobar(paddr, pmask));
89
 
90
  constant hconfig : ahb_config_type := (
91
 
92
  others => zero32);
93
 
94
  --edcl constants
95
  type szvct is array (0 to 6) of integer;
96
  constant ebuf : szvct := (64, 128, 128, 256, 256, 256, 256);
97
  constant eabits: integer := log2(edclbufsz) + 8;
98
  constant ebufsize : integer := ebuf(log2(edclbufsz));
99
 
100
  signal irq : std_ulogic;
101
 
102
  --rx ahb fifo
103
  signal rxrenable      : std_ulogic;
104
  signal rxraddress     : std_logic_vector(8 downto 0);
105
  signal rxwrite        : std_ulogic;
106
  signal rxwdata        : std_logic_vector(31 downto 0);
107
  signal rxwaddress     : std_logic_vector(8 downto 0);
108
  signal rxrdata        : std_logic_vector(31 downto 0);
109
  --tx ahb fifo  
110
  signal txrenable      : std_ulogic;
111
  signal txraddress     : std_logic_vector(8 downto 0);
112
  signal txwrite        : std_ulogic;
113
  signal txwdata        : std_logic_vector(31 downto 0);
114
  signal txwaddress     : std_logic_vector(8 downto 0);
115
  signal txrdata        : std_logic_vector(31 downto 0);
116
  --edcl buf     
117
  signal erenable       : std_ulogic;
118
  signal eraddress      : std_logic_vector(15 downto 0);
119
  signal ewritem        : std_ulogic;
120
  signal ewritel        : std_ulogic;
121
  signal ewaddressm     : std_logic_vector(15 downto 0);
122
  signal ewaddressl     : std_logic_vector(15 downto 0);
123
  signal ewdata         : std_logic_vector(31 downto 0);
124
  signal erdata         : std_logic_vector(31 downto 0);
125
 
126
begin
127
  gtxc0: greth_gbitc
128
    generic map(
129
      ifg_gap        => ifg_gap,
130
      attempt_limit  => attempt_limit,
131
      backoff_limit  => backoff_limit,
132
      slot_time      => slot_time,
133
      mdcscaler      => mdcscaler,
134
      nsync          => nsync,
135
      edcl           => edcl,
136
      edclbufsz      => edclbufsz,
137
      burstlength    => burstlength,
138
      macaddrh       => macaddrh,
139
      macaddrl       => macaddrl,
140
      ipaddrh        => ipaddrh,
141
      ipaddrl        => ipaddrl,
142
      phyrstadr      => phyrstadr,
143
      sim            => sim,
144
      oepol          => oepol,
145
      scanen         => scanen)
146
    port map(
147
      rst            => rst,
148
      clk            => clk,
149
      --ahb mst in   
150
      hgrant         => ahbmi.hgrant(hindex),
151
      hready         => ahbmi.hready,
152
      hresp          => ahbmi.hresp,
153
      hrdata         => ahbmi.hrdata,
154
      --ahb mst out  
155
      hbusreq        => ahbmo.hbusreq,
156
      hlock          => ahbmo.hlock,
157
      htrans         => ahbmo.htrans,
158
      haddr          => ahbmo.haddr,
159
      hwrite         => ahbmo.hwrite,
160
      hsize          => ahbmo.hsize,
161
      hburst         => ahbmo.hburst,
162
      hprot          => ahbmo.hprot,
163
      hwdata         => ahbmo.hwdata,
164
      --apb slv in 
165
      psel           => apbi.psel(pindex),
166
      penable        => apbi.penable,
167
      paddr          => apbi.paddr,
168
      pwrite         => apbi.pwrite,
169
      pwdata         => apbi.pwdata,
170
      --apb slv out
171
      prdata         => apbo.prdata,
172
      --irq
173
      irq            => irq,
174
      --rx ahb fifo
175
      rxrenable      => rxrenable,
176
      rxraddress     => rxraddress,
177
      rxwrite        => rxwrite,
178
      rxwdata        => rxwdata,
179
      rxwaddress     => rxwaddress,
180
      rxrdata        => rxrdata,
181
      --tx ahb fifo  
182
      txrenable      => txrenable,
183
      txraddress     => txraddress,
184
      txwrite        => txwrite,
185
      txwdata        => txwdata,
186
      txwaddress     => txwaddress,
187
      txrdata        => txrdata,
188
      --edcl buf
189
      erenable       => erenable,
190
      eraddress      => eraddress,
191
      ewritem        => ewritem,
192
      ewritel        => ewritel,
193
      ewaddressm     => ewaddressm,
194
      ewaddressl     => ewaddressl,
195
      ewdata         => ewdata,
196
      erdata         => erdata,
197
      --ethernet input signals
198
      gtx_clk        => ethi.gtx_clk,
199
      tx_clk         => ethi.tx_clk,
200
      rx_clk         => ethi.rx_clk,
201
      rxd            => ethi.rxd,
202
      rx_dv          => ethi.rx_dv,
203
      rx_er          => ethi.rx_er,
204
      rx_col         => ethi.rx_col,
205
      rx_crs         => ethi.rx_crs,
206
      mdio_i         => ethi.mdio_i,
207
      phyrstaddr     => ethi.phyrstaddr,
208
      --ethernet output signals
209
      reset          => etho.reset,
210
      txd            => etho.txd,
211
      tx_en          => etho.tx_en,
212
      tx_er          => etho.tx_er,
213
      mdc            => etho.mdc,
214
      mdio_o         => etho.mdio_o,
215
      mdio_oe        => etho.mdio_oe,
216
      --scantest     
217
      testrst        => ahbmi.testrst,
218
      testen         => ahbmi.testen);
219
 
220
  irqdrv : process(irq)
221
  begin
222
    apbo.pirq       <= (others => '0');
223
    apbo.pirq(pirq) <= irq;
224
  end process;
225
 
226
  ahbmo.hconfig <= hconfig;
227
  ahbmo.hindex  <= hindex;
228
  ahbmo.hirq    <= (others => '0');
229
 
230
  apbo.pconfig  <= pconfig;
231
  apbo.pindex   <= pindex;
232
-------------------------------------------------------------------------------
233
-- FIFOS ----------------------------------------------------------------------
234
-------------------------------------------------------------------------------
235
  tx_fifo0 : syncram_2p generic map(tech => memtech, abits => fabits,
236
    dbits => 32, sepclk => 0)
237
    port map(clk, txrenable, txraddress(fabits-1 downto 0), txrdata, clk,
238
    txwrite, txwaddress(fabits-1 downto 0), txwdata);
239
 
240
  rx_fifo0 : syncram_2p generic map(tech => memtech, abits => fabits,
241
    dbits => 32, sepclk => 0)
242
    port map(clk, rxrenable, rxraddress(fabits-1 downto 0), rxrdata, clk,
243
    rxwrite, rxwaddress(fabits-1 downto 0), rxwdata);
244
 
245
-------------------------------------------------------------------------------
246
-- EDCL buffer ram ------------------------------------------------------------
247
-------------------------------------------------------------------------------
248
  edclram : if (edcl = 1) generate
249
    r0 : syncram_2p generic map (memtech, eabits, 16) port map (
250
      clk, erenable, eraddress(eabits-1 downto 0), erdata(31 downto 16), clk,
251
      ewritem, ewaddressm(eabits-1 downto 0), ewdata(31 downto 16));
252
    r1 : syncram_2p generic map (memtech, eabits, 16) port map (
253
      clk, erenable, eraddress(eabits-1 downto 0), erdata(15 downto 0), clk,
254
      ewritel, ewaddressl(eabits-1 downto 0), ewdata(15 downto 0));
255
  end generate;
256
 
257
-- pragma translate_off
258
  bootmsg : report_version
259
  generic map (
260
    "greth" & tost(hindex) & ": 10/100/1000 Mbit Ethernet MAC rev " &
261
    tost(REVISION) & tost(hindex) & ", EDCL " & tost(edcl) & ", buffer " &
262
    tost(edclbufsz*edcl) & " kbyte " & tost(fifosize) & " txfifo, " &
263
    " irq " & tost(pirq)
264
  );
265
-- pragma translate_on
266
 
267
end architecture;

powered by: WebSVN 2.1.0

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