【问题标题】:sintaxis error that i can t understand with port map我无法通过端口映射理解的 sintaxis 错误
【发布时间】:2019-05-10 19:03:50
【问题描述】:

我正在尝试从一个 fulladder 1bit 做一个 4 位的 fulladder,但是我使用的 vivado 平台给出了语法错误,但我不知道为什么? 这是第一个模块(名称是 HA2(Fulladder1bits(我必须为 FA 更改字母 HA2,但我知道该怎么做)))

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity HA2 is
    Port ( a : in  STD_LOGIC;
           b : in  STD_LOGIC;
           s : out  STD_LOGIC;
           cin : in  STD_LOGIC;
           count : out  STD_LOGIC);
end HA2;

architecture Behavioral of HA2 is

begin

s <= a xor b xor cin;
count <= (a and b) or (cin and (a or b));

end Behavioral;

错误出现在下一个模块中(名为“fulladder4bits”):

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity fulladder4bits is
    Port ( A : in STD_LOGIC_VECTOR (3 downto 0);
           B : in STD_LOGIC_VECTOR (3 downto 0);
           S : out STD_LOGIC_VECTOR (3 downto 0);
           C3 : out STD_LOGIC);
end fulladder4bits;

architecture Behavioral of fulladder4bits is

COMPONENT HA2
    Port ( a : in  STD_LOGIC;
           b : in  STD_LOGIC;
           s : out  STD_LOGIC;
           cin : in  STD_LOGIC;
           count : out  STD_LOGIC);
end COMPONENT;
signal C0,C1,C2 : std_logic ;
begin

fa1 : HA2 port map(A(0),B(0),'0',S(0),C0) ;**HERE the plataform vivado give me a syntaxis error but i don t know why 
fa2 : HA2 port map(A(1),B(1),'C0',S(1),C1) ;**HERE 
fa3 : HA2 port map(A(2),B(2),'C1',S(2),C2) ;**HERE 
fa4 : HA2 port map(A(3),B(3),'C2',S(3),C3) ;**HERE 

end Behavioral;

但是由于错误以及我可以进行综合和实现的所有操作,所以我真的不知道问题出在哪里。

【问题讨论】:

    标签: vhdl vivado


    【解决方案1】:

    组件中端口的顺序很重要。实例化已与另一个订单一起使用。 scin 的顺序不正确。因此,您可以使用 to 的方式来解决问题。

    fa1: HA2 port map(A(0), B(0), S(0),'0', C0);
    fa2: HA2 port map(A(1), B(1), S(1), C0, C1);
    fa3: HA2 port map(A(2), B(2), S(2), C1, C2);
    fa4: HA2 port map(A(3), B(3), S(3), C2, C3);
    

    或者(这种方式是更好的选择)

    fa0:HA2 port map(a=>A(0), b=>B(0), cin=>'0', s=>S(0), count=>C0);
    fa1:HA2 port map(a=>A(1), b=>B(1), cin=>C0, s=>S(1), count=>C1);
    fa2:HA2 port map(a=>A(2), b=>B(2), cin=>C1, s=>S(2), count=>C2);
    fa3:HA2 port map(a=>A(3), b=>B(3), cin=>C2, s=>S(3), count=>C3);
    

    您的代码的第二个问题是端口映射中的 'C0' ('C1', 'C2')。它 应该是 C0 (C1, C2)。

    【讨论】:

      【解决方案2】:

      这解决了我的问题,但我真的不知道为什么:

      fa0:HA2 port map(a=>A(0),b=>B(0),cin=>'0',s=>S(0),count=>C0);
      fa1:HA2 port map(a=>A(1),b=>B(1),cin=>C0,s=>S(1),count=>C1);
      fa2:HA2 port map(a=>A(2),b=>B(2),cin=>C1,s=>S(2),count=>C2);
      fa3:HA2 port map(a=>A(3),b=>B(3),cin=>C2,s=>S(3),count=>C3);
      

      【讨论】:

      • IEEE Std 1076-2008 6.5.7 关联列表 6.5.7.1 “如果正式指示符明确出现,则称关联元素为命名;否则,称为是位置的。对于位置关联,关联列表中给定位置的实际指示符对应于界面列表中相同位置的界面元素。命名关联可以按任意顺序给出,. .." 您问题中的位置顺序不正确。命名的关联可以按照此处的任何给定顺序排列。
      猜你喜欢
      • 1970-01-01
      • 2022-10-17
      • 2016-09-20
      • 1970-01-01
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 2022-08-05
      相关资源
      最近更新 更多