OpenCores
URL https://opencores.org/ocsvn/core_arm/core_arm/trunk

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [sparc/] [ahbmst.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
 
2
 
3
 
4
 
5
----------------------------------------------------------------------------
6
--  This file is a part of the LEON VHDL model
7
--  Copyright (C) 1999  European Space Agency (ESA)
8
--
9
--  This library is free software; you can redistribute it and/or
10
--  modify it under the terms of the GNU Lesser General Public
11
--  License as published by the Free Software Foundation; either
12
--  version 2 of the License, or (at your option) any later version.
13
--
14
--  See the file COPYING.LGPL for the full details of the license.
15
 
16
 
17
-----------------------------------------------------------------------------   
18
-- Entity:      ahbmst
19
-- File:        ahbmst.vhd
20
-- Author:      Jiri Gaisler - Gaisler Research
21
-- Description: Simple AHB master interface
22
------------------------------------------------------------------------------  
23
 
24
library IEEE;
25
use IEEE.std_logic_1164.all;
26
use IEEE.std_logic_unsigned."+";
27
use IEEE.std_logic_arith.conv_unsigned;
28
 
29
use work.amba.all;
30
use work.leon_iface.all;
31
use work.macro.all;
32
 
33
 
34
entity ahbmst is
35
  generic (incaddr : integer := 0);
36
   port (
37
      rst  : in  std_logic;
38
      clk  : in  clk_type;
39
      dmai : in ahb_dma_in_type;
40
      dmao : out ahb_dma_out_type;
41
      ahbi : in  ahb_mst_in_type;
42
      ahbo : out ahb_mst_out_type
43
      );
44
end;
45
 
46
architecture rtl of ahbmst is
47
 
48
type reg_type is record
49
  start   : std_logic;
50
  retry   : std_logic;
51
  grant   : std_logic;
52
  active  : std_logic;
53
end record;
54
 
55
signal r, rin : reg_type;
56
 
57
begin
58
 
59
  comb : process(ahbi, dmai, rst, r)
60
  variable v       : reg_type;
61
  variable ready   : std_logic;
62
  variable retry   : std_logic;
63
  variable mexc    : std_logic;
64
  variable inc     : std_logic_vector(3 downto 0);    -- address increment
65
 
66
  variable haddr   : std_logic_vector(31 downto 0);   -- AHB address
67
  variable hwdata  : std_logic_vector(31 downto 0);   -- AHB write data
68
  variable htrans  : std_logic_vector(1 downto 0);    -- transfer type 
69
  variable hwrite  : std_logic;                       -- read/write
70
  variable hburst  : std_logic_vector(2 downto 0);    -- burst type
71
  variable newaddr : std_logic_vector(9 downto 0); -- next sequential address
72
  variable hbusreq : std_logic;   -- bus request
73
  begin
74
 
75
    v := r; ready := '0'; mexc := '0'; retry := '0';
76
 
77
    haddr := dmai.address; hbusreq := dmai.start; hwdata := dmai.wdata;
78
    newaddr := dmai.address(9 downto 0);
79
 
80
    inc := decode(dmai.size);
81
 
82
    if incaddr > 0 then
83
-- pragma translate_off
84
      if not is_x(haddr(9 downto 0)) then
85
-- pragma translate_on
86
        newaddr := haddr(9 downto 0) + inc(2 downto 0);
87
-- pragma translate_off
88
      end if;
89
-- pragma translate_on
90
    end if;
91
 
92
    if dmai.burst = '1' then hburst := HBURST_INCR;
93
    else hburst := HBURST_SINGLE; end if;
94
 
95
    if dmai.start = '1' then
96
      if (r.active and dmai.burst and not r.retry) = '1' then
97
        htrans := HTRANS_SEQ; hburst := HBURST_INCR;
98
        haddr(9 downto 0) := newaddr;
99
      else htrans := HTRANS_NONSEQ; end if;
100
    else htrans := HTRANS_IDLE; end if;
101
 
102
    if r.active = '1' then
103
      if ahbi.hready = '1' then
104
        case ahbi.hresp is
105
        when HRESP_OKAY => ready := '1';
106
        when HRESP_RETRY | HRESP_SPLIT=> retry := '1';
107
        when others => ready := '1'; mexc := '1';
108
        end case;
109
      end if;
110
      if ((ahbi.hresp = HRESP_RETRY) or (ahbi.hresp = HRESP_SPLIT)) then
111
        v.retry := not ahbi.hready;
112
      else v.retry := '0'; end if;
113
    end if;
114
 
115
    if r.retry = '1' then htrans := HTRANS_IDLE; end if;
116
 
117
    v.start := '0';
118
    if ahbi.hready = '1' then
119
      v.grant := ahbi.hgrant;
120
      if (htrans = HTRANS_NONSEQ) or (htrans = HTRANS_SEQ) then
121
        v.active := r.grant; v.start := r.grant;
122
      else
123
        v.active := '0';
124
      end if;
125
    end if;
126
 
127
 
128
    if rst = '0' then v.retry := '0'; v.active := '0'; end if;
129
 
130
    rin <= v;
131
 
132
    ahbo.haddr   <= haddr;
133
    ahbo.htrans  <= htrans;
134
    ahbo.hbusreq <= hbusreq;
135
    ahbo.hwdata  <= dmai.wdata;
136
    ahbo.hlock   <= '0';
137
    ahbo.hwrite  <= dmai.write;
138
    ahbo.hsize   <= '0' & dmai.size;
139
    ahbo.hburst  <= hburst;
140
    ahbo.hprot   <= "0011";     -- non-cached supervisor data
141
 
142
    dmao.start   <= r.start;
143
    dmao.active  <= r.active;
144
    dmao.ready   <= ready;
145
    dmao.mexc    <= mexc;
146
    dmao.retry   <= retry;
147
    dmao.haddr   <= newaddr;
148
    dmao.rdata   <= ahbi.hrdata;
149
 
150
  end process;
151
 
152
 
153
    regs : process(clk)
154
    begin if rising_edge(clk) then r <= rin; end if; end process;
155
 
156
 
157
 
158
end;

powered by: WebSVN 2.1.0

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