Virtex-6/Spartan-6 デバイスをターゲットにした場合、次のようなエラー メッセージが表示されます。しかし、これよりも前のデバイスをターゲットにすると、警告メッセージが表示されます。
この問題の解決方法を教えてください。
ERROR:HDLCompiler:410 - "<file>.vhd" Line xx: Expression has x elements ; expected y
コード例 :
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity ex_0006 is
port(a,b : in unsigned (7 downto 0);
res : out unsigned (8 downto 0));
end ex_0006;
architecture beh of ex_0006 is
begin
res <= a + b; -- Note: Error points here
end beh;
上記のコードは VHDL LRM に準拠していません。
この問題を解決するには、numeric_std パッケージの resize 関数を使用して割り当ての左側および右側を揃える必要があります。
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity ex_0006 is
port(a,b : in unsigned (7 downto 0);
res : out unsigned (8 downto 0));
end ex_0006;
architecture beh of ex_0006 is
begin
res <= resize(a,9) + resize(b,9); -- Note: Error points here
end beh;
ISE Design Suite 11.2 XST では、Virtex-6 および Spartan-6 ファミリ用に新しい VHDL/Verilog パーサーが採用されています。
この変更の詳細は、(ザイリンクス アンサー 32927) を参照してください。