[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [f-cpu] What's wrong here?
Sorry,
I have made a little mistake, I have forgot the return line.
Just an Illusion wrote:
> Hello,
>
> The variable H and L can't be used to calculate the size of B, more
> they are unnecessary.
>
> When you call the function inv_word with a vector, the A'HIGH and the
> A'LOW aren't referred to the real size of the vecteur, but the part
> connected.
>
> The good version is more like :
>
> function inv_word (A : in std_ulogic_vector) return std_ulogic_vector is
> variable B : std_ulogic_vector ( A'HIGH downto 0);
> begin
> for i in 0 to B'HIGH loop
> B(i)=A(A'HIGH-i);
> end loop;
return B;
>
> end inv_word;
>
> or
>
> function inv_word (A : in std_ulogic_vector) return std_ulogic_vector is
> variable B : std_ulogic_vector ( A'LENGHT-1 downto 0);
> begin
> for i in 0 to B'LENGHT-1 loop
> B(i)=A(A'LENGHT-1-i);
> end loop;
return B;
>
> end inv_word;
>
> Or any combinaison of both.
>
>
> Michael Riepe wrote:
>
>> Ok... can anybody tell me what's wrong with this function?
>>
>> function inv_word(A : in std_ulogic_vector) return
>> std_ulogic_vector is
>> variable L : natural := A'low;
>> variable H : natural := A'high;
>> variable B : std_ulogic_vector(H downto L);
>> begin
>> for i in L to H loop
>> B(i) := A(H+L-i);
>> end loop;
>> return B;
>> end function;
>>
>> Hint: consider the possible index ranges of the argument.
>>
> Just an Illusion
>
Just an Illusion
--
______________________________
"The matrix is my world, I am a shadow.
Shadow in world, shadow in life. Don't try to keep me,
I am a Corpo's Killer.
Don't follow me or die..."
The KingWalker - 1996
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu in the body. http://f-cpu.seul.org/