0% found this document useful (0 votes)
74 views

EN TP1 Doc

This document describes a homework assignment to build a 4-bit adder/subtractor circuit in Logisim. Students are asked to: 1. Design basic components like a half-adder and full-adder using NAND gates. 2. Combine multiple full-adders to build a 4-bit ripple carry adder. 3. Add indicator circuits to detect zero, negative, overflow outputs. 4. Extend the adder to perform subtraction by inverting one input and adding 1 to the carry in. 5. Students can further extend the circuit with improvements like more efficient adders, registers, ALU functions.

Uploaded by

Smail Smart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

EN TP1 Doc

This document describes a homework assignment to build a 4-bit adder/subtractor circuit in Logisim. Students are asked to: 1. Design basic components like a half-adder and full-adder using NAND gates. 2. Combine multiple full-adders to build a 4-bit ripple carry adder. 3. Add indicator circuits to detect zero, negative, overflow outputs. 4. Extend the adder to perform subtraction by inverting one input and adding 1 to the carry in. 5. Students can further extend the circuit with improvements like more efficient adders, registers, ALU functions.

Uploaded by

Smail Smart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

M’HAMED BOUGARA UNIVERSITY– BOUMERDES

FACULTY OF SCIENCE
COMPUTER SCIENCE DEPARTMENT

Module : Introduction to operating system 2 lecturer : Mokrani Hocine


Branch : 1st year engineer Semester : 2
TP 1: Building a compositional circuit by composition

Objectives
The goal of this first homework is to familiarize you with the Logisim tool, and to build a combinatorial circuit in a
hierarchical way. The circuit you'll be building is a 4-bit adder/subtractor.

To create such a circuit, you'll need to build a 1-bit half-adder, a full 1-bit adder, a 4-bit adder, a 4-bit adder with flags,
and finally an extension of the 4-bit adder to take subtraction into account.

In this homework, we assume that numbers represented on 4 bits are coded in two's complement (Cà2). We ask you
to use only NAND gates in your circuits.

I. Designing a half-adder
This first circuit represents the basic building block of our 4-bit adder, taking two bits A and B as input and producing
an output S and a carry C. Figure 1 shows the input/output diagram of a complete 1-bit adder.

Figure1: Inputs and outputs diagram of a 1-bit half-adder


In this part, you are asked to:
a) Calculate the truth table of a half-adder.
b) Design a half-adder (1 bit) based on its truth table. When generating the circuit, check the Use NAND Gates Only
option. Name the circuit "Half_Add_1b".
c) Run a few tests (using Logisim's simulation mode) to check that your circuit works correctly.

II. Building a full adder


A full adder takes two bits A and B as input, plus the previous carryover Cin. It calculates the sum S of these three
binary values and the carryout Cout. The figure (Figure 2) shows the inputs and outputs of the circuit.

Figure2 : Input/output diagram of a 1-bit full adder.

Page 1 sur 3
In this part, you are asked to:
a) Produce a full adder (1 bit) using the half-adder you have just built. Name the circuit “add_1b”. Use only NAND
gates.
b) Perform a few tests to check that your circuit is working correctly.

III. Building a 4-bit adder


The simplest way to build a 4-bit adder is to use the notion of carry propagation. The idea comes from the manual
addition method. Pairs of bits are added column by column, and carries are propagated to the left. The figure (Figure 3)
shows the composition of a 4-bit adder using the carry propagation principle.

Figure 3: Schematic diagram of a 4-bit adder based on 4 1-bit full adders.

In this part, you are asked to:


a) Make a 4-bit adder using 4 complete 1-bit adders. Name your circuit “Add_4b". The value of C0 is always set to
0, since there's no carry to calculate in the first column (the low weight).
b) If we add 0111 and 0100, what does the circuit display (simulate it)? Explain the result obtained.

IV. First extension (Indicator calculation)


In an ALU, there are flags. These flags indicate: if the result obtained is zero, if the result is negative, or if the result is
erroneous (overflow). It even shows the last hold calculated. To achieve this, the adder is simply extended by circuits,
each of which performs one of four functions.

In this part, you are asked to:


a) Extend the 4-bit adder with a circuit that checks whether the adder output is equal to 0. So, the circuit responds
with 1 if the value is zero, 0 otherwise. Name the output of this circuit (Z).
b) Also add a circuit that responds with 1 if a number is negative, 0 if the number is positive. Name the output of
this circuit (N). Assume that the number is written in two's complement (C2).
c) Add a third circuit that responds with 1 if the capacitance is exceeded. To help you detect a capacitance shift
when numbers are coded in (C2). All you need to do is compare the output value of the last two carries. If the
two carries are different, then we have a capacitance overflow. Name the output of this circuit (O).
d) Add a final circuit that displays the last carry. Name the output of this circuit (C).
e) Add 0111 and 0100, what does the circuit now display?
f) Name this extension of the 4-bit adder with 4 flags "Add_Ind_4b".

V. Deuxième extension (Réalisation d’un additionneur/soustraction)


We can perform addition and subtraction operations using a small extension on the adder!!!! The idea is very simple.
To calculate the difference between two binary values A - B, we simply perform the addition operation of A and (-B), i.e.
A + (-B). In other words, we add A to the two's complement (C2) of B.

Reminder: The two's complement of a binary value is calculated by inverting the bits and adding 1 at the end.
Page 2 sur 3
So, how do you make this circuit?

Fortunately, the circuit is as simple to implement as the idea itself. All you have to do is invert each bit and set 1
(to add the 1) on the holdback C0 instead of 0. In other words, C0 is used to increase the value of the inverse of B by
1, and also a bit to detect whether B or -B is taken. The figure (Figure 4) shows the idea behind this circuit.

Figure 4 : Extension of a 4-bit adder to create a 4-bit adder/subtractor.

In this part, you are asked to:

a) Create an adder/subtractor circuit. Name this circuit "Add_Sous_4b".


b) Perform the following operations: 0011 + 1011, 1011-1100, 1111 + 0001. What does the circuit display?

V.I. Troisième extension (Amélioration de additionneur/soustraction)


In this section, you're free to choose how you want to extend your adder/subtractor and propose new extensions to
your circuit.

To help you, you can research the following points:

1. Building other types of 4-bit adders that are more efficient than the carry-propagation adder used so far in this
homework project.
2. Use registers to save both input numbers and calculation results.
3. Save calculation indicators in a specific register (Status register).
4. Use displays (e.g. 7-segment display) to display numbers in decimal.
5. Extend the circuit for logic operations.
6. Build a 4-bit ALU.
7. You can propose other possible ideas…

Information notes for students:

1- Students are organized in groups of three.


2- The work must be completed in one week.
3- Each three-person team must submit a printed report on its work, not exceeding 10 pages.
4- The font size for the report is 11 pts for the text and 12 pts for the headings.
5- The style used must be: Calibri or Arial.
6- The report must contain an Introduction, a description of the TP steps and a conclusion.
7- Copy/paste in any section will result in a mark of 0 in that section.
8- Presentation sessions of your work on the simulator will be included in the TP sessions.
Page 3 sur 3

You might also like