A recent example was something like this: We have a 128-bit input vector and a 128-bit replacement vector. N indicates the replacement point. That is, the output vector needs to be composed of bits [127:N] from the input vector and bits [N-1:0] of the replacement vector. The actual case was more complex, and I am not sure I am summarizing it correctly. So, the intutitive but illegal way to code this is out[127:0] = { in[127:N], replace[N-1:0] } ; To actually get this, you can do something like (I'm not sure this is correct): {(in >> N), replace << (127-N)} >> N
128'( { in>>N, replace<<(128-N) }>>N )
There are other ways to do this.
128'(-1)<<N & in
| ~( 128'(-1)<<N ) & replace
Using selection vectors this way is natural enough, and also synthesizes to vector of MUXs driven by a triangular-decoder for N,All are ugly, non-intuitive, hard to read, and even harder to write correctly.
128'1
in place of 128'(-1)
,
it might look simpler.?:
It means there are "ways", but you're handwaving about the "means".The fact that there are ways to do this means that there are ways to transform the currently illegal form into a legal form.
I agree with this intent, but [lo:hi] indexing is a coding style with a lot of collateral damage, as others have pointed out.Why shouldn't this transformation be automatic instead of forcing the designer to waste his time doing code contortions and usually requiring several passes until he gets it correct?
This archive was generated by hypermail 2.1.8 : Fri May 07 2010 - 11:31:52 PDT