copyleft: gplv3 added and set repo to public
[calu.git] / cpu / src / mem_pkg.vhd
1 --   `Deep Thought', a softcore CPU implemented on a FPGA
2 --
3 --  Copyright (C) 2010 Markus Hofstaetter <markus.manrow@gmx.at>
4 --  Copyright (C) 2010 Martin Perner <e0725782@student.tuwien.ac.at>
5 --  Copyright (C) 2010 Stefan Rebernig <stefan.rebernig@gmail.com>
6 --  Copyright (C) 2010 Manfred Schwarz <e0725898@student.tuwien.ac.at>
7 --  Copyright (C) 2010 Bernhard Urban <lewurm@gmail.com>
8 --
9 --  This program is free software: you can redistribute it and/or modify
10 --  it under the terms of the GNU General Public License as published by
11 --  the Free Software Foundation, either version 3 of the License, or
12 --  (at your option) any later version.
13 --
14 --  This program is distributed in the hope that it will be useful,
15 --  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 --  GNU General Public License for more details.
18 --
19 --  You should have received a copy of the GNU General Public License
20 --  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 library IEEE;
23
24 use IEEE.std_logic_1164.all;
25 use IEEE.numeric_std.all;
26
27 package mem_pkg is
28
29         component r_w_ram is
30         generic (
31                                 ADDR_WIDTH : integer range 1 to integer'high;
32                                 DATA_WIDTH : integer range 1 to integer'high
33                         );
34         port(
35                 --System inputs
36                         clk : in std_logic;
37                 --Input
38                         wr_addr, rd_addr : in std_logic_vector(ADDR_WIDTH-1 downto 0);
39                         
40                         wr_en : in std_logic;
41                         data_in : in std_logic_vector(DATA_WIDTH-1 downto 0);
42                         
43                 --Output
44                         data_out: out std_logic_vector(DATA_WIDTH-1 downto 0)
45                 );
46         end component r_w_ram;
47
48         component r_w_ram_be is
49         generic (
50                                 ADDR_WIDTH : integer range 1 to integer'high
51                         );
52         port(
53                 clk : in std_logic;
54
55                 waddr, raddr : in std_logic_vector(ADDR_WIDTH-1 downto 0);
56
57                 be : in std_logic_vector (3 downto 0);
58                 
59                 we : in std_logic;
60
61                 wdata : in std_logic_vector(31 downto 0);
62                 
63                 q : out std_logic_vector(31 downto 0)
64         );
65         end component r_w_ram_be;
66
67         component ram_xilinx is
68         generic (
69                                 ADDR_WIDTH : integer range 1 to integer'high
70                         );
71         port(
72                 clk : in std_logic;
73
74                 waddr, raddr : in std_logic_vector(ADDR_WIDTH-1 downto 0);
75
76                 be : in std_logic_vector (3 downto 0);
77                 
78                 we : in std_logic;
79
80                 wdata : in std_logic_vector(31 downto 0);
81                 
82                 q : out std_logic_vector(31 downto 0)
83         );
84         end component ram_xilinx;
85
86         component rom is
87         generic (
88                                 ADDR_WIDTH : integer range 1 to integer'high;
89                                 DATA_WIDTH : integer range 1 to integer'high
90                         );
91         port(
92                 --System inputs
93                         clk : in std_logic;
94                 --Input
95                         rd_addr : in std_logic_vector(ADDR_WIDTH-1 downto 0);                   
96                 --Output
97                         data_out : out std_logic_vector(DATA_WIDTH-1 downto 0)
98                 );
99         end component rom;
100         
101         component r2_w_ram is
102         generic (
103                                 ADDR_WIDTH : integer range 1 to integer'high;
104                                 DATA_WIDTH : integer range 1 to integer'high
105                         );
106         port(
107                 --System inputs
108                         clk : in std_logic;
109                 --Input
110                         wr_addr, rd_addr1, rd_addr2 : in std_logic_vector(ADDR_WIDTH-1 downto 0);
111                         
112                         wr_en : in std_logic;
113                         data_in : in std_logic_vector(DATA_WIDTH-1 downto 0);
114                         
115                 --Output
116                         data_out1, data_out2: out std_logic_vector(DATA_WIDTH-1 downto 0)
117                 );
118         end component r2_w_ram;
119         
120         component rw_r_ram is
121         generic (
122                                 ADDR_WIDTH : integer range 1 to integer'high;
123                                 DATA_WIDTH : integer range 1 to integer'high
124                         );
125         port(
126                 --System inputs
127                         clk : in std_logic;
128                 --Input
129                         rw_addr, rd_addr : in std_logic_vector(ADDR_WIDTH-1 downto 0);
130                         
131                         wr_en : in std_logic;
132                         data_in : in std_logic_vector(DATA_WIDTH-1 downto 0);
133                         
134                 --Output
135                         rw_out, rd_out: out std_logic_vector(DATA_WIDTH-1 downto 0)
136                 );
137         end component rw_r_ram;
138
139 end package mem_pkg;