On 2007-03-29, Paul Brook 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])
>
These are good for REG << SHIFT. But, do we care about REG << REG? If
we did, which I suspect we don't, we could use
wire is_small_neg = &{shift[31:5]};
wire is_small_pos = ! |{shift[31:5]};
always ...
...
z <= is_small_neg? (y >> -shift[5:0])
: is_small_pos? (y << shift[4:0])
: {31{y[31] & x[31]}};
The would reduce the negation to 5 bits.
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)