The shift operations supported are
- No shift
- Rotate Right - set carry to bit 0, move all bits one place to the right and set bit 7 to carry input
- Rotate Left - set carry to bit 7, move all bits one place to the left and set bit 0 to carry input
- Arithmetic Shift Right - set carry to bit 0, move all bits one place to the right and set bit 7 to zero
- Arithmetic Shift Left - set carry to bit 7, move all bits one place to the left and set bit 0 to zero
- Shift Right fill with 1 - set carry to bit 0, move all bits one place to the right and set bit 7 to one
- Shift Left fill with 1 - set carry to bit 7, move all bits one place to the left and set bit 0 to one
For information on how to use the Rotate and Arithmetic shift operations to perform multi-byte division and multiplication see CPU multi-byte mathematical operations.
The Shift Right and Shift Left fill with 1 operations are not of mathematical use but are supported as a consequence of the design.
The ALU flags supported are
- Zero Flag (Z) - set to 1 if the output of the ALU is zero
- Overflow Flag (V) - set to 1 if addition or subtraction has resulted in an overflow. The flag output is always calculated but only makes sense when a 2's complement addition or subtraction is being performed.
- Negative Flag (N) - set to 1 if the 7th bit of the ALU result is 1. The Negative flag output is always calculated but only makes sense when 2's complement numbers are being used by the programmer.
- Carry Flag - set to 1 if a carry has occurred. The Carry flag is always calculated but only makes sense when an addition or subtraction operation is being performed. NB the value of carry is controlled by the CSEL inputs. To select the carry from the adder the CSEL inputs need to be set to 3.
The Eagle schematic can be downloaded here
![]() |
ALU Flag and Shifter schematic |
The Inputs are as follows
INPUT[0..3] - output from the first ALU board processing bits 0..3
- I0 - bit 0 of the ALU result
- I1 - bit 1
- I2 - bit 2
- I3 - bit 3
- I4 - bit 4
- I5 - bit 5
- I6 - bit 6
- I7 - bit 7
- ADDERCOUT - carry out from the adder
- L7 - the Left Bus bit 7 input to the ALU. Used for calculating overflow.
- R7 - the Right Bus bit 7 input to the ALU. Used for calculating overflow.
- CIN - the carry input to the ALU. Used in shift operations.
- SHIFT SEL0 - combined with SHIFT SEL1 selects the shift operation performed
- SEL1 | SEL0
- 00 = no shift
- 01 = shift right
- 10 = shift left
- 11 = not used (results in output of zero)
- SHIFT SEL1 - combined with SHIFT SEL0
- CSEL0- combined with CSEL1 selects the value to use for carry
- CSEL1 | CSEL0
- 00 = Carry in from the status register
- 01 = 0 (force the value of carry to 0)
- 10 = 1 (force the value of carry to 1)
- 11 = Adder Carry Out
FLAG_OUTPUT
- Overflow flag
- Cout - Carry Out (NB dependent upon the CSEL control)
- Zero Flag
- Neg Flag - Negative flag
- Z0..7 - bits 0 to 7
![]() |
ALU Flag and Shifter PCB layout |
The parts list
Exported from ShifterAndFlagLogicv0.1.brd at 10/11/2013 21:48:37
EAGLE Version 6.5.0 Copyright (c) 1988-2013 CadSoft
Assembly variant:
Part Value Package Library Position (inch) Orientation
C1 10uF E5-5 rcl (0.9 0.35) R90
C2 0.1uF C050-030X075 rcl (1.35 2.25) R270
C4 0.1uF C050-030X075 rcl (2 0.35) R270
C5 0.1uF C050-030X075 rcl (3 1.4) R270
C6 0.1uF C050-030X075 rcl (1.35 1.3) R270
C7 0.1uF C050-030X075 rcl (0.35 0.55) R270
C8 0.1uF C050-030X075 rcl (2 1.3) R270
C9 0.1uF C050-030X075 rcl (2 2.25) R270
C10 0.1uF C050-030X075 rcl (1.1 1.6) R90
CONTROL 4 1X04 pinhead (1.45 0.2) R180
FLAG_OUTPUT 4 1X04 pinhead (2.85 0.2) R0
IC1 74HC153N DIL16 74xx-eu (2.3 2.7) R90
IC2 74HC153N DIL16 74xx-eu (0.7 1.95) R270
IC3 74HC251N DIL16 74xx-eu (0.7 1) R90
IC4 74HC153N DIL16 74xx-eu (1.65 2.7) R90
IC5 74HC153N DIL16 74xx-eu (2.3 1.75) R90
IC6 74HC153N DIL16 74xx-eu (1.65 1.75) R90
IC7 74HC153N DIL16 74xx-eu (2.3 0.8) R90
IC10 4078N DIL14 40xx (3.3 1.8) R90
INPUT[0..3] 8 1X08 pinhead (0.2 2.3) R270
INPUT[4..7] 8 1X08 pinhead (0.2 1.45) R270
POWER 1X02 pinhead (0.6 0.25) R180
SHIFT_OUTPUT 8