On 3/28/07, Paul Brook <[EMAIL PROTECTED]> wrote:
> However, consider this: > > input [31:0] x; > input [5:0] shift; > output [31:0] z; > wire [63:0] y = {x, 31'b0}; > assign z = y >> (shift + 32); > > The shift+32 is cheap, because all you're really doing is inverting > the high bit of the shift amount. The only question is how much more > expensive is a 64-bit shifter than a 32-bit shifter.How does this compare to: z = shift[5] ? (y >> shift[4:0]) : (y << shift[4:0])
Not sure. It could be better or worse. We'd have to try it. It all depends on how shifters are implemented.
If you turned this into a switch statement you could also use the high bits of the shift count to select between arithmetic and logical shifts. For the compiler size of things, or-ing a few high bits is as easy as negating the shift count.
True. The bit codes in the instructions don't have to seem sensible to humans. -- Timothy Normand Miller http://www.cse.ohio-state.edu/~millerti Open Graphics Project _______________________________________________ Open-graphics mailing list [email protected] http://lists.duskglow.com/mailman/listinfo/open-graphics List service provided by Duskglow Consulting, LLC (www.duskglow.com)
