1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at --- 53 unchanged lines hidden (view full) --- 62// ---------------------------------------------------------------------------- 63 64#define MSB_STATEMENT(n) if (x >> n) { x >>= n; i += n; } 65 66inline int 67scfx_find_msb(unsigned long x) 68{ 69 int i = 0; |
70# if SC_LONG_64 |
71 MSB_STATEMENT(32); |
72# endif // SC_LONG_64 |
73 MSB_STATEMENT(16); 74 MSB_STATEMENT(8); 75 MSB_STATEMENT(4); 76 MSB_STATEMENT(2); 77 MSB_STATEMENT(1); 78 return i; 79} 80 81#undef MSB_STATEMENT 82 83#define LSB_STATEMENT(n) if (x << n) { x <<= n; i -= n; } 84 85inline int 86scfx_find_lsb(unsigned long x) 87{ 88 int i; |
89# if SC_LONG_64 |
90 i = 63; 91 LSB_STATEMENT(32); 92# else 93 i = 31; |
94# endif // SC_LONG_64 |
95 LSB_STATEMENT(16); 96 LSB_STATEMENT(8); 97 LSB_STATEMENT(4); 98 LSB_STATEMENT(2); 99 LSB_STATEMENT(1); 100 return i; 101} 102 --- 391 unchanged lines hidden --- |