diff options
author | Korey Sewell <ksewell@umich.edu> | 2007-06-22 19:03:42 -0400 |
---|---|---|
committer | Korey Sewell <ksewell@umich.edu> | 2007-06-22 19:03:42 -0400 |
commit | 753adb38d5471d23315d1bcfc6a744d1c6e03975 (patch) | |
tree | 9ae1cc842f4c3756acf86147a5fd6772d7a6622f /src/base/bitfield.hh | |
parent | 16c1b5484f576b6aebea9ab5ffab4ea64f080de0 (diff) | |
download | gem5-753adb38d5471d23315d1bcfc6a744d1c6e03975.tar.xz |
mips import pt. 1
src/arch/mips/SConscript:
"mips import pt.1".
--HG--
extra : convert_revision : 2e393341938bebf32fb638a209262d074fad4cc1
Diffstat (limited to 'src/base/bitfield.hh')
-rw-r--r-- | src/base/bitfield.hh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/base/bitfield.hh b/src/base/bitfield.hh index 518bad6b8..70a46386e 100644 --- a/src/base/bitfield.hh +++ b/src/base/bitfield.hh @@ -59,6 +59,17 @@ bits(T val, int first, int last) } /** + * Extract the bit from this position from 'val' and right justify it. + */ +template <class T> +inline +T +bits(T val, int bit) +{ + return bits(val, bit, bit); +} + +/** * Mask off the given bits in place like bits() but without shifting. * msb = 63, lsb = 0 */ @@ -102,6 +113,17 @@ insertBits(T val, int first, int last, B bit_val) } /** + * Overloaded for access to only one bit in value + */ +template <class T, class B> +inline +T +insertBits(T val, int bit, B bit_val) +{ + return insertBits(val, bit, bit, bit_val); +} + +/** * A convenience function to replace bits first to last of val with bit_val * in place. */ @@ -113,6 +135,14 @@ replaceBits(T& val, int first, int last, B bit_val) val = insertBits(val, first, last, bit_val); } +/** Overloaded function to allow to access only 1 bit*/ +template <class T, class B> +inline +void +replaceBits(T& val, int bit, B bit_val) +{ + val = insertBits(val, bit, bit, bit_val); +} /** * Returns the bit position of the MSB that is set in the input */ |