inverse function, how?

P

Pasacco

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
 
K

Kai Harrekilde-Petersen

Pasacco said:
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
 
A

Andy

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
 
P

Pasacco

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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top