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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [epp/] [test_memory.vhd] - Blame information for rev 53

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 budinero
-------------------------------------------------------------------------------
2
-- Title      :  Single port RAM
3
-- Project    :  Memory Cores
4
-------------------------------------------------------------------------------
5
-- File        : spmem.vhd
6
-- Author      : Jamil Khatib  (khatib@ieee.org)
7
-- Organization: OpenIPCore Project
8
-- Created     : 1999/5/14
9
-- Last update : 2000/12/19
10
-- Platform    : 
11
-- Simulators  : Modelsim 5.3XE/Windows98
12
-- Synthesizers: Leonardo/WindowsNT
13
-- Target      : 
14
-- Dependency  : ieee.std_logic_1164,ieee.std_logic_unsigned
15
-------------------------------------------------------------------------------
16
-- Description:  Single Port memory
17
-------------------------------------------------------------------------------
18
-- Copyright (c) 2000 Jamil Khatib
19
-- 
20
-- This VHDL design file is an open design; you can redistribute it and/or
21
-- modify it and/or implement it after contacting the author
22
-- You can check the draft license at
23
-- http://www.opencores.org/OIPC/license.shtml
24
 
25
-------------------------------------------------------------------------------
26
-- Revisions  :
27
-- Revision Number :   1
28
-- Version         :   0.1
29
-- Date            :   12 May 1999
30
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
31
-- Desccription    :   Created
32
-- Known bugs      :   
33
-- To Optimze      :   
34
-------------------------------------------------------------------------------
35
-- Revisions  :
36
-- Revision Number :   2
37
-- Version         :   0.2
38
-- Date            :   19 Dec 2000
39
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
40
-- Desccription    :   General review
41
--                     Two versions are now available with reset and without
42
--                     Default output can can be defined
43
-- Known bugs      :   
44
-- To Optimze      :   
45
-------------------------------------------------------------------------------
46
-- Revisions  :
47
-- Revision Number :   3
48
-- Version         :   0.3
49
-- Date            :   5 Jan 2001
50
-- Modifier        :   Jamil Khatib (khatib@ieee.org)
51
-- Desccription    :   Registered Read Address feature is added to make use of
52
--                     Altera's FPGAs memory bits
53
--                     This feature was added from Richard Herveille's
54
--                     contribution and his memory core
55
-- Known bugs      :   
56
-- To Optimze      :   
57
-------------------------------------------------------------------------------
58
-- Revisions  :
59
-- Revision Number :   1asinc
60
-- Version         :   0.1asinc
61
-- Date            :   13 Mar 2009
62
-- Modifier        :   Aguilera Facundo (afacu@ieee.org)
63
-- Desccription    :   Original file modified to reduce code and to make WR and  
64
--                     reset signals positive, Reset sincronous, data transfer 
65
--                     asinc.
66
-------------------------------------------------------------------------------
67
 
68
-- (!)
69
-- Original file modified to reduce code and to make WR and reset signals 
70
-- positive, Reset sincronous, data transfer asinc.
71
 
72
 
73
library ieee;
74
 
75
use ieee.std_logic_1164.all;
76
 
77
use ieee.std_logic_unsigned.all;
78
 
79
-------------------------------------------------------------------------------
80
-- Single port Memory core with reset
81
-- To make use of on FPGA memory bits do not use the RESET option
82
-- For Altera's FPGA you have to use also OPTION := 1
83
 
84
entity test_memory is
85
 
86
  generic ( --USE_RESET   : boolean   := false;  -- use system reset
87
 
88
            --USE_CS      : boolean   := false;  -- use chip select signal
89
 
90
            DEFAULT_OUT : std_logic := '0';  -- Default output
91
            --OPTION      : integer   := 1;  -- 1: Registered read Address(suitable
92
                                        -- for Altera's FPGAs
93
                                        -- 0: non registered read address
94
            ADD_WIDTH   : integer   := 8;
95
            WIDTH       : integer   := 8);
96
  port (
97
    cs       : in  std_logic;           -- chip select
98
    clk      : in  std_logic;           -- write clock
99
    reset    : in  std_logic;           -- System Reset
100
    add      : in  std_logic_vector(add_width -1 downto 0);  --  Address
101
    Data_In  : in  std_logic_vector(WIDTH -1 downto 0);  -- input data
102
    Data_Out : out std_logic_vector(WIDTH -1 downto 0);  -- Output Data
103
    WR       : in  std_logic);          -- Read Write Enable
104
end test_memory;
105
 
106
 
107
 
108
architecture spmem_beh of test_memory is
109
 
110
  type data_array is array (integer range <>) of std_logic_vector(WIDTH-1 downto 0);
111
 -- signal s_reset: std_logic;
112
                                                      -- Memory Type
113
  signal data : data_array(0 to (2** add_width-1) );  -- Local data
114
 
115
 
116
        -- FLEX/APEX devices require address to be registered with inclock for read operations
117
  -- This signal is used only when OPTION = 1 
118
        -- signal regA : std_logic_vector( (add_width -1) downto 0);
119
 
120
  procedure init_mem(signal memory_cell : inout data_array ) is
121
 
122
  begin
123
 
124
    for i in 0 to (2** add_width-1) loop
125
      memory_cell(i) <= (others => '0');
126
    end loop;
127
 
128
  end init_mem;
129
 
130
begin  -- spmem_beh
131
-- -------------------------------------------------------------------------------
132
-- -- Non Registered Read Address
133
-- -------------------------------------------------------------------------------
134
   -- NON_REG         : if OPTION = 0 generate
135
-- -------------------------------------------------------------------------------
136
-- -- Clocked Process with Reset
137
-- -------------------------------------------------------------------------------
138
   -- Reset_ENABLED : if USE_RESET = true generate
139
 
140
-- -------------------------------------------------------------------------------
141
--      CS_ENABLED  : if USE_CS = true generate
142
 
143
        process (clk, reset,CS,WR, add)
144
 
145
        begin  -- PROCESS
146
          -- activities triggered by asynchronous reset (active low)
147
 
148
          -- activities triggered by rising edge of clock
149
 
150
          data_out <= data(conv_integer(add));
151
 
152
 
153
          if clk'event and clk = '1' then
154
                if reset = '1' then
155
              init_mem (data);
156
                elsif CS = '1' then
157 43 budinero
              if WR = '1' then
158
                  data(conv_integer(add)) <= Data_In;
159
              end if;
160
            end if;
161 19 budinero
          end if;
162
 
163
 
164
        end process;
165
--     end generate CS_ENABLED;
166
-------------------------------------------------------------------------------
167
-------------------------------------------------------------------------------
168
      -- CS_DISABLED : if USE_CS = false generate
169
 
170
        -- process (clk, reset)
171
 
172
 
173
        -- begin  -- PROCESS
174
          -- -- activities triggered by asynchronous reset (active low)
175
 
176
          -- if reset = '0' then
177
            -- data_out <= (others => DEFAULT_OUT);
178
            -- init_mem ( data);
179
 
180
            -- -- activities triggered by rising edge of clock
181
          -- elsif clk'event and clk = '1' then
182
            -- if WR = '0' then
183
              -- data(conv_integer(add)) <= data_in;
184
              -- data_out                <= (others => DEFAULT_OUT);
185
            -- else
186
              -- data_out                <= data(conv_integer(add));
187
            -- end if;
188
 
189
          -- end if;
190
 
191
        -- end process;
192
      -- end generate CS_DISABLED;
193
 
194
-- -------------------------------------------------------------------------------
195
-- -------------------------------------------------------------------------------
196
    -- end generate Reset_ENABLED;
197
-- -------------------------------------------------------------------------------
198
-- -------------------------------------------------------------------------------
199
-- -------------------------------------------------------------------------------
200
-- -- Clocked Process without Reset
201
-- -------------------------------------------------------------------------------
202
    -- Reset_DISABLED : if USE_RESET = false generate
203
 
204
-- -------------------------------------------------------------------------------
205
-- -------------------------------------------------------------------------------    
206
      -- CS_ENABLED   : if USE_CS = true generate
207
 
208
        -- process (clk)
209
        -- begin  -- PROCESS
210
 
211
          -- -- activities triggered by rising edge of clock
212
          -- if clk'event and clk = '1' then
213
            -- if cs = '1' then
214
              -- if WR = '0' then
215
                -- data(conv_integer(add)) <= data_in;
216
                -- data_out                <= (others => DEFAULT_OUT);
217
              -- else
218
                -- data_out                <= data(conv_integer(add));
219
              -- end if;
220
            -- else
221
              -- data_out                  <= (others => DEFAULT_OUT);
222
            -- end if;
223
 
224
 
225
          -- end if;
226
 
227
        -- end process;
228
      -- end generate CS_ENABLED;
229
-- -------------------------------------------------------------------------------
230
-- -------------------------------------------------------------------------------
231
      -- CS_DISABLED : if USE_CS = false generate
232
 
233
        -- process (clk)
234
        -- begin  -- PROCESS
235
 
236
          -- -- activities triggered by rising edge of clock
237
          -- if clk'event and clk = '1' then
238
            -- if WR = '0' then
239
              -- data(conv_integer(add)) <= data_in;
240
              -- data_out                <= (others => DEFAULT_OUT);
241
            -- else
242
              -- data_out                <= data(conv_integer(add));
243
            -- end if;
244
 
245
          -- end if;
246
 
247
        -- end process;
248
      -- end generate CS_DISABLED;
249
-- -------------------------------------------------------------------------------
250
-- -------------------------------------------------------------------------------
251
    -- end generate Reset_DISABLED;
252
-- -------------------------------------------------------------------------------
253
-- -------------------------------------------------------------------------------
254
-- -------------------------------------------------------------------------------
255
  -- end generate NON_REG;
256
-------------------------------------------------------------------------------
257
-------------------------------------------------------------------------------
258
-------------------------------------------------------------------------------
259
-------------------------------------------------------------------------------
260
-- REG: if OPTION = 1 generate
261
-- -------------------------------------------------------------------------------
262
-- -- Clocked Process with Reset
263
-- -------------------------------------------------------------------------------
264
    -- Reset_ENABLED : if USE_RESET = true generate
265
 
266
-- -------------------------------------------------------------------------------
267
      -- CS_ENABLED  : if USE_CS = true generate
268
 
269
        -- process (clk, reset)
270
 
271
        -- begin  -- PROCESS
272
          -- -- activities triggered by asynchronous reset (active low)
273
 
274
          -- if reset = '0' then
275
            -- data_out <= (others => DEFAULT_OUT);
276
            -- init_mem ( data);
277
 
278
            -- -- activities triggered by rising edge of clock
279
          -- elsif clk'event and clk = '1' then
280
 
281
            -- regA <= add;
282
 
283
            -- if CS = '1' then
284
              -- if WR = '0' then
285
                -- data(conv_integer(add)) <= data_in;
286
                -- data_out                <= (others => DEFAULT_OUT);
287
              -- else
288
                -- data_out                <= data(conv_integer(regA));
289
              -- end if;
290
            -- else
291
              -- data_out                  <= (others => DEFAULT_OUT);
292
            -- end if;
293
 
294
          -- end if;
295
 
296
        -- end process;
297
      -- end generate CS_ENABLED;
298
-- -------------------------------------------------------------------------------
299
-- -------------------------------------------------------------------------------
300
      -- CS_DISABLED : if USE_CS = false generate
301
 
302
        -- process (clk, reset)
303
 
304
 
305
        -- begin  -- PROCESS
306
          -- -- activities triggered by asynchronous reset (active low)
307
 
308
          -- if reset = '0' then
309
            -- data_out <= (others => DEFAULT_OUT);
310
            -- init_mem ( data);
311
 
312
            -- -- activities triggered by rising edge of clock
313
          -- elsif clk'event and clk = '1' then
314
            -- regA <= add;
315
 
316
            -- if WR = '0' then
317
              -- data(conv_integer(add)) <= data_in;
318
              -- data_out                <= (others => DEFAULT_OUT);
319
            -- else
320
              -- data_out                <= data(conv_integer(regA));
321
            -- end if;
322
 
323
          -- end if;
324
 
325
        -- end process;
326
      -- end generate CS_DISABLED;
327
 
328
-- -------------------------------------------------------------------------------
329
-- -------------------------------------------------------------------------------
330
    -- end generate Reset_ENABLED;
331
-- -------------------------------------------------------------------------------
332
-- -------------------------------------------------------------------------------
333
-- -------------------------------------------------------------------------------
334
-- -- Clocked Process without Reset
335
-- -------------------------------------------------------------------------------
336
    -- Reset_DISABLED : if USE_RESET = false generate
337
 
338
-- -------------------------------------------------------------------------------
339
-- -------------------------------------------------------------------------------    
340
      -- CS_ENABLED   : if USE_CS = true generate
341
 
342
        -- process (clk)
343
        -- begin  -- PROCESS
344
 
345
          -- -- activities triggered by rising edge of clock
346
          -- if clk'event and clk = '1' then
347
 
348
            -- regA <= add;
349
 
350
            -- if cs = '1' then
351
              -- if WR = '0' then
352
                -- data(conv_integer(add)) <= data_in;
353
                -- data_out                <= (others => DEFAULT_OUT);
354
              -- else
355
                -- data_out                <= data(conv_integer(regA));
356
              -- end if;
357
            -- else
358
              -- data_out                  <= (others => DEFAULT_OUT);
359
            -- end if;
360
 
361
 
362
          -- end if;
363
 
364
        -- end process;
365
      -- end generate CS_ENABLED;
366
-- -------------------------------------------------------------------------------
367
-- -------------------------------------------------------------------------------
368
      -- CS_DISABLED : if USE_CS = false generate
369
 
370
        -- process (clk)
371
        -- begin  -- PROCESS
372
 
373
          -- -- activities triggered by rising edge of clock
374
          -- if clk'event and clk = '1' then
375
 
376
            -- regA <= add;
377
 
378
            -- if WR = '0' then
379
              -- data(conv_integer(add)) <= data_in;
380
              -- data_out                <= (others => DEFAULT_OUT);
381
            -- else
382
              -- data_out                <= data(conv_integer(regA));
383
            -- end if;
384
 
385
          -- end if;
386
 
387
        -- end process;
388
      -- end generate CS_DISABLED;
389
-- -------------------------------------------------------------------------------
390
-- -------------------------------------------------------------------------------
391
    -- end generate Reset_DISABLED;
392
-- -------------------------------------------------------------------------------
393
-- -------------------------------------------------------------------------------
394
-- -------------------------------------------------------------------------------
395
 
396
-- end generate REG;
397
 
398
end spmem_beh;
399
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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