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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [techmap/] [inferred/] [memory_inferred.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
-----------------------------------------------------------------------------
19
-- Entity:      various
20
-- File:        mem_gen_gen.vhd
21
-- Author:      Jiri Gaisler Gaisler Research
22
-- Description: Behavioural memory generators
23
------------------------------------------------------------------------------
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
library grlib;
28
use grlib.stdlib.all;
29
 
30
entity generic_syncram is
31
  generic ( abits : integer := 10; dbits : integer := 8 );
32
  port (
33
    clk      : in std_ulogic;
34
    address  : in std_logic_vector((abits -1) downto 0);
35
    datain   : in std_logic_vector((dbits -1) downto 0);
36
    dataout  : out std_logic_vector((dbits -1) downto 0);
37
    write    : in std_ulogic
38
  );
39
end;
40
 
41
architecture behavioral of generic_syncram is
42
 
43
  type mem is array(0 to (2**abits -1))
44
        of std_logic_vector((dbits -1) downto 0);
45
  signal memarr : mem;
46
  signal ra  : std_logic_vector((abits -1) downto 0);
47
 
48
begin
49
 
50
  main : process(clk)
51
  begin
52
    if rising_edge(clk) then
53
      if write = '1' then
54
        memarr(conv_integer(address)) <= datain;
55
      end if;
56
      ra <= address;
57
    end if;
58
  end process;
59
 
60
  dataout <= memarr(conv_integer(ra));
61
 
62
end;
63
 
64
-- synchronous 2-port ram, common clock
65
 
66
LIBRARY ieee;
67
use ieee.std_logic_1164.all;
68
library grlib;
69
use grlib.stdlib.all;
70
 
71
entity generic_syncram_2p is
72
  generic (
73
    abits : integer := 8;
74
    dbits : integer := 32;
75
    sepclk: integer := 0
76
  );
77
  port (
78
    rclk : in std_ulogic;
79
    wclk : in std_ulogic;
80
    rdaddress: in std_logic_vector (abits -1 downto 0);
81
    wraddress: in std_logic_vector (abits -1 downto 0);
82
    data: in std_logic_vector (dbits -1 downto 0);
83
    wren : in std_ulogic;
84
    q: out std_logic_vector (dbits -1 downto 0)
85
  );
86
end;
87
 
88
architecture behav of generic_syncram_2p is
89
  type dregtype is array (0 to 2**abits - 1)
90
        of std_logic_vector(dbits -1 downto 0);
91
  signal rfd : dregtype;
92
  signal wa, ra : std_logic_vector (abits -1 downto 0);
93
begin
94
 
95
  wp : process(wclk)
96
  begin
97
    if rising_edge(wclk) then
98
      if wren = '1' then rfd(conv_integer(wraddress)) <= data; end if;
99
    end if;
100
  end process;
101
 
102
  oneclk : if sepclk = 0 generate
103
    rp : process(wclk) begin
104
    if rising_edge(wclk) then ra <= rdaddress; end if;
105
    end process;
106
  end generate;
107
 
108
  twoclk : if sepclk = 1 generate
109
    rp : process(rclk) begin
110
    if rising_edge(rclk) then ra <= rdaddress; end if;
111
    end process;
112
  end generate;
113
 
114
  q <= rfd(conv_integer(ra));
115
 
116
end;
117
 
118
 
119
library ieee;
120
use ieee.std_logic_1164.all;
121
library grlib;
122
use grlib.stdlib.all;
123
 
124
entity generic_regfile_3p is
125
  generic (tech : integer := 0; abits : integer := 6; dbits : integer := 32;
126
           wrfst : integer := 0; numregs : integer := 40);
127
  port (
128
    wclk   : in  std_ulogic;
129
    waddr  : in  std_logic_vector((abits -1) downto 0);
130
    wdata  : in  std_logic_vector((dbits -1) downto 0);
131
    we     : in  std_ulogic;
132
    rclk   : in  std_ulogic;
133
    raddr1 : in  std_logic_vector((abits -1) downto 0);
134
    re1    : in  std_ulogic;
135
    rdata1 : out std_logic_vector((dbits -1) downto 0);
136
    raddr2 : in  std_logic_vector((abits -1) downto 0);
137
    re2    : in  std_ulogic;
138
    rdata2 : out std_logic_vector((dbits -1) downto 0)
139
  );
140
end;
141
 
142
architecture rtl of generic_regfile_3p is
143
  type mem is array(0 to numregs-1)
144
        of std_logic_vector((dbits -1) downto 0);
145
  signal memarr : mem;
146
  signal ra1, ra2, wa  : std_logic_vector((abits -1) downto 0);
147
  signal din  : std_logic_vector((dbits -1) downto 0);
148
  signal wr  : std_ulogic;
149
 
150
begin
151
 
152
  main : process(wclk)
153
  begin
154
    if rising_edge(wclk) then
155
      din <= wdata; wr <= we;
156
      if (we = '1')
157
-- pragma translate_off
158
        and (conv_integer(waddr) < numregs)
159
-- pragma translate_on
160
      then wa <= waddr; end if;
161
      if (re1 = '1')
162
-- pragma translate_off
163
        and (conv_integer(raddr1) < numregs)
164
-- pragma translate_on
165
      then ra1 <= raddr1; end if;
166
      if (re2 = '1')
167
-- pragma translate_off
168
        and (conv_integer(raddr2) < numregs)
169
-- pragma translate_on
170
      then ra2 <= raddr2; end if;
171
      if wr = '1' then
172
        memarr(conv_integer(wa)) <= din;
173
      end if;
174
    end if;
175
  end process;
176
 
177
  rdata1 <= din when (wr = '1') and (wa = ra1) and (wrfst = 1)
178
        else memarr(conv_integer(ra1));
179
  rdata2 <= din when (wr = '1') and (wa = ra2) and (wrfst = 1)
180
        else memarr(conv_integer(ra2));
181
 
182
end;
183
 

powered by: WebSVN 2.1.0

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