【问题标题】:Entity Instantiation Inside of a Process进程内部的实体实例化
【发布时间】:2017-04-17 05:39:31
【问题描述】:

我正在尝试制作具有特定逻辑的全加器的二维数组及其输入和输出。我目前有两个用于生成行和列的语句,然后是一个 if-elsif-else 语句来决定如何连接该全加器。我的代码如下所示:

   rows : for row in 0 to n-1 generate
    columns : for col in 0 to n-1 generate
            if row = 0 then 
                null;
            elsif row = 1 then
                first: entity work.fa
                port map (  A => Ain(row)(col),
                                B => Bin(row)(col),
                                sum => sum(row+1)(col),
                                cin => cin,
                                cout => cout(row)(col+1)
                             );
            else
                process begin
                if (row = n/2) then
                    last: entity work.fa
                    port map ( A => Ain(row)(col),
                                B => Bin(row)(col-offset),
                                sum => sum(row)(col-offset),
                                cin => cin,
                                cout => cout(row)(col)
                             );
                else
                    middle: entity work.fa
                    port map (  A => mandq(row)(col-offset), 
                                B => sout(row)(col-offset),
                                sum => sout(row)(col-offset),
                                cin => cout(row)(col),
                                cout => cout(row)(col+1)
                             );
                end if;
                end process;
            end if;
            end process;
    end generate;
 end generate;

每个实体都收到以下错误: - “实体”附近的语法错误。 - “端口”附近的语法错误。 - “;”附近的语法错误。

标题为firstmiddlelast 的行出现“实体”错误

“端口”问题出现在实体之后的行上。

“;”包含以 ); 结尾的端口映射的行出现问题

【问题讨论】:

  • 流程语句部分只能包含顺序语句。组件实例化(例如您的设计实体 work.fa)是并发语句。
  • 您可以尝试使用if...generate 构造来生成需求实例化。
  • 您的代码示例不是 Minimal, Complete and Verifiable example 尤其缺少声明,这意味着有人很难向您展示正确的构造并且不可能复制错误。
  • 这能回答你的问题吗? port map in structural VHDL code

标签: vhdl hdl xilinx-ise digital-logic


【解决方案1】:

您不应使用if .. then,而应使用if .. generate。 在 VHDL-2008 中,这变得非常容易,因为支持 elsif .. generate 等。甚至case ... generate

你可以这样写:

rows : for row in 1 to n-1 generate -- shouldn't this only go to (n/2) ?
    columns : for col in 0 to n-1 generate
        element: case row generate
            -- when 0 no longer occurs with modified range
            when 1 =>
                first: entity work.fa
                port map (
                    A => Ain(row)(col),
                    B => Bin(row)(col),
                    sum => sum(row+1)(col),
                    cin => cin,
                    cout => cout(row)(col+1)
                    );
            when n/2 =>
                last: entity work.fa
                port map (
                    A => Ain(row)(col),
                    B => Bin(row)(col-offset),
                    sum => sum(row)(col-offset),
                    cin => cin,
                    cout => cout(row)(col)
                    );
            when others =>
                middle: entity work.fa
                port map (
                    A => mandq(row)(col-offset), 
                    B => sout(row)(col-offset),
                    sum => sout(row)(col-offset),
                    cin => cout(row)(col),
                    cout => cout(row)(col+1)
                    );
        end generate;
    end generate;
end generate;

【讨论】:

    【解决方案2】:
    1. 进程不应出现在 if 语句中。它应该只在架构主体内部自行运行。

    2. 您不能(也不需要)将流程用于实体实例化。在处理过程中,您编写了一些对时钟边缘敏感的顺序,或者例如一些并行语句。但绝对不是实体实例化。

    您可能想使用 process,因为它有 if...else 语句。它的并行等效项是when...else 语句。但我不确定它应该如何在这里使用。正如 cmets 中已经提到的 user1155120,您应该发布一个 Minimal, Complete and Verifiable example。您错过了所有声明,包括实体。

    编辑: 当然也有 if...generate,正如 J.H.Bonarius 所写。

    【讨论】:

    • if ... generate 怎么样? ;)
    猜你喜欢
    • 1970-01-01
    • 2011-05-03
    • 1970-01-01
    • 2016-07-13
    • 2015-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多