Code

Magnitude Approximation functions in BSV

March 29, 20111 comment Coded in Bluespec SystemVerilog (BSV) for the FPGA/ASIC (RTL)
// |V| = Max + Min/2
function UInt#(18) magEst1(Complex#(UInt#(18)) c);
  if (c.rel > c.img) return( c.rel   +  c.img/2);
  else               return( c.rel/2 +  c.img);
endfunction

// |V| = 15(Max + Min/2)/16
function UInt#(18) magEst2(Complex#(UInt#(18)) c);
  let v = magEst1(c);
  return( v - v/16);
endfunction