Project 1

advertisement
Spring 2001
CS 207
Project 1
The goal is to design a simple BCD calculator that accepts input data in decimal form, encodes the
data in BCD, performs computations on the BCD data and outputs the result in decimal form. For
example, if the 2-digit decimal numbers X=19 an Y=45 are input into the calculator to compute
(X+Y), the resulting output 64 is displayed in decimal form by the calculator. In BCD representation,
each digit (0-9) of a decimal number is encoded by a 4-bit binary [b3b2b1b0]2 with weights 8, 4, 2,
and 1. Thus, a 2-digit decimal is represented by two 4-bit binary numbers. For example the decimal 45
is encoded by 0100 0101.
The calculator consists of three subsystems or functional modules:
The input functional module is used to input one or two 2-digit decimals (X or Y) into the calculator.
This module contains four (16 keys) data key pads and a (4 keys) operation key pad. The data key pad
is composed of hexadecimal keys represented by binary variables di (i=0,1,2,…,9, A, B, C, D, E, F).
Variable di is equal to 1 if the corresponding key is pressed and 0 otherwise. Only one of the data
keys can be pressed at a time. A data key pad is associated with each decimal digit of the inputs X and
Y (for extra credit, devise a better solution that use only one key pad to input the digits of X and
Y). The valid values of X and Y for the operations defined below are the 10 decimal numbers 0…9.
The operation key pad has four keys N (NOP), A (ADD), IC(INC), IV(INV), corresponding to the
BCD ALU operations. Only one of the operation keys can be pressed at a time.
The BCD ALU (Arithmetic logic unit) functional module performs computations on the input X
and Y. It contains a 3-digit output register represented by R=[R2R1R0] and two 2-digit input registers
represented by X=[ X1X0] and Y=[ Y1Y0]. The operations of the ALU are defined as follows:
- NOP resets all values to 0 and output 0 on the seven-segment displays.
- ADD adds the values of inputs X and Y in BCD form. The possible values of X and Y are
the positive 2-digit decimals 0, 1, …, 99. The result of and ADD operation is a 3-digit
decimal [R2R1R0].
- INC increments the value of input X by 1 and displays the result on the seven-segments
displays.
- INV computes the 9's complement of input X and displays the result on the seven segment
displays. The left most seven-segment displays shows a "-" for the complemented value.
The output functional module consists of four seven-segments displays. The first three are used to
display the contents of the output register R. The ith display corresponds to Ri (i=0,1,2). Display 2
contains a minus sign if the result of an operation (see INV above) is negative. The fourth display is
for displaying the error in the input. It should display zero if there is no error and display one
otherwise. Error codes should start from 200. For example if x input is in error then the output register
should display 200 and the error display (D3 see figure on next page) should display 1, if y is in error
it should display 201 and so on. X and Y both are decimals, they will not display error for input
values 0…9 but they will display an error for any value after that (ie A…F ). Make sure you identify
all possible errors and specify appropriate codes for them. Initially or whenever operation key NOP is
pressed, input registers X and Y are set to "F", the output registers are set to 0, all the displays (D0,
D1, D2, D3) are set to 0.
Deliverables and due dates:
On March 30 you should hand in a preliminary report that gives a top-level description of your
solution (see documentation standards of your textbook and discuss this with the lab instructor). You
must use logic works to realise your the BCD calculator. On April 7 you must hand in a final report.
Your final report should contain: the description of the problem, objective, description of the methods
and the tools used to do this project, and the complete technical report of the process to achieve your
objective and conclusions. The project report must accompany with your work on a disk. Also you
must show different data used to test your circuit.
012 3
45 6 7
8 9AB
CDEF
BCD ALU
X0
X
012 3
45 6 7
8 9AB
CDEF
012 3
45 6 7
8 9AB
CDEF
D0
X1
R
4
6
R0
0
R2
D1
R1
Y0
Y
012 3
45 6 7
8 9AB
CDEF
D2
D3
Y1
N A IC IV
D3: is 0 if valid and E if error
Display: D0, D1, D2, D3
Add 19, 45
Download