I am new to VHDL and I try to find all places where I can replace if/else statements with cases of inlined OR/AND operations to get more things executed in parallel instead of sequence.
Now I have the following statement:
if (val = 0) then
returnVal := 0;
end if;
if (val > 0)
then
returnVal := 1;
end if;
returnVal := 2;
return returnVal;
As I can see, this will be executed sequentially with a depth of 3.
Is this exact statement possible to do in a more efficient manner?
NOTE: The values 0, 1 and 2 are not important - they must just be different, e.g. could be -123, 234 and 432 if that makes it easier for optimizing
Thanks
UPDATE: As pointed out, this logic was broken. The intended logic is:
if (val = 0) then
return 0;
end if;
if (val > 0)
then
return 1:
end if;
return 2;
UPDATE 2: I am programming VHDL and deploying to an FPGA which is important as it differs from microcontrollers in the terms of parallelism.
UPDATE 3: I realise, that I may not have been explicit about my exact question, so my apoligies. What I mean is: The three statements are mutually exclusive: Than value is either < 0, = 0 or > 0. And even though a case switch cant be used here, I was wondering if anyone had another input to how to improve performance of this.