VHDL之间的差异=>和< =

时间:2011-11-02 22:29:26

标签: syntax vhdl

我一直在忘记,很难在教科书或互联网上搜索答案。

4 个答案:

答案 0 :(得分:6)

嗯,< =是作业。

signal <= A or B;

=&GT;用于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;

=&GT;也可用于数组赋值

myVector <= (1=>'1', OTHERS=>'0');  -- assigns ('0','1','0','0') to "myVector"

来源:http://www.eda.org/comp.lang.vhdl/html3/gloss_example.html

答案 1 :(得分:1)

<=表示赋值运算符,而case语句中使用=>,例如:

case sel is
  when "01"   => line <= "1";
  when others => line <= "0";
end case
如果line为“01”,则

sel设置为“1”,否则设置为“0”。

=>也用于端口映射中的结构代码。

答案 2 :(得分:1)

运算符&lt; =被称为a 信号分配操作员突出其真正目的。信号分配运算符指定信号之间的关系。换句话说,信号分配运算符左侧的信号取决于运算符右侧的信号。 (来源:Digital_Mclogic_Design作者:Bryan Mealy,部分:信号分配算子:“&lt; =”,第339页)我找不到关于=&gt;的任何具体信息。操作

答案 3 :(得分:1)

记忆何时使用的方法=&gt;什么时候使用&lt; =是思考如下。

“&lt; =”作为信号作为目标的指定(对于变量,它是“:=”)。

示例:

y <= a + b + c; --y is a signal
v := a + b +c; --v is a variable

<强> “=&gt;” 中作为映射。

组件显式映射示例(推荐样式IMHO):

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");

优点是这种样式允许您按照您选择的顺序进行映射(不一定是组件/函数定义中的顺序......)。此外,在只有一个项目的数组的特殊情况下,它是必需的。

最后,使用“=&gt;”,关键字其他允许映射尚未映射的所有剩余内容。

分配数组的示例:

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'));