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/] [misc/] [ahbmst.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:      ahbmst
20
-- File:        ahbmst.vhd
21
-- Author:      Jiri Gaisler - Gaisler Research
22
-- Description: Generic AHB master interface
23
------------------------------------------------------------------------------  
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
library grlib;
28
use grlib.amba.all;
29
use grlib.stdlib.all;
30
use grlib.devices.all;
31
library gaisler;
32
use gaisler.misc.all;
33
 
34
entity ahbmst is
35
  generic (
36
    hindex  : integer := 0;
37
    hirq    : integer := 0;
38
    venid   : integer := VENDOR_GAISLER;
39
    devid   : integer := 0;
40
    version : integer := 0;
41
    chprot  : integer := 3;
42
    incaddr : integer := 0);
43
   port (
44
      rst  : in  std_ulogic;
45
      clk  : in  std_ulogic;
46
      dmai : in ahb_dma_in_type;
47
      dmao : out ahb_dma_out_type;
48
      ahbi : in  ahb_mst_in_type;
49
      ahbo : out ahb_mst_out_type
50
      );
51
end;
52
 
53
architecture rtl of ahbmst is
54
 
55
constant hconfig : ahb_config_type := (
56
 
57
  others => zero32);
58
 
59
type reg_type is record
60
  start   : std_ulogic;
61
  retry   : std_ulogic;
62
  grant   : std_ulogic;
63
  active  : std_ulogic;
64
end record;
65
 
66
signal r, rin : reg_type;
67
 
68
begin
69
 
70
  comb : process(ahbi, dmai, rst, r)
71
  variable v       : reg_type;
72
  variable ready   : std_ulogic;
73
  variable retry   : std_ulogic;
74
  variable mexc    : std_ulogic;
75
  variable inc     : std_logic_vector(3 downto 0);    -- address increment
76
 
77
  variable haddr   : std_logic_vector(31 downto 0);   -- AHB address
78
  variable hwdata  : std_logic_vector(31 downto 0);   -- AHB write data
79
  variable htrans  : std_logic_vector(1 downto 0);    -- transfer type
80
  variable hwrite  : std_ulogic;                      -- read/write
81
  variable hburst  : std_logic_vector(2 downto 0);    -- burst type
82
  variable newaddr : std_logic_vector(9 downto 0); -- next sequential address
83
  variable hbusreq : std_ulogic;   -- bus request
84
  variable hprot   : std_logic_vector(3 downto 0);    -- transfer type 
85
  variable xhirq    : std_logic_vector(NAHBIRQ-1 downto 0);
86
  begin
87
 
88
    v := r; ready := '0'; mexc := '0'; retry := '0'; inc := (others => '0');
89
    hprot := conv_std_logic_vector(chprot, 4); -- non-cached supervisor data
90
    xhirq := (others => '0'); xhirq(hirq) := dmai.irq;
91
 
92
    haddr := dmai.address; hbusreq := dmai.start; hwdata := dmai.wdata;
93
    newaddr := dmai.address(9 downto 0);
94
 
95
    if INCADDR > 0 then
96
      inc(conv_integer(dmai.size)) := '1';
97
      newaddr := haddr(9 downto 0) + inc;
98
    end if;
99
 
100
    if dmai.burst = '0' then hburst := HBURST_SINGLE;
101
    else hburst := HBURST_INCR; end if;
102
    if dmai.start = '1' then
103
      if (r.active and dmai.burst and not r.retry) = '1' then
104
        haddr(9 downto 0) := newaddr;
105
        if dmai.busy = '1' then htrans := HTRANS_BUSY;
106
        else htrans := HTRANS_SEQ; end if;
107
        hburst := HBURST_INCR;
108
      else htrans := HTRANS_NONSEQ; end if;
109
    else htrans := HTRANS_IDLE; end if;
110
 
111
    if r.active = '1' then
112
      if ahbi.hready = '1' then
113
        case ahbi.hresp is
114
        when HRESP_OKAY => ready := '1';
115
        when HRESP_RETRY | HRESP_SPLIT=> retry := '1';
116
        when others => ready := '1'; mexc := '1';
117
        end case;
118
      end if;
119
      if ((ahbi.hresp = HRESP_RETRY) or (ahbi.hresp = HRESP_SPLIT)) then
120
        v.retry := not ahbi.hready;
121
      else v.retry := '0'; end if;
122
    end if;
123
 
124
    if r.retry = '1' then htrans := HTRANS_IDLE; end if;
125
 
126
    v.start := '0';
127
    if ahbi.hready = '1' then
128
      v.grant := ahbi.hgrant(hindex);
129
      if (htrans = HTRANS_NONSEQ) or (htrans = HTRANS_SEQ) or (htrans = HTRANS_BUSY) then
130
        v.active := r.grant; v.start := r.grant;
131
      else
132
        v.active := '0';
133
      end if;
134
    end if;
135
 
136
    if rst = '0' then v.retry := '0'; v.active := '0'; end if;
137
 
138
    rin <= v;
139
 
140
    ahbo.haddr   <= haddr;
141
    ahbo.htrans  <= htrans;
142
    ahbo.hbusreq <= hbusreq;
143
    ahbo.hwdata  <= dmai.wdata;
144
    ahbo.hconfig <= hconfig;
145
    ahbo.hlock   <= '0';
146
    ahbo.hwrite  <= dmai.write;
147
    ahbo.hsize   <= '0' & dmai.size;
148
    ahbo.hburst  <= hburst;
149
    ahbo.hprot   <= hprot;
150
    ahbo.hirq    <= xhirq;
151
    ahbo.hindex  <= hindex;
152
 
153
    dmao.start   <= r.start;
154
    dmao.active  <= r.active;
155
    dmao.ready   <= ready;
156
    dmao.mexc    <= mexc;
157
    dmao.retry   <= retry;
158
    dmao.haddr   <= newaddr;
159
    dmao.rdata   <= ahbi.hrdata;
160
 
161
  end process;
162
 
163
    regs : process(clk)
164
    begin if rising_edge(clk) then r <= rin; end if; end process;
165
 
166
end;

powered by: WebSVN 2.1.0

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