VHDL实现FIFO

FIFO

FIFO缓冲器经常使用在很多设计中,成为连接具有相同或者不同时钟的子系统的桥梁,来达到临时访问的要求。
下面的代码实现的是深度8字,宽度9bits的的FIFO,包含组合和同步逻辑设计。

代码

------------------------------------------------------------------------------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity fifo89 is
    Port (     	
    	clk : in std_logic;
        rst : in std_logic;
        rd : in std_logic;
        wr : in std_logic;
        rdinc : in std_logic;
        wrinc : in std_logic;
        rdptrclr : in std_logic;
        wrptrclr : in std_logic;
        data_in : in std_logic_vector(8 downto 0);
        data_out : out std_logic_vector(8 downto 0));
end fifo89;

-- clk: used to synchronize the buffers;
-- rst: reset the buffers
-- rd: when valid, the output buffers are enabled;
-- wr: when valid, write register with 9-bit width is permitted; 
-- rdinc: read counter enabled;
-- wrinc: write counter enabled;
-- rdptrclr: reset read counter, pointing to the first register for
-- read purpose;
-- wrptrclr: reset write counter, pointing to the first register for
-- write purpose;
-- data_in: data inputs with 9-bit width to the FIFOs;
-- data_out: data outputs with 9-bit width from the FIFOs.

architecture Behavioral of fifo89 is
	type fifo_array is array(7 downto 0) of std_logic_vector(8 downto 0);
	signal fifo: fifo_array;
	signal wrptr, rdptr: std_logic_vector(2 downto 0);
	signal en: std_logic_vector( 7 downto 0);
	signal dmuxout: std_logic_vector(8 downto 0);

begin
	
-- fifo register_array:
reg_array: process (rst, clk)
	begin
		if rst = '1' then
			for i in 7 downto 0 loop
				fifo(i) <
  • 3
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

壹零捌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值