diff --git a/tools/oneclick/base/common.py b/tools/oneclick/base/common.py index 63a3ff5172fd6be6ab5dd35dafc047fedcafda7a..a1a94c09a28ba7c6548ee1faa5479106ed66a040 100644 --- a/tools/oneclick/base/common.py +++ b/tools/oneclick/base/common.py @@ -453,6 +453,20 @@ def rotate_list(in_list, n): """ return in_list[n:] + in_list[:n] +def to_uword(arg): + """ + Represent 32 bit value as unsigned word. Note that: + + common.to_signed(common.to_uword(-1), 32) = -1 + + """ + vRet = [] + vList = listify(arg) + for value in vList: + v = int(value) & c_word_mask # mask the 32 bits, also accept float value by converting to int + vRet.append(v) + return unlistify(vRet) + def to_unsigned(arg, width): """ Interpret value[width-1:0] as unsigned