数据流描述(dataflow description)是结构体描述方法之一,它描述了数据流程的运动路径、运动方向和运动结果。例如,同样是一个8位比较器采用数据流法编程,则如例1所示:
【例1】 用数据流描述法设计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;
上述程序设计的数据流程为:当a=b时,g=1;其余时间g=0。注意,数据流描述的句法与行为描述的句法是不一样的。
cale—when:条件信号赋值语句。
with—select—when:选择信号赋值语句。
这两种语句是数据流描述法常用的语法,同样采用布尔方程,也可用数据流描述法,如例2所示。
【例2】 用布尔方程的数据流描述法设计的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;
布尔方程的数据流描述法描述了信号的数据流的路径。这种描述法比例1-6的结构体复杂,因为例1-6的结构体描述与端口结构无关。只要a=b,g就输出1,与a、b的大小无关。而例1-7是一个8位比较器,布尔方程定义的端口尺寸为8位。
数据流描述法采用并发信号赋值语句,而不是进程顺序语句。一个结构体可以有多重信号赋值语句,且语句可以并发执行。