CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
Lut.cc File Reference
#include "L1Trigger/DTTraco/interface/Lut.h"

Go to the source code of this file.

Functions

void DSPtoIEEE32 (short DSPmantissa, short DSPexp, float *f)
 
char exaDigit (int i)
 
void IEEE32toDSP (float f, short *DSPmantissa, short *DSPexp)
 
std::string lutFmt (int i)
 

Function Documentation

void DSPtoIEEE32 ( short  DSPmantissa,
short  DSPexp,
float *  f 
)

Definition at line 393 of file Lut.cc.

References funct::pow().

394 {
395  DSPexp -= 15;
396  *f = DSPmantissa * (float)pow( 2.0, DSPexp );
397 
398  return;
399 }
double f[11][100]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
char exaDigit ( int  i)

Definition at line 137 of file Lut.cc.

Referenced by lutFmt().

137  {
138  if ( i < 10 ) return ( i + '0' );
139  else return ( ( i - 10 ) + 'A' );
140 }
int i
Definition: DBlmapReader.cc:9
void IEEE32toDSP ( float  f,
short *  DSPmantissa,
short *  DSPexp 
)

Definition at line 402 of file Lut.cc.

References f, and i.

403 {
404  //long *pl, lm;
405  uint32_t *pl = 0;
406  uint32_t lm;
407 
408  //101104 SV convert float to int in safe way
409  union { float f; uint32_t i; } u;
410  u.f = f;
411  *pl = u.i;
412 
413  bool sign=false;
414  if( f==0.0 )
415  {
416  *DSPexp = 0;
417  *DSPmantissa = 0;
418  }
419  else
420  {
421  //pl = reinterpret_cast<uint32_t*> (&f);
422  //pl = (long*) (&f);
423  if((*pl & 0x80000000)!=0)
424  sign=true;
425  lm =( 0x800000 | (*pl & 0x7FFFFF)); // [1][23bit mantissa]
426  lm >>= 9; //reduce to 15bits
427  lm &= 0x7FFF;
428  *DSPexp = ((*pl>>23)&0xFF)-126;
429  *DSPmantissa = (short)lm;
430  if(sign)
431  *DSPmantissa = - *DSPmantissa; // convert negative value in 2.s
432  // complement
433  }
434  return;
435 }
int i
Definition: DBlmapReader.cc:9
double f[11][100]
std::string lutFmt ( int  i)

Definition at line 142 of file Lut.cc.

References exaDigit(), and asciidump::s.

142  {
143  char* buf = new char[6];
144  buf[2] = ' ';
145  buf[5] = '\0';
146  int j4 = i % 16;
147  i /= 16;
148  int j3 = i % 16;
149  i /= 16;
150  int j2 = i % 16;
151  i /= 16;
152  int j1 = i % 16;
153  buf[0] = exaDigit( j1 );
154  buf[1] = exaDigit( j2 );
155  buf[3] = exaDigit( j3 );
156  buf[4] = exaDigit( j4 );
157  std::string s( buf );
158  return s;
159 }
int i
Definition: DBlmapReader.cc:9
char exaDigit(int i)
Definition: Lut.cc:137
string s
Definition: asciidump.py:422