似乎无法执行某些功能,例如VHDL中的以下代码。是否可以使用其他语法?是否有if语句可以放在范围声明中?我在网上找不到任何有关此的信息。
if not using_census_vector then
variable diff : natural range 0 to ((2**cRed_pixel_bits)+(2**cGreen_pixel_bits)+(2**cBlue_pixel_bits)) * window_size * window_size - 1 := 0;
else
variable diff : natural range 0 to ((window_size * window_size * 3 )) := 0;
end if;
答案 0 :(得分:0)
使用函数返回高索引。可能不需要参数(除非您希望使其通用并移至程序包),因为所有其他参数均应在范围内
function calc_high return integer is
begin
if not using_census_vector then
return ((2**cRed_pixel_bits)+(2**cGreen_pixel_bits)+(2**cBlue_pixel_bits)) * window_size * window_size - 1;
else
return ((window_size * window_size * 3 ));
end if;
end function
variable diff : natural range 0 to calc_high := 0;