PlayDoughが指摘している構文項目と欠落した宣言に加えて、パッケージnumeric_std(Synopsysの算術ページstd_logic_unsignedと混同しないでください)とmath_real(未使用)の2つの余分なコンテキスト節があります。すべての変更がで編集された後
:fv
への割り当てがありません注意して、
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
-- use ieee.numeric_std.all;
-- use ieee.math_real.all;
entity getgxgy is
generic (width : natural := 66;
height : natural := 130); -- width and height of the image window.
port(pxl : in std_logic_vector(7 downto 0);
clk : in bit;
fv : out real); -- need to configure 'fv' signal properly to appropriate bit vector.
end getgxgy; -- WAS gethogfv;
architecture behave of getgxgy is
function by2i (b : std_logic_vector(7 downto 0)) return natural is
variable num : natural;
begin
num := 0;
for i in b'range loop
if b(i) = '1' then
num := num + 2 ** i;
end if;
end loop; -- MISSING ';'
return num; -- MISSING ';'
end function by2i;
type bufarr is array (1 to height, 1 to width) of natural;
type gxgy is array (1 to height - 2, 1 to width - 2) of integer;
--signal tempfv : mat4;
begin -- for architecture modiy WAS MISSING
process (clk, pxl)
variable buf: bufarr;
variable gx, gy: gxgy;
variable mag, ang: gxgy; -- MISSING DECLARATIONS
begin
--buffer to store/create 64*128 pixels/widthindowidth
for h in 2 to height - 1 loop
for w in 2 to width - 1 loop
buf(h, w) := by2i(pxl); -- WAS buf(h)(w)
end loop;
end loop;
--1pixel padding
for w in 1 to width loop
buf(1, w) := 0; -- WAS buf(1)(w)
end loop;
for w in 1 to width loop
buf(height, w) := 0; -- WAS buf(height)(w)
end loop;
for h in 2 to height - 1 loop
buf(h, 1) := 0; -- WAS buf(h)(1)
end loop;
for h in 2 to height - 1 loop
buf(h, width) := 0; -- WAS buf(h)(width)
end loop;
--compute gradients
for h in 2 to height - 1 loop
for w in 2 to width - 1 loop
gx(h, w) := buf(h + 1, w) - buf(h - 1, w); -- WAS gx(h)(w), buf(h+1)(w) and buf(h-1)(w)
gy(h, w) := buf(h, w + 1) - buf(h, w - 1); -- WAS gy(h)(w), buf(h)(w+1) and buf(h)(w-1)
mag(h, w) := abs(gx(h, w) + gy(h, w)); -- WAS mag(h)(w), x(h)(w) and gy(h)(w)
ang(h, w) := gy(h, w)/gx(h, w); --WAS ang(h)(w), gy(h)(w) and gx(h)(w)
end loop;
end loop;
end process;
end architecture behave;
あなたのコードが分析し、詳しく説明、タイプREALは、対象と合成されていないとclk
のない合成資格を使用することはありません。
clk
がstd_logic(またはstd_ulogic)だった場合は、std_logic_1164関数rising_edgeを使用できます。認識された順序論理RTLクロックエッジに対して構築追加
を与える:
process (clk) -- pxl NOT NEEDED , pxl)
variable buf: bufarr;
variable gx, gy: gxgy;
variable mag, ang: gxgy; -- MISSING DECLARATIONS
begin
if clk'event and clk = '1' then
--buffer to store/create 64*128 pixels/widthindowidth
for h in 2 to height - 1 loop
for w in 2 to width - 1 loop
buf(h, w) := conv_integer(pxl); -- WAS buf(h)(w)
end loop; -- CHANGED to use conv_integer
end loop;
--1pixel padding
for w in 1 to width loop
buf(1, w) := 0; -- WAS buf(1)(w)
end loop;
for w in 1 to width loop
buf(height, w) := 0; -- WAS buf(height)(w)
end loop;
for h in 2 to height - 1 loop
buf(h, 1) := 0; -- WAS buf(h)(1)
end loop;
for h in 2 to height - 1 loop
buf(h, width) := 0; -- WAS buf(h)(width)
end loop;
--compute gradients
for h in 2 to height - 1 loop
for w in 2 to width - 1 loop
gx(h, w) := buf(h + 1, w) - buf(h - 1, w); -- WAS gx(h)(w), buf(h+1)(w) and buf(h-1)(w)
gy(h, w) := buf(h, w + 1) - buf(h, w - 1); -- WAS gy(h)(w), buf(h)(w+1) and buf(h)(w-1)
mag(h, w) := abs(gx(h, w) + gy(h, w)); -- WAS mag(h)(w), x(h)(w) and gy(h)(w)
ang(h, w) := gy(h, w)/gx(h, w); --WAS ang(h)(w), gy(h)(w) and gx(h)(w)
end loop;
end loop;
end if;
end process;
も機能by2i
を使用することから、パッケージstd_logic_unsigned機能conv_integerにスイッチを指摘しました。
したがって、これらの変更は、by2i関数の削除とともに行われます。
library ieee;
use ieee.std_logic_1164.all;
entity getgxgy_tb is
end entity;
architecture foo of getgxgy_tb is
signal pxl: std_logic_vector(7 downto 0) := (others => '0');
signal clk: bit;
signal fv: real;
begin
DUT:
entity work.getgxgy
port map (
pxl => pxl,
clk => clk,
fv => fv
);
CLOCK:
process
begin
wait for 10 ns;
clk <= not clk;
if now > 120 ns then
wait;
end if;
end process;
end architecture;
をそして、我々は手の込んだとテストベンチを実行し、実行時エラーを取得:
は、境界エラーを探すためにテストベンチをアップGenning!
ang
への割り当てでエラーがゼロ除算になるため、アルゴリズムにはまだ少しの作業が必要です。
if文で、私たちが割り当てにおける境界エラーがあります見つけることブロッキング:
gx(h, w) := buf(h + 1, w) - buf(h - 1, w); -- WAS gx(h)(w), buf(h+1)(w) and buf(h-1)(w)
そして、それはとき
type gxgy is array (1 to height - 2, 1 to width - 2) of integer;
タイプgxgy
の二次元w
= 65を押すことによって引き起こされていますw
に対応する範囲はwidth - 2
の範囲であり、w
はwidth - 1
に達する範囲外である。
それでは、さらにアルゴリズム的な表現の調整がまだあります。
登録する予定は特にありません。現在のところプロセスの感度リストがpxl
およびgx
に設定されている場合、gy
,mag
およびang
がシグナルに変換され、異なるプロセスで発生する可能性があるのはfv
の場合のみです。
abs、multiplies、およびdivideがすべてターゲットFPGAに収まらない可能性があり、算術演算に共通のリソースを使用して演算をいくつかのクロックに分散する必要があります。 VHDLはハードウェアを表し、すべてのオペレータ呼び出しまたは関数呼び出しは、それ自身のハードウェアを暗示することができます。
ループステートメントには、「展開された」ステートメントのシーケンスがあり、相互依存関係が見つからない場合は別のハードウェアが生成されます。あなたの入れ子にされたループの2〜1の範囲と2〜幅1の範囲では、gx
とgy
のそれぞれについて8001減算を意味し、absと加算してmag
を加算し、ang
の値を変更しますpxl
。これは、あなたのハードウェアが、時間と空間のトレードオフのうちのいくつかのクロックでリソースを共有することなく、どのFPGAにも適合しないことを示しています。
あなたのアルゴリズムはちょっとした作業が必要なだけでなく、実装リソースも考慮する必要があります。
VHDLでハードウェアを記述することはできません。
符号なしの値を含む 'std_logic_vector'を整数に変換する場合は、' value_as_int <= to_integer(unsigned(value_as_std_logic_vector)); 'を使用してください。 –