VHDL信号分配混乱

时间:2015-01-25 19:03:46

标签: vhdl hdl

我正在学习VHDL并遇到了一个我无法找到答案的问题。我理解下面的例子以及为什么结果是7:

architecture SIGN of EXAMPLE is
  signal TRIGGER, RESULT: integer := 0; 
  signal signal1: integer :=1;
  signal signal2: integer :=2;
  signal signal3: integer :=3;
begin

  process 
  begin
    wait on TRIGGER;
    signal1 <= signal2;
    signal2 <= signal1 + signal3;
    signal3 <= signal2;
    RESULT <= signal1 + signal2 + signal3;
  end process;

end SIGN;

然而,如果我将signal1放入敏感度列表会怎样?还是所有的信号?

2 个答案:

答案 0 :(得分:2)

首先,如果为流程创建了敏感性列表,则必须删除或注释掉wait on TRIGGER语句,因为具有敏感性列表的流程也不能包含wait语句。

如果signal1是过程敏感性列表,则只要对signal1进行更改,就会先运行该过程然后重新运行。

默认情况下的值或基于流程运行中的分配的值适用于signal1signal2signal3RESULT

Default.:  1,  2,  3,  0
First...:  2,  4,  2,  6
Re-run 1:  4,  4,  4,  8
Re-run 2:  4,  8,  4, 12

请记住,根据增量循环模拟模型,信号分配在过程完成后才会生效。

由于重新运行1和2之间的signal1没有变化,因此该进程不再运行,因此RESULT的值为12,从上次运行开始。

如果signal1signal2在过程敏感性列表中,则每个过程运行将改变其中一个信号,因此该过程将继续重新运行,直到达到模拟器增量循环迭代限制或integer数据类型将超出范围值,导致值不再进一步更改。

答案 1 :(得分:2)

你没有展示完整的例子以及你提出的改变,而是在挥手。

目前,为什么结果= 0?

为什么你没有模拟这一切?

entity example is
end entity;

architecture SIGN of EXAMPLE is
signal TRIGGER, RESULT: integer := 0; 
signal signal1: integer :=1;
signal signal2: integer :=2;
signal signal3: integer :=3;
begin
process 
begin
wait on TRIGGER;
signal1 <= signal2;
signal2 <= signal1 + signal3;
signal3 <= signal2;
RESULT <= signal1 + signal2 + signal3;
end process;
monitor:
    process(RESULT)
    begin
        report "RESULT = " & integer'image(RESULT);
    end process;
end SIGN;
  

sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 0

entity example is
end entity;

architecture SIGN of EXAMPLE is
signal TRIGGER, RESULT: integer := 0; 
signal signal1: integer :=1;
signal signal2: integer :=2;
signal signal3: integer :=3;
begin
process (signal1)
begin
-- wait on TRIGGER;
signal1 <= signal2;
signal2 <= signal1 + signal3;
signal3 <= signal2;
RESULT <= signal1 + signal2 + signal3;
end process;
monitor:
    process(RESULT)
    begin
        report "RESULT = " & integer'image(RESULT);
    end process;
end SIGN;
  

sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 0
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 6
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 8
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 12

entity example is
end entity;

architecture SIGN of EXAMPLE is
signal TRIGGER, RESULT: integer := 0; 
signal signal1: integer :=1;
signal signal2: integer :=2;
signal signal3: integer :=3;
begin
process (signal1, signal2, signal3)
begin
-- wait on TRIGGER;
signal1 <= signal2;
signal2 <= signal1 + signal3;
signal3 <= signal2;
RESULT <= signal1 + signal2 + signal3;
end process;
monitor:
    process(RESULT)
    begin
        report "RESULT = " & integer'image(RESULT);
    end process;
end SIGN;
  

sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 0
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 6
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 8
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 12
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 16
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 24
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 32
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 48
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 64
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 96
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 128
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 192
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 256
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 384
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 512
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 768
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 1024
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 1536
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 2048
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 3072
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 4096
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 6144
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 8192
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 12288
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 16384
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 24576
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 32768
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 49152
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 65536
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 98304
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 131072
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 196608
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 262144
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 393216
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 524288
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 786432
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 1048576
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 1572864
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 2097152
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 3145728
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 4194304
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 6291456
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 8388608
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 12582912
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 16777216
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 25165824
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 33554432
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 50331648
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= 67108864
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 100663296
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 134217728
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 201326592
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 268435456
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 402653184
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 536870912
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 805306368
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 1073741824
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 1610612736
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = -2147483648
  sign.vhdl:21:9:@ 0ms :(报告说明):结果= -1073741824
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 0
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = -2147483648
  sign.vhdl:21:9:@ 0ms :(报告说明):RESULT = 0

RESULTTRIGGER添加到敏感度列表会给出相同的答案。你能说出原因吗?

值rollover实际上揭示了这个VHDL实现中的一个错误。

IEEE Std 1076-2008,5.2.3整数类型,5.2.3.1概述,第7 / -1993号,3.1.2整数类型,第7段(注释9.2参考在1992年的7.2中):

  

为所有整数类型预定义相同的算术运算符(见9.2)。如果执行此类操作(特别是隐式转换)无法提供正确的结果(即,如果与数学结果对应的值不是整数类型的值),则会出错。

&#34;这是一个错误&#34;没有留下没有正确结果的余地。对于&#34; +&#34;模拟应该有一个错误。操作结果超过INTEGER&#39; HIGH。它未能测试声明为INTEGER类型的信号子类型的边界。