⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fifo.vhd

📁 在quartus开发环境下
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity fifo is
port(clk:in std_logic;-----时钟信号
     clr:in std_logic;-----清零信号
     wr:in std_logic;------写信号
     rd:in std_logic;------读信号
     din:in std_logic_vector(7 downto 0);-------数据写入端口 
     dout:out std_logic_vector(7 downto 0);-----数据读出端口
     empty:out std_logic;-------存储器为空信号
     full:out std_logic);-------存储器已满信号
end;
architecture one of fifo is
	type memory is array(0 to 7)of std_logic_vector(7 downto 0);-----定义存储空间
begin
process(clk,clr)
	variable a,b:integer range 0 to 7;-----地址
	variable data:memory;
	variable x,y:std_logic;-----------存储空间状态控制信号,控制存储空间是否为空或满
begin
if clr='1' then -----------------------清零
	dout<=(others=>'0');
	a:=0;b:=0;
	x:='0';y:='0';
elsif clk'event and clk='1' then
	if wr='1' and rd='0' and x='0' then-------写入数据
		data(a):=din;
		a:=a+1;
		y:='1';
		empty<='0';
		if a=b then 
		   x:='1';
		end if;
	elsif wr='0' and rd='1' and y='1' then----读出数据
		dout<=data(b);
		b:=b+1;
		x:='0';
		full<='0';
		if a=b then
		   y:='0';
		end if;
	end if;
	if x='0' and y='0' then-----------存储器为空
		empty<='1';
		dout<=(others=>'0');
	elsif x='1' and y='1' then--------存储器为满
		full<='1';
	end if;
end if;
end process;
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -