Shifting + jamming LSB

P

pallav

Guest
I am trying to implement the following operation: If exponent (zexp)
is negative, shift the significand (zsig0) right by the -zexp (negated
zexp so it is positive) and if any of the shifted off bits are one,
the LSB is jammed as 1. The maximum shift amt can be 32. I'm trying to
figure out how I can do this efficiently. I have the following so far:

reg [11:0] zexp;
reg [31:0] zsig0, zsig0t, jambits;

always @(/*AUTOSENSE*/)
begin
// if exponent is negative
if (zexp[11]) begin
{zsig0t, jambits} = {zsig0, 32'b0} >> ((zexp[4:0] ^ {5{zexp
[11]}) + {4'b0, zexp[11]}); // shift zsig0 right by -zexp[4:0].
zsig0t = {zsig0t[31:1], zsig[0] | (| jambits)};
end
end

Is there a better way to do the above? Main problem is the jamming of
the LSB if done as above requires a 64-bit shifter.
Thanks for any ideas.

Kind regards.
 
"pallav" <pallavgupta@gmail.com> wrote in message
news:c9bd46c4-fa8f-4d09-b434-7b2ffb38507a@t10g2000vbg.googlegroups.com...
I am trying to implement the following operation: If exponent (zexp)
is negative, shift the significand (zsig0) right by the -zexp (negated
zexp so it is positive) and if any of the shifted off bits are one,
the LSB is jammed as 1. The maximum shift amt can be 32. I'm trying to
figure out how I can do this efficiently. I have the following so far:

reg [11:0] zexp;
reg [31:0] zsig0, zsig0t, jambits;

always @(/*AUTOSENSE*/)
begin
// if exponent is negative
if (zexp[11]) begin
{zsig0t, jambits} = {zsig0, 32'b0} >> ((zexp[4:0] ^ {5{zexp
[11]}) + {4'b0, zexp[11]}); // shift zsig0 right by -zexp[4:0].
zsig0t = {zsig0t[31:1], zsig[0] | (| jambits)};
end
end

Is there a better way to do the above? Main problem is the jamming of
the LSB if done as above requires a 64-bit shifter.
Thanks for any ideas.
Should be able to do it with a single FF, call it underflow. Clock in the
lsb or'ed with underflow's current value, initially 0. Read that value
rather than lsb. The problem is knowing when to reset underflow to 0. If
it's amenable to your design, a data-ready strobe should do it.
 
On Jun 8, 12:54 pm, pallav <pallavgu...@gmail.com> wrote:
I am trying to implement the following operation: If exponent (zexp)
is negative, shift the significand (zsig0) right by the -zexp (negated
zexp so it is positive) and if any of the shifted off bits are one,
the LSB is jammed as 1. The maximum shift amt can be 32. I'm trying to
figure out how I can do this efficiently. I have the following so far:

reg [11:0] zexp;
reg [31:0] zsig0, zsig0t, jambits;

always @(/*AUTOSENSE*/)
  begin
      // if exponent is negative
      if (zexp[11]) begin
         {zsig0t, jambits} = {zsig0, 32'b0} >> ((zexp[4:0]  ^ {5{zexp
[11]}) + {4'b0, zexp[11]});  // shift zsig0 right by -zexp[4:0].
         zsig0t = {zsig0t[31:1], zsig[0] | (| jambits)};
      end
  end

Is there a better way to do the above? Main problem is the jamming of
the LSB if done as above requires a 64-bit shifter.
Thanks for any ideas.

Kind regards.
You don't really need a 64-bit shifter if the shifted out bits are
only used to detect non-zero data being shifted. The synthesis
tool would probably rip most of it out for you and just do the
compare with zero of the |zexp| LSB's of the original data.
 

Welcome to EDABoard.com

Sponsor

Back
Top