# Combinational Circuits

## Goals

1. To design a word-level combinational circuit.

## What to turn in

You will get credit for this recitation by completing the Recitation 18 Quiz in Canvas.

## Assignment

Start from the following skeleton file: R18.circ

## Exercise: 8-bit Decrementer

You will design a circuit that takes an 8-bit 2's complement number A as input, and produces A - 1. You need to do a stepwise design.

1. First decide on and understand the algorithm that your circuit is to implement. There are at least two options for a decrementer:

Option 1: to decrement 1 from any (2's complement or unsigned) binary integer, we use the grade school algorithm: work our way from the least significant bit (LSB) to the left towards the most significant bit (MSB). Work out three examples on paper.

Option 2: we can add the 2's complement of 1 (i.e., -1) to the number. Work out three examples on paper.

2. Decompose the algorithm into a set of functions for each bit and write their truth tables. This is the most challenging part.

In both options, the logic for each bit needs two inputs (A and Xin) and two outputs (S and Xout). A is the value of the bit. S is the result of the decrement for that bit position. Xin and Xout have different meanings depending on the option you chose:

Option 1: Xin is the borrow-in bit. If it is 1, it means that the bit position to the right needs to borrow. Xout is the borrow-out bit. If it is 1, it means that this bit position needs to borrow from the left. This is exactly how we would subtract numbers by hand.

Option 2: Xin is the carry-in bit. If it is 1, it means that the bit position to the right generated a carry bit. Xout is the carry-out bit. If it is 1, it means that this bit position needs to carry a bit to the left.

Build the truth table for a bit position according to the option you chose and have your TA check it before you proceed:

 Xin A S Xout
3. Now implement and test it in Logisim:
• First, build the E3_DecrOneBit sub-circuit that deals with a single bit position as explained above.
• In the E3_Main sub-circuit, build your logic by making 8 copies of the E3_DecrOneBit sub-circuit and connecting them appropriately. The input to your circuit should come from the splitter in the input section. The output of your circuit should go to the splitter in the output section. Don't add any additional input or output pins in the main circuit. If you need a constant 0 or 1, use the Constant element under the Wiring library.
• Finally, note that the bit-0 sub-circuit can be simplified so that it doesn't need a Xin input. Build the E3_DecrBit0 sub-circuit and use that in the E3_Main sub-circuit for the LSB instead of E3_DecrOneBit.