1
votes

Simple question. I know it's a logical shift. But does it mean it shifts in an 1? or just 1 to the right? If it's not shifting in an 1, is it a circular shift? I've googled this, but there's a lot of conflicting information out there. Thanks.

4
please state which language you are talking about. As Brian Drummond has stated, in VHDL this would be a syntax error. - youR.Fate

4 Answers

3
votes

Logical shift right, 1 bit.

So 1001b >> 1 = 0100

It will pad a 0 to left left and shift all the bits to the right by what ever number you are shifting, so 1 bit. user3372159 is right that a flag will be set in the processor with the bit that was shifted off, but you will need some assembly knowledge to work with it, or just use more binary operations to get the first bit before shifting.

It's useful for many things, but notably for dividing/multiplying by 2.

10 = 1010b
1010b >> 1 = 0101b = 5
0101b << 1 = 1010b = 10 
3
votes

As this question is tagged VHDL, A >> 1 is a syntax error.

Shift operators in VHDL are sll, sla, srl, sra for shift [left|right][logical|arithmetic] making them less incomprehensible in the first place.

0
votes

Usually it means you are shifting 1 to the right the number being shifted in is almost always zero unless you are shifting through the carry flag. However, I have never done any vhdl programming. This knowledge is from assembly.

0
votes

Also it can be expressed in the following way:

(x << k) == (x multiplied by (2 to the power of k))
(x >> k) == (x divided by (2 to the power of k))