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/] [core/] [eth_ahb_mst.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:      eth_ahb_mst
20
-- File:        eth_ahb_mst.vhd
21
-- Author:      Marko Isomaki - Gaisler Research
22
-- Description: Ethernet MAC AHB master interface
23
-------------------------------------------------------------------------------
24
library ieee;
25
use ieee.std_logic_1164.all;
26
library grlib;
27
use grlib.stdlib.all;
28
library eth;
29
use eth.grethpkg.all;
30
 
31
entity eth_ahb_mst is
32
  port(
33
    rst     : in  std_ulogic;
34
    clk     : in  std_ulogic;
35
    ahbmi   : in  ahbc_mst_in_type;
36
    ahbmo   : out ahbc_mst_out_type;
37
    tmsti   : in  eth_tx_ahb_in_type;
38
    tmsto   : out eth_tx_ahb_out_type;
39
    rmsti   : in  eth_rx_ahb_in_type;
40
    rmsto   : out eth_rx_ahb_out_type
41
  );
42
end entity;
43
 
44
architecture rtl of eth_ahb_mst is
45
  type reg_type is record
46
    bg     : std_ulogic; --bus granted
47
    bo     : std_ulogic; --bus owner, 0=rx, 1=tx
48
    ba     : std_ulogic; --bus active
49
    bb     : std_ulogic; --1kB burst boundary detected
50
    retry  : std_ulogic;
51
  end record;
52
 
53
  signal r, rin : reg_type;
54
begin
55
  comb : process(rst, r, tmsti, rmsti,  ahbmi) is
56
  variable v       : reg_type;
57
  variable htrans  : std_logic_vector(1 downto 0);
58
  variable hbusreq : std_ulogic;
59
  variable hwrite  : std_ulogic;
60
  variable haddr   : std_logic_vector(31 downto 0);
61
  variable hwdata  : std_logic_vector(31 downto 0);
62
  variable nbo     : std_ulogic;
63
  variable tretry  : std_ulogic;
64
  variable rretry  : std_ulogic;
65
  variable rready  : std_ulogic;
66
  variable tready  : std_ulogic;
67
  variable rerror  : std_ulogic;
68
  variable terror  : std_ulogic;
69
  variable tgrant  : std_ulogic;
70
  variable rgrant  : std_ulogic;
71
  begin
72
    v := r; htrans := HTRANS_IDLE; rready := '0'; tready := '0'; tretry := '0';
73
    rretry := '0'; rerror := '0'; terror := '0'; tgrant := '0'; rgrant := '0';
74
 
75
    if r.bo = '0' then hwdata := rmsti.data;
76
    else hwdata := tmsti.data; end if;
77
 
78
    hbusreq := tmsti.req or rmsti.req;
79
    if hbusreq = '1' then htrans := HTRANS_NONSEQ; end if;
80
 
81
    if r.retry = '0' then
82
      nbo := tmsti.req and not (rmsti.req and not r.bo);
83
    else
84
      nbo := r.bo;
85
    end if;
86
 
87
    if nbo = '0' then
88
      haddr := rmsti.addr; hwrite := rmsti.write;
89
      if (rmsti.req and r.ba and not r.bo and not r.retry) = '1' then
90
        htrans := HTRANS_SEQ;
91
      end if;
92
      if (rmsti.req and r.bg and ahbmi.hready and not r.retry) = '1'
93
      then rgrant := '1'; end if;
94
    else
95
      haddr := tmsti.addr; hwrite := tmsti.write;
96
      if (tmsti.req and r.ba and r.bo and not r.retry) = '1' then
97
        htrans := HTRANS_SEQ;
98
      end if;
99
      if (tmsti.req and r.bg and ahbmi.hready and not r.retry) = '1'
100
      then tgrant := '1'; end if;
101
    end if;
102
 
103
    --1 kB burst boundary
104
    if ahbmi.hready = '1' then
105
      if haddr(9 downto 2) = "11111111" then
106
        v.bb := '1';
107
      else
108
        v.bb := '0';
109
      end if;
110
    end if;
111
 
112
    if (r.bb = '1') and (htrans /= HTRANS_IDLE) then
113
      htrans := HTRANS_NONSEQ;
114
    end if;
115
 
116
    if r.bo = '0' then
117
      if r.ba = '1' then
118
        if ahbmi.hready = '1' then
119
          case ahbmi.hresp is
120
          when HRESP_OKAY => rready := '1';
121
          when HRESP_SPLIT | HRESP_RETRY => rretry := '1';
122
          when HRESP_ERROR => rerror := '1';
123
          when others => null;
124
          end case;
125
        end if;
126
      end if;
127
    else
128
      if r.ba = '1' then
129
        if ahbmi.hready = '1' then
130
          case ahbmi.hresp is
131
          when HRESP_OKAY => tready := '1';
132
          when HRESP_SPLIT | HRESP_RETRY => tretry := '1';
133
          when HRESP_ERROR => terror := '1';
134
          when others => null;
135
          end case;
136
        end if;
137
      end if;
138
    end if;
139
 
140
    if (r.ba = '1') and
141
       ((ahbmi.hresp = HRESP_RETRY) or (ahbmi.hresp = HRESP_SPLIT))
142
    then v.retry := not ahbmi.hready; else v.retry := '0'; end if;
143
 
144
    if r.retry = '1' then htrans := HTRANS_IDLE; end if;
145
 
146
    if ahbmi.hready = '1' then
147
      v.bo := nbo; v.bg := ahbmi.hgrant;
148
      if (htrans = HTRANS_NONSEQ) or (htrans = HTRANS_SEQ) then
149
        v.ba := r.bg;
150
      else
151
        v.ba := '0';
152
      end if;
153
    end if;
154
 
155
    if rst = '0' then
156
      v.bg := '0'; v.ba := '0'; v.bo := '0'; v.bb := '0';
157
    end if;
158
 
159
    rin <= v;
160
    tmsto.data     <= ahbmi.hrdata;
161
    rmsto.data     <= ahbmi.hrdata;
162
    tmsto.error    <= terror;
163
    tmsto.retry    <= tretry;
164
    tmsto.ready    <= tready;
165
    rmsto.error    <= rerror;
166
    rmsto.retry    <= rretry;
167
    rmsto.ready    <= rready;
168
    tmsto.grant    <= tgrant;
169
    rmsto.grant    <= rgrant;
170
    ahbmo.htrans   <= htrans;
171
    ahbmo.hbusreq  <= hbusreq;
172
    ahbmo.haddr    <= haddr;
173
    ahbmo.hwrite   <= hwrite;
174
    ahbmo.hwdata   <= hwdata;
175
  end process;
176
 
177
  regs : process(clk)
178
  begin
179
    if rising_edge(clk) then r <= rin; end if;
180
  end process;
181
 
182
  ahbmo.hlock    <= '0';
183
  ahbmo.hsize    <= HSIZE_WORD;
184
  ahbmo.hburst   <= HBURST_INCR;
185
  ahbmo.hprot    <= "0011";
186
end architecture;

powered by: WebSVN 2.1.0

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