【发布时间】:2011-12-20 17:55:08
【问题描述】:
我总是忘记,而且很难在教科书或互联网上找到答案。
【问题讨论】:
-
我不是指大于/小于或等于 btw。
-
好的,谢谢大家,我标记了接受的答案。在我的上下文中,它用于向量分配,但可以用于其他事情。
我总是忘记,而且很难在教科书或互联网上找到答案。
【问题讨论】:
嗯,
signal <= A or B;
=> 是用于 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;
=> 也可以用于数组赋值
myVector <= (1=>'1', OTHERS=>'0'); -- assigns ('0','1','0','0') to "myVector"
来源: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
"=>" 作为映射。
组件显式映射示例(推荐样式恕我直言):
my_instance : my_component
port map(
port1 => my_signal1
);
函数显式映射示例(在参数不重要时很有用):
my_signal <= my_function(parameter1 => something1, parameter2 => something2);
数组显式映射示例
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");
记录显式映射示例
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");
优点是这种风格允许您按照您选择的顺序进行映射(不一定是组件/功能定义中的顺序...)。此外,在数组只有一项的特殊情况下,它是必需的。
最后,使用“=>”,关键字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'));
【讨论】:
<=表示赋值运算符,=>用于case语句,例如:
case sel is
when "01" => line <= "1";
when others => line <= "0";
end case
如果sel 为“01”,则将line 设置为“1”,否则设置为“0”。
=> 也用于端口映射的结构代码中。
【讨论】:
运算符 运算符的具体内容。
【讨论】: