0

I have such signal:

sw : std_logic_vector(7 downto 0);

and now I want to make another one, which will have it as upper bits, 1 the rest:

std_logic_vector(31 downto 0) := (7 downto 0 => sw, others => '1');

but it won't compile. any help please? I don't want to do it bit by bit.

1
  • 1
    You haven't specified which VHDL tool, which can be important to whether or not slices are supported in aggregates using a -2008 compliant mode. That aggregate would either be (sw, others => '1') for positional association or (31 downto 24 => sw, others => '1') for named association assuming a target subtype of std_logic_vector (31 downto 0). See VHDL 2008 Just the New Stuff Peter Ashenden and Jim Lewis, 6.4 Slices in Aggregates, or IEEE Std 1076-2008, 9.3.3.3 Array aggregates. Slices in array aggregates may not be supported in your tool chain. Commented Apr 30, 2017 at 18:15

2 Answers 2

1

I'm not entirely sure where should go this smaller signal, but you probably want to do this:

signal sw: std_logic_vector(7 downto 0);
signal big: std_logic_vector(31 downto 0);

big <= sw & x"FFFFFF";

This will assign sw vector to 8 most significant bits of big vector, and '1' to rest of bits. Write in comments, if you want to do something else.

Sign up to request clarification or add additional context in comments.

3 Comments

I want something similar but actually sw is 6 downto 0, so it becomes little ugly your way and I prefer previous notation if possible....
I don't think it is possible. You would have to assign each bit separately.
Look here, there is good explanation of the topic.
1

What you are trying to do is assign a signal -which is variable- to another signal during initialization. What do you expect to happen?

I.e. at the moment you define a signal, you can only initialize it. If you want to assign something to the signal, you have to write a declaration.

  • definition -> initialization
  • declaration -> assignment

So in this case you can define big a larger range, and fix the constant bits in initialization

signal big : std_logic_vector(31 downto 0) => (others => '1');

And when you want to assign sw to any part of big, do that after the begin.

big(31 downto 24) <= sw;

or

big(7 downto 0) <= sw;

etc. The bits you initialized as '1' will be overwritten by the assignment.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.