【问题标题】:Using configuration specification in VHDL/ModelSim在 VHDL/ModelSim 中使用配置规范
【发布时间】:2018-09-06 05:48:47
【问题描述】:

我正在尝试使用 VHDL 配置规范进行预设

这应该是可能的,如 IEEE1076-2008,第 7.3.2.1 节所示,其中给出了以下示例:

entity AND_GATE is
    generic (I1toO, I2toO: DELAY_LENGTH := 4 ns);
    port (I1, I2: in BIT; O: out BIT);
end entity AND_GATE;

entity XOR_GATE is
    generic (I1toO, I2toO: DELAY_LENGTH := 4 ns);
    port (I1, I2: in BIT; O: out BIT);
end entity XOR_GATE;

package MY_GATES is
    component AND_GATE is
        generic (I1toO, I2toO: DELAY_LENGTH := 4 ns);
        port (I1, I2: in BIT; O: out BIT);
    end component AND_GATE;
    component XOR_GATE is
        generic (I1toO, I2toO: DELAY_LENGTH := 4 ns);
        port (I1, I2: in BIT; O: out BIT);
    end component XOR_GATE;
end package MY_GATES;

entity Half_Adder is
    port (X, Y: in BIT; Sum, Carry: out BIT);
end entity Half_Adder;

use WORK.MY_GATES.all;

architecture Structure of Half_Adder is
    for L1: XOR_GATE use
        entity WORK.XOR_GATE(Behavior) -- The primary binding
            generic map (3 ns, 3 ns) -- indication for instance L1.
            port map (I1 => I1, I2 => I2, O => O);
    for L2: AND_GATE use
        entity WORK.AND_GATE(Behavior) -- The primary binding
            generic map (3 ns, 4 ns) -- indication for instance L2.
            port map (I1, open, O);
begin
    L1: XOR_GATE port map (X, Y, Sum);
    L2: AND_GATE port map (X, Y, Carry);
end architecture Structure;

use WORK.GLOBAL_SIGNALS.all;

configuration Different of Half_Adder is
    for Structure
        for L1: XOR_GATE
            generic map (2.9 ns, 3.6 ns); -- The incremental binding
        end for; -- indication of L1; rebinds its generics.
        for L2: AND_GATE
            generic map (2.8 ns, 3.25 ns) -- The incremental binding
            port map (I2 => Tied_High); -- indication of L2; rebinds
        end for; -- its generics and binds its open port.
    end for;
end configuration Different;

即使我自己添加示例中缺少的包

package GLOBAL_SIGNALS is
    constant Tied_High : bit := '1';
end package GLOBAL_SIGNALS;

Modelsim 中的细化仍然失败。

错误:[...]/half_adder.vhd(36): (vcom-1035) 正式端口“I2”已打开或没有实际关联。

线路造成的

port map (I1, open, O);

这似乎表明 Modelsim 不能正确支持这些配置语句。

我想使用此配置规范来简化我的设计输入。

例子:

entity comp is
    generic(step : time; defined: boolean);
    port(clk, data : in bit);
end entity;

entity e is end entity e;

architecture a of e is
    component comp is
        generic(step : time; defined: boolean);
        port(clk, data : in bit);
    end component;
    
    signal clk1, clk2 : bit;
    
    for a : comp use
        entity work.comp
            generic map(step => 1 ns)
            port map(clk => clk1);
    for b : comp use
        entity work.comp
            generic map(step => 100 ns)
            port map(clk => clk2);
    for all : comp use
        entity work.comp
            generic map(defined => true);

    signal sig_a, sig_b : bit;
    
begin
    a: comp
        port map(data => sig_a);

    b_gen : for i in 0 to 2 generate
        b: comp
            port map(data => sig_b);
    end generate;
end architecture;

这段代码抛出大量错误:

错误:[...]/e.vhd(19): (vcom-1031) 正式的泛型“已定义”已打开或没有实际关联。

错误:[...]/e.vhd(19): (vcom-1035) 正式端口“数据”已打开或没有实际关联。

错误:[...]/e.vhd(23): (vcom-1031) 正式的泛型“已定义”已打开或没有实际关联。

错误:[...]/e.vhd(23): (vcom-1035) 正式端口“数据”已打开或没有实际关联。

错误:[...]/e.vhd(26): (vcom-1031) 正式的通用“步骤”已打开或没有实际关联。

错误:[...]/e.vhd(24):组件“comp”的所有配置规范尝试重新绑定已绑定的实例。

错误:[...]/e.vhd(24):组件“comp”的所有配置规范尝试重新绑定已绑定的实例。

错误:[...]/e.vhd(32): (vcom-1031) 正式的通用“步骤”已打开或没有实际关联。

错误:[...]/e.vhd(32): (vcom-1031) 正式的泛型“已定义”已打开或没有实际关联。

错误:[...]/e.vhd(32): (vcom-1035) 正式端口“clk”已打开或没有实际关联。

错误:[...]/e.vhd(36): (vcom-1031) 正式的通用“步骤”已打开或没有实际关联。

错误:[...]/e.vhd(36): (vcom-1031) 正式的泛型“已定义”已打开或没有实际关联。

错误:[...]/e.vhd(36): (vcom-1035) 正式端口“clk”已打开或没有实际关联。

警告:[...]/e.vhd(24): (vcom-1263) 配置规范“all : comp”不适用于任何组件实例化语句。

错误:[...]/e.vhd(20):未找到带有标签“b”的语句。

因此,这似乎不是使用配置规范的受支持方式。太糟糕了,因为它会简化我的设计输入。

我这只是一个 Modelsim 错误,或者配置规范不会以这种方式帮助这些默认绑定?

【问题讨论】:

  • 配置声明中的配置规范可能非常强大——它们不需要更改原始设计描述。例如,您可以将一个库中的实体替换为另一个库,并提供一个允许使用不同实际名称的接口。这方面的一个例子是使用不同供应商的单元库。您没有使用它的部分原因是综合供应商不支持将其视为零和竞争的配置声明,而它们可用于测试平台中的验证,例如不同的抽象级别。
  • 正如 L2 的答案 I2 的评论中所指出的:AND_GATE 的端口映射是 Tied_High,来自未提供的包 global_signals 的信号描述为在库工作中通过 use 子句找到的。这将是位类型包中的信号,默认值为“1”。
  • @user1155120 哇,你甚至删除了你的答案并投了赞成票。仅供参考:我在我的问题中添加了更多信息以澄清我的观点。我发现这是必要的,因为在您的回答中,您告诉了我我已经知道的事情。对我来说,这意味着我需要改变我的问题,因为你不清楚我想知道什么。它仍然不是,似乎。
  • 您的问题包括“但是为什么 Modelsim 不接受我的配置规范?”这就是答案所要解决的问题。所有的编辑是什么?看来您只是想要一个场所来抱怨标准(而且我与 P1076 无关)。
  • 我的问题很严重。第一:有没有办法做我想做的事,使用配置。第二:modelsim 中的配置是否未正确实现。

标签: vhdl modelsim


【解决方案1】:

问题变了,答案也变了。

Modelsim 中的细化仍然失败。

错误:[...]/half_adder.vhd(36): (vcom-1035) 正式端口“I2”已打开或没有实际关联。

线路造成的

port map (I1, open, O);

这似乎已经表明 Modelsim 不能正确支持这些配置语句。

没有“正确”可以应用于您的结论,VHDL 标准不支持这一点。

该错误似乎是由于在 I2 未绑定时尝试详细说明 Half_Adder 引起的。配置规范将 I2 与 open 关联,这是不允许的。

如果你创建一个Minimal, Complete and Verifiable example:

-- IEEE Std 1076-1993 5.2.1 Binding Indication (example)
-- -2008 7.3.2.1

package global_signals is   -- THIS PACKAGE MISSING IN THE EXAMPLE
    signal Tied_High:   bit := '1';
end package;

entity AND_GATE is           -- ADDED entity and architecture
    generic (I1toO, I2toO: DELAY_LENGTH := 4 ns);
    port        (I1, I2: in BIT;   O: out BIT);
end entity AND_GATE;

architecture Behavior of AND_GATE is  -- ADDED
    signal In1, In2:    BIT;
begin
    In1 <= I1 after I1toO;
    In2 <= I2 after I2toO;

    O <= In1 and In2;

    process
    begin
        report
            LF & HT & "I1to0 = " & time'image(I1toO) &
            LF & HT & "I2to0 = " & time'image(I2toO);
        wait;
    end process;
end architecture Behavior;

entity XOR_GATE is            -- ADDED entity and architecture
    generic (I1toO, I2toO : DELAY_LENGTH := 4 ns);
    port        (I1, I2: in BIT;    O : out BIT);
end entity XOR_GATE;

architecture Behavior of XOR_GATE is  -- ADDED
    signal In1, In2:    BIT;
begin
    In1 <= I1 after I1toO;
    In2 <= I2 after I2toO;

    O <= In1 xor In2;

    process
    begin
        report
            LF & HT & "I1to0 = " & time'image(I1toO) &
            LF & HT & "I2to0 = " & time'image(I2toO);
        wait;
    end process;
end architecture Behavior;

package MY_GATES is
   component AND_GATE is
      generic  (I1toO, I2toO: DELAY_LENGTH := 4 ns);
      port       (I1, I2: in BIT;   O: out BIT);
   end component AND_GATE;

   component XOR_GATE is
      generic  (I1toO, I2toO: DELAY_LENGTH := 4 ns);
      port       (I1, I2: in BIT;   O : out BIT);
   end component XOR_GATE;
end package MY_GATES;

entity Half_Adder is
    port    (X, Y: in BIT;
               Sum, Carry: out BIT);
end entity Half_Adder;

use WORK.MY_GATES.all;
architecture Structure of Half_Adder is
    signal O:   bit;            -- Added
    for L1: XOR_GATE use
        entity WORK.XOR_GATE(Behavior)      --  The primary binding indication
             generic map (3 ns, 3 ns)       --  for instance L1.
             port map (I1 => I1, I2 => I2, O => O);

    for L2: AND_GATE use
        entity WORK.AND_GATE(Behavior)      --  The primary binding indication
             -- generic map (3 ns, 4 ns)       --  for instance L2.
             port map (I1, open, O);

begin
    L1: XOR_GATE    port map (X, Y, Sum);
    L2: AND_GATE    port map (X, Y, Carry);
end architecture Structure;

use WORK.GLOBAL_SIGNALS.all;

configuration Different of Half_Adder is
    for Structure
        for L1: XOR_GATE
            generic map (2.9 ns, 3.6 ns); --  The  incremental binding
        end for;               --  indication of L1; rebinds its generics.

        for L2: AND_GATE
            generic map (2.8 ns, 3.25 ns)  -- The incremental binding
            port map (I2 => Tied_High); -- indication L2; rebinds its generics
        end for;                          -- and binds its open port.
    end for;
end configuration Different;

在这种情况下,它在一个设计文件中进行分析、阐述和模拟:

ghdl -a Half_Adder.vhdl
ghdl -e 不同
ghdl -r 不同
Half_Adder.vhdl:44:9:@0ms:(报告说明): I1to0 = 2900000 fs I2to0 = 3600000 fs Half_Adder.vhdl:22:9:@0ms:(报告说明): I1to0 = 2800000 fs I2to0 = 3250000 fs

同时演示代码中表达的增量绑定功能是否正确。

请注意,这需要从包含最近 Github 提交的源代码构建的 ghdl 实现。

提交:9e0cf4af3cf2141002b37db9803c15afec8ea2f4 [9e0cf4a]
家长:b801510561
作者:特里斯坦·金戈尔德
日期:2017 年 10 月 30 日上午 7:19:41 GMT+13

分析、详细说明和运行上述 Half_Adder 需要在 2017 年 10 月 30 日之后从 Github 存储库构建的 ghdl,增量绑定的能力在更改应用语义分析的方式时意外丢失,最近恢复了。发布时,该功能将在 ghdl-0.35 中。

几年来没有人注意到这种缺失。该功能可能不像增量绑定的作者所希望的那样受到热烈欢迎。您还可以注意到标准中的示例不完整,并且在以后的修订中出现了额外的错字。 MCVe 现在已包含在 ghdl 的测试套件中。

您生成的第二个示例代码 (e.vhdl) 未提供配置声明。

附录 I(信息性)词汇表

增量绑定:配置声明中的绑定指示,它重新关联先前关联的本地通用常量或关联先前未关联的本地端口,称为增量重新绑定绑定指示适用的组件实例或多个实例。 (7.3.2.1)

这种“限制”是如何产生的,是语义要求的问题。

可以从 Jean-Michel Bergé、Alain Fonkoua、Serge Maginot 和 Jacques Rouillard 的著作“VHDL'92”的作者那里获得对增量绑定的理解。参见 VHDL'92, 6. Incremental Binding,第 47 至 56 页。

(增量绑定也可以在 IEEE Std P1076-1992c 中找到,随后被纳入 IEEE Std 1076-1993 修订版)。

您的第二个示例存在各种语义缺陷:

e.vhdl:

entity comp is
    generic(step : time; defined: boolean);
    port(clk, data : in bit);
end entity;

entity e is end entity e;

architecture a of e is
    component comp is
        generic(step : time; defined: boolean);
        port(clk, data : in bit);
    end component;

    signal clk1, clk2 : bit;

    for a : comp use                          -- Line 15
        entity work.comp
            generic map(step => 1 ns)
            port map(clk => clk1);
    for b : comp use                          -- Line 20
        entity work.comp
            generic map(step => 100 ns)
            port map(clk => clk2);
    for all : comp use                        -- Line 24
        entity work.comp
            generic map(defined => true);

    signal sig_a, sig_b : bit;

begin
    a: comp                                   -- Line 31
        port map(data => sig_a);

    b_gen : for i in 0 to 2 generate
        b: comp                              -- Line 35
            port map(data => sig_b);
    end generate;
end architecture;

除了缺少配置声明之外,该示例还通过 Modelsim 错误和警告以及 ghdl 展示了这些缺点:

ghdl -a e.vhdl
e.vhdl:31:5:error: no actual for constant interface "step"
e.vhdl:35:9:error: no actual for constant interface "step"
e.vhdl:20:9:error: no component instantation with label "b"
e.vhdl:24:5:error: component instance "a" is already bound by a configuration specification
e.vhdl:16:5:error: (previous is configuration specification)
ghdl:error: compilation error

综合工具通常支持配置规范,但不支持配置声明。当应用于面向硅的设计时,增量绑定并没有真正的实际用途。

【讨论】:

  • 谢谢。嗯,这意味着我不能对组件的不同默认分配使用配置规范,正如 IEEE1076-2008,第 7.3.2.1 节似乎表明的那样(有关更详细的示例,请参阅我的问题中的编辑。)这种方式我实际上没有看到配置规范的附加价值:可以在de组件声明中添加默认分配,并且可以在实例化label: entity work.ent_name(arch_name)中选择实体/架构。这种方式我认为配置规范的使用非常有限。 (使用时非常精细。)
  • 是的,你是对的。但是,通过使用默认绑定,您可能会错过忘记指定的绑定(这可能发生在大型 VLSI 设计中)。让它打开,你会得到一个错误。我想使用defined 泛型来检查配置是否已成功解析。但我好像做不到。
  • 我只是尝试在 Modelsim(-2008 模式)中运行 IEEE1076-2008 第 7.3.2.1 节中的示例。但似乎 Modelsim 不会计算。 “正式端口“I2”已打开或没有实际关联。”在架构StructureL2 的配置规范行。 Modelsim 错了,还是示例错了?无论如何,配置的附加值似乎并不高,因为他们没有付出足够的努力让它正常工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-10
  • 2016-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多