Reputation: 483
It doesn't seem to be possible to do something that functions like the code below in VHDL. Is this possible using some other syntax? Is there such a thing as an if statement that can be put inside the range declaration? I can't find anything online about this.
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;
Upvotes: 1
Views: 433
Reputation: 4471
Use a function to return the high index. Possibly no need for parameters (unless you want it common and moved to a package) because all other paramters should be in scope
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;
Upvotes: 1