In the first question, in the solution they provided, why did they do the LLS? It seems that in the z’ string the weights of the masked bits are bigger by 1 than they should be. I’d appreciate if someone could help me clarify this. And also if someone knows how to solve using arithmetic shifter, i’d be really grateful for an explanation. i tried creating masks, but i encountered some problems related to the fact that everything is in 2’s complement.

please include screenshots of the question and solution you are referring to

I think i understand now why they did the LLS - so that the weight becomes 2^q and 2^p. But i still would really like to see the solution using shifters. Thanks.

yes exactly, you are right, the shift was to get the desired wight for the bits X[p-1] and X[q-1].

the solution with the arithmetic shifters is very similar to a question we saw in the recitation. The idea for the solution is shifting the string left and then right while the right shifting duplicates the MSB. to create the shift amount we use a trick seen in the recitation, which is applying bitwise not on the bits of P or Q to create a shift of (2^k-p-1=n-p-1) then we can apply another shift with a constant shift amount of 1.

Thanks, i think it works, although i had to use 9 shifters.

could you please explain why in the solution pictured above we need to do the right shift, bitwise AND, and then shift back left?

This is to get the correct wait for the bits. we want bits X[p-1] and X[q-1] but we want their wait to be 2^p and 2^q (and not 2^(p-1) and 2^(q-1)).