【问题标题】:VHDL difference between => and <==> 和 <= 之间的 VHDL 区别
【发布时间】:2011-12-20 17:55:08
【问题描述】:

我总是忘记,而且很难在教科书或互联网上找到答案。

【问题讨论】:

标签: syntax vhdl


【解决方案1】:

嗯,

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

【讨论】:

  • 嗯,这与场景很接近,但我在使用寄存器时遇到了它。应该声明第一个 D: ie: others=> (others=>'0')
  • 你指的是向量赋值吗?我更新了我的答案。使用向量时,您可以使用此运算符将值分配给向量的特定部分。
【解决方案2】:

一种记住什么时候用=>和什么时候用

"

例子:

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

【讨论】:

    【解决方案3】:

    &lt;=表示赋值运算符,=&gt;用于case语句,例如:

    case sel is
      when "01"   => line <= "1";
      when others => line <= "0";
    end case
    

    如果sel 为“01”,则将line 设置为“1”,否则设置为“0”。

    =&gt; 也用于端口映射的结构代码中。

    【讨论】:

      【解决方案4】:

      运算符 运算符的具体内容。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-03-08
        • 1970-01-01
        • 2014-11-09
        • 1970-01-01
        • 2021-12-25
        • 2020-05-10
        • 2014-09-20
        • 2010-10-28
        相关资源
        最近更新 更多