好吧,<=是任务.
signal <= A or B;
Run Code Online (Sandbox Code Playgroud)
=>是用于case语句的语法,如:(来自http://www.cs.umbc.edu/portal/help/VHDL/sequential.html)
case my_val is
when 1 => // This is kind of like how the : operator is used for switch in many languages
a:=b;
when 3 =>
c:=d;
do_it;
when others =>
null; // do nothing
end case;
end case;
Run Code Online (Sandbox Code Playgroud)
=>也可用于数组赋值
myVector <= (1=>'1', OTHERS=>'0'); -- assigns ('0','1','0','0') to "myVector"
Run Code Online (Sandbox Code Playgroud)
资料来源:http://www.eda.org/comp.lang.vhdl/html3/gloss_example.html
记住何时使用 => 以及何时使用 <= 的方法是按照以下方式思考。
"<=" 作为信号作为目标的赋值(对于变量它是 ":=" )。
例子:
y <= a + b + c; --y is a signal
v := a + b +c; --v is a variable
Run Code Online (Sandbox Code Playgroud)
“=>”作为映射。
组件显式映射示例(推荐风格恕我直言):
my_instance : my_component
port map(
port1 => my_signal1
);
Run Code Online (Sandbox Code Playgroud)
函数显式映射的示例(当参数不重要时很有用):
my_signal <= my_function(parameter1 => something1, parameter2 => something2);
Run Code Online (Sandbox Code Playgroud)
数组显式映射示例
type array_type is array(0 to 1) of std_logic_vector(7 downto 0);
constant my_array : array_type := (0 => x"AB", 1 => x"CD");
Run Code Online (Sandbox Code Playgroud)
记录显式映射的示例
type record_type is record
a : natural;
b : std_logic_vector(2 downto 0);
end record;
constant my_record: record_type := (a => 0, b => "101");
Run Code Online (Sandbox Code Playgroud)
优点是这种风格允许您按照您选择的顺序进行映射(不一定是组件/功能定义中的顺序...)。此外,在只有一项的数组的特殊情况下,它是必需的。
最后,通过“=>”,关键字others允许映射所有尚未映射的剩余内容。
分配数组的示例:
type array_type is array(0 to 5) of std_logic_vector(7 downto 0);
constant my_array : array_type := (0 => x"AB", 1 => x"CD", others => (others => '0'));
Run Code Online (Sandbox Code Playgroud)