View Single Post
  #3 (permalink)  
Old 02-02-2010, 10:15 PM
John_H
Guest
 
Posts: n/a
Default Re: concatenation with a for loop

On Feb 2, 4:15*pm, fpgaasicdesigner <fpgaasicdesig...@gmail.com>
wrote:
> Hi all,
>
> How can I write more with more elegance this:
>
> *header={register[0],register[1],register[2]}.
>
> Meaning having a for loop to concatenate these bus ?
>
> Thanks


A generate statement is the way to go for a wide bus. There really is
no clean way to reverse the order of a bus so the "generate for" will
take care of it in a somewhat better fashion. But if you have few
elements, just write it out. Even 16 elements can come out clean with
4 rows of 4 elements each all lined up under each other in a visible
grid.

header <= { register[ 0], register[ 1], register[ 2], register[ 3]
, register[ 4], register[ 5], register[ 6], register[ 7]
, register[ 8], register[ 9], register[10], register[11]
, register[12], register[13], register[14], register
[15] };

It's possible to use bit manipulation or perhaps the width syntax

header[n] <= register[ n-1 :+ 1 ];

to use a normal for loop but things really start to look unclear to
the reader.
Reply With Quote