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

Subversion Repositories memory_cores

[/] [memory_cores/] [trunk/] [dpmem/] [dpmem.vhd] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 20 khatib
-------------------------------------------------------------------------------
2
-- 
3
-- Copyright Jamil Khatib 1999
4
-- 
5
--
6
-- This VHDL design file is an open design; you can redistribute it and/or
7
-- modify it and/or implement it under the terms of the Openip General Public
8
-- License as it is going to be published by the OpenIP Organization and any
9
-- coming versions of this license.
10
-- You can check the draft license at
11
-- http://www.openip.org/oc/license.html
12
--
13
--
14
-- Creator : Jamil Khatib
15
-- Date 14/5/99
16
--
17 22 khatib
-- version 0.19991224
18 20 khatib
--
19
-- This file was tested on the ModelSim 5.2EE
20
-- The test vecors for model sim is included in vectors.do file
21
-- This VHDL design file is proved through simulation but not verified on Silicon
22
-- 
23
--
24
-------------------------------------------------------------------------------
25
LIBRARY ieee;
26
USE ieee.std_logic_1164.ALL;
27
 
28
USE ieee.std_logic_signed.ALL;
29
 
30
 
31
 
32
-- Dual port Memory core
33
 
34
 
35
 
36
ENTITY dpmem IS
37
generic ( ADD_WIDTH: integer := 8 ;
38
                 WIDTH : integer := 8);
39
  PORT (
40
    clk      : IN  std_logic;                                -- write clock
41
    reset    : IN  std_logic;                                -- System Reset
42
    W_add    : IN  std_logic_vector(add_width -1 downto 0);  -- Write Address
43
    R_add    : IN  std_logic_vector(add_width -1 downto 0);  -- Read Address
44
    Data_In  : IN  std_logic_vector(WIDTH - 1  DOWNTO 0);    -- input data
45
    Data_Out : OUT std_logic_vector(WIDTH -1   DOWNTO 0);    -- output Data
46
    WR       : IN  std_logic;                                -- Write Enable
47
    RE       : IN  std_logic);                               -- Read Enable
48
END dpmem;
49
 
50
 
51
-------------------------------------------------------------------------------
52
 
53
ARCHITECTURE dpmem_v1 OF dpmem IS
54
 
55
 
56
 
57
  TYPE data_array IS ARRAY (integer range <>) OF std_logic_vector(WIDTH -1  DOWNTO 0);
58
                                        -- Memory Type
59
  SIGNAL data : data_array(0 to (2** add_width) );  -- Local data
60
 
61
 
62
 
63
  procedure init_mem(signal memory_cell : inout data_array ) is
64
  begin
65
 
66
    for i in 0 to (2** add_width) loop
67
      memory_cell(i) <= (others => '0');
68
    end loop;
69
 
70
  end init_mem;
71
 
72
 
73
BEGIN  -- dpmem_v1
74
 
75
  PROCESS (clk, reset)
76
 
77
  BEGIN  -- PROCESS
78
 
79
 
80
    -- activities triggered by asynchronous reset (active low)
81
    IF reset = '0' THEN
82
      data_out <= (OTHERS => 'Z');
83
      init_mem ( data);
84
 
85
      -- activities triggered by rising edge of clock
86
    ELSIF clk'event AND clk = '1' THEN
87
      IF RE = '1' THEN
88
        data_out <= data(conv_integer(R_add));
89
      else
90
        data_out <= (OTHERS => 'Z');    -- Defualt value
91
      END IF;
92
 
93
      IF WR = '1' THEN
94
        data(conv_integeR(W_add)) <= Data_In;
95
      END IF;
96
    END IF;
97
 
98
 
99
 
100
  END PROCESS;
101
 
102
 
103
END dpmem_v1;
104
 
105
 
106
 
107
-------------------------------------------------------------------------------
108
 
109 22 khatib
-- This Architecture was tested on the ModelSim 5.2EE
110
-- The test vectors for model sim is included in vectors.do file
111
-- It is Synthesized using Xilinx Webfitter
112
--
113 20 khatib
-- 
114
-- The variable result_data is used as an intermediate variable in the process
115
-- 
116
 
117
ARCHITECTURE dpmem_v2 OF dpmem IS
118
 
119
 
120
 
121
  TYPE data_array IS ARRAY (integer range <>) OF std_logic_vector(WIDTH -1 DOWNTO 0);
122
                                        -- Memory Type
123
  SIGNAL data : data_array(0 to (2** add_width) );  -- Local data
124
 
125
 
126
-- Initialize the memory to zeros 
127
  procedure init_mem(signal memory_cell : inout data_array ) is
128
  begin
129
 
130
    for i in 0 to (2** add_width) loop
131
      memory_cell(i) <= (others => '0');
132
    end loop;
133
 
134
  end init_mem;
135
 
136
 
137
BEGIN  -- dpmem_v2
138
 
139
  PROCESS (clk, reset)
140
 
141
    variable result_data : std_logic_vector(WIDTH -1  downto 0);
142
 
143
  BEGIN  -- PROCESS
144
 
145
-- init data_out
146
 
147
 
148
    -- activities triggered by asynchronous reset (active low)
149
    IF reset = '0' THEN
150
      result_data := (OTHERS => 'Z');
151
      init_mem ( data);
152
 
153
      -- activities triggered by rising edge of clock
154
    ELSIF clk'event AND clk = '1' THEN
155
      IF RE = '1' THEN
156
        result_data := data(conv_integer(R_add));
157
      else
158
        result_data := (OTHERS => 'Z');    -- Defualt value
159
      END IF;
160
 
161
      IF WR = '1' THEN
162
        data(conv_integeR(W_add)) <= Data_In;
163
      END IF;
164
    END IF;
165
 
166
data_out <= result_data;
167
 
168
 
169
END PROCESS;
170
 
171
 
172
END dpmem_v2;
173
 
174
 
175
 
176
-------------------------------------------------------------------------------
177 22 khatib
-- This Architecture was tested on the ModelSim 5.2EE
178
-- The test vectors for model sim is included in vectors.do file
179
-- It is Synthesized using Xilinx Webpack
180
--
181 20 khatib
-- This is the same as dpmem_v1 but without the Z state
182
-- instead the output goes to all 1's during reset and 
183
-- when RE = 0
184
 
185
ARCHITECTURE dpmem_v3 OF dpmem IS
186
 
187
 
188
 
189
  TYPE data_array IS ARRAY (integer range <>) OF std_logic_vector(WIDTH -1 DOWNTO 0);
190
                                        -- Memory Type
191
  SIGNAL data : data_array(0 to (2** add_width) );  -- Local data
192
 
193
 
194
 
195
  procedure init_mem(signal memory_cell : inout data_array ) is
196
  begin
197
 
198
    for i in 0 to (2** add_width) loop
199
      memory_cell(i) <= (others => '0');
200
    end loop;
201
 
202
  end init_mem;
203
 
204
 
205
BEGIN  -- dpmem_v3
206
 
207
  PROCESS (clk, reset)
208
 
209
  BEGIN  -- PROCESS
210
 
211
 
212
    -- activities triggered by asynchronous reset (active low)
213
    IF reset = '0' THEN
214
      data_out <= (OTHERS => '1');
215
      init_mem ( data);
216
 
217
      -- activities triggered by rising edge of clock
218
    ELSIF clk'event AND clk = '1' THEN
219
      IF RE = '1' THEN
220
        data_out <= data(conv_integer(R_add));
221
      else
222
        data_out <= (OTHERS => '1');    -- Defualt value
223
      END IF;
224
 
225
      IF WR = '1' THEN
226
        data(conv_integeR(W_add)) <= Data_In;
227
      END IF;
228
    END IF;
229
 
230
 
231
 
232
  END PROCESS;
233
 
234
 
235
END dpmem_v3;
236
 
237
 
238
 
239
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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