Deleted Added
sdiff udiff text old ( 11932:98961d1b51ca ) new ( 12226:36dff288b076 )
full compact
1/*
2 * Copyright (c) 2017 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 25 unchanged lines hidden (view full) ---

34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Steve Reinhardt
41 * Nathan Binkert
42 */
43
44#ifndef __BASE_BITFIELD_HH__
45#define __BASE_BITFIELD_HH__
46
47#include <inttypes.h>
48
49/**
50 * Generate a 64-bit mask of 'nbits' 1s, right justified.
51 */
52inline uint64_t
53mask(int nbits)
54{
55 return (nbits == 64) ? (uint64_t)-1LL : (1ULL << nbits) - 1;
56}
57
58
59
60/**
61 * Extract the bitfield from position 'first' to 'last' (inclusive)
62 * from 'val' and right justify it. MSB is numbered 63, LSB is 0.
63 */
64template <class T>
65inline
66T
67bits(T val, int first, int last)

--- 82 unchanged lines hidden (view full) ---

150/** Overloaded function to allow to access only 1 bit*/
151template <class T, class B>
152inline
153void
154replaceBits(T& val, int bit, B bit_val)
155{
156 val = insertBits(val, bit, bit, bit_val);
157}
158/**
159 * Returns the bit position of the MSB that is set in the input
160 */
161inline
162int
163findMsbSet(uint64_t val) {
164 int msb = 0;
165 if (!val)
166 return 0;

--- 85 unchanged lines hidden ---