Digital icon indicating copy to clipboard operation
Digital copied to clipboard

How does the barrel shifter work?

Open sudhashbahu opened this issue 6 years ago • 2 comments

I want to implement the equivalent of the C bitwise Operations D >> N and D << N, where D is 16 bit data and N is the unsigned value by which the shift is done.

I have created two barrel shifters for the two operations. The "in" input of set to the 16 bit D. The property is DataWidth=16. The "shift" property is set to bits 0-3 of N (via Splitter). 4 bits are used for the shift value as there is no point shifting more than 16 bits.

I get the error "There are 5 bits needed, but 4 bits found. Affected are: Signal 0-3, Barrel shifter, shift"

Also, it is nor clear from the documentation how the "mode" property behaves.

sudhashbahu avatar Jun 27 '20 14:06 sudhashbahu

4 bits are used for the shift value as there is no point shifting more than 16 bits.

You are right, but you should be able to shift 16 bits, which outputs a zero, and to do this, a 5 bits shift input is required.

Also, it is nor clear from the documentation how the "mode" property behaves.

But the "mode" combo box seems clear to me: "Logical", "Arithmetic" or "Rotation". Even though "Arithmetic" and "Left" doesn't make that much sense. When shifting to the left, "Logical" and "Arithmetic" are identical.

hneemann avatar Jun 27 '20 15:06 hneemann

Thank you for the prompt response and clarifications.

sudhashbahu avatar Jun 27 '20 15:06 sudhashbahu