summaryrefslogtreecommitdiff
path: root/src/intersim/misc_utils.cpp
blob: 6ba6a20a44a5581d0e1e0cd8956c3cee1f4de7f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "booksim.hpp"
#include "misc_utils.hpp"

int powi( int x, int y ) // compute x to the y
{
   int r = 1;

   for ( int i = 0; i < y; ++i ) {
      r *= x;
   }

   return r;
}

int log_two( int x )
{
   int r = 0;

   x >>= 1;
   while ( x ) {
      r++; x >>= 1;
   }

   return r;
}