Test the 4-Bit Increment Using Hex Numbers & Imbed it in to

advertisement
INTRODUCTION
In this laboratory exercise I have built three circuits from primitive logic gates that
will provide part of the functionality of a complete microprocessor. These circuits will
allow you add two 1-bit numbers (i.e., the half-adder function), increment a 4-bit
number2, and perform the two's complement operation on a 4-bit number. In this
exercise, you will also be modularizing the circuits you build so that they can be
easily used and their functions easily understood. Creating modules (a.k.a. sub
circuits) from complex circuits and using these modules to create more complex
modules is a powerful strategy that will allow you to create complex circuits whose
modularized diagrams can easily be interpreted and used.
EQUIPMENT: 1.Personal Computer.
2.Logic Works.
OBJECTIVE AND OUTCOMES: In this experiment, we will gain some experience building and debugging
combinational logic circuits using Logic Works.
When we complete the task in this experiment, we should be able to: 1. Describe the truth tables that characterize the addition of two single bit
numbers.
2. Write the Boolean algebraic expressions that characterize the sum and carry
functions for the half adder.
3. Build and debug a simulation of a circuit that will perform the half-adder
operation.
4. Build and debug a simulation of a circuit that will perform the 4-bit increment
operation.
5. Build and debug a simulation of a circuit that will perform the 2’s complement
operation.
Building the Half Adder
The circuit realizing the SUM and CRY functions that define the 1-bit half adder is
shown in the Figure below.
1-BIT HALF ADDER CIRCUIT.
A
K=A'B
SUM
B
L=AB'
CRY
Task 1-1: Build and Test the 1-Bit Half-Adder
“Use Logic Works™ to build and test the 1-bit half-adder circuit as shown in Figure
1-55. (If you are not sure how to use Logic Works™ refer to Simulator Tutorial:
Using Logic Works™ for Windows®6.) To test this circuit, place switches on the
inputs (A and B) and put binary probes on the outputs (SUM and CRY).
Toggle the input switches through every (A, B) combination and compare the SUM
and CRY outputs observed from the binary probe with those prescribed by the truth
table of the above Figure. Record the results of these tests in your notebook. If the
outputs of your circuit generates agree with the outputs specified by the truth table of
the above Figure then your circuit is working correctly. If they do not agree, you have
a problem with your circuit and you need to check that the connections have been
made correctly.”
Work preformed
In this task I built a half adder as it was shown in the above figure. After I finished with the
circuit I checked the output of the circuit by placing Binary Switches at input A and B and a
Binary Probe at SUM and CRY. Then I compared the results I obtained from the test and
compared with the Truth Table, which is constructed below: -
A
B
CRY
SUM
0
0
0
1
0
0
0
1
1
1
0
1
0
1
1
0
All the results matched correctly, I was now sure that my 1 bit half adder circuit was
ready and working.
What was Learned
I learned that it was always best to check and re check your circuit. So that u can be
confident about your circuit. The best way to make sure your circuit is working is by
constructing a truth table and comparing the results produced by the circuit with the
truth table.
Task 1-2: Imbed the 1-Bit Half Adder in a Sub circuit
“After you have built and tested the circuit, the next task is to create a module by
imbedding your circuit in a sub circuit. Imbed your half-adder circuit in a sub circuit
using the sub circuit shown in the above Figure (To do this, you will have to remove
the binary switches and probes you used in testing your circuit [if you have not done
so already] and place properly configured input/output port symbols on the
input/output lines, respectively. Then follow the directions for creating a sub circuit
described in Simulator Tutorial: Using Logic Works™ 4 for Windows®8.) Label
your sub circuit ‘HA_1’. ‘HA’ stands for ‘half adder’ and the ‘1’ indicates that the
circuit operates on 1-bit operands. (In subsequent laboratory exercises you will build
circuits that operate on binary numbers with multiple bits; hence, it is important to
specify the bit length in labeling each sub circuit so that the length of the operands
accepted by each sub circuit can be determined simply by observing the label.) After
you have created the sub circuit, test the circuit using the same procedure describe
above. (I.e., place binary switches on the inputs of the sub circuit, binary probes at the
outputs, and compare the output values obtained from your circuit with those
contained in the truth table of Figure 1-5 for every combination of A, B inputs.) If the
sub circuit does not work correctly, retrace your steps and try to debug your circuit.
Ask a laboratory assistant for help if you need it. Once you are convinced that your
circuit is working correctly, add the sub circuit to your library.”
WORKED PREFORMED
The half adder circuit that I made in the last task, in this I imbedded in a sub circuit
shown below: -
SUB CIRCUIT OF 1-BIT HALF ADDER
HA_1
A
SUM
B
CRY
This is a sub circuit that has a 1-bit half adder circuit embedded in it. I rechecked this
circuit to make sure that the 1-bit half adder circuit was embedded and weather it gave
the right results or not.
What was Learned
I learnt that building a sub circuit is a very important step towards building a
microprocessor this is because it reduces the complexity and hence narrow down the
chances of errors that can be made by us.
Task 1-3: Build a 4-Bit Increment Circuit
In this task I built a 4 bit half adder. Which was pretty easy. The carry of the first half
adder goes into the incrementing input of the next as shown in the circuit below: -
HA_1
HA_1
A3
A
B
SUM
Y3
CRY
CRY
A2
B
A
Cin
B
SUM
Y0
A1
A
B
CRY
SUM
Y2
CRY
HA_1
HA_1
A0
A
SUM
CRY
Y1
What was Learned
In the 3rd task I learnt to build a 4-bit increment circuit.
Task 4 & Task 5: Test the 4-Bit Increment Using Hex Numbers & Imbed it in
to the subcircuit.
In the task 4 I had to test the 4-Bit Increment circuit by using the Hex Numbers, I did that by
first imbedding the circuit into INC_4. Then I connected the Hex Keyboard to all the inputs
(A0,,A1,,A2,,A3) of the INC_4 (4-Bit Increment circuit imbedded into it) and all the
outputs(Y0,,Y1,,Y2,,Y3) to the Hex Display. I also connected the Cin to a Binary switch and
CRY to a binary probe. The Circuit that I tested is shown below: -
INC_4
0
4
8
C
1
5
9
D
2
6
A
E
3
7
B
F
A3
Y3
A2
Y2
0
1
0
A1
Y1
A0
Y0
Cin
CRY
1
Task 6: Use INC_4 To Perform Two’s – Complement Operation
Twos’ compliment numbers are used for performing arithmetic operations. For
example a microprocessor doesn’t actually subtract. The circuit is shown below:-
INC_4
0
4
8
C
1
5
9
D
2
6
A
E
3
7
B
F
A3
Y3
A2
Y2
A1
Y1
A0
Y0
1
+5V
0
Cin
CRY
INC_4
0
4
8
C
1
5
9
D
2
6
A
E
3
7
B
F
A3
Y3
A2
Y2
A1
Y1
A0
Y0
0
+5V
1
Cin
CRY
I tested the 2’s compliment circuit by connecting a hex keyboard to the inputs
(A0,,A1,,A2,,A3) and a hex display to the outputs(Y0,,Y1,,Y2,,Y3). Two’s
compliment is taking the binary value of a number inverting 1’s to 0 and 0’s to 1
because of the inverters placed in front of the Hex Keyboard and adding one to the
result. The hex value of that binary number is then the two’s complement. I tested the
above circuit for all the numbers. For example if the input is F the output is expected
to be 1 and if the input is 1 the two’s complement is 0 but with a carry of 1.This is
because the binary representation of 0 is 0000 and when inverted to 1’s it is 1111 and
then when 1 is added to it , it becomes 1 0000(the 1 being the carry).This is displayed
in the circuit above.
WHAT WAS LERANED
A proper understanding of the below mentioned circuits and to work with them as
well as make them work.
1)
2)
3)
4)
5)
6)
Half Adder (Adds two 1-bit binary numbers)
A Sub-circuit for the Half Adder
A 4-Bit increment Circuit
Testing the 4-Bit increment using hex numbers
A Sub-circuit for the 4-Bit increment circuit
Using the 4-Bit increment circuit for Two’s-Complement Operation.
THE END
Download