--//////////////////////////////////////////////////////////////////////
|
--//////////////////////////////////////////////////////////////////////
|
--//// ////
|
--//// ////
|
--//// ////
|
--//// ////
|
--//// ////
|
--//// ////
|
--//// This file is part of the MicroSimplez project ////
|
--//// This file is part of the MicroSimplez project ////
|
--//// http://opencores.org/project,usimplez ////
|
--//// http://opencores.org/project,usimplez ////
|
--//// ////
|
--//// ////
|
--//// Description ////
|
--//// Description ////
|
--//// Implementation of MicroSimplez IP core according to ////
|
--//// Implementation of MicroSimplez IP core according to ////
|
--//// MicroSimplez IP core specification document. ////
|
--//// MicroSimplez IP core specification document. ////
|
--//// ////
|
--//// ////
|
--//// To Do: ////
|
--//// To Do: ////
|
--//// - ////
|
--//// - ////
|
--//// ////
|
--//// ////
|
--//// Author(s): ////
|
--//// Author(s): ////
|
--//// - Daniel Peralta, peraltahd@opencores.org, designer ////
|
--//// - Daniel Peralta, peraltahd@opencores.org, designer ////
|
--//// - Martin Montero, monteromrtn@opencores.org, designer ////
|
--//// - Martin Montero, monteromrtn@opencores.org, designer ////
|
--//// - Julian Castro, julyan@opencores.org, reviewer ////
|
--//// - Julian Castro, julyan@opencores.org, reviewer ////
|
--//// - Pablo A. Salvadeo, pas.@opencores, manager ////
|
--//// - Pablo A. Salvadeo, pas.@opencores, manager ////
|
--//// ////
|
--//// ////
|
--//////////////////////////////////////////////////////////////////////
|
--//////////////////////////////////////////////////////////////////////
|
--//// ////
|
--//// ////
|
--//// Copyright (C) 2011 Authors and OPENCORES.ORG ////
|
--//// Copyright (C) 2011 Authors 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 WIDTH_ADDRESS 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;
|
use ieee.numeric_std.all;
|
use ieee.numeric_std.all;
|
|
|
entity usimplez_ram is
|
entity usimplez_ram is
|
|
|
generic( WIDTH_WORD: natural:= 12;
|
generic( WIDTH_WORD: natural:= 12;
|
WIDTH_ADDRESS: natural:= 9
|
WIDTH_ADDRESS: natural:= 9
|
);
|
);
|
|
|
port
|
port
|
(
|
(
|
clk_i : in std_logic;
|
clk_i : in std_logic;
|
addr_i : in unsigned((WIDTH_ADDRESS-1) downto 0);
|
addr_i : in unsigned((WIDTH_ADDRESS-1) downto 0);
|
data_i : in std_logic_vector((WIDTH_WORD-1) downto 0);
|
data_i : in std_logic_vector((WIDTH_WORD-1) downto 0);
|
we_i : in std_logic ;
|
we_i : in std_logic ;
|
data_o : out std_logic_vector((WIDTH_WORD-1) downto 0)
|
data_o : out std_logic_vector((WIDTH_WORD-1) downto 0)
|
);
|
);
|
|
|
end usimplez_ram;
|
end usimplez_ram;
|
|
|
architecture rtl of usimplez_ram is
|
architecture rtl of usimplez_ram is
|
|
|
subtype word_t is std_logic_vector((WIDTH_WORD-1) downto 0);
|
subtype word_t is std_logic_vector((WIDTH_WORD-1) downto 0);
|
type memory_t is array(2**WIDTH_ADDRESS-1 downto 0) of word_t;
|
type memory_t is array(2**WIDTH_ADDRESS-1 downto 0) of word_t;
|
|
|
signal ram : memory_t;
|
signal ram : memory_t;
|
attribute ram_init_file : string;
|
attribute ram_init_file : string;
|
-- attribute ram_init_file of ram : signal is "sumador.mif"; --code sumador.txt
|
attribute ram_init_file of ram : signal is "adder.mif"; --code adder.txt
|
attribute ram_init_file of ram : signal is "fibonacci.mif"; --code fibonacci.txt
|
-- attribute ram_init_file of ram : signal is "fibonacci.mif"; --code fibonacci.txt
|
|
|
signal addr_reg_s : unsigned((WIDTH_ADDRESS-1) downto 0);
|
signal addr_reg_s : unsigned((WIDTH_ADDRESS-1) downto 0);
|
|
|
begin
|
begin
|
|
|
process(clk_i)
|
process(clk_i)
|
begin
|
begin
|
if(falling_edge(clk_i)) then
|
if(falling_edge(clk_i)) then
|
if(we_i = '1') then
|
if(we_i = '1') then
|
ram(to_integer(addr_i)) <= data_i;
|
ram(to_integer(addr_i)) <= data_i;
|
end if;
|
end if;
|
|
|
addr_reg_s <= addr_i;
|
addr_reg_s <= addr_i;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
data_o <= ram(to_integer(addr_reg_s));
|
data_o <= ram(to_integer(addr_reg_s));
|
|
|
end rtl;
|
end rtl;
|
|
|