|
我刚接触VHDL,联系编了一个比较器的程序,下面这个是我编的,后面那个是标准答案,请问各位答案里的i1,i2,i3还有后面那一段有什么作用,我觉得我编的已经表达出意思了啊,不过我没有在软件上编译,请各位帮我解答一下,谢谢~另外我还想问一下为什么看到的很多例子结构体的后面的名称都是rtl,有什么特殊含义么~
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY comparator IS
PORT(a0,a1,a2,a3:IN STD_LOGIC;
b0,b1,b2,b3:IN STD_LOGIC;
gt,eq,lt:OUT STD_LOGIC);
END comparator;
ARCHITECTURE rtl OF comparator IS
SINGAL a_tmp,b_tmp:STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
a_tmp<=a3&a2&a1&a0;
b_tmp<=b3&b2&b1&b0;
PROCESS(a_tmp,b_tmp)
BEGIN
IF(a_tmp>b_tmp) THEN
gt<='1',eq<='0',lt<='0';
ELSIF(a_tmp<b_tmp) THEN
gt<='0',eq<='0',lt<='1';
ELSIF(a_tmp=b_tmp) THEN
gt<='0',eq<='1',lt<='0';
END IF;
END PROCESS;
END rtl;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY comparator IS
PORT(a0,a1,a2,a3:IN STD_LOGIC;
b0,b1,b2,b3:IN STD_LOGIC;
i1,i2,i3:IN STD_LOGIC;
gt,eq,lt:OUT STD_LOGIC);
END comparator;
ARCHITECTURE rtl OF comparator IS
SINGAL a_tmp,b_tmp:STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
a_tmp<=a3&a2&a1&a0;
b_tmp<=b3&b2&b1&b0;
PROCESS(a_tmp,b_tmp,i1,i2,i3)
BEGIN
IF(a_tmp>b_tmp) THEN
gt<='1',eq<='0',lt<='0';
ELSIF(a_tmp<b_tmp) THEN
gt<='0',eq<='0',lt<='1';
ELSIF(a_tmp=b_tmp) THEN
IF(i2='1') THEN
gt<='0',eq<='1',lt<='0';
ELSIF(i1='1') THEN
gt<='1',eq<='0',lt<='0';
ELSIF(i3='1') THEN
gt<='0',eq<='0',lt<='1';
END IF;
END IF;
END PROCESS;
END rtl; |
|