From abd9e13b6994cd073c98b984e8b6dc5406f7bfe2 Mon Sep 17 00:00:00 2001 From: Erik Kooistra <kooistra@astron.nl> Date: Thu, 16 Mar 2017 12:47:00 +0000 Subject: [PATCH] Added to_uword(). --- tools/oneclick/base/common.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/oneclick/base/common.py b/tools/oneclick/base/common.py index 63a3ff5172..a1a94c09a2 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 -- GitLab