OpenCores
URL https://opencores.org/ocsvn/vhdl-pipeline-mips/vhdl-pipeline-mips/trunk

Subversion Repositories vhdl-pipeline-mips

[/] [vhdl-pipeline-mips/] [trunk/] [4_memory_access/] [data_memory.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 elujan
--
2
-- Memoria de datos del procesador MIPS Segmentado
3
--
4
-- Licencia: Copyright 2008 Emmanuel Luján
5
--
6
--      This program is free software; you can redistribute it and/or
7
--      modify it under the terms of the GNU General Public License as
8
--      published by the Free Software Foundation; either version 2 of
9
--      the License, or (at your option) any later version. This program
10
--      is distributed in the hope that it will be useful, but WITHOUT
11
--      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
--      or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13
--      License for more details. You should have received a copy of the
14
--      GNU General Public License along with this program; if not, write
15
--      to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
16
--      Boston, MA 02110-1301 USA.
17
-- 
18
-- Autor:       Emmanuel Luján
19
-- Email:       info@emmanuellujan.com.ar
20
-- Versión:    1.0
21
--
22
 
23
library std;
24
use std.textio.all;
25
 
26
library ieee;
27
use ieee.std_logic_1164.all;
28
use ieee.numeric_std.all;
29
 
30
library work;
31
use work.segm_mips_const_pkg.all;
32
 
33
 
34
entity DATA_MEMORY is
35
        generic (N :NATURAL; M :NATURAL); -- N = tam. dir. M = tamaño de la memoria
36
        port(
37
                RESET           :       in  STD_LOGIC;                          --Reset asincrónico
38
                ADDR            :       in  STD_LOGIC_VECTOR (N-1 downto 0);     --Dirección a ser leida o escrita
39
                WRITE_DATA      :       in  STD_LOGIC_VECTOR (N-1 downto 0);     --Datos a ser escritos
40
                MemRead         :       in  STD_LOGIC;                          --Señal de habilitación para lectura
41
                MemWrite        :       in  STD_LOGIC;                          --Señal de habilitación para escritura
42
                READ_DATA       :       out STD_LOGIC_VECTOR (N-1 downto 0)      --Datos leidos
43
        );
44
end DATA_MEMORY;
45
 
46
 
47
architecture DATA_MEMORY_ARC of DATA_MEMORY is
48
 
49
        type MEM_T is array (M-1 downto 0) of STD_LOGIC_VECTOR (N-1 downto 0);
50
        signal MEM : MEM_T;
51
 
52
begin
53
 
54
        MEM_PROC:
55
                process(RESET,MemWrite,MemRead,WRITE_DATA,MEM,ADDR)
56
                begin
57
                        if (RESET = '1') then -- Reset Asincrónico
58
                                for i in 0 to M-1 loop
59
                                        MEM(i) <= (others => '1');
60
                                end loop;
61
                         -- Ejecuto las ordenes de la unidad de control:
62
                        elsif MemWrite='1' then -- O bien escribo en la memoria
63
                                MEM(to_integer(unsigned( ADDR(9 downto 0) ))) <= WRITE_DATA;
64
                        elsif MemRead='1' then -- O bien leo de ella
65
                                READ_DATA <= MEM(to_integer(unsigned( ADDR(9 downto 0) )));
66
                        end if;
67
                end process MEM_PROC;
68
 
69
end DATA_MEMORY_ARC;

powered by: WebSVN 2.1.0

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