Hi Hans,
Thank you for your help.
Error_O_v := '0'; -- its value is initialized here
for j in 0 to G_TOP_LEVEL loop
...if Error_O_v = '0' then -- always 0? it is true on first entry
......if Error_O_m(j) = '1' then -- an error happens if true
..........Error_O_v := '1'; -- it is refreshed here if an error is detected, after that above if-condition = false, and all remaining testing skips
> In your second example you never clear Error_O but instead you clear
> Error_Oi. So I suspect you get an 'X' for Error_O?
You are right, but it is an error that is corrected after my posting, Error_Oi is introduced to be the internal value of output port Error_O for VHDL-2002: Error_O <= Error_Oi; after compiling, Error_O <= '1' is corrected as Error_Oi <= '1';.
After reading your text, I added the signal Get_Index_View to see what happens to it when an error happens.
v_Index := Get_Index(Error_O_m);
Get_Index_View <= v_Index; -- added signal to watch after Get_Index(Error_O_m)
if v_Index /= 255 then
Error_Oi <= '1';
Error_Code_O <= Error_Code_O_m(v_Index);
Error_Level_O <= v_Index;
end if;
Simulation shows Get_Index_View = 255 always.
function Get_Index (x: std_logic_vector) return integer is
...variable index : integer;
begin
...index := 0;
...for j in x'low to x'high loop
......if x(index) = '1' then
.........index := j;
.........return index; -- ?, no action!
......end if;
...end loop;
...return 255; -- always! simulation shows!
end Get_Index;
I would like to hear your advice on how to implementing the function. I think my version should be the simplest.
Thank you.
Weng