VHDL测试台、配置单元
VHDL test bench, configuration unit
我一直在尝试使用带有配置单元的测试台。我有以下代码:
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;
当我编译时,我收到以下消息:
Error (10482): VHDL error at AND_2.vhd(48): object "AND_2" is used but not declared
我看的书在test bench或者configuration unit的使用上不是很清楚。有人能指出错误吗。不管它多么明显。
非常感谢
D
如果您对实体使用直接实例化,则不能以这种方式使用配置。你在哪里:
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);
你的配置语句是正确的,你应该up并且运行这两个修改。
我一直在尝试使用带有配置单元的测试台。我有以下代码:
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;
当我编译时,我收到以下消息:
Error (10482): VHDL error at AND_2.vhd(48): object "AND_2" is used but not declared
我看的书在test bench或者configuration unit的使用上不是很清楚。有人能指出错误吗。不管它多么明显。 非常感谢 D
如果您对实体使用直接实例化,则不能以这种方式使用配置。你在哪里:
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);
你的配置语句是正确的,你应该up并且运行这两个修改。