數(shù)據(jù)流描述(dataflow description)是結(jié)構(gòu)體描述方法之一,它描述了數(shù)據(jù)流程的運(yùn)動(dòng)路徑、運(yùn)動(dòng)方向和運(yùn)動(dòng)結(jié)果。例如,同樣是一個(gè)8位比較器采用數(shù)據(jù)流法編程,則如例1所示:
【例1】 用數(shù)據(jù)流描述法設(shè)計(jì)8位比較器
library ieee;
use ieee std_logic_1164.all;
entity comparator is
port (a,b:in std_logic_vector(7 downto 0);
g:out std_logic);
end comparator;
architecture dataflow of comp is
begin
g <=1 when (a = b) else0;
end dataflow;
上述程序設(shè)計(jì)的數(shù)據(jù)流程為:當(dāng)a=b時(shí),g=1;其余時(shí)間g=0。注意,數(shù)據(jù)流描述的句法與行為描述的句法是不一樣的。
cale—when:條件信號(hào)賦值語(yǔ)句。
with—select—when:選擇信號(hào)賦值語(yǔ)句。
這兩種語(yǔ)句是數(shù)據(jù)流描述法常用的語(yǔ)法,同樣采用布爾方程,也可用數(shù)據(jù)流描述法,如例2所示。
【例2】 用布爾方程的數(shù)據(jù)流描述法設(shè)計(jì)的8位比較器
library ieee;
use ieee std_logic_1164.all;
entity comparator is
port (a,b:in std_logic_vector(7 downto 0);
g:out std_logic);
end comparator;
architecture bool of comparator is
begin
g<=not(a(0)xorb(0))and
not(a(1)xorb(1))
and not(a(2)xorb(2))
and not(a(3)xorb(3))
and not(a(4)xorb(4))
and not(a(5)xorb(5))
and not(a(6)xorb(6))
and not(a(7)xorb(7));
end bool;
布爾方程的數(shù)據(jù)流描述法描述了信號(hào)的數(shù)據(jù)流的路徑。這種描述法比例1-6的結(jié)構(gòu)體復(fù)雜,因?yàn)槔?-6的結(jié)構(gòu)體描述與端口結(jié)構(gòu)無關(guān)。只要a=b,g就輸出1,與a、b的大小無關(guān)。而例1-7是一個(gè)8位比較器,布爾方程定義的端口尺寸為8位。
數(shù)據(jù)流描述法采用并發(fā)信號(hào)賦值語(yǔ)句,而不是進(jìn)程順序語(yǔ)句。一個(gè)結(jié)構(gòu)體可以有多重信號(hào)賦值語(yǔ)句,且語(yǔ)句可以并發(fā)執(zhí)行。