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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [sparc/] [ahbram.vhd] - Blame information for rev 4

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) 2003 Gaisler Research
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:      ahbram
19
-- File:        ahbram.vhd
20
-- Author:      Jiri Gaisler - Gaisler Reserch
21
-- Description: AHB ram. 0-waitstate read, 0/1-waitstate write.
22
------------------------------------------------------------------------------
23
 
24
library IEEE;
25
use IEEE.std_logic_1164.all;
26
use IEEE.std_logic_unsigned.conv_integer;
27
use work.leon_target.all;
28
use work.leon_config.all;
29
use work.leon_iface.all;
30
use work.amba.all;
31
use work.tech_map.all;
32
 
33
entity ahbram is
34
  generic ( abits : integer := 10);
35
  port (
36
    rst    : in  std_logic;
37
    clk    : in  clk_type;
38
    ahbsi  : in  ahb_slv_in_type;
39
    ahbso  : out ahb_slv_out_type
40
  );
41
end;
42
 
43
architecture rtl of ahbram is
44
type reg_type is record
45
  hwrite : std_logic;
46
  hready : std_logic;
47
  hsel   : std_logic;
48
  addr   : std_logic_vector(abits+1 downto 0);
49
  size   : std_logic_vector(1 downto 0);
50
end record;
51
signal r, c : reg_type;
52
signal ramsel : std_logic;
53
signal write : std_logic_vector(3 downto 0);
54
signal ramaddr  : std_logic_vector(abits-1 downto 0);
55
begin
56
 
57
  comb : process (ahbsi, r, rst)
58
  variable bs : std_logic_vector(3 downto 0);
59
  variable v : reg_type;
60
  variable haddr  : std_logic_vector(abits-1 downto 0);
61
  begin
62
    v := r; v.hready := '1'; bs := (others => '0');
63
    if (r.hwrite or not r.hready) = '1' then haddr := r.addr(abits+1 downto 2);
64
    else
65
      haddr := ahbsi.haddr(abits+1 downto 2); bs := (others => '0');
66
    end if;
67
    if ahbsi.hready = '1' then
68
      v.hsel := ahbsi.hsel and ahbsi.htrans(1);
69
      v.hwrite := ahbsi.hwrite and v.hsel;
70
      v.addr := ahbsi.haddr(abits+1 downto 0);
71
      v.size := ahbsi.hsize(1 downto 0);
72
    end if;
73
    if r.hwrite = '1' then
74
      case r.size(1 downto 0) is
75
      when "00" => bs (conv_integer(r.addr(1 downto 0))) := '1';
76
      when "01" => bs := r.addr(1) & r.addr(1) & not (r.addr(1) & r.addr(1));
77
      when others => bs := (others => '1');
78
      end case;
79
      v.hready := not (v.hsel and not ahbsi.hwrite);
80
      v.hwrite := v.hwrite and v.hready;
81
    end if;
82
    if rst = '0' then v.hwrite := '0'; end if;
83
    write <= bs; ramsel <= v.hsel or r.hwrite; ahbso.hready <= r.hready;
84
    ramaddr <= haddr; c <= v;
85
  end process;
86
 
87
  ahbso.hresp <= "00"; ahbso.hsplit <= (others => '0');
88
 
89
  ra : for i in 0 to 3 generate
90
    aram :  syncram generic map (abits, 8) port map (
91
        ramaddr, clk, ahbsi.hwdata(i*8+7 downto i*8),
92
        ahbso.hrdata(i*8+7 downto i*8), ramsel, write(3-i));
93
  end generate;
94
 
95
  reg : process (clk)
96
  begin
97
    if rising_edge(clk ) then r <= c; end if;
98
  end process;
99
end;

powered by: WebSVN 2.1.0

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