2015-05-16 50 views
0

随着代码:数组声明是不明确

type x_array is array(1 to 2 * con'high - 2) of signed (7 downto 0); 

什么是con'high的工作?

在程序con是被定义为一个阵列:

generic(
    con : const_array := ("00110011", "00110011", "00110011", "00110011")); 
    ... 

const_array是8位的无约束阵列。

请说明什么是2 * con'high - 2

+0

你应该为你的问题添加更多细节,我们怎么知道con'high可能意味着什么 –

+0

package --- is type const_array是signed(7 downto)的数组(正数组) 封装; –

回答

2

con'high是对con数组的high属性的引用,并返回con数组范围的最高(最大)索引值。

所以对于x_array2 * con'high - 2是为了定义基于conx_array范围用作索引范围'x_array'的一部分。

con'high的实际值取决于const_array的声明,或者取决于const_array范围的类型。的const_array所以对于各种声明:

type const_array is array(positive range <>) of signed(7 downto 0); 
-- Range is 1 to 4, and con'high = 4 

type const_array is array(natural range <>) of signed(7 downto 0); 
-- Range is 0 to 3, and con'high = 3 

type const_array is array(integer range <>) of signed(7 downto 0); 
-- Range is integer'low to integer'low + 3, and con'high = integer'low + 3, 
-- e.g. -2147483645 for 32-bit integer 

以上的奇数,如:

subtype const_array_range is natural range 17 downto 14; 
type const_array is array(const_array_range) of std_logic_vector(7 downto 0); 
-- Range is 17 to 14, and con'high = 17 

或者甚至可以在一个枚举类型像声明的值:

type const_array_range is (ALFA, BRAVO, CHARLIE, DELTA, ECHO); 
type const_array is array(const_array_range range <>) of std_logic_vector(7 downto 0); 
-- Range is ALFA to DELTA, and con'high = DELTA 

最后如果在2 * con'high - 2中使用con'high,当然会导致错误,但是值又取决于const_array的声明。