source: trunk/IPs/systemC/processor/Morpheo/Include/ToBase2.h @ 3

Last change on this file since 3 was 2, checked in by kane, 17 years ago

Import Morpheo

File size: 452 bytes
Line 
1#ifndef morpheo_ToBase2
2#define morpheo_ToBase2
3
4/*
5 * $Id$
6 *
7 * [ Description ]
8 *
9 */
10
11#include <sstream>
12using namespace std;
13
14namespace morpheo              {
15
16  inline string toBase2 (uint32_t value, uint32_t size)
17  {
18    ostringstream res;
19    uint32_t      mask = 1<<(size-1);
20
21    while (mask != 0)
22      {
23        res  << ((value&mask)?'1':'0');
24        mask >>= 1;
25      }
26
27    return res.str();
28  }
29 
30}; // end namespace morpheo             
31
32#endif
Note: See TracBrowser for help on using the repository browser.