# How do I implement a rotate left 1 bit operation in a 16-bit ALU in logisim

I'm creating a 16-bit ALU that has to perform logical AND, logical OR, addition, subtraction and rotate left one bit. I have everything working perfectly except the rotate left one bit. I think I need to implement this at the 16-bit level instead of inside the 1-bit ALU, which I've chained together to create the 16-bit ALU. Any advice on how to do this would appreciated. I'm thinking it has something to do with the carry out bit, but I can't quite figure it out.

• To have an answerable question, you'd need to show the current architecture of your ALU and its data paths. This should implicitly demonstrate how you are chaining together 1 bit ALU's to create a 16 bit one, which sounds at the very least challenging in its own right... Oct 12 '20 at 0:46
• It's just a lane-change operation. How hard is that? Often, that's already required for other reasons, anyway. But yeah, you can use the adder to do this, too.
– jonk
Oct 12 '20 at 3:14
• As others have mentioned, there is no difference between a left shift and x + x. However a more useful function is a right shift which cannot be emulated by a subtraction. Oct 12 '20 at 8:58
• Just be clear on the difference between shift left and rotate left! Oct 12 '20 at 14:14

• That would be a left shift not rotate, or 17-bit rotate-through-carry, like x86 rcl. A 16-bit rotate left (like x86 rol) would need to feed the carry-out directly into the low bit, as well as into the carry flag. (To be fair, some ISAs only have rotate-through-carry and just call it rotate, e.g. AVR where it uses the ADC opcode.) And yes, adc same,same is equivalent to rcl reg by 1. To emulate rol reg, you could add reg,reg / adc reg,0 to left shift and then add the carry-out to the zero you shifted in. Oct 12 '20 at 12:47