On 10/12/2012 2:53 AM,
wrote:
> Am Freitag, 12. Oktober 2012 05:57:29 UTC+2 schrieb Carlos:
>> Hello,
>>
>>
>>
>> I sometimes have to concatenate/de-concatenate vectors for example to feed them to a common FIFO (see below).
>>
>>
>>
>> signal Ain, Aout : std_logic_vector(I-1 downto 0);
>>
>> signal Bin, Bout : std_logic_vector(J-1 downto 0);
>>
>> signal Cin, Cout : std_logic_vector(K-1 downto 0);
>>
>> signal FIFOin, FIFOout : std_logic_vector(I+J+K-1 downto 0);
>>
>> -- ...
>>
>>
>>
>> FIFOin<= Ain& Bin& Cin;
>>
>> -- ...
>>
>> Aout<= FIFOout(Aout'length + Bout'length + Cout'length-1 downto Bout'length + Cout'length);
>>
>> Bout<= FIFOout(Bout'length + Cout'length-1 downto Cout'length);
>>
>> Cout<= FIFOout(Cout'length-1 downto 0);
>>
>>
>>
>> This works fine, but my question would be, is there a neater way of doing the same thing since the code becomes quite lengthy and hard to follow when the number of vectors increases?
>>
>> *** (Ideally something like a de-concatenate sort of operation would be nice, as shown below)
>>
>> *** Aout& Bout& Cout<= FIFOout; -- INCORRECT
>>
>>
>>
>> Thanks.
>
> hi,
> yes, I think it can simply be done like this:
>
> (Aout, Bout, Cout)<= FIFOout;
>
> Of course the sum of bits of A,B,C has to match the number of bits of the FIFO signal. And the basic types must match too.
>
> Have a nice synthesis
> Eilert
Using the & operator is called concatenation. This is an expression
producing a result and can not be used on the left side of an assignment.
The grouping of signals in parentheses as above is called an aggregate.
It makes a larger signal from small ones and can be used on the left
side of an assignment.
In the old days tools had a difficult time with aggregates on the left
side of assignments, but I think they all support this now.
Rick