inverse function, how?

P

Pasacco

Guest
Hi

I need some idea how to implement "inverse function", when the function
is one-to-one mapping.

Input : A(0), A(1), A(2), A(3)
Output : B(0), B(1), B(2), B(3)

provided that
(1) each of A(0), A(1), A(2), A(3) are one of 0, 1, 2, 3.
(2) each of A(0), A(1), A(2), A(3) are different.

For example,

A(0)=0, A(1)=3, A(2)=1, A(2)=2

I need to implement a component to generate

B(0)=0, B(1)=2, B(2)=3, B(3)=1

Does anyone have idea or pointer?

Thankyou in advance
 
"Pasacco" <pasacco@gmail.com> writes:

Hi

I need some idea how to implement "inverse function", when the function
is one-to-one mapping.

Input : A(0), A(1), A(2), A(3)
Output : B(0), B(1), B(2), B(3)

provided that
(1) each of A(0), A(1), A(2), A(3) are one of 0, 1, 2, 3.
(2) each of A(0), A(1), A(2), A(3) are different.

For example,

A(0)=0, A(1)=3, A(2)=1, A(2)=2

I need to implement a component to generate

B(0)=0, B(1)=2, B(2)=3, B(3)=1

Does anyone have idea or pointer?

for i in 0 to 3 do loop
for j in 0 to 3 do loop
if A(i) = j then
B(j) = i;
exit; -- tells DC that only one of the j's can match
end if;
end loop;
end loop;

Ugly, but it should work.


Kai
--
Kai Harrekilde-Petersen <khp(at)harrekilde(dot)dk>
 
Try this in vhdl, assuming you're using subtypes of integer for your
data:

for i in b'range loop
b(a(i)) <= i;
end loop;

Andy

Pasacco wrote:
Hi

I need some idea how to implement "inverse function", when the function
is one-to-one mapping.

Input : A(0), A(1), A(2), A(3)
Output : B(0), B(1), B(2), B(3)

provided that
(1) each of A(0), A(1), A(2), A(3) are one of 0, 1, 2, 3.
(2) each of A(0), A(1), A(2), A(3) are different.

For example,

A(0)=0, A(1)=3, A(2)=1, A(2)=2

I need to implement a component to generate

B(0)=0, B(1)=2, B(2)=3, B(3)=1

Does anyone have idea or pointer?

Thankyou in advance
 
Thankyou. Simple as that :)
By the way, I do not have idea how the hardware will look like.
It looks like just wires and multiplexors, but if you have idea, let me
know,


Kai Harrekilde-Petersen schreef:

"Pasacco" <pasacco@gmail.com> writes:

Hi

I need some idea how to implement "inverse function", when the function
is one-to-one mapping.

Input : A(0), A(1), A(2), A(3)
Output : B(0), B(1), B(2), B(3)

provided that
(1) each of A(0), A(1), A(2), A(3) are one of 0, 1, 2, 3.
(2) each of A(0), A(1), A(2), A(3) are different.

For example,

A(0)=0, A(1)=3, A(2)=1, A(2)=2

I need to implement a component to generate

B(0)=0, B(1)=2, B(2)=3, B(3)=1

Does anyone have idea or pointer?


for i in 0 to 3 do loop
for j in 0 to 3 do loop
if A(i) = j then
B(j) = i;
exit; -- tells DC that only one of the j's can match
end if;
end loop;
end loop;

Ugly, but it should work.


Kai
--
Kai Harrekilde-Petersen <khp(at)harrekilde(dot)dk
 

Welcome to EDABoard.com

Sponsor

Back
Top