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

Subversion Repositories usimplez

[/] [usimplez/] [trunk/] [QuartusII/] [usimplez_ram.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 pas.
--//////////////////////////////////////////////////////////////////////
2
--////                                                                                                                          ////
3
--////                                                                                                                          ////
4
--////                                                                                                                          ////
5
--//// This file is part of the MicroSimplez project                            ////
6
--//// http://opencores.org/project,usimplez                                            ////
7
--////                                                                                                                          ////
8
--//// Description                                                                                                      ////
9
--//// Implementation of MicroSimplez IP core according to                      ////
10
--//// MicroSimplez IP core specification document.                             ////
11
--////                                                                                                                          ////
12
--//// To Do:                                                                                                           ////
13
--//// -                                                                                                                        ////
14
--////                                                                                                                          ////
15
--//// Author(s):                                                                                                       ////
16
--//// - Daniel Peralta, peraltahd@opencores.org, designer                      ////
17
--//// - Martin Montero, monteromrtn@opencores.org, designer            ////
18
--//// - Julian Castro, julyan@opencores.org, reviewer                          ////
19
--//// - Pablo A. Salvadeo,     pas.@opencores, manager                                 ////
20
--////                                                                                                                          ////
21
--//////////////////////////////////////////////////////////////////////
22
--////                                                                                                                          ////
23
--//// Copyright (C) 2011 Authors and OPENCORES.ORG                             ////
24
--////                                                                                                                          ////
25
--//// This source file may be used and distributed without             ////
26
--//// restriction provided that this copyright statement is not        ////
27
--//// removed from the file and that any derivative work contains      ////
28
--//// the original copyright notice and the associated disclaimer.     ////
29
--////                                                                                                                          ////
30
--//// This source file is free software; you can redistribute it       ////
31
--//// and/or modify it under the terms of the GNU Lesser General       ////
32
--//// Public License as published by the Free Software Foundation;     ////
33
--//// either version 2.1 of the License, or (at your option) any       ////
34
--//// later version.                                                                                           ////
35
--////                                                                                                                          ////
36
--//// This source is distributed in the hope that it will be           ////
37
--//// useful, but WITHOUT ANY WARRANTY; without even the implied       ////
38
--//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR          ////
39
--//// PURPOSE. See the GNU Lesser General Public License for more      ////
40
--//// details.                                                                                                         ////
41
--////                                                                                                                          ////
42 3 pas.
--//// You should have received a copy of the GNU Lesser General        ////
43 2 pas.
--//// Public License along with this source; if not, download it       ////
44
--//// from http://www.opencores.org/lgpl.shtml                                         ////
45
--////                                                                                                                          ////
46
--//////////////////////////////////////////////////////////////////////
47
 
48 3 pas.
 
49 2 pas.
library ieee;
50
use ieee.std_logic_1164.all;
51
use ieee.std_logic_unsigned.all;
52
use ieee.numeric_std.all;
53
 
54
entity usimplez_ram is
55
 
56
generic( WIDTH_WORD: natural:= 12;
57
                 WIDTH_ADDRESS: natural:= 9
58
           );
59
 
60
        port
61
        (
62
                clk_i   : in std_logic;
63
                addr_i  : in unsigned((WIDTH_ADDRESS-1) downto 0);
64
                data_i  : in std_logic_vector((WIDTH_WORD-1) downto 0);
65
                we_i    : in std_logic ;
66
                data_o  : out std_logic_vector((WIDTH_WORD-1) downto 0)
67
        );
68
 
69
end usimplez_ram;
70
 
71
architecture rtl of usimplez_ram is
72
 
73
        subtype word_t is std_logic_vector((WIDTH_WORD-1) downto 0);
74
        type memory_t is array(2**WIDTH_ADDRESS-1 downto 0) of word_t;
75
 
76
        signal ram : memory_t;
77
        attribute ram_init_file : string;
78
--      attribute ram_init_file of ram : signal is "adder.mif"; --code adder.txt
79
        attribute ram_init_file of ram : signal is "fibonacci.mif"; --code fibonacci.txt
80
 
81
        signal addr_reg_s : unsigned((WIDTH_ADDRESS-1) downto 0);
82
 
83
begin
84
 
85
        process(clk_i)
86
        begin
87
        if(falling_edge(clk_i)) then
88
                if(we_i = '1') then
89
                        ram(to_integer(addr_i)) <= data_i;
90
                end if;
91
 
92
        addr_reg_s <= addr_i;
93
        end if;
94
        end process;
95
 
96
        data_o <= ram(to_integer(addr_reg_s));
97
 
98
end rtl;

powered by: WebSVN 2.1.0

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