博客
关于我
EDA设计——在 ISE 软件中 使用 VHDL 语言实现 FIFO 存储器
阅读量:345 次
发布时间:2019-03-04

本文共 4180 字,大约阅读时间需要 13 分钟。

FIFO实验与仿真验证

实验内容

本实验主要进行了FIFO(先进先出)队列的实现与仿真验证。通过VHDL(超级大规模积体电路)代码实现一个简单的FIFO模块,并利用仿真工具进行验证,以确保模块的正确性。

实验步骤

(1) 新建工程

创建一个新的VHDL项目,选择合适的工具链进行开发。
(2) 新建VHDL Module文件
在项目中添加一个新的VHDL文件,命名为fifo.vhd,用于存储FIFO模块的实现代码。
(3) 编写VHDL文件,编译运行
fifo.vhd中编写FIFO模块的逻辑代码,包括输入输出端口的定义、内部信号的声明以及主过程的实现。完成编写后,使用VHDL工具进行编译和运行,验证模块的基本功能是否正确。
(4) 新建仿真文件VHDL Test Bench
创建一个仿真测试基准文件,用于生成仿真输入信号并验证FIFO模块的行为。
(5) 编写仿真文件
在仿真测试基准文件中定义仿真输入信号(如时钟周期、写入启能信号、读取启能信号、重置信号等),并配置仿真工具进行仿真。
(6) 编译运行,观看仿真图形
完成仿真文件的编译后,启动仿真工具,运行仿真程序,并观察FIFO模块的行为是否符合预期。
(7) 得出实验结果,验证是否正确
根据仿真结果和实际测试数据,分析FIFO模块的性能,判断其是否满足设计要求。

实验结果

(1) 仿真激励 仿真过程中,通过设置适当的输入信号(如rst为0,write_en为1,等待时钟周期后rst为1)来激励FIFO模块的运行。具体激励步骤如下:

  • rst <= '0'; write_en <= '1'; 等待时钟周期;rst <= '1';
  • din <= "00000001"; 等待时钟周期;
  • din <= "00000010"; 等待时钟周期;
  • din <= "00000100"; 等待时钟周期;
  • din <= "00001000"; 等待时钟周期;
  • din <= "00010000"; 等待时钟周期;
  • din <= "00100000"; 等待时钟周期;
  • write_en <= '0'; 等待时钟周期;
  • read_en <= '1'; 等待10个时钟周期;
  • read_en <= '0';

(2) 运行结果

通过仿真工具观察到FIFO模块在激励输入信号后,能够正确地读取和写入数据,并输出相应的emptyfull信号。

代码附录

VHDL文件 fifo.vhd

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity fifo is
port(
clk : in std_logic;
write_en : in std_logic;
read_en : in std_logic;
rst : 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 fifo;
architecture Behavioral of fifo is
type fifo_array is array(0 to 63) of std_logic_vector(7 downto 0);
signal fifo_memory : fifo_array;
signal full_flag : std_logic;
signal empty_flag : std_logic;
signal read_add : std_logic_vector(5 downto 0);
signal write_add : std_logic_vector(5 downto 0);
signal counter : std_logic_vector(5 downto 0);
begin
process(rst, clk)
begin
if rst = '0' then
dout <= "00000000";
elsif clk'event and clk = '1' then
if read_en = '1' and empty_flag = '0' then
dout <= fifo_memory(conv_integer(read_add));
end if;
end if;
end process;
process(clk)
begin
if clk'event and clk = '1' then
if rst = '1' and write_en = '1' and full_flag = '0' then
fifo_memory(conv_integer(write_add)) <= din;
end if;
end if;
end process;
process(rst, clk)
begin
if rst = '0' then
write_add <= "000000";
elsif clk'event and clk = '1' then
if write_en = '1' and full_flag = '0' then
write_add <= write_add + 1;
end if;
end if;
end process;
process(rst, clk)
begin
if rst = '0' then
read_add <= "000000";
elsif clk'event and clk = '1' then
if read_en = '1' and empty_flag = '0' then
read_add <= read_add + 1;
end if;
end if;
end process;
process(rst, clk)
variable temp : std_logic_vector(1 downto 0);
begin
if rst = '0' then
counter <= "000000";
elsif clk'event and clk = '1' then
temp := read_en and write_en;
case temp is
when "00" =>
counter <= counter;
when "01" =>
if (counter /= "111111") then
counter <= counter + 1;
end if;
when "10" =>
if (counter /= "000000") then
counter <= counter - 1;
end if;
when "11" =>
counter <= counter;
when others =>
counter <= counter;
end case;
end if;
end process;
process(counter)
begin
if (counter = "000000") then
empty_flag <= '1';
else
empty_flag <= '0';
end if;
end process;
process(counter)
begin
if (counter = "111111") then
full_flag <= '1';
else
full_flag <= '0';
end if;
end process;
full <= full_flag;
empty <= empty_flag;
end Behavioral;

转载地址:http://kute.baihongyu.com/

你可能感兴趣的文章
nrf24l01+arduino
查看>>
nrf开发笔记一开发软件
查看>>
nrm —— 快速切换 NPM 源 (附带测速功能)
查看>>
nrm报错 [ERR_INVALID_ARG_TYPE]
查看>>
NS3 IP首部校验和
查看>>
NSDateFormatter的替代方法
查看>>
NSError 的使用方法
查看>>
NSGA-Ⅲ源代码
查看>>
nsis 安装脚本示例(转)
查看>>
NSJSON的用法(oc系统自带的解析方法)
查看>>
nslookup 的基本知识与命令详解
查看>>
NSNumber与NSInteger的区别 -bei
查看>>
NSOperation基本操作
查看>>
NSRange 范围
查看>>
NSSet集合 无序的 不能重复的
查看>>
NSURLSession下载和断点续传
查看>>
NSUserdefault读书笔记
查看>>
NS图绘制工具推荐
查看>>
NT AUTHORITY\NETWORK SERVICE 权限问题
查看>>
NT symbols are incorrect, please fix symbols
查看>>