【问题标题】:Syntax error in VHDLVHDL 中的语法错误
【发布时间】:2011-02-22 02:49:52
【问题描述】:

我正在尝试使用结构化 VHDL 和组件来实现一位计数器。 尝试执行端口映射时出现语法错误。 错误是“错误 (10028): Can't resolve multiple constant drivers for net "P" at Assign4.vhd(47)” 这是我到目前为止所拥有的: 提前感谢您的任何想法。

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--------------------------------------------------------------
Entity Assign4 is
      Generic (bits: POSITIVE := 1);
      Port (CLK: in std_logic;
            SE1,SE2: in std_logic;
            P: out std_logic);
End Entity Assign4;
---------------------------------------------------------------
Architecture Structural of Assign4 is 
--------------------------------
Component Counter is
--    Generic (N: Positive := 1);
    Port(clock,sel1,sel2: in std_logic;
         Q: out std_logic);
End Component;
--------------------------------
Signal x,y,z: std_logic;

begin
P <= x;
--Qn <= x;
  process(CLK)
  begin
    if (Clk'event and CLK = '1') then
        x <= x xor (SE1 and SE2);

    end if;
  end process;

--------------COUNTER-------------------------------------
count1: Counter PORT MAP (clk,SE1,SE2,P);
---------------END COUNTER--------------------------------


-- The generate will be used later for implementing more bits in the counter
--gen: FOR i IN 0 TO 1 GENERATE
--  count1: Counter PORT MAP (SE1 <= inbits(0),SE2 <= inbits(1),clock <= CLK, 
--                            outA <= SE1 and SE2, q <= outA xor  q);
--end GENERATE gen;

---------------------------------------------------

end Architecture;

【问题讨论】:

  • @TomiJ 有正确的答案。但是您的代码中还有一些其他问题: 1. 避免使用 ieee.std_logic_unsigned.all。改用 ieee.numeric_std:parallelpoints.com/node/3 2. 你有两个死信号 Y 和 Z。我敢打赌你写它们是因为你以后想使用它们。
  • 别忘了添加一个重置来初始化X(你的状态),否则什么都不会发生。
  • 非常感谢你们。是的,你是对的 TomiJ 是对的。代码现在可以工作了。

标签: syntax counter vhdl hdl


【解决方案1】:

错误信息不言自明:您从两个不同的地方驾驶 P:

P <= x;

count1: Counter PORT MAP (clk, SE1, SE2, P);

(在 Counter 组件中,您已将最后一个端口列为输出,因此它也在驱动 P。)

我不能说你想要哪种说法,虽然很可能是后者;您需要注释掉第一个分配,这将解决此编译错误。

【讨论】:

    【解决方案2】:

    在端口映射语句中,语法为

    label: componentName PORT MAP (componentSig => externalSig, ...)
    

    你的箭头指向错误的方向。

    【讨论】:

    • jualin 代码中的那部分似乎被注释掉了。
    • @Jualin,您可能希望删除问题中的注释代码。这只会让以后阅读它的人感到困惑。
    • 是的,这是来自之前的测试。我忘了把它取下来。
    • 啊,我一定错过了评论字符。箭头仍然向后,但这不是问题。 TomiJ 是对的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多