CS Fall HSF Lab 3
CS Fall HSF Lab 3
INTRODUCTION
Digital circuits form the backbone of modern computing systems, enabling the manipulation
and processing of digital information through a series of logical and arithmetic operations. At
the heart of these circuits lies the Arithmetic Logic Unit (ALU), a critical component
responsible for executing fundamental arithmetic computations and logical comparisons
essential for data processing tasks. In this laboratory session, we will extend our adders to
perform multiplication and delve into the intricacies of designing an ALU using multiplexers,
comparators, and full adders.
The objective of this laboratory session is to provide students with hands-on experience in
designing, implementing, and testing key components of an ALU, thereby deepening their
understanding of digital logic and arithmetic operations. Through a series of guided exercises
and practical tasks, students will explore the functionalities of multiplexers, comparators, and
full adders within the context of ALU design, focusing on their roles in data routing,
comparison and arithmetic computation.
Throughout the lab session, students will be tasked with conceptualizing and constructing a
functional ALU circuit that can perform basic arithmetic operations such as addition and
subtraction, multiplication and division as well as logical comparisons between input values.
By integrating multiplexers to control data flow, comparators to facilitate comparison
operations, and full adders to execute arithmetic computations, students will gain insight into
the interplay between various digital circuit components and their collective contribution to
ALU functionality.
Page 1 of 21
environment, this session aims to empower students with practical skills and knowledge that
are applicable across various domains of digital circuit design and computer architecture.
In summary, this laboratory session serves as a foundational exploration into the principles
and practices of digital circuit design, offering students a tangible opportunity to engage with
the complexities of ALU architecture and gain valuable insights into the inner workings of
digital computing systems. Through experimentation, collaboration, and reflection, students
will emerge with a deeper appreciation for the intricacies of digital logic and a solid
foundation upon which to build further expertise in the field of computer engineering and
electronics.
Lab Objectives:
An adder can be extended to perform multiplication. In this part, we will extend the adder to
perform the multiplication of 2-bit numbers. Here, we will need some AND gates in addition
to our full-bit adder.
The binary multiplication rules are as follows:
1×1=1
1×0=0
0×1=0
0×0=0
Page 2 of 21
Here, you will realize that we need four AND gates and TWO adders to perform this
multiplication. The result of multiplying 2-bit inputs results in a maximum of 4-bit output
result.
Notice that at each point in the addition process, at most 2 bits are added. What does this tell
us? We can use half adders to design our 2-bit multiplier. Can you think of how full bit
adders can be used to accomplish this same design?
Explanation of Outputs:
Sum (S): This output is the result of the XOR operation on the two inputs A and B. It
is high (1) when either (but not both) of the inputs is high.
Carry (C): This output is the result of the AND operation on the two inputs A and B.
It is high (1) only when both inputs are high (1).
Logical Expressions:
The half-adder is used in building more complex arithmetic circuits, such as full adders and
binary adders.
a. A 2-bit multiplier with two half bit adders and four AND gates shown in the image
below:
Page 3 of 21
Figure 1. 2-bit multiplier with half adders
Activity 1:
Implement the half adder
Name the half adder as halfbitadder 2-bit multiplier as mult2bit and 3-bit multiplier as
NB: Note that both half and full adders can be combined to design a multiplier. Also we
have designed a full bit adder in our previous lab so brainstorm on what the half bit
1. How many AND gates and adders will be required in designing a 3-bit multiplier?
2. How many XOR and AND gate (s) will be required in designing the half bit adder?
Page 4 of 21
Figure 2. 3-bit Multiplier
In figure 2 above, 128 is divided with 8, which results in 16 as the answer, with 0 as the
remainder. So case, 128 is called the dividend, 8 is called the divisor, 16 is called the
Page 5 of 21
quotient, and 0 is called the remainder. Now, let us take an example of binary division. First,
the following four rules of binary division are the achievable conditions for binary division.
Step 1: First, look at the first two numbers in the dividend and compare with the divisor. Add
the number 1 in the quotient place. Then subtract the value, and you get 1 as the remainder.
Step 2: Then bring down the next number from the dividend portion and do the step 1 process
again.
Step 3: Repeat the process until the remainder becomes zero by comparing the dividend and
the divisor value.
Step 4: Now, in this case, after you get the remainder value as 0, you have zero left in the
dividend portion, so bring that zero to the quotient portion.
Page 6 of 21
Therefore, the resultant value is the quotient value which is equal to 111110.
NB: You would realize that designing a divider circuit is more complex. For example, if you
wanted to divide 17 by 5, you could subtract 5 from 17 and use a counter to track the number
of times until you are left with a remainder lesser than 5. Therefore, most of these complex
circuits are programmed or described using a hardware description language.
Part 3 (Post – Lab Activity): Design a simple 8-bit Arithmetic Unit (AU).
At this point, you have built an addsub module that can add and subtract two 8-bit numbers.
The module takes a two-bit signal as a control for addition or subtraction. The next step is to
combine this module with other modules from the library to create a complex module that
performs addition, subtraction, multiplication and division. You will use your designed 8-bit
addsub together with the in-built multiplier and divider to implement an 8-bit AU.
Create a circuit called AU in the same Logisim file and connect two inputs A and B of 8-bits
each to your addsub, multiplier and divider as shown in the image below:
At this point, you will have three possible results coming out from the add/sub, multiplier and
divider modules. These results are:
Sum/difference
Product
Quotient
Page 7 of 21
Since the processor must perform one operation at a time, there has to be a means to select
one of the results as the final output. You can use a multiplexer.
A multiplexer (mux) is a combinational circuit that takes 2^n data inputs, n selection inputs
and only 1 output. For instance, a 2-input mux should have 2 data inputs, 1 selection input
and a single output. Similarly, a 4-input mux takes 4 data inputs, 2 selection inputs and a
single output.
Simulations:
Use a 4-to-1 multiplexer to connect the three results from your arithmetic unit to the inputs of
your mux. Since you have only three inputs being filled, your mux should have one empty
data input. Using the selector, you can choose which module’s result will be at the output.
Test the result of the circuit the following way. Use the following test cases in testing your
ALU:
Add A = 64 and B = 8
Subtract A = 10 from B = 32
Multiply A = 20 and B = 2
Divide A = 40 by B = 8
Below is a truth table for evaluating the equality of two 1-bit inputs A and B.
Page 8 of 21
Input A Input B A=B
0 0 1
0 1 0
1 0 0
1 1 1
From the truth table, we can realize that our expression would be E = A’B’ + AB. You will
realize that our expression E = A’B’ + AB (and truth table above) is equivalent to the XNOR
Gate truth table. Thus, we can simply use the XNOR Gate to realize equality by designing a
circuit (name as equal1bit) which outputs high when both input bits are equal, as show in the
image below:
Now, let us design an 8-bit equality checker which takes two 8-bit inputs A and B and
produces a high when both inputs are equal. Name the module circuit as equal8bit. You will
realize that we will need 8 XNOR Gates. We will later need one more AND Gate to AND all
results from the individual bit comparisons to achieve the equality check. Your circuit will
Page 9 of 21
Figure 4. 8-bit equality checker
From the truth table above, we can derive our expression, L = A’B, as implemented in the
image below. Name circuit as less1bit.
Page 10 of 21
Figure 5. 1-bit less than
Unlike checking for equality which is straightforward by comparing bit by bit and ANDing
all outputs from each bit-by-bit comparison, the less than operation requires that we take into
consideration, the positional weights of the bits while comparing. For example:
A = 00000101 = 5
B = 00001000 = 8
In the example above, A < B will result in a low output (right after comparing the A0 and B0)
if we do just bit-by-bit comparison.
From the truth table above, we can derive our expression, L = AB’, as implemented in the
image below. Name circuit as great1bit.
Like the less than operation, we must take into consideration, the positional weights of the
bits while comparing. We leave it as a challenge to design such circuit.
For example:
Page 11 of 21
A = 00000100 = 4
B = 00000001 = 1
In the example above, A > B will result in a low output (right after comparing the A0 and B0)
if we do just bit-by-bit comparison.
The objective of this section is to implement the operations involved in the Logical Unit (LU)
of an Arithmetic Logic. These are the basic operations of a comparator – equal, greater and
less than. Afterward, the Logic Unit can be combined with the Arithmetic Unit to form a
basic 8-bit Arithmetic Logic Unit.
Add a new circuit and name it as LU. In this part, we will use Logisim’s comparator which
allows us to easily compare two values for any number of input bits. The comparator can be
found in the Arithmetic folder, like the image below:
The first input bit(s), A is the input preceding the operator, while B follows the operator.
Here, you will supply the comparator with two 8-bit inputs and expect a 1-bit output (high or
low) each from the three operations after comparison. Ensure that the Numeric Type
Property of your comparator is Unsigned. For example:
A = 00000010 = 2
B = 00000001 = 1
Page 12 of 21
We can extend our logic unit to include other operations and a mux as shown in the image
below. (Hint: we are using an 8-input mux because we have 6 possible outputs from our
Logic Unit, hence the use of a 3-bit selector).
From this:
To this:
Page 13 of 21
Combine these 2 units to form an 8-bit Arithmetic Unit (Hint: example below)
An ALU with a simple Logical Unit that has four possible outputs (hence the use of a 4-input
mux and a 2-bit selector) is shown in the image below:
Now, replicate the same for your ALU. Note that your Logic Unit will have 3 selectors
due to your implementation in Part 4 above.
Test Case B:
Divide A = 255 and B = 5 by hand. Indicate the quotient in binary.
Indicate a high (true) or a low (false) for the following:
I. A != B
II. A >= B
Justify your responses above by simulating your circuit and attach screenshots.
Page 14 of 21
Test Case C:
Subtract A = 250 and B = 27 by hand. Indicate the difference in binary.
Indicate a high (true) or a low (false) for the following:
III. A<B
IV. A=B
Justify your responses above by simulating your circuit and attach screenshots.
Problem Statement: Design a combinational logic circuit for an Automatic Water Pump
Controller that operates based on water levels monitored by sensors:
Inputs:
L, M, H
Output:
Steps to Follow:
1. Truth Table: Create the truth table for all sensor combinations.
2. SOP and POS:
o Develop the SOP and POS expressions.
3. Universal Gate Implementation:
o Design the circuit using NAND or NOR gates only by converting the Boolean
expressions.
o Implement the design in Logisim Evolution using universal gates.
4. Simulation:
Page 15 of 21
o Simulate the circuit to verify that the pump operates correctly under various
water level conditions.
Real-World Application: This system mimics an automatic water tank controller for
efficient water management in homes or industries.
Problem Statement: Design a combinational logic circuit for a Digital Lock System. The
lock uses a 4-digit combination, with each digit represented as a binary input:
The lock opens (output 1) if the correct combination (A,B,C,D) is entered. For this problem,
let the combination be 1010.
Inputs:
Output:
Steps to Follow:
1. Truth Table: Create the truth table for all input combinations (16 rows).
2. SOP and POS:
o Write the SOP and POS expressions for the correct combination.
3. Universal Gate Implementation:
o Convert the expressions into NAND or NOR gate implementations.
o Build the circuit in Logisim Evolution using these gates.
4. Verification:
o Test the circuit to ensure it unlocks with the correct combination.
Real-World Application: This system models basic security logic in digital locks and
keypads used in safes or secure areas.
Problem Statement: Design a combinational logic circuit for a Voting System Majority
Detector. The system takes 5 inputs from voters, each vote represented as:
1 for YES
0 for NO
Page 16 of 21
1 (MAJORITY YES) if at least 3 votes are YES.
0 (MAJORITY NO) if fewer than 3 votes are YES.
Inputs:
V 1 ,V 2 , V 3 ,V 4 ,V 5 (voter inputs)
Output:
Steps to Follow:
1. Truth Table: Construct the truth table for all voting combinations (32 rows).
2. SOP and POS:
o Write both SOP and POS forms of the Boolean expression for majority
detection.
3. Universal Gate Implementation:
o Convert the Boolean expressions to use NAND or NOR gates exclusively.
o Build the circuit in Logisim Evolution using these gates.
4. Testing:
o Test the circuit to confirm it correctly identifies majority votes.
Problem Statement: Design a combinational logic circuit for a Home Security Alarm
System. The system has 4 sensors:
Inputs:
F, B, W, M
Output:
Page 17 of 21
Steps to Follow:
1. Truth Table: Develop the truth table with all possible input combinations.
2. SOP and POS:
o Write both the SOP and POS forms of the Boolean expression for the alarm
logic.
3. Universal Gate Implementation:
o Convert the expressions into a form that can be implemented using NAND or
NOR gates only.
o Design and simulate the circuit using Logisim Evolution, ensuring that all
gates used are NAND or NOR.
4. Testing:
o Test the circuit to verify that the alarm triggers correctly under various
conditions.
2. Reflect on the role of comparators within the ALU design. How did these components
facilitate comparison operations, and what challenges or limitations did you encounter
when integrating them into the circuit?
3. Discuss the significance of full adders in the ALU's arithmetic operations. How did
the utilization of full adders impact the efficiency and functionality of addition and
subtraction processes within the ALU?
Page 18 of 21
5. Consider the trade-offs and design decisions involved in balancing performance,
complexity, and resource utilization within the ALU design. How did you navigate
these trade-offs to achieve an optimal solution?
6. Reflect on the overall design process and teamwork dynamics during the lab session.
What were the key challenges faced by the team, and how were they addressed
collaboratively? What lessons can be learned from the design and implementation
process for future projects or improvements?
Submission:
Please submit a zip file (name as ID_Lab3) containing:
PDF of your written responses.
Updated Logisim-evolution file.
Grading Rubric for Logisim Evolution Logic Design Lab Session (Total: 100
Points)
Needs
Criteria Excellent (16-20) Good (11-15) Satisfactory (6-10) Points
Improvement (0-5)
Design meets
Design meets all
most Design meets basic Design does not
specifications;
specifications; specifications; meet specifications;
Design Accuracy circuits function /20
minor errors in several errors in circuits do not
correctly for all
function for function. function.
test cases.
some cases.
Effectively uses a
variety of
Uses appropriate
components Limited variety of Incorrect or
components, but
Use of (AND, OR, NOT, components; may inappropriate use of
may not fully /20
Components XOR, etc.) and rely heavily on one components; lacks
utilize available
demonstrates type. understanding.
options.
understanding of
universal gates.
Logic circuits are
Logic circuits are Basic
optimized and
implemented implementation of Poor implementation
implemented
correctly but logic circuits; of logic circuits; lack
Logic using universal
could be further minimal of optimization; no /20
Implementation gates where
optimized; some optimization; use of universal
applicable; clear
use of universal limited use of gates.
and efficient
gates. universal gates.
design.
Test Cases and Comprehensive Adequate test Minimal test cases; No test cases /20
Page 19 of 21
Needs
Criteria Excellent (16-20) Good (11-15) Satisfactory (6-10) Points
Improvement (0-5)
test cases covering
cases covering
all possible
most scenarios; validation is provided; outputs are
Validation scenarios; all
some outputs inconsistent. not validated.
outputs validated
validated.
correctly.
Clear, detailed
Adequate
documentation
documentation Basic
including circuit Poor or no
with some circuit documentation
diagrams, truth documentation;
Documentation diagrams and provided; missing
tables, and disorganized /20
and Presentation explanations; key components;
explanations of presentation;
presentation is presentation lacks
design choices; difficult to follow.
somewhat clarity.
well-organized
organized.
presentation.
Actively engaged
Participated in Limited
in group work;
Collaboration group work; participation; Did not participate;
contributed
and contributed but minimal no contribution to /10
significantly to the
Participation could have contribution to group work.
project and helped
engaged more. group effort.
peers.
Demonstrates
Shows some No creativity shown;
exceptional Basic design with
creativity in relies entirely on
Creativity and creativity in little creativity;
design; attempts existing designs /10
Innovation design; innovative follows standard
innovative without any
approaches to approaches.
approaches. adaptation.
solving problems.
Grading Scale:
This rubric is designed to effectively assess the students’ performance in the logic design lab
session, ensuring comprehensive evaluation across critical areas of their work, scaled to a
total of 100 points.
Page 20 of 21
Page 21 of 21