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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_rams.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 madsilicon
-----------------------------------------------------------------
2
--                                                             --
3
-----------------------------------------------------------------
4
--                                                             --
5
-- Copyright (C) 2017 Stefano Tonello                          --
6
--                                                             --
7
-- This source file may be used and distributed without        --
8
-- restriction provided that this copyright statement is not   --
9
-- removed from the file and that any derivative work contains --
10
-- the original copyright notice and the associated disclaimer.--
11
--                                                             --
12
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY         --
13
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   --
14
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   --
15
-- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      --
16
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         --
17
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    --
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   --
19
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        --
20
-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  --
21
-- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  --
22
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  --
23
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         --
24
-- POSSIBILITY OF SUCH DAMAGE.                                 --
25
--                                                             --
26
-----------------------------------------------------------------
27
 
28
------------------------------------------------------------
29
-- synchronous write, synchronous-read 1 read/write port RAM
30
-- with separated input and output data buses 
31
------------------------------------------------------------
32
 
33
library ieee;
34
use ieee.std_logic_1164.all;
35
use ieee.numeric_std.all;
36
 
37
library work;
38
use work.RV01_CONSTS_PKG.all;
39
use work.RV01_TYPES_PKG.all;
40
use work.RV01_FUNCS_PKG.all;
41
 
42
entity RV01_RAM_1RW is
43
  generic(
44
    -- I/O data bus width
45
    DWIDTH : integer := 16;
46
    -- word count
47
    WCOUNT : integer := 256;
48
    STYLE : string := "auto"
49
  );
50
  port(
51
    CLK_i : in std_logic;
52
    A_i : in unsigned(log2(WCOUNT)-1 downto 0);
53
    D_i : in std_logic_vector(DWIDTH-1 downto 0);
54
    WE_i : in std_logic;
55
 
56
    Q_o : out std_logic_vector(DWIDTH-1 downto 0)
57
  );
58
end RV01_RAM_1RW;
59
 
60
architecture ARC of RV01_RAM_1RW is
61
 
62
  type MEM_TYPE is array (WCOUNT-1 downto 0) of std_logic_vector(DWIDTH-1 downto 0);
63
  signal RAM_DATA : MEM_TYPE;
64
 
65
  attribute ram_style: string;
66
  attribute ram_style of RAM_DATA : signal is STYLE;
67
 
68
begin
69
 
70
  process(CLK_i)
71
  begin
72
    if(CLK_i = '1' and CLK_i'event)then
73
      if WE_i = '1' then
74
        RAM_DATA(to_integer(A_i)) <= D_i;
75
      end if;
76
      Q_o <= RAM_DATA(to_integer(A_i));
77
    end if;
78
  end process;
79
 
80
end ARC;
81
 
82
------------------------------------------------------------
83
-- synchronous write, synchronous-read 1 read/write port,
84
-- plus 1 read-only port, RAM, with separated input and
85
-- output data buses 
86
------------------------------------------------------------
87
 
88
library ieee;
89
use ieee.std_logic_1164.all;
90
use ieee.numeric_std.all;
91
 
92
library work;
93
use work.RV01_CONSTS_PKG.all;
94
use work.RV01_TYPES_PKG.all;
95
use work.RV01_FUNCS_PKG.all;
96
 
97
entity RV01_RAM_1RW1R is
98
  generic(
99
    -- I/O data bus width
100
    DWIDTH : integer := 16;
101
    -- word count
102
    WCOUNT : integer := 256;
103
    STYLE : string := "auto"
104
  );
105
  port(
106
    CLK_i : in std_logic;
107
    A_i : in unsigned(log2(WCOUNT)-1 downto 0);
108
    DPRA_i : in unsigned(log2(WCOUNT)-1 downto 0);
109
    D_i : in std_logic_vector(DWIDTH-1 downto 0);
110
    WE_i : in std_logic;
111
 
112
    Q_o : out std_logic_vector(DWIDTH-1 downto 0);
113
    DPQ_o : out std_logic_vector(DWIDTH-1 downto 0)
114
  );
115
end RV01_RAM_1RW1R;
116
 
117
architecture ARC of RV01_RAM_1RW1R is
118
 
119
  type MEM_TYPE is array (WCOUNT-1 downto 0) of std_logic_vector(DWIDTH-1 downto 0);
120
  signal RAM_DATA : MEM_TYPE;
121
 
122
  attribute ram_style: string;
123
  attribute ram_style of RAM_DATA : signal is STYLE;
124
 
125
begin
126
 
127
  process(CLK_i)
128
  begin
129
    if(CLK_i = '1' and CLK_i'event)then
130
      if WE_i = '1' then
131
        RAM_DATA(to_integer(A_i)) <= D_i;
132
      end if;
133
      Q_o <= RAM_DATA(to_integer(A_i));
134
      DPQ_o <= RAM_DATA(to_integer(DPRA_i));
135
    end if;
136
  end process;
137
 
138
end ARC;
139
 
140
------------------------------------------------------------
141
-- synchronous write, synchronous-read 1 read/write port,
142
-- plus 1 read-only port, RAM, with separated input and
143
-- output data buses.
144
-- This version supports byte-selectable writes, and
145
-- therefore WIDTH generic value must be a multiple of 8.
146
------------------------------------------------------------
147
 
148
library ieee;
149
use ieee.std_logic_1164.all;
150
use ieee.numeric_std.all;
151
 
152
library work;
153
use work.RV01_CONSTS_PKG.all;
154
use work.RV01_TYPES_PKG.all;
155
use work.RV01_FUNCS_PKG.all;
156
 
157
entity RV01_RAM_1RW1R_BE is
158
  generic(
159
    -- I/O data bus width
160
    DWIDTH : integer := 16;
161
    -- word count
162
    WCOUNT : integer := 256;
163
    STYLE : string := "auto"
164
  );
165
  port(
166
    CLK_i : in std_logic;
167
    A_i : in unsigned(log2(WCOUNT)-1 downto 0);
168
    DPRA_i : in unsigned(log2(WCOUNT)-1 downto 0);
169
    D_i : in std_logic_vector(DWIDTH-1 downto 0);
170
    BE_i : in std_logic_vector(DWIDTH/8-1 downto 0);
171
    WE_i : in std_logic;
172
 
173
    Q_o : out std_logic_vector(DWIDTH-1 downto 0);
174
    DPQ_o : out std_logic_vector(DWIDTH-1 downto 0)
175
  );
176
end RV01_RAM_1RW1R_BE;
177
 
178
architecture ARC of RV01_RAM_1RW1R_BE is
179
 
180
  constant BW : integer := 8;
181
 
182
  type MEM_TYPE is array (WCOUNT-1 downto 0) of std_logic_vector(DWIDTH-1 downto 0);
183
  signal RAM_DATA : MEM_TYPE;
184
 
185
  attribute ram_style: string;
186
  attribute ram_style of RAM_DATA : signal is STYLE;
187
 
188
begin
189
 
190
  process(CLK_i)
191
    variable TMP : std_logic_vector(DWIDTH-1 downto 0);
192
  begin
193
    if(CLK_i = '1' and CLK_i'event)then
194
      if WE_i = '1' then
195
        TMP := RAM_DATA(to_integer(A_i));
196
        for i in 0 to DWIDTH/BW-1 loop
197
          if(BE_i(i) = '1') then
198
            TMP(BW*(i+1)-1 downto BW*i) := D_i(BW*(i+1)-1 downto BW*i);
199
          end if;
200
        end loop;
201
        RAM_DATA(to_integer(A_i)) <= TMP;
202
      end if;
203
      Q_o <= RAM_DATA(to_integer(A_i));
204
      DPQ_o <= RAM_DATA(to_integer(DPRA_i));
205
    end if;
206
  end process;
207
 
208
end ARC;
209
 
210
------------------------------------------------------------
211
-- synchronous write, synchronous-read 1 read/write port,
212
-- RAM, with separated input and output data buses.
213
-- This version supports byte-selectable writes, and
214
-- therefore WIDTH generic value must be a multiple of 8.
215
------------------------------------------------------------
216
 
217
library ieee;
218
use ieee.std_logic_1164.all;
219
use ieee.numeric_std.all;
220
 
221
library work;
222
use work.RV01_CONSTS_PKG.all;
223
use work.RV01_TYPES_PKG.all;
224
use work.RV01_FUNCS_PKG.all;
225
 
226
entity RV01_RAM_1RW_BE is
227
  generic(
228
    -- I/O data bus width
229
    DWIDTH : integer := 16;
230
    -- word count
231
    WCOUNT : integer := 256;
232
    STYLE : string := "auto"
233
  );
234
  port(
235
    CLK_i : in std_logic;
236
    A_i : in unsigned(log2(WCOUNT)-1 downto 0);
237
    D_i : in std_logic_vector(DWIDTH-1 downto 0);
238
    BE_i : in std_logic_vector(DWIDTH/8-1 downto 0);
239
    WE_i : in std_logic;
240
 
241
    Q_o : out std_logic_vector(DWIDTH-1 downto 0)
242
  );
243
end RV01_RAM_1RW_BE;
244
 
245
architecture ARC of RV01_RAM_1RW_BE is
246
 
247
  constant BW : integer := 8;
248
 
249
  type MEM_TYPE is array (WCOUNT-1 downto 0) of std_logic_vector(DWIDTH-1 downto 0);
250
  signal RAM_DATA : MEM_TYPE;
251
 
252
  attribute ram_style: string;
253
  attribute ram_style of RAM_DATA : signal is STYLE;
254
 
255
begin
256
 
257
  process(CLK_i)
258
    variable TMP : std_logic_vector(DWIDTH-1 downto 0);
259
  begin
260
    if(CLK_i = '1' and CLK_i'event)then
261
      if WE_i = '1' then
262
        TMP := RAM_DATA(to_integer(A_i));
263
        for i in 0 to DWIDTH/BW-1 loop
264
          if(BE_i(i) = '1') then
265
            TMP(BW*(i+1)-1 downto BW*i) := D_i(BW*(i+1)-1 downto BW*i);
266
          end if;
267
        end loop;
268
        RAM_DATA(to_integer(A_i)) <= TMP;
269
      end if;
270
      Q_o <= RAM_DATA(to_integer(A_i));
271
    end if;
272
  end process;
273
 
274
end ARC;

powered by: WebSVN 2.1.0

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