对于一堂课,我被要求编写一个VHDL过程,该过程接受两个整数输入A和B,然后将A替换为A + B,将B替换为A-B。我编写了以下程序和测试平台。它完成了实现和“行为语法”检查,但不会进行模拟。尽管没有错误,但我确实收到一些警告,指出A和B处于组合反馈循环中。有人可以阐明可能是什么问题吗?
模块:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Problem2 is
Port ( A : inout integer;
B : inout integer);
end Problem2;
architecture Behavioral of Problem2 is
procedure AB (signal A,B: inout integer) is
begin
A<=A+B after 20 ns;
B<=A-B after 30 ns;
end AB;
begin
AB(A=>A, B=>B);
end Behavioral;
试验台:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY Problem2_test IS
END Problem2_test;
ARCHITECTURE behavior OF Problem2_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT Problem2
PORT(
A : INOUT integer;
B : INOUT integer
);
END COMPONENT;
--BiDirs
signal A : integer;
signal B : integer;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Problem2 PORT MAP (
A => A,
B => B
);
ABproc: process is
begin
A<=25;
B<=22;
wait;
end process;
END;
最佳答案
问题是:
您的组件将写入自己的输入。这等效于无限循环。您这样做的原因是因为....
问题的描述没有意义。
我被要求编写一个VHDL过程,该过程需要两个整数输入A和B。
精细
...并将A替换为...
什么?!
您无法替换A
(或B
),因为会遇到此问题。您可以编写一个接受两个整数输入并给出两个整数输出的过程。这些输出然后可以提供一些寄存器,然后再提供输入,但是必须有一个寄存器才能中断组合反馈环路。