This file is intended to be loaded by Logisim (httpwww.cburc.docx
1. This file is intended to be loaded by Logisim
(http://www.cburch.com/logisim/).
addr/data: 8 8
0
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13. CPS250, Logic Design Project #1
Binary Coded Decimal
The basic binary number system (for unsigned numbers) and the
2's complement binary system (for
14. signed numbers) are two ways to represent numbers using bits.
However, there are other ways. One is
known as binary coded decimal, or BCD. BCD numbers are a
little easier for humans to understand,
because there is a direct mapping to decimal numbers. For the
purposes of this assignment, we will
consider only unsigned BCD numbers.
A decimal number is encoded in BCD as follows: Each decimal
digit is represented by four bits. But
since there are only 10 decimal digits and yet 16 combinations
of four bits, some of the bit patterns are
unused. This is summarized by the table below.
bits digit
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
bits digit
1000 8
15. 1001 9
1010 unused
1011 unused
1100 unused
1101 unused
1110 unused
1111 unused
As an example, the decimal number 685 would be represented
by 0110 1000 0101
Addition of 12-bit BCD numbers can then be demonstrated as
such:
1000 0011 0111 837
+ 0001 0010 0110 + 126
----------------------- -----
1001 0110 0011 963
Note that a carry had to occur from the rightmost decimal
column. Simply binary addition would not
accomplish that on the left, so special circuitry is needed to
complete BCD additions.
Your Goal
16. The purpose of your work on this assignment is to complete a
set of circuits that both accomplish BCD
addition and display the results on simulated LED devices.
These devices are available in the Logisim
Input/Output library. The figure below shows the final goal of
this assignment.
The circuit shown here is provided to you in the file
“BCD_add_partial.circ”, along with the pin
layouts for the auxiliary circuits you will design. The circuit is
named “LCD_test”
After downloading the file, please change the name to
“BCD_add.circ”.
A major goal of this project is to allow you to explore and
experiment with Logisim and the
components available there. To that end, you are permitted to
use any devices you find in the Logisim
libraries. There is much there to familiarize yourself with, so
start early!
The Logisim help facility is very complete and very
informative. You should use Help-->Library
Reference frequently while working in Logisim, as all the
devices are described there. Some devices of
particular interest are: comparator, adder, and splitter. (This is
not a complete list of all the devices
you will find useful.)
In the discussions that follow, please remember that when
decisions need to be made using hardware,
the most common tool is a multiplexor.
17. Follow the instructions carefully. You must complete each
device in the circuit provided for that
purpose. You must not change the arrangements of the input and
output pins, and you must not
add any new pins. You should use the pins exactly as they are
provided.
Part I: Digit converter circuit (10 points)
In the image above, you will notice the small devices labeled
“DC”. The implementation of these
devices will be developed by you inside the circuit named
“digit_converter”. Here is what this device
accomplishes:
• Input: 4-bit binary unsigned value X.
• Outputs: 4-bit binary value Y. 1-bit value P.
• If X <= 9:
◦ Y = X
◦ P = 0
• If X > 9:
◦ Y = 1110 (0xE)
◦ P = 1
Recall that the only valid bit patterns for a BCD digit are those
between 0000 and 1001. The purpose of
this device is to let the user know if the input pins represent an
erroneous value. So, if any values
greater than 9 are entered, the value displayed on the LCD will
be “E” (in this case, for “error”), and
the small dot in the lower right corner of the LCD display will
be lit.
18. The LCD devices used are the “Hex Digit Display” devices
found in the Logisim Input/Output library.
Look to the Library Reference for a complete description of
how this device works.
Once your device is complete, if it is working properly you
should be able to see the values on the
input pins appear on the top row of LCD devices. (If the value
is >9, you should see “E.” there.)
Part II: BCD Full Adder (15 points)
This device will be completed by you in the circuit named
“BCD-FA”.
This device will handle the addition of two 4-bit BCD digits and
an incoming carry, as follows:
• Inputs: 4-bit BCD digit A. 4-bit BCD digit B, 1-bit carry-in
Cin.
• Outputs: 4-bit sum BCD digit S, 1-bit carry-out Cout.
• if (A+B+Cin)<=9: // NOTE that A+B+Cin must be a 5-bit sum
◦ S = lower 4 bits of A+B+Cin
◦ Cout = 0
• if (A+B+Cin)>9
◦ S = lower 4 bits of (A+B+Cin)-10
◦ Cout = 1
The idea here is is that we are adding two decimal digits (A and
B) and a possible carry-in (Cin) of 0 or
1. If that sum is >9, then there is a carry-out of 1 and the sum
needs adjusted. If not, the sum is fine and
there is a carry-out of 0.
19. Part III: BCD Ripple-carry Adder (10 points)
Develop this device in the circuit named “BCD_adder”.
The BCD full adder produced in Part II is completely analogous
to the binary full-adder used to build a
binary ripple-carry adder. In the figure shown previously and in
the “LCD_test” circuit, this final
device is the one labeled “BCD_adder”.
The device is quite similar to a binary ripple-carry adder. The
difference is that each stage represents a
decimal digit rather than a bit.
• Inputs: (A3,A2,A1,A0) – 4 digit BCD number A.
(B3,B2,B1,B0) – 4 digit BCD number B.
• Outputs: (S3,S2,S1,S0) – 4 digit BCD sum S
What to Submit
Submit what you have completed in the file “BCD_add.circ”.