网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> EDA >> Synplify综合 >> 文章正文
  存储器举例:(注3)FIFO           ★★★ 【字体:
存储器举例:(注3)FIFO
作者:61IC    文章来源:本站原创    点击数:    更新时间:2006-11-2    

-- A First-in First-out Memory

-- a first-in first out memory, uses a synchronising clock

-- generics allow fifos of different sizes to be instantiated

 

 

library IEEE;

use IEEE.Std_logic_1164.all;

 

entity FIFOMXN is

   generic(m, n : Positive := 8); --m is fifo depth, n is fifo width

   port(RESET, WRREQ, RDREQ, CLOCK : in Std_logic;

         DATAIN : in Std_logic_vector((n-1) downto 0);

         DATAOUT : out Std_logic_vector((n-1) downto 0);

         FULL, EMPTY : inout Std_logic);

end FIFOMXN;

 

architecture V2 of FIFOMXN is

 

   type Fifo_array is array(0 to (m-1)) of Bit_vector((n-1) downto 0);

   signal Fifo_memory : Fifo_array;

   signal Wraddr, Rdaddr, Offset : Natural range 0 to (m-1);

   signal Rdpulse, Wrpulse, Q1, Q2, Q3, Q4 : Std_logic;

   signal Databuffer : Bit_vector((n-1) downto 0);

 

begin

 

--pulse synchronisers for WRREQ and RDREQ

--modified for Synplify to a process

 

sync_ffs : process

        begin

                wait until rising_edge(CLOCK);

                Q1 <= WRREQ;

                Q2 <= Q1;

                Q3 <= RDREQ;

                Q4 <= Q3;

end process;

 

--concurrent logic to generate pulses

 

Wrpulse <= Q2 and not(Q1);

Rdpulse <= Q4 and not(Q3);  

 

 

Fifo_read : process

   begin

      wait until rising_edge(CLOCK);

      if RESET = '1' then

         Rdaddr <= 0;

         Databuffer <= (others => '0');

      elsif (Rdpulse = '1' and EMPTY = '0') then

         Databuffer <= Fifo_memory(Rdaddr);

         Rdaddr <= (Rdaddr + 1) mod m;

      end if;

   end process;

 

 

Fifo_write : process

   begin

      wait until rising_edge(CLOCK);

      if RESET = '1' then

         Wraddr <= 0;

      elsif (Wrpulse = '1' and FULL = '0') then

         Fifo_memory(Wraddr) <= To_Bitvector(DATAIN);

         Wraddr <= (Wraddr + 1) mod m;

      end if;

   end process;

 

Offset <= (Wraddr - Rdaddr) when (Wraddr > Rdaddr)

            else (m - (Rdaddr - Wraddr)) when (Rdaddr > Wraddr)

            else 0;

 

EMPTY <= '1' when (Offset = 0) else '0';

FULL <= '1' when (Offset = (m-1)) else '0';

 

DATAOUT <= To_Stdlogicvector(Databuffer) when RDREQ = '0'

            else (others => 'Z');

 

end V2;

 

注1: 含有不可综合语句,请自行修改

注2: 一些PLD只允许I/O口对外三态,不支持内部三态,使用时要注意

注3: 设计RAM的最好方法是利用器件厂家提供的软件自动生成RAM元件,并在VHDL程序中例化

 

               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    FFT实现的参考文献
    FPGA核NIOS全面接触(1)
    FPGA核NIOS全面接触(2)
    Quartus II 7.2正式版和crac…
    一种用VHDL语言实现的帧同步…
    二进制格雷码与自然二进制码…
    HDL其他相关资料
    HDL软件培训资料
    Verilog HDL参考资料
    VHDL语法参考资料
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号