From e85e51514dce94ccd635eb76af60c434e129ca56 Mon Sep 17 00:00:00 2001 From: Rick Altherr Date: Wed, 13 Dec 2017 16:38:40 -0800 Subject: [PATCH] lib: bit_ops: Allow bit_field_set() to implicitly cast value to desired type Signed-off-by: Rick Altherr Signed-off-by: Tim 'mithro' Ansell --- lib/include/prjxray/bit_ops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/include/prjxray/bit_ops.h b/lib/include/prjxray/bit_ops.h index 5979e2b5..baeaab1c 100644 --- a/lib/include/prjxray/bit_ops.h +++ b/lib/include/prjxray/bit_ops.h @@ -31,10 +31,10 @@ constexpr UInt bit_field_get(UInt value, const int top_bit, const int bottom_bit return (value & bit_mask_range(top_bit, bottom_bit)) >> bottom_bit; } -template +template constexpr UInt bit_field_set(const UInt reg_value, const int top_bit, const int bottom_bit, - const UInt field_value) { + const ValueType field_value) { return ((reg_value & ~bit_mask_range(top_bit, bottom_bit)) | ((static_cast(field_value) << bottom_bit) & bit_mask_range(top_bit, bottom_bit)));