我一直在尝试使用配置单元的测试台。我有以下代码:
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY AND_2 IS
PORT (
a,b : IN std_logic;
x : OUT std_logic
);
END ENTITY AND_2;
ARCHITECTURE EX_1 OF AND_2 IS
BEGIN
x <= a and b;
END ARCHITECTURE EX_1;
ARCHITECTURE EX_2 OF AND_2 IS
SIGNAL ab : std_logic_vector(1 DOWNTO 0);
BEGIN
ab <= (a & b);
WITH ab SELECT
x <= '1' WHEN "11",
'0' WHEN OTHERS;
END ARCHITECTURE EX_2;
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY TEST_AND_2 IS
END ENTITY TEST_AND_2;
ARCHITECTURE IO OF TEST_AND_2 IS
SIGNAL a, b, x : std_logic;
BEGIN
G1 : ENTITY work.AND_2(EX_1) PORT MAP ( a => a, b => b, x => x);
a <= '0', '1' AFTER 100 NS;
b <= '0', '1' AFTER 200 NS;
END ARCHITECTURE IO;
CONFIGURATION TESTER1 OF TEST_AND_2 IS
FOR IO
FOR G1 : AND_2
USE ENTITY work.AND_2(EX_1);
END FOR;
END FOR;
END CONFIGURATION TESTER1;
编译时,我收到以下消息:
错误(10482):AND_2.vhd(48)处的VHDL错误:对象“AND_2”已使用但未声明
我正在阅读的书中没有明确使用测试台或配置单元。有人可以指出错误。但它可能很明显。 非常感谢 d
答案 0 :(得分:2)
如果您对实体使用直接实例化,则无法以这种方式使用配置。你在哪里:
G1 : ENTITY work.AND_2(EX_1) PORT MAP ( a => a, b => b, x => x);
这是直接实例化,通常可以节省输入和重复代码,但不允许通过配置指定体系结构。要在声明性区域(定义信号的位置)中使用配置,请为AND_2
声明一个组件:
COMPONENT AND_2 IS
PORT (
a,b : IN std_logic;
x : OUT std_logic
);
END COMPONENT;
然后像这样实例化AND_2
:
G1 : AND_2 PORT MAP ( a => a, b => b, x => x);
您的配置声明是正确的,您应该启动并运行这两项更改。