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

Subversion Repositories memory_cores

[/] [memory_cores/] [trunk/] [spmem/] [spmem.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 Hardware 
8
-- General Public License as publilshed by the OpenIP organization and any
9
-- coming versions of this license.
10
-- You can check the current license at
11
-- http://www.openip.org/oc/license.html
12
--
13
--
14
-- Creator : Jamil Khatib
15
-- Date 14/5/99
16
--
17
-- Conntact me at khatib@ieee.org
18
--
19
-- version 1.01-19991218
20
--
21
-- 
22
-- This VHDL design file is proved through simulation and synthesis but not 
23
-- verified on Silicon
24
--
25
-------------------------------------------------------------------------------
26
 
27
LIBRARY ieee;
28
USE ieee.std_logic_1164.ALL;
29
USE ieee.std_logic_signed.All;
30
-------------------------------------------------------------------------------
31
-- Single port Memory core
32
 
33
 
34
LIBRARY ieee;
35
USE ieee.std_logic_1164.ALL;
36
 
37
 
38
 
39
ENTITY Spmem IS
40
generic ( add_width : integer := 3 ;
41
                 WIDTH : integer := 8);
42
 
43
  PORT (
44
    clk      : IN  std_logic;                     -- write clock
45
    reset    : IN  std_logic;                     -- System Reset
46
    add      : IN  std_logic_vector(add_width -1 downto 0);  --  Address
47
    Data_In  : IN  std_logic_vector(WIDTH -1  DOWNTO 0);  -- input data
48
    Data_Out : OUT std_logic_vector(WIDTH -1 DOWNTO 0);  -- Output Data
49
    WR       : IN  std_logic);                    -- Read Write Enable
50
END Spmem;
51
 
52
 
53
 
54
-------------------------------------------------------------------------------
55
-- This Architecture was tested on the ModelSim 5.2EE
56
-- The test vectors for model sim is included in vectors.do file
57
 
58
 
59
ARCHITECTURE spmem_v1 OF Spmem IS
60
 
61
 
62
 
63
  TYPE data_array IS ARRAY (integer range <>) OF std_logic_vector(7 DOWNTO 0);
64
                                        -- Memory Type
65
  SIGNAL data : data_array(0 to (2** add_width) );  -- Local data
66
 
67
 
68
 
69
  procedure init_mem(signal memory_cell : inout data_array ) is
70
  begin
71
 
72
    for i in 0 to (2** add_width) loop
73
      memory_cell(i) <= (others => '0');
74
    end loop;
75
 
76
  end init_mem;
77
 
78
BEGIN  -- spmem_v1
79
 
80
 
81
PROCESS (clk, reset)
82
--    VARIABLE result_data : std_logic_vector(WIDTH -1 DOWNTO 0);
83
 
84
 
85
BEGIN  -- PROCESS
86
    -- activities triggered by asynchronous reset (active low)
87
-- Data_Out <= (OTHERS => 'Z');
88
 
89
    IF reset = '0' THEN
90
      data_out <= (OTHERS => 'Z');
91
      init_mem ( data);
92
 
93
    -- activities triggered by rising edge of clock
94
    ELSIF clk'event AND clk = '1' THEN
95
        IF WR = '0' THEN
96
 
97
            data(conv_integer(add)) <= data_in;
98
        -- ELSE
99
         -- data_out <= data(conv_integer(add));
100
        END IF;
101
data_out <= data(conv_integer(add));
102
    END IF;
103
 
104
END PROCESS;
105
 
106
 
107
END spmem_v1;
108
 
109
 
110
 
111
 
112
-------------------------------------------------------------------------------
113
-- This Architecture was tested on the ModelSim 5.2EE
114
-- The test vectors for model sim is included in vectors.do file
115
-- It is Synthesized using Xilinx Webpack
116
--
117
-- This is the same as spmem_v1 but without the Z state
118
-- instead the output goes to all 1's during reset
119
 
120
 
121
 
122
 
123
ARCHITECTURE spmem_v2 OF Spmem IS
124
 
125
 
126
 
127
  TYPE data_array IS ARRAY (integer range <>) OF std_logic_vector(WIDTH -1 DOWNTO 0);
128
                                        -- Memory Type
129
  SIGNAL data : data_array(0 to (2** add_width) );  -- Local data
130
 
131
 
132
  procedure init_mem(signal memory_cell : inout data_array ) is
133
  begin
134
 
135
    for i in 0 to (2** add_width) loop
136
      memory_cell(i) <= (others => '0');
137
    end loop;
138
 
139
  end init_mem;
140
 
141
BEGIN  -- spmem_v2
142
 
143
 
144
PROCESS (clk, reset)
145
--    VARIABLE result_data : std_logic_vector(WIDTH -1 DOWNTO 0);
146
 
147
 
148
BEGIN  -- PROCESS
149
    -- activities triggered by asynchronous reset (active low)
150
 
151
    IF reset = '0' THEN
152
      data_out <= (OTHERS => '1');
153
      init_mem ( data);
154
 
155
    -- activities triggered by rising edge of clock
156
    ELSIF clk'event AND clk = '1' THEN
157
        IF WR = '0' THEN
158
 
159
            data(conv_integer(add)) <= data_in;
160
        -- ELSE
161
         -- data_out <= data(conv_integer(add));
162
        END IF;
163
data_out <= data(conv_integer(add));
164
    END IF;
165
 
166
END PROCESS;
167
 
168
 
169
END spmem_v2;

powered by: WebSVN 2.1.0

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