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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [trunk/] [rtl/] [vhdl/] [ram/] [dpram_generic.vhd] - Blame information for rev 96

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

Line No. Rev Author Line
1 59 JonasDC
----------------------------------------------------------------------  
2
----  dpram_generic                                               ---- 
3
----                                                              ---- 
4
----  This file is part of the                                    ----
5
----    Modular Simultaneous Exponentiation Core project          ---- 
6
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
7
----                                                              ---- 
8
----  Description                                                 ---- 
9 60 JonasDC
----    behavorial description of a dual port ram with one 32-bit ----
10 59 JonasDC
----    write port and one 32-bit read port                       ----            
11
----                                                              ---- 
12
----  Dependencies: none                                          ----
13
----                                                              ----
14
----  Authors:                                                    ----
15
----      - Geoffrey Ottoy, DraMCo research group                 ----
16
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
17
----                                                              ---- 
18
---------------------------------------------------------------------- 
19
----                                                              ---- 
20
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
21
----                                                              ---- 
22
---- This source file may be used and distributed without         ---- 
23
---- restriction provided that this copyright statement is not    ---- 
24
---- removed from the file and that any derivative work contains  ---- 
25
---- the original copyright notice and the associated disclaimer. ---- 
26
----                                                              ---- 
27
---- This source file is free software; you can redistribute it   ---- 
28
---- and/or modify it under the terms of the GNU Lesser General   ---- 
29
---- Public License as published by the Free Software Foundation; ---- 
30
---- either version 2.1 of the License, or (at your option) any   ---- 
31
---- later version.                                               ---- 
32
----                                                              ---- 
33
---- This source is distributed in the hope that it will be       ---- 
34
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
35
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
36
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
37
---- details.                                                     ---- 
38
----                                                              ---- 
39
---- You should have received a copy of the GNU Lesser General    ---- 
40
---- Public License along with this source; if not, download it   ---- 
41
---- from http://www.opencores.org/lgpl.shtml                     ---- 
42
----                                                              ---- 
43
----------------------------------------------------------------------
44
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
use ieee.std_logic_unsigned.all;
48
 
49
library mod_sim_exp;
50
use mod_sim_exp.std_functions.all;
51
 
52
-- altera infers ramblocks from a depth of 9
53
-- xilinx infers ramblocks from a depth of 2
54
entity dpram_generic is
55
  generic (
56
    depth : integer := 2
57
  );
58
  port  (
59 94 JonasDC
    -- write port A
60
    clkA   : in std_logic;
61
    waddrA : in std_logic_vector(log2(depth)-1 downto 0);
62
    weA    : in std_logic;
63
    dinA   : in std_logic_vector(31 downto 0);
64
    -- read port B
65
    clkB   : in std_logic;
66
    raddrB : in std_logic_vector(log2(depth)-1 downto 0);
67
    doutB  : out std_logic_vector(31 downto 0)
68 59 JonasDC
  );
69
end dpram_generic;
70
 
71
architecture behavorial of dpram_generic is
72
  -- the memory
73
  type ram_type is array (depth-1 downto 0) of std_logic_vector (31 downto 0);
74 94 JonasDC
  shared variable RAM : ram_type := (others => (others => '0'));
75 59 JonasDC
 
76
  -- xilinx constraint to use blockram resources
77
  attribute ram_style : string;
78 94 JonasDC
  attribute ram_style of ram:variable is "block";
79 60 JonasDC
  -- altera constraints:
80
  -- for smal depths:
81 61 JonasDC
  --  if the synthesis option "allow any size of RAM to be inferred" is on, these lines 
82
  --  may be left commented.
83
  --  uncomment this attribute if that option is off and you know wich primitives should be used.
84 60 JonasDC
  --attribute ramstyle : string;
85 94 JonasDC
  --attribute ramstyle of RAM : variable is "M9K, no_rw_check";
86 59 JonasDC
begin
87 94 JonasDC
  process (clkA)
88 59 JonasDC
  begin
89 94 JonasDC
    if rising_edge(clkA) then
90
      if (weA = '1') then
91
        RAM(conv_integer(waddrA)) := dinA;
92 59 JonasDC
      end if;
93
    end if;
94
  end process;
95 94 JonasDC
 
96
  process (clkB)
97
  begin
98
    if rising_edge(clkB) then
99
      doutB <= RAM(conv_integer(raddrB));
100
    end if;
101
  end process;
102
 
103 59 JonasDC
end behavorial;
104
 

powered by: WebSVN 2.1.0

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