-- $Id: ram_1swsr_wfirst_gen.vhd 686 2015-06-04 21:08:08Z mueller $
|
-- $Id: ram_1swsr_wfirst_gen.vhd 686 2015-06-04 21:08:08Z mueller $
|
--
|
--
|
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
--
|
--
|
-- This program is free software; you may redistribute and/or modify it under
|
-- This program is free software; you may redistribute and/or modify it under
|
-- the terms of the GNU General Public License as published by the Free
|
-- the terms of the GNU General Public License as published by the Free
|
-- Software Foundation, either version 2, or at your option any later version.
|
-- Software Foundation, either version 2, or at your option any later version.
|
--
|
--
|
-- This program is distributed in the hope that it will be useful, but
|
-- This program is distributed in the hope that it will be useful, but
|
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
-- for complete details.
|
-- for complete details.
|
--
|
--
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
-- Module Name: ram_1swsr_rfirst_gen - syn
|
-- Module Name: ram_1swsr_rfirst_gen - syn
|
-- Description: Single-Port RAM with with one synchronous read/write port
|
-- Description: Single-Port RAM with with one synchronous read/write port
|
-- and 'read-through' semantics (as block RAM).
|
-- and 'read-through' semantics (as block RAM).
|
-- The 'ram_style' attribute is set to 'block', this will
|
-- The 'ram_style' attribute is set to 'block', this will
|
-- force in XST a synthesis as block RAM.
|
-- force in XST a synthesis as block RAM.
|
--
|
--
|
-- Notes: For xst 8.1.03i: can be written with a signal or a shared
|
-- Notes: For xst 8.1.03i: can be written with a signal or a shared
|
-- variable declared at the architecture level. Use variable
|
-- variable declared at the architecture level. Use variable
|
-- because this seemed better for simulation. Using a simple
|
-- because this seemed better for simulation. Using a simple
|
-- variable declared at process level leads to an array of
|
-- variable declared at process level leads to an array of
|
-- registers and a big mux.
|
-- registers and a big mux.
|
--
|
--
|
-- Dependencies: -
|
-- Dependencies: -
|
-- Test bench: -
|
-- Test bench: -
|
-- Target Devices: generic Spartan, Virtex
|
-- Target Devices: generic Spartan, Virtex
|
-- Tool versions: xst 8.2-14.7; ghdl 0.18-0.31
|
-- Tool versions: xst 8.2-14.7; ghdl 0.18-0.31
|
-- Revision History:
|
-- Revision History:
|
-- Date Rev Version Comment
|
-- Date Rev Version Comment
|
-- 2011-11-08 422 1.0.4 now numeric_std clean
|
-- 2011-11-08 422 1.0.4 now numeric_std clean
|
-- 2010-06-03 299 1.0.3 use sv_ prefix for shared variables
|
-- 2010-06-03 299 1.0.3 use sv_ prefix for shared variables
|
-- 2008-03-08 123 1.0.2 use std_..._arith, not _unsigned; use unsigned();
|
-- 2008-03-08 123 1.0.2 use std_..._arith, not _unsigned; use unsigned();
|
-- 2008-03-02 122 1.0.1 change generic default for BRAM models
|
-- 2008-03-02 122 1.0.1 change generic default for BRAM models
|
-- 2007-06-03 45 1.0 Initial version
|
-- 2007-06-03 45 1.0 Initial version
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.numeric_std.all;
|
use ieee.numeric_std.all;
|
|
|
use work.slvtypes.all;
|
use work.slvtypes.all;
|
|
|
entity ram_1swsr_wfirst_gen is -- RAM, 1 sync r/w ports, write first
|
entity ram_1swsr_wfirst_gen is -- RAM, 1 sync r/w ports, write first
|
generic (
|
generic (
|
AWIDTH : positive := 11; -- address port width
|
AWIDTH : positive := 11; -- address port width
|
DWIDTH : positive := 9); -- data port width
|
DWIDTH : positive := 9); -- data port width
|
port(
|
port(
|
CLK : in slbit; -- clock
|
CLK : in slbit; -- clock
|
EN : in slbit; -- enable
|
EN : in slbit; -- enable
|
WE : in slbit; -- write enable
|
WE : in slbit; -- write enable
|
ADDR : in slv(AWIDTH-1 downto 0); -- address port
|
ADDR : in slv(AWIDTH-1 downto 0); -- address port
|
DI : in slv(DWIDTH-1 downto 0); -- data in port
|
DI : in slv(DWIDTH-1 downto 0); -- data in port
|
DO : out slv(DWIDTH-1 downto 0) -- data out port
|
DO : out slv(DWIDTH-1 downto 0) -- data out port
|
);
|
);
|
end ram_1swsr_wfirst_gen;
|
end ram_1swsr_wfirst_gen;
|
|
|
|
|
architecture syn of ram_1swsr_wfirst_gen is
|
architecture syn of ram_1swsr_wfirst_gen is
|
|
|
constant memsize : positive := 2**AWIDTH;
|
constant memsize : positive := 2**AWIDTH;
|
constant datzero : slv(DWIDTH-1 downto 0) := (others=>'0');
|
constant datzero : slv(DWIDTH-1 downto 0) := (others=>'0');
|
type ram_type is array (0 to memsize-1) of slv(DWIDTH-1 downto 0);
|
type ram_type is array (0 to memsize-1) of slv(DWIDTH-1 downto 0);
|
shared variable sv_ram : ram_type := (others=>datzero);
|
shared variable sv_ram : ram_type := (others=>datzero);
|
|
|
attribute ram_style : string;
|
attribute ram_style : string;
|
attribute ram_style of sv_ram : variable is "block";
|
attribute ram_style of sv_ram : variable is "block";
|
|
|
signal R_DO : slv(DWIDTH-1 downto 0) := datzero;
|
signal R_DO : slv(DWIDTH-1 downto 0) := datzero;
|
|
|
begin
|
begin
|
|
|
proc_clk: process (CLK)
|
proc_clk: process (CLK)
|
begin
|
begin
|
if rising_edge(CLK) then
|
if rising_edge(CLK) then
|
if EN = '1' then
|
if EN = '1' then
|
if WE = '1' then
|
if WE = '1' then
|
sv_ram(to_integer(unsigned(ADDR))) := DI;
|
sv_ram(to_integer(unsigned(ADDR))) := DI;
|
end if;
|
end if;
|
R_DO <= sv_ram(to_integer(unsigned(ADDR)));
|
R_DO <= sv_ram(to_integer(unsigned(ADDR)));
|
end if;
|
end if;
|
end if;
|
end if;
|
end process proc_clk;
|
end process proc_clk;
|
|
|
DO <= R_DO;
|
DO <= R_DO;
|
|
|
end syn;
|
end syn;
|
|
|
|
|