如何测试 VHDL 文件
我已经用 VHDL 制作了一个双端口寄存器组,我想测试它以确保它有效。我该怎么做呢?我知道我想做什么(将寄存器 2 设置为常量,在测试程序中读出它,写入寄存器 3 并将其读回,看看是否有相同的结果)。
唯一的问题是,我是 VHDL 新手,所以我不知道是否有控制台,也不知道测试程序是如何构造的,也不知道如何实例化寄存器文件,甚至不知道用什么来编译它(我一直在使用 quartus迄今为止)。
这是我的注册文件:
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
-- Register File
entity RF is
port(
signal clk, we: in std_logic;
signal ImmediateValue : in std_logic_vector(15 downto 0);
signal RegisterSelectA, RegisterSelectB : in integer range 0 to 15;
signal AOut, BOut : out std_logic_vector(15 downto 0)
);
end RF
architecture behavior of RF is
array std_logic_vector_field is array(15 downto 0) of std_logic_vector(15 downto 0);
variable registers : std_logic_vector(15 downto 0);
process (clk, we, RegisterSelectA, RegisterSelectB, ImmediateValue)
wait until clk'event and clk = '1';
registers(RegisterSelectA) := ImmediateValue when we = '1';
AOut <= registers(RegisterSelectA);
BOut <= registers(RegisterSelectB);
end process;
end behavior;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,如果您是 VHDL 设计的新手,那么您最好从网络教程开始,或者阅读诸如 “VHDL 设计指南”。
不管怎样,就像软件设计一样,要测试VHDL设计,你必须编写一些测试代码。在硬件设计中,通常这些测试类似于单元测试,但通常称为“testbenches”。
对于您给出的设计,您需要创建如下内容:
First of all, if you are new to VHDL design, you might be best off starting with a tutorial on the web, or grabbing a book like "The Designer's Guide to VHDL".
Anyway, just like a software design, to test a VHDL design, you have to write some test code. In hardware design, usually these tests are unit-test like, but are often called "testbenches".
For the design you've given, you'll need to create something like this: