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.

some clever bitmanipulations for VHDL please.

Status
Not open for further replies.

completelyuseless

Junior Member level 1
Joined
Jun 4, 2008
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,442
vhdl invert vector

Hi all,

i have to synthesise some VHDL code that will manipulate bits in a certain way.

in a vector of say 'n' bits, i need to find the position of the most significant '1' in the vector and and invert the 0's that are to the left of it.

eg:
lets say a i have a vector that is 9 bits long, and arbitrarily it is say 000110100

there are 3 zeros before the most significant 1 in the obove vector, so i need a clever sort of masking system that will invert those zeros, making it 111110100.
Even if the position of that most significant '1' changes, the method must be general and work for any case, (provided the vector size does not change of course)

i know this can be done with a whole lot of if's and else's but id like to know if there is some clever quick masking system that i dont know about that exists to tackle this problem.

thanks in advance
 

vhdl invert

Similar operations can most easily be implemented by a FOR LOOP iterative scheme. Generally you should consider, that all equivalent design descriptions can be expected to end up in the same code due to the VHDL compiler's optimization action. Thus readability and compactness of code are the main criteria.
 

vhdl inverting vector

I think you can either use a case statement or a loop..
 

masking vhdl

This is how you do it.

input and output are signals of the same length.

Code:
process(clk)
  variable leading_zeros: boolean;
begin
  if rising_edge(clk) then
    for a in input'high dowoto input'low loop
      leading_zeros := true;
        if input(a) = '0' and leading_zeros then
           output(a) <= '1';
        else
           output(a) <= input(a);
           leading_zeros := false;
        end if;
     end loop;
   end if;
end process;

There is going to be syntax errors in this. But this is how you do it.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top