| 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 |
|
|
---- behovorial description of a dual port ram with one 32-bit ----
|
| 10 |
|
|
---- 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 tdpram_generic is
|
| 55 |
|
|
generic (
|
| 56 |
|
|
depth : integer := 9
|
| 57 |
|
|
);
|
| 58 |
|
|
port (
|
| 59 |
|
|
-- port A
|
| 60 |
|
|
clkA : in std_logic;
|
| 61 |
|
|
addrA : in std_logic_vector(log2(depth)-1 downto 0);
|
| 62 |
|
|
weA : in std_logic;
|
| 63 |
|
|
dinA : in std_logic_vector(31 downto 0);
|
| 64 |
|
|
doutA : out std_logic_vector(31 downto 0);
|
| 65 |
|
|
-- port B
|
| 66 |
|
|
clkB : in std_logic;
|
| 67 |
|
|
addrB : in std_logic_vector(log2(depth)-1 downto 0);
|
| 68 |
|
|
weB : in std_logic;
|
| 69 |
|
|
dinB : in std_logic_vector(31 downto 0);
|
| 70 |
|
|
doutB : out std_logic_vector(31 downto 0)
|
| 71 |
|
|
);
|
| 72 |
|
|
end tdpram_generic;
|
| 73 |
|
|
|
| 74 |
|
|
architecture behavorial of tdpram_generic is
|
| 75 |
|
|
-- the memory
|
| 76 |
|
|
type ram_type is array (depth-1 downto 0) of std_logic_vector (31 downto 0);
|
| 77 |
|
|
shared variable RAM: ram_type;
|
| 78 |
|
|
|
| 79 |
|
|
-- xilinx constraint to use blockram resources
|
| 80 |
|
|
attribute ram_style : string;
|
| 81 |
|
|
attribute ram_style of RAM:variable is "block";
|
| 82 |
|
|
-- altera constraint
|
| 83 |
|
|
--attribute ramstyle : string;
|
| 84 |
|
|
--attribute ramstyle of RAM:variable is "M9K, no_rw_check";
|
| 85 |
|
|
begin
|
| 86 |
|
|
-- port A
|
| 87 |
|
|
process (clkA)
|
| 88 |
|
|
begin
|
| 89 |
|
|
if (clkA'event and clkA = '1') then
|
| 90 |
|
|
if ( weA = '1') then
|
| 91 |
|
|
RAM(conv_integer(addrA)) := dinA ;
|
| 92 |
|
|
end if;
|
| 93 |
|
|
doutA <= RAM(conv_integer(addrA));
|
| 94 |
|
|
end if;
|
| 95 |
|
|
end process;
|
| 96 |
|
|
|
| 97 |
|
|
-- port B
|
| 98 |
|
|
process (clkB)
|
| 99 |
|
|
begin
|
| 100 |
|
|
if (clkB'event and clkB = '1') then
|
| 101 |
|
|
if ( weB = '1') then
|
| 102 |
|
|
RAM(conv_integer(addrB)) := dinB ;
|
| 103 |
|
|
end if;
|
| 104 |
|
|
doutB <= RAM(conv_integer(addrB));
|
| 105 |
|
|
end if;
|
| 106 |
|
|
end process;
|
| 107 |
|
|
end behavorial;
|
| 108 |
|
|
|