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

Subversion Repositories minimips

[/] [minimips/] [trunk/] [miniMIPS/] [bench/] [ram.vhd] - Blame information for rev 17

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

Line No. Rev Author Line
1 2 poppy
------------------------------------------------------------------------------------
2
--                                                                                --
3
--    Copyright (c) 2004, Hangouet Samuel                                         --
4
--                  , Jan Sebastien                                               --
5
--                  , Mouton Louis-Marie                                          --
6
--                  , Schneider Olivier     all rights reserved                   --
7
--                                                                                --
8
--    This file is part of miniMIPS.                                              --
9
--                                                                                --
10
--    miniMIPS is free software; you can redistribute it and/or modify            --
11 6 poppy
--    it under the terms of the GNU Lesser General Public License as published by --
12
--    the Free Software Foundation; either version 2.1 of the License, or         --
13 2 poppy
--    (at your option) any later version.                                         --
14
--                                                                                --
15
--    miniMIPS is distributed in the hope that it will be useful,                 --
16
--    but WITHOUT ANY WARRANTY; without even the implied warranty of              --
17
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               --
18 6 poppy
--    GNU Lesser General Public License for more details.                         --
19 2 poppy
--                                                                                --
20 6 poppy
--    You should have received a copy of the GNU Lesser General Public License    --
21 2 poppy
--    along with miniMIPS; if not, write to the Free Software                     --
22
--    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   --
23
--                                                                                --
24
------------------------------------------------------------------------------------
25
 
26
 
27
-- If you encountered any problem, please contact :
28
--
29
--   lmouton@enserg.fr
30
--   oschneid@enserg.fr
31
--   shangoue@enserg.fr
32
--
33
 
34
 
35
 
36
library ieee;
37
use ieee.std_logic_1164.all;
38
use ieee.numeric_std.all;
39
 
40
library work;
41
use work.pack_mips.all;
42
 
43
entity ram is
44
   generic (mem_size : natural := 256;  -- Size of the memory in words
45
            latency : time := 0 ns);
46
   port(
47
       req         : in std_logic;
48
       adr         : in bus32;
49
       data_inout  : inout bus32;
50
       r_w         : in std_logic;
51
       ready       : out std_logic
52
   );
53
end;
54
 
55
 
56
architecture bench of ram is
57
    type storage_array is array(natural range 1024 to 1024+4*mem_size - 1) of bus8;
58
    signal storage : storage_array; -- The memory
59
begin
60
 
61
 
62
    process(adr, data_inout, r_w)
63
        variable inadr : integer;
64
        variable i : natural;
65
    begin
66
        inadr := to_integer(unsigned(adr));
67
 
68
        if (inadr>=storage'low) and (inadr<=storage'high) then
69
 
70
            ready <= '0', '1' after latency;
71
            if req = '1' then
72
                if r_w /= '1' then  -- Reading in memory
73
                    for i in 0 to 3 loop
74
                        data_inout(8*(i+1)-1 downto 8*i) <= storage(inadr+(3-i)) after latency;
75
                    end loop;
76
                else
77
                    for i in 0 to 3 loop
78
                        storage(inadr+(3-i)) <= data_inout(8*(i+1)-1 downto 8*i) after latency;
79
                    end loop;
80
                    data_inout <= (others => 'Z');
81
                end if;
82
            else
83
                data_inout <= (others => 'Z');
84
            end if;
85
        else
86
            data_inout <= (others => 'Z');
87
            ready <= 'L';
88
        end if;
89
    end process;
90
 
91
end bench;

powered by: WebSVN 2.1.0

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