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

Subversion Repositories modular_oscilloscope

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

powered by: WebSVN 2.1.0

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