【发布时间】:2018-06-08 10:15:52
【问题描述】:
我开始为我的大学考试学习 VHDL,我有一个问题:BIT_VECTOR 类型和 ARRAY OF BIT 之间有什么区别?
【问题讨论】:
-
只要做一个简单的谷歌搜索,你就会找到答案。
我开始为我的大学考试学习 VHDL,我有一个问题:BIT_VECTOR 类型和 ARRAY OF BIT 之间有什么区别?
【问题讨论】:
如上所述here
bit_vector 是一维数组类型,其元素的类型为 Bit。 bit_vector 类型是在 Standard 包中预定义的。 语法:
type bit_vector is array (natural range <>) of bit;
这也可以在 IEEE1076-2008 标准的第 5.3.2.3 节“预定义数组类型”中找到。
编辑:我不完整。 bit_vector 是bit 的预定义(无约束)数组。但是由于牛是一种动物,但并非所有动物都是牛,所以你可以有更多的类型。由于 VHDL 是强类型的,这意味着您不能简单地将不同的类型连接在一起而无需强制转换函数。
参见下面的示例代码:
entity e is end entity;
architecture a of e is
signal s1 : bit_vector(0 downto 0);
type own_bit_vector is array(natural range <>) of bit;
signal s2 : own_bit_vector(0 downto 0);
begin
-- next line doesn't work
--s2 <= s1;
-- "Error: D:/Hdl/BitVector/BitVector.vhd(7):
-- Signal "s1" is type std.STANDARD.BIT_VECTOR;
-- expecting type own_bit_vector."
-- but this is allowed
process(s1) begin
for i in s1'range loop
s2(i) <= s1(i);
end loop;
end process;
end architecture;
【讨论】: