On 6/14/06, tsuraan <[EMAIL PROTECTED]> wrote:
Thanks for this!
> wire g;
> assign g = f[2]; // assign bit 2 of f to g;
>
> The bit-select can be variable:
>
> wire [7:0] h;
> wire i = f[h];
>
> You can do bit slices, but the range must be constants:
>
> wire [3:0] j = e[7:4];
Can I select an arbitrary range of wires from a bus? i.e:
wire [3:0] j = e[1,3:4,7]
I'm not entirely sure why you'd want non-contiguous elements, but
maybe it could be useful. I'm mostly just curious :)
That would be very nice, but I'm afraid not.
To do what you want to do, you'll need to use this syntax:
wire [3:0] j = {e[1], e[4:3], e[7]};
If you think that's cumbersome, you should try it in VHDL. :)
Actually, VHDL isn't so bad for this, but VHDL can't do this:
wire [3:0] j = {4{e[1]}};
This replicates the one bit n times. You can replicate bit vectors of
arbitrary length arbitrary numbers of times.
One book suggested that you could do e[3:4] and reverse the bits, but
I think I've tried it, and it didn't work. You'd have to code a loop
in behavioral code for that.
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)