在fpga内部实现2个双口ram,可以实现乒乓操作 library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_ARITH.all; use IEEE.STD_LOGIC_UNSIGNED.all;
entity dualportram is port ( clk : in std_logic; --dout_1: inout std_logic_vector(7 downto 0); --dout_2: inout std_logic_vector(7 downto 0) dout : inout std_logic_vector(7 downto 0) ); end dualportram;
architecture action of dualportram is
component lpmramdp_1 PORT ( data : IN STD_LOGIC_VECTOR (15 DOWNTO 0); wren : IN STD_LOGIC := '1'; wraddress : IN STD_LOGIC_VECTOR (11 DOWNTO 0); rdaddress : IN STD_LOGIC_VECTOR (12 DOWNTO 0); clock : IN STD_LOGIC; q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); end component;
component lpmramdpplus PORT ( data : IN STD_LOGIC_VECTOR (15 DOWNTO 0); wren : IN STD_LOGIC := '1'; wraddress : IN STD_LOGIC_VECTOR (12 DOWNTO 0); rdaddress : IN STD_LOGIC_VECTOR (13 DOWNTO 0); clock : IN STD_LOGIC ; q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); end component;
signal wrCount_1 : std_logic_vector (11 DOWNTO 0); signal rdCount_1 : std_logic_vector (12 DOWNTO 0); signal dataIn_1 : std_logic_vector (15 downto 0); signal dataOut_1 : std_logic_vector (7 downto 0); signal wrCount_2 : std_logic_vector (12 DOWNTO 0); signal rdCount_2 : std_logic_vector (13 DOWNTO 0); signal dataIn_2 : std_logic_vector (15 downto 0); signal dataOut_2 : std_logic_vector (7 downto 0); signal flag:std_logic;
begin process(clk) begin if rising_edge(clk) then wrCount_1 <= wrCount_1 + 1; rdCount_1 <= rdCount_1 + 1; wrCount_2 <= wrCount_2 + 1; rdCount_2 <= rdCount_2 + 1; flag <= not flag; if (flag = '1') then dout <= dataOut_1; else dout <= dataOut_2; end if; end if; end process;
用户417832 2013-3-28 15:32