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/] [tdpram_generic.vhd] - Diff between revs 59 and 60

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 59 Rev 60
----------------------------------------------------------------------  
----------------------------------------------------------------------  
----  dpram_generic                                               ---- 
----  tdpram_generic                                              ---- 
----                                                              ---- 
----                                                              ---- 
----  This file is part of the                                    ----
----  This file is part of the                                    ----
----    Modular Simultaneous Exponentiation Core project          ---- 
----    Modular Simultaneous Exponentiation Core project          ---- 
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
----                                                              ---- 
----                                                              ---- 
----  Description                                                 ---- 
----  Description                                                 ---- 
----    behovorial description of a dual port ram with one 32-bit ----
----    behavorial description of a true dual port ram with 2     ----
----    write port and one 32-bit read port                       ----            
----    32-bit write/read ports                                   ----        
----                                                              ---- 
----                                                              ---- 
----  Dependencies: none                                          ----
----  Dependencies: none                                          ----
----                                                              ----
----                                                              ----
----  Authors:                                                    ----
----  Authors:                                                    ----
----      - Geoffrey Ottoy, DraMCo research group                 ----
----      - Geoffrey Ottoy, DraMCo research group                 ----
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
----                                                              ---- 
----                                                              ---- 
---------------------------------------------------------------------- 
---------------------------------------------------------------------- 
----                                                              ---- 
----                                                              ---- 
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
----                                                              ---- 
----                                                              ---- 
---- This source file may be used and distributed without         ---- 
---- This source file may be used and distributed without         ---- 
---- restriction provided that this copyright statement is not    ---- 
---- restriction provided that this copyright statement is not    ---- 
---- removed from the file and that any derivative work contains  ---- 
---- removed from the file and that any derivative work contains  ---- 
---- the original copyright notice and the associated disclaimer. ---- 
---- the original copyright notice and the associated disclaimer. ---- 
----                                                              ---- 
----                                                              ---- 
---- This source file is free software; you can redistribute it   ---- 
---- This source file is free software; you can redistribute it   ---- 
---- and/or modify it under the terms of the GNU Lesser General   ---- 
---- and/or modify it under the terms of the GNU Lesser General   ---- 
---- Public License as published by the Free Software Foundation; ---- 
---- Public License as published by the Free Software Foundation; ---- 
---- either version 2.1 of the License, or (at your option) any   ---- 
---- either version 2.1 of the License, or (at your option) any   ---- 
---- later version.                                               ---- 
---- later version.                                               ---- 
----                                                              ---- 
----                                                              ---- 
---- This source is distributed in the hope that it will be       ---- 
---- This source is distributed in the hope that it will be       ---- 
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
---- details.                                                     ---- 
---- details.                                                     ---- 
----                                                              ---- 
----                                                              ---- 
---- You should have received a copy of the GNU Lesser General    ---- 
---- You should have received a copy of the GNU Lesser General    ---- 
---- Public License along with this source; if not, download it   ---- 
---- Public License along with this source; if not, download it   ---- 
---- from http://www.opencores.org/lgpl.shtml                     ---- 
---- from http://www.opencores.org/lgpl.shtml                     ---- 
----                                                              ---- 
----                                                              ---- 
----------------------------------------------------------------------
----------------------------------------------------------------------
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
 
 
library mod_sim_exp;
library mod_sim_exp;
use mod_sim_exp.std_functions.all;
use mod_sim_exp.std_functions.all;
 
 
-- altera infers ramblocks from a depth of 9
-- altera infers ramblocks from a depth of 9
-- xilinx infers ramblocks from a depth of 2
-- xilinx infers ramblocks from a depth of 2
entity tdpram_generic is
entity tdpram_generic is
  generic (
  generic (
    depth : integer := 9
    depth : integer := 9
  );
  );
  port (
  port (
    -- port A
    -- port A
    clkA  : in std_logic;
    clkA  : in std_logic;
    addrA : in std_logic_vector(log2(depth)-1 downto 0);
    addrA : in std_logic_vector(log2(depth)-1 downto 0);
    weA    : in std_logic;
    weA    : in std_logic;
    dinA   : in std_logic_vector(31 downto 0);
    dinA   : in std_logic_vector(31 downto 0);
    doutA  : out std_logic_vector(31 downto 0);
    doutA  : out std_logic_vector(31 downto 0);
    -- port B
    -- port B
    clkB  : in std_logic;
    clkB  : in std_logic;
    addrB : in std_logic_vector(log2(depth)-1 downto 0);
    addrB : in std_logic_vector(log2(depth)-1 downto 0);
    weB    : in std_logic;
    weB    : in std_logic;
    dinB   : in std_logic_vector(31 downto 0);
    dinB   : in std_logic_vector(31 downto 0);
    doutB  : out std_logic_vector(31 downto 0)
    doutB  : out std_logic_vector(31 downto 0)
  );
  );
end tdpram_generic;
end tdpram_generic;
 
 
architecture behavorial of tdpram_generic is
architecture behavorial of tdpram_generic is
  -- the memory
  -- the memory
  type ram_type is array (depth-1 downto 0) of std_logic_vector (31 downto 0);
  type ram_type is array (depth-1 downto 0) of std_logic_vector (31 downto 0);
  shared variable RAM: ram_type;
  shared variable RAM: ram_type;
 
 
  -- xilinx constraint to use blockram resources
  -- xilinx constraint to use blockram resources
  attribute ram_style : string;
  attribute ram_style : string;
  attribute ram_style of RAM:variable is "block";
  attribute ram_style of RAM:variable is "block";
  -- altera constraint
  -- altera constraints:
 
  -- for smal depths:
 
  --  if the synthesis option : allow any size of RAM to be inferred, is on these lines 
 
  --  may be left uncommented.
 
  --  uncomment this attribute if that option is of and you know wich primitives should be used.
  --attribute ramstyle : string;
  --attribute ramstyle : string;
  --attribute ramstyle of RAM:variable is "M9K, no_rw_check";
  --attribute ramstyle of ram : signal is "M9K, no_rw_check";
begin
begin
  -- port A
  -- port A
  process (clkA)
  process (clkA)
  begin
  begin
    if (clkA'event and clkA = '1') then
    if (clkA'event and clkA = '1') then
      if ( weA = '1') then
      if ( weA = '1') then
        RAM(conv_integer(addrA)) := dinA ;
        RAM(conv_integer(addrA)) := dinA ;
      end if;
      end if;
        doutA <= RAM(conv_integer(addrA));
        doutA <= RAM(conv_integer(addrA));
    end if;
    end if;
  end process;
  end process;
 
 
  -- port B
  -- port B
  process (clkB)
  process (clkB)
  begin
  begin
    if (clkB'event and clkB = '1') then
    if (clkB'event and clkB = '1') then
      if ( weB = '1') then
      if ( weB = '1') then
        RAM(conv_integer(addrB)) := dinB ;
        RAM(conv_integer(addrB)) := dinB ;
      end if;
      end if;
        doutB <= RAM(conv_integer(addrB));
        doutB <= RAM(conv_integer(addrB));
    end if;
    end if;
  end process;
  end process;
end behavorial;
end behavorial;
 
 
 
 

powered by: WebSVN 2.1.0

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