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 81

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
    clk : in std_logic;
60
    -- write port
61
    waddr : in std_logic_vector(log2(depth)-1 downto 0);
62
    we    : in std_logic;
63
    din   : in std_logic_vector(31 downto 0);
64
    -- read port
65
    raddr : in std_logic_vector(log2(depth)-1 downto 0);
66
    dout  : out std_logic_vector(31 downto 0)
67
  );
68
end dpram_generic;
69
 
70
architecture behavorial of dpram_generic is
71
  -- the memory
72
  type ram_type is array (depth-1 downto 0) of std_logic_vector (31 downto 0);
73 61 JonasDC
  signal RAM : ram_type := (others => (others => '0'));
74 59 JonasDC
 
75
  -- xilinx constraint to use blockram resources
76
  attribute ram_style : string;
77
  attribute ram_style of ram:signal is "block";
78 60 JonasDC
  -- altera constraints:
79
  -- for smal depths:
80 61 JonasDC
  --  if the synthesis option "allow any size of RAM to be inferred" is on, these lines 
81
  --  may be left commented.
82
  --  uncomment this attribute if that option is off and you know wich primitives should be used.
83 60 JonasDC
  --attribute ramstyle : string;
84 61 JonasDC
  --attribute ramstyle of RAM : signal is "M9K, no_rw_check";
85 59 JonasDC
begin
86
  process (clk)
87
  begin
88
    if (clk'event and clk = '1') then
89
      if (we = '1') then
90 61 JonasDC
        RAM(conv_integer(waddr)) <= din;
91 59 JonasDC
      end if;
92 61 JonasDC
      dout <= RAM(conv_integer(raddr));
93 59 JonasDC
    end if;
94
  end process;
95
end behavorial;
96
 

powered by: WebSVN 2.1.0

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