2012-04-01 92 views
4

对于一个类,我被要求编写一个VHDL过程,它接受两个整数输入A和B,并用A + B和B用A-B替换A.我写了下面的程序和测试台。它完成实现和行为语法检查,但不会模拟。尽管我没有得到任何的错误,但我确实得到了一些警告,指出A和B在组合反馈循环中。有人可以解释一下问题可能是什么?VHDL程序

模块:

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; 
+0

这并没有得到任何意义...... – ferdepe 2017-01-27 15:17:43

回答

6

的问题是:

  1. 你的组件写入它自己的投入。这相当于一个无限循环。你这样做的原因是因为......
  2. 该问题的描述没有意义。

我被要求写一个VHDL程序,它有两个整数输入A和B ...

精细

...并取代了用...

什么?!

您不能替换A(或B),因为你会得到这个问题。您可以编写一个采用两个整数输入的过程,并给出两个整数输出。那些输出然后可以馈送一些寄存器,然后馈送输入,但是必须有一个寄存器来打破组合反馈循环。

1

不要在problem2实体内测试它。只需从您的测试台上直接调用该程序即可。

(此代码是没有测试!)

ABproc: process is 
begin 
    A<=25; 
    B<=22; 
    AB(A, B); 
    wait 1 ns; 
    assert A = 47; 
    assert B = 3; 
    wait; -- forever 
end process;