Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to reverse the order of bits in VHDL?

Status
Not open for further replies.

voho

Full Member level 2
Joined
Feb 24, 2004
Messages
121
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Nador City
Activity points
852
Hi all,

I have a vector A(15 downto 0)=0000 0000_000F FFFF
how to do in VHDL in order to obtain B(15 downto 0)= FFFF F000_0000 0000

Thank's in advance
 

Re: complement in vhdl??

Please say again what do you want to do because you do some mistakes.
First you say that the vector has 16 bits and you give to it a 64 bits value.

Second , by the way you wrote there I think that you want to reverse the order of the bits in the vector.

you must write :

B(15)<=A(0);
B(14)<=A(1);
B(13)<=A(2);
B(12)<=A(3);
...................
B(1)<=A(14);
B(0)<=A(15);
 

Re: complement in vhdl??

Hi All,

Of course A(63 downto 0) and B(63 downto 0).
Thank's master.ro for your help.

Regards
 

Re: complement in vhdl??

it's not clear yet what do you want: to reverse the order of the bits as you say earlyer or to calculate the complement?

if you want the complement :

B(63 downto 0) <= not A (63 downto 0);

or

B(63 downto 0) <= not A (63 downto 0) + '1';
 

Re: complement in vhdl??

To reverse the order of bits without having to do it long-hand

Code:
process(A)
begin
    for i in A'range loop
        B(B'left - i) <= A(i);
    end loop
end process
This should be synthesisable. My use of B'left assumes that A and B are both defined with the same range (63 downto 0 in your case).
 

Re: complement in vhdl??

You don't need to loop or anything, this simple statement will do:
Code:
B(0 to 63) <= A(63 downto 0);
Cheers.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top