So First I created a mask that creates all 1's by (1U << len) -1,
So essentially, 1U << len creates a 1 followed by many zeros, and the -1 reduces it to all ones
for ex: the len = 3, then ((1U << 3) - 1) ==> 0b1000 - 1 ==> 0b111, which practically gives us the mask we need and AND it with the reg to get final value