Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

can i assign signal in the following way??

can i assign signal in the following way??

can i assign signal in the following way??

I am new to vhdl and while coding i want to invert a cetain number of bits in a signal. the code is somewhat like this:

CODE --> vhdl

signal flag : STD_LOGIC_VECTOR(31 downto 0) := (others => '0') ;
signal first_part : STD_LOGIC_VECTOR(31 downto 0) := (others => '0') ;
signal second_part: STD_LOGIC_VECTOR(31 downto 0) := (others => '0') ; 

now i want to do something like this, the signal first_part in a previuos parts of the code copies a number of bits from an fpga stream, whose number of bits is variable but not more than 3. For example if the maximum number of bits are copied into first_part are 3, 001, in first case, in second case 01. however, the order of bits in first_part is inverted and 1 is missing. i.e the actual output for 001 is 1100, so i have to add 1 at the 4th position and also invert the order of 001 to 100. also for second case (01) the output should be 110 after attaching 1 at the third position.
the signal first_part contains the copied bits from the stream, signal flag contain the actual no bits, either 111 for 001 or 11 for 01 and signal second_part contains the final inverted form. Here, i want to ask that if the do the following, would it achieve my purpose without error:

CODE --> vhdl

first_part(0) <= '1';-- because i want to attach the missing 1.
--also first_part(31 downto 1) the signal contains bits "0000000000000000000000000000001" and corresponding flag signal wud be "0000000000000000000000000000111"
second_part(31 downto 4) <= "0000000000000000000000000000"--padding with zeros bc max number of bits to be used for this signal are 4.
second_part(3 downto 0)<= first_part(0 to 3) if flag(2)='1' or '0' & first_part(0 to 2) if flag(1)='1' or "00" & first_part(0 to 1) if flag(0)='1' or "000" & first_part(0) if flag(0)='0'; 

I want to ask if this will in first case put value 1100 in second_part signal and in second case put value 110 in second_part?
Any help is appreciated.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close