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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [epp/] [memory_8bit_reset.vhd] - Blame information for rev 19

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
 
59
-- (!)
60
-- Original file modified to reduce code and make WR and reset signals 
61
-- positive, make Reset sincronous, make data transfer asinc.
62
 
63
 
64
library ieee;
65
 
66
use ieee.std_logic_1164.all;
67
 
68
use ieee.std_logic_unsigned.all;
69
 
70
-------------------------------------------------------------------------------
71
-- Single port Memory core with reset
72
-- To make use of on FPGA memory bits do not use the RESET option
73
-- For Altera's FPGA you have to use also OPTION := 1
74
 
75
entity mem_8bit_reset is
76
 
77
  generic ( --USE_RESET   : boolean   := false;  -- use system reset
78
 
79
            --USE_CS      : boolean   := false;  -- use chip select signal
80
 
81
            DEFAULT_OUT : std_logic := '0';  -- Default output
82
            --OPTION      : integer   := 1;  -- 1: Registered read Address(suitable
83
                                        -- for Altera's FPGAs
84
                                        -- 0: non registered read address
85
            ADD_WIDTH   : integer   := 8;
86
            WIDTH       : integer   := 8);
87
 
88
  port (
89
    cs       : in  std_logic;           -- chip select
90
    clk      : in  std_logic;           -- write clock
91
    reset    : in  std_logic;           -- System Reset
92
    add      : in  std_logic_vector(add_width -1 downto 0);  --  Address
93
    Data_In  : in  std_logic_vector(WIDTH -1 downto 0);  -- input data
94
    Data_Out : out std_logic_vector(WIDTH -1 downto 0);  -- Output Data
95
    WR       : in  std_logic);          -- Read Write Enable
96
end mem_8bit_reset;
97
 
98
 
99
 
100
architecture spmem_beh of mem_8bit_reset is
101
 
102
  type data_array is array (integer range <>) of std_logic_vector(WIDTH-1 downto 0);
103
 -- signal s_reset: std_logic;
104
                                                      -- Memory Type
105
  signal data : data_array(0 to (2** add_width-1) );  -- Local data
106
 
107
 
108
        -- FLEX/APEX devices require address to be registered with inclock for read operations
109
  -- This signal is used only when OPTION = 1 
110
        -- signal regA : std_logic_vector( (add_width -1) downto 0);
111
 
112
  procedure init_mem(signal memory_cell : inout data_array ) is
113
 
114
  begin
115
 
116
    for i in 0 to (2** add_width-1) loop
117
      memory_cell(i) <= (others => '0');
118
    end loop;
119
 
120
  end init_mem;
121
 
122
begin  -- spmem_beh
123
-- -------------------------------------------------------------------------------
124
-- -- Non Registered Read Address
125
-- -------------------------------------------------------------------------------
126
   -- NON_REG         : if OPTION = 0 generate
127
-- -------------------------------------------------------------------------------
128
-- -- Clocked Process with Reset
129
-- -------------------------------------------------------------------------------
130
   -- Reset_ENABLED : if USE_RESET = true generate
131
 
132
-- -------------------------------------------------------------------------------
133
--      CS_ENABLED  : if USE_CS = true generate
134
 
135
        process (clk, reset,CS,WR, add)
136
 
137
        begin  -- PROCESS
138
          -- activities triggered by asynchronous reset (active low)
139
 
140
          -- activities triggered by rising edge of clock
141
 
142
          data_out <= data(conv_integer(add));
143
 
144
 
145
          if clk'event and clk = '1' then
146
                if reset = '1' then
147
              init_mem (data);
148
                elsif CS = '1' then
149
                  if WR = '1' then
150
                      data(conv_integer(add)) <= Data_In;
151
                  end if;
152
                end if;
153
          end if;
154
 
155
 
156
        end process;
157
--     end generate CS_ENABLED;
158
-------------------------------------------------------------------------------
159
-------------------------------------------------------------------------------
160
      -- CS_DISABLED : if USE_CS = false generate
161
 
162
        -- process (clk, reset)
163
 
164
 
165
        -- begin  -- PROCESS
166
          -- -- activities triggered by asynchronous reset (active low)
167
 
168
          -- if reset = '0' then
169
            -- data_out <= (others => DEFAULT_OUT);
170
            -- init_mem ( data);
171
 
172
            -- -- activities triggered by rising edge of clock
173
          -- elsif clk'event and clk = '1' then
174
            -- if WR = '0' then
175
              -- data(conv_integer(add)) <= data_in;
176
              -- data_out                <= (others => DEFAULT_OUT);
177
            -- else
178
              -- data_out                <= data(conv_integer(add));
179
            -- end if;
180
 
181
          -- end if;
182
 
183
        -- end process;
184
      -- end generate CS_DISABLED;
185
 
186
-- -------------------------------------------------------------------------------
187
-- -------------------------------------------------------------------------------
188
    -- end generate Reset_ENABLED;
189
-- -------------------------------------------------------------------------------
190
-- -------------------------------------------------------------------------------
191
-- -------------------------------------------------------------------------------
192
-- -- Clocked Process without Reset
193
-- -------------------------------------------------------------------------------
194
    -- Reset_DISABLED : if USE_RESET = false generate
195
 
196
-- -------------------------------------------------------------------------------
197
-- -------------------------------------------------------------------------------    
198
      -- CS_ENABLED   : if USE_CS = true generate
199
 
200
        -- process (clk)
201
        -- begin  -- PROCESS
202
 
203
          -- -- activities triggered by rising edge of clock
204
          -- if clk'event and clk = '1' then
205
            -- if cs = '1' then
206
              -- if WR = '0' then
207
                -- data(conv_integer(add)) <= data_in;
208
                -- data_out                <= (others => DEFAULT_OUT);
209
              -- else
210
                -- data_out                <= data(conv_integer(add));
211
              -- end if;
212
            -- else
213
              -- data_out                  <= (others => DEFAULT_OUT);
214
            -- end if;
215
 
216
 
217
          -- end if;
218
 
219
        -- end process;
220
      -- end generate CS_ENABLED;
221
-- -------------------------------------------------------------------------------
222
-- -------------------------------------------------------------------------------
223
      -- CS_DISABLED : if USE_CS = false generate
224
 
225
        -- process (clk)
226
        -- begin  -- PROCESS
227
 
228
          -- -- activities triggered by rising edge of clock
229
          -- if clk'event and clk = '1' then
230
            -- if WR = '0' then
231
              -- data(conv_integer(add)) <= data_in;
232
              -- data_out                <= (others => DEFAULT_OUT);
233
            -- else
234
              -- data_out                <= data(conv_integer(add));
235
            -- end if;
236
 
237
          -- end if;
238
 
239
        -- end process;
240
      -- end generate CS_DISABLED;
241
-- -------------------------------------------------------------------------------
242
-- -------------------------------------------------------------------------------
243
    -- end generate Reset_DISABLED;
244
-- -------------------------------------------------------------------------------
245
-- -------------------------------------------------------------------------------
246
-- -------------------------------------------------------------------------------
247
  -- end generate NON_REG;
248
-------------------------------------------------------------------------------
249
-------------------------------------------------------------------------------
250
-------------------------------------------------------------------------------
251
-------------------------------------------------------------------------------
252
-- REG: if OPTION = 1 generate
253
-- -------------------------------------------------------------------------------
254
-- -- Clocked Process with Reset
255
-- -------------------------------------------------------------------------------
256
    -- Reset_ENABLED : if USE_RESET = true generate
257
 
258
-- -------------------------------------------------------------------------------
259
      -- CS_ENABLED  : if USE_CS = true generate
260
 
261
        -- process (clk, reset)
262
 
263
        -- begin  -- PROCESS
264
          -- -- activities triggered by asynchronous reset (active low)
265
 
266
          -- if reset = '0' then
267
            -- data_out <= (others => DEFAULT_OUT);
268
            -- init_mem ( data);
269
 
270
            -- -- activities triggered by rising edge of clock
271
          -- elsif clk'event and clk = '1' then
272
 
273
            -- regA <= add;
274
 
275
            -- if CS = '1' then
276
              -- if WR = '0' then
277
                -- data(conv_integer(add)) <= data_in;
278
                -- data_out                <= (others => DEFAULT_OUT);
279
              -- else
280
                -- data_out                <= data(conv_integer(regA));
281
              -- end if;
282
            -- else
283
              -- data_out                  <= (others => DEFAULT_OUT);
284
            -- end if;
285
 
286
          -- end if;
287
 
288
        -- end process;
289
      -- end generate CS_ENABLED;
290
-- -------------------------------------------------------------------------------
291
-- -------------------------------------------------------------------------------
292
      -- CS_DISABLED : if USE_CS = false generate
293
 
294
        -- process (clk, reset)
295
 
296
 
297
        -- begin  -- PROCESS
298
          -- -- activities triggered by asynchronous reset (active low)
299
 
300
          -- if reset = '0' then
301
            -- data_out <= (others => DEFAULT_OUT);
302
            -- init_mem ( data);
303
 
304
            -- -- activities triggered by rising edge of clock
305
          -- elsif clk'event and clk = '1' then
306
            -- regA <= add;
307
 
308
            -- if WR = '0' then
309
              -- data(conv_integer(add)) <= data_in;
310
              -- data_out                <= (others => DEFAULT_OUT);
311
            -- else
312
              -- data_out                <= data(conv_integer(regA));
313
            -- end if;
314
 
315
          -- end if;
316
 
317
        -- end process;
318
      -- end generate CS_DISABLED;
319
 
320
-- -------------------------------------------------------------------------------
321
-- -------------------------------------------------------------------------------
322
    -- end generate Reset_ENABLED;
323
-- -------------------------------------------------------------------------------
324
-- -------------------------------------------------------------------------------
325
-- -------------------------------------------------------------------------------
326
-- -- Clocked Process without Reset
327
-- -------------------------------------------------------------------------------
328
    -- Reset_DISABLED : if USE_RESET = false generate
329
 
330
-- -------------------------------------------------------------------------------
331
-- -------------------------------------------------------------------------------    
332
      -- CS_ENABLED   : if USE_CS = true generate
333
 
334
        -- process (clk)
335
        -- begin  -- PROCESS
336
 
337
          -- -- activities triggered by rising edge of clock
338
          -- if clk'event and clk = '1' then
339
 
340
            -- regA <= add;
341
 
342
            -- if cs = '1' then
343
              -- if WR = '0' then
344
                -- data(conv_integer(add)) <= data_in;
345
                -- data_out                <= (others => DEFAULT_OUT);
346
              -- else
347
                -- data_out                <= data(conv_integer(regA));
348
              -- end if;
349
            -- else
350
              -- data_out                  <= (others => DEFAULT_OUT);
351
            -- end if;
352
 
353
 
354
          -- end if;
355
 
356
        -- end process;
357
      -- end generate CS_ENABLED;
358
-- -------------------------------------------------------------------------------
359
-- -------------------------------------------------------------------------------
360
      -- CS_DISABLED : if USE_CS = false generate
361
 
362
        -- process (clk)
363
        -- begin  -- PROCESS
364
 
365
          -- -- activities triggered by rising edge of clock
366
          -- if clk'event and clk = '1' then
367
 
368
            -- regA <= add;
369
 
370
            -- if WR = '0' then
371
              -- data(conv_integer(add)) <= data_in;
372
              -- data_out                <= (others => DEFAULT_OUT);
373
            -- else
374
              -- data_out                <= data(conv_integer(regA));
375
            -- end if;
376
 
377
          -- end if;
378
 
379
        -- end process;
380
      -- end generate CS_DISABLED;
381
-- -------------------------------------------------------------------------------
382
-- -------------------------------------------------------------------------------
383
    -- end generate Reset_DISABLED;
384
-- -------------------------------------------------------------------------------
385
-- -------------------------------------------------------------------------------
386
-- -------------------------------------------------------------------------------
387
 
388
-- end generate REG;
389
 
390
end spmem_beh;
391
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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