Digital Lab Manual 2023
Digital Lab Manual 2023
Manual for
Digital Electronics and Computer
Organization Lab
ENCS 2110
Table of Experiments
II
LABORATORY REGULATIONS AND SAFETY RULES
The following Regulations and Safety Rules must be observed in the laboratory:
1) It is the duty of all concerned who use any electrical laboratory to take all reasonable steps to
safeguard the HEALTH and SAFETY of themselves and all other users and visitors.
2) Be sure that all equipment is properly working before using them for laboratory exercises.
Any defective equipment must be reported immediately to the Lab. Instructors or Lab.
Technical Staff.
3) Students are allowed to use only the equipment provided in the experiment manual or
equipment used for senior project laboratory.
4) Power supply terminals connected to any circuit are only energized with the presence of the
Instructor or Lab. Staff.
5) Students should keep a safe distance from the circuit breakers, electric circuits or any moving
parts during the experiment.
6) Avoid any part of your body to be connected to the energized circuit and ground.
7) Switch off the equipment and disconnect the power supplies from the circuit before leaving
the laboratory.
8) Observe cleanliness and proper laboratory housekeeping of the equipment and other related
accessories.
9) Double check your circuit connections before switching “ON” the power supply.
10) Make sure that the last connection to be made in your circuit is the power supply and first
thing to be disconnected is also the power supply.
11) Equipment should not be removed, transferred to any location without permission from the
laboratory staff.
12) Software installation in any computer laboratory is not allowed without the permission from
the Laboratory Staff.
13) Computer games are strictly prohibited in the computer laboratory.
14) Students are not allowed to use any equipment without proper orientation and actual hands-on
equipment operation.
15) Smoking and drinking in the laboratory are not permitted.
III
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 1 - Combinational Logic Circuits
1.1 Objectives
• To become familiar with AND, OR, NOT, NAND, NOR, and OR operations and them
implementation.
• To construct NOT, AND, OR, and XOR gates using NAND gates.
• To become familiar with the concept of theTruth table.
• To implement the different Boolean functions using NAND gate only.
• To learn techniques of the solution to logic design problems.
• To become familiar with minimization techniques and with the use of Karnaugh maps.
• To construct an AOI gate with basic gates.
1
1.3 Introduction
Logic gates are digital circuits capable of performing a particular logic function by
operating on several binary inputs. Logic gates can be broadly classified as Basic, Universal,
and other logic gates.
Figure 1.1: The AND gate function, symbol, truth table, and Boolean expression.
1.3.1.2 OR GATE:
Figure 1.2: The function, symbol, truth table, and Boolean expression for OR gate.
2
1.3.1.3 NOT GATE:
The NOT gate is called an inverter. The output is high when the input is low. The
output is low when the input is high. Figure 1.3 shows all information for the NOT gate.
Figure 1.3: The function, symbol, truth table, and Boolean expression for NOT gate.
The NAND gate is a contraction of AND-NOT. The output is high when both
inputs are low and any one of the inputs is low. The output is low level when both inputs
are high. Figure 1.4 shows all information for the NAND gate.
Figure 1.4: The function, symbol, truth table, and Boolean expression for NAND gate.
3
1.3.2.2 NOR GATE:
The NOR gate is a contraction of OR-NOT. The output is high when both inputs
are low. The output is low when one or both inputs are high. Figure 1.5 shows all
information for the NOR gate.
Figure 1.5: The function, symbol, truth table, and Boolean expression for NOR gate.
The output is high when any one of the inputs is high. The output is low when both
the inputs are low, and both the inputs are high. Figure 1.6 shows all information for the
EX-OR gate.
Figure 1.6: The function, symbol, truth table, and Boolean expression for X-OR gate.
The X-NOR gate is a contraction of X-OR and NOT. The output is high when the
number of ones is even. The output is low when the number of one is odd. Figure 1.7
shows all information for the X-NOR gate.
4
Figure 1.7: The function, symbol, truth table, and Boolean expression for the X-NOR gate.
5
1.4 Procedure
In section 1.4 we will learn how to build different gates using NAND and NOR gates.
b) Then select the first gate U6 in Figure 1.8. Connect inputs A and B with Data
switch TTL level in power supply SW0 and SW1. connect output F1 with Logic
Indicator (LED) L0 in the power supply. write the result in Table 1.1.
0 1
1 0
1 1
6
c) Use the same connection in part b. Set SW0 to “0” and change SW1 to “0”, see
the result of the output F1 then change SW1 to “1”, and see the output to make it
clear go to Table 1.2 and write the result in the table.
0 1
• Find another way to build a NOT gate using NOR gate and draw the circuit in
the box below. (Hint: return to Figure 1.5 and see the truth table of NOR gate
look when the inputs are the same the output will be the opposite of inputs).
d) Use two of U6 to construct a buffer as shown in Figure 1.9. Insert connection clips
between A and B, connect F1 with A1 then connect A1 with B1. Connect input A to
SW0 and output F3 to L1. write the result in Table 1.3.
7
Table 1.3: Data for part 1.4.1 (d).
SW0(A) L1 (F3)
0
1
• Build OR gate using NOR gate only gate and draw the circuit in the box below.
(Hint: we can build OR gate using NOR and NOT gates. we learn how to build
a NOT gate using NOR gate).
e) Use two of U6 to construct an OR gate. Insert connection clips between F1-A1 and
A1-B1. Connect inputs A to SW0, B to SW1; and output F3 to L1. Follow the input
sequences shown below and record the output states in Table 1.4.
0 1
1 0
1 1
8
f) Know we need to build AND gate using NOR gate only. to learn how to construct
it, let's solve the following equation. We know that AND gate equation is F=A.B
if we take the inverse for this equation and then use De morgan low the equation
becomes
F`=………………………………….
If we take the inverse for the above equation, then the equation becomes:
F``=………………………………….
g) From the above equation (F``) we can see that we can build AND gate using one
NOR gate and two NOT gates. Insert connection clips according to Figure 1.11
below. Connect A to SW0; D to SW1; F1 to A1; F2 to B1; F3 to L1. Follow the
input sequences given below, and record the output states in Table 1.5.
Figure 1.11: build AND gate using NOR gate using kits.
0 1
1 0
1 1
9
1.4.2 The characteristic of NAND gate.
a) Set module IT-3002 and locate block NAND gate as shown in Figure 1.12. Connect
the +5V of module IT-3002 to the +5V output of the fixed power supply IT-3000 and
do the same for the ground (GND).
b) Then select the first gate U4 in Figure 1.12. Connect A and A1 in block a with Data
switch SW0 and SW1 TTL level in the power supply sequentially and connect output
F2 with Logic Indicator L0 in the power supply. write the result in Table 1.6.
0 1
1 0
1 1
c) Use the same connection in part b. Set SW0 to “1” and change SW1 to “0”, see the
result of the output F2 then change SW1 to “1”, and see the output to make it clear go
to Table 1.7 and write the result in the table.
10
Table 1.7: Data for part 1.4.2 (c).
• Find another way to build a NOT gate using a NAND gate and draw the circuit
in the box below. (Hint: return to Figure 1.4 and see the truth table of the NAND
gate look when the inputs are the same the output will be the opposite of the
inputs).
d) Use two of U4 to construct a buffer as shown in Figure 1.13. Insert connection clips
between A and A1, connect F2 with A2 then connect A2 with B2. Connect input A to
SW0 and output F4 to L1. write the result in Table 1.8.
11
Table 1.8: Data for part 1.4.2 (d).
SW0(A) L1 (F)
0
1
• Build AND gate using NAND gate only gate and draw the circuit in the box
below. (Hint: we can build AND gate using NAND and NOT gates. we learn
how to build NOT gate using NAND gate).
e) Use two U4 to construct an AND gate. Insert connection clips between F2-A2 and A2-
B2. Connect inputs A to SW0, A1 to SW1; and output F4 to L1. Follow the input
sequences shown below and record the output states in Table 1.9.
12
Table 1.9: Data for part 1.4.2 (e).
0 1
1 0
1 1
f) Know we need to build OR gate using NAND gate only to learn how to construct it,
let's solve the following equation. We know that OR gate equation is F=A+B if we
take the inverse for this equation and then use De Morgan low the equation becomes
F`=…………………………………..
If we take the inverse for the above equation, then the equation becomes:
F``=………………………………….
g) From the above equation (F``) we can see that we can build OR gate using one
NAND and two NOT gates. Insert connection clips according to Figure 1.15 below.
Connect A to SW0; D to SW1; connect A with A1; and D with B1 and F2 to A2; F3 to
B2 then connect the output F4 with L1. Follow the input sequences given below, and
record the output states in Table 1.10.
13
Table 1.10: Data for part 1.4.2 (g).
0 1
1 0
1 1
Figure 1.16 (a): Constructed with basic gates. Figure 1.16 (b): Constructed with NAND gates.
14
1.4.3.1 Constructing XOR gate with NAND gate (Module IT-3002
block NAND gates)
Insert connection clips according to Figure 1.17. a) to construct the circuit of Figure
1.17. Connect inputs A to SW1, D to SW2; outputs F1 to L1, F2 to L2; F3 to L3 and
F4 to L4. record the output in Table 1.11.
• Now determine the Boolean expression for F1, F2, F3 and F4.
F1=…………………………….
F2=…………………………….
F3=…………………………….
F4=…………………………….
15
1.4.3.2 Constructing XOR gate with Basic Gate (Module IT-3002 block
Comparator1)
16
1.4.4 AOI Gate Circuits.
AND-OR-INVERTER (AOI) gates consist of two AND gates, one OR gate, and
one INVERTER (NOT) gate. The symbol of an AOI gate is shown in Figure 1.19. The
Boolean expression for the output F is F = (AB+CD)' ……... (1)
a) Use U1 and U2 on block Comparator 1 of module IT-3002, shown in Figure 1.20 (a), to
construct the A-O-I gate of Figure 1.20 (b). Figure1.20 (c) is the equivalent A-O-I
circuit.
17
Figure 1.20(b): AOI circuit Actual circuit
b) Connect inputs A, A1, B, B1 to Date Switches SW0, SW1, SW2 and SW3 respectively.
Connect outputs F3, and F4 to Logic Indicators L1 and L2 respectively.
c) Set B×B1to “0”, follow the input sequences for A, A1 in Table 1.13, and record the outputs
d) WhenA1×A is “0”, follow the input sequences for B, B1 in Table 1.14 and record the
Outputs.
18
Table 1.14: Data for part 1.4.4 (d).
19
1.5 Post Lab
• Draw the logic diagram showing the implementation of the following
Boolean equation using “NAND” gates
a) F = AB (CA).
b) F= (D.A) + (C.B)
c) F = XZ + Y’Z + X’YZ
• Draw the logic diagram of the following Boolean equations using NOR
gates.
a) F=(A+B) (CD+A)
b) F= (ABC+D) C
b) F2=A’D+A’C+BD+AB’D’
20
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 2 - Comparators, Adders, and Subtractors
2.1 Objectives
• To understand the construction and operating principle of digital comparators
• To implement half- and full adders using basic logic gates and ICs
21
2.3 Pre Lab
1) Prepare all sections and work out all the required designs.
22
2.4 Theory
The half adder accepts two binary digits on its inputs and produces two binary
digits outputs, a sum bit, and a carry bit. The half-adder is an example of a simple,
functional digital circuit built from two logic gates. The half-adder adds to one-bit binary
numbers (AB). The output is the sum of the two bits (S) and the carry (C)as shown in
Figure 2.1.
Note how the same two inputs are directed to two different gates. The inputs to the
XOR gate are also the inputs to the AND gate. The input "wires" to the XOR gate are tied
to the input wires of the AND gate; thus, when voltage is applied to the A input of the
XOR gate, the A input to the AND gate receives the same voltage. As shown in Figure
2.2.
23
2.4.1.2 Full Adder:
The full adder accepts two input bits and an input carry and generates a sum output
and an output carry. The full-adder circuit adds three one-bit binary numbers (Cin, A, B)
and outputs two one-bit binary numbers, a sum (S) and a carry (Cout) as shown in Figure
2.3. The full adder is usually a component in a cascade of adders, which add 8, 16, 32,
etc. binary numbers.
In Figure 2.4 (a), if you look closely, you'll see the full adder is simply two half
adders joined by an OR. We can implement a full adder circuit with the help of half-
adder circuits. The first half adder will be used to add A and B to produce a partial Sum.
The second half adder logic can be used to add CIN to the Sum produced by the first half
adder to get the final S output. If any of the half-adder logic produces a carry, there will
be an output carry. Thus, COUT will be an OR function of the half-adder Carry outputs.
We can see the truth table of the full adder in Figure 2.4 (b).
24
Figure 2.4 (b): Full-Adder Truth table.
When FA1 adds A1 and B1, a sum S1 and a carry C1 is generated. C1 will be
added to A2 and B2 by FA2, generating another sum S2 and another carry C2. In the case
of Figure 2.5, the sum of the four adders do not stabilize at the same time, delaying the
adding process. This delay can be eliminated by using the "Look-Ahead" adder.
Look-ahead adders do not have to wait for the previous adder to stabilize before
performing the next addition, saving valuable time. In Boolean expression we assume:
Pi =Ai ⊕Bi
Gi =Ai x Bi
The output and carry can be expressed as:
Si = Pi ⊕ Cj
Ci+1 = Gi + PiCi
25
Gi is called "Carry Generate". When Ai and Bi are both "1", Gi is "1" and
unrelated to the carry input. Pi is called "Carry Transmit", related to the carry transmit
between Ci and Ci+1. If we substitute the carry function of each stage by the previous
carry, we get:
C2 = G1 + P1 C1
C3 = G2 + P2 C2 = G2 + P2 G1 + P2 P1 C1
C4=G3+P3C3=G3+P3P2G1+P3P2P1C1
Figure 2.6 shows the carry path of a look-ahead adder. The 74182 is a look-ahead
adder TTL-IC.
Binary adders can be converted into BCD adders. Since BCD has 4 bits with
the largest number being 9; and the largest 4-bit binary number is equivalent to 15, there
is a difference of 6 between the binary and the BCD adder: Under following conditions 6
must be added when binary adders are used to add BCD codes:
1. When there is any carry.
2. When the sum is larger than 9.
If the order of priority is S8, S4, S2, S1 and the sum is larger than 9 then S8 x S4 +
S8u x S2. If any carry is involved, assuming the carry is CY, under this term, 6 must be
added: CY + S8 X S4 + S8 X S2.
26
Figure 2.7: BCD adder.
27
2.4.2.2 Full Subtractor:
full subtractor is a combinational circuit that performs subtraction of two bits, one
is minuend and other is subtrahend, taking into account borrow of the previous adjacent
lower minuend bit. This circuit has three inputs and two outputs. The three inputs A, B
and Bin, denote the minuend, subtrahend, and previous borrow, respectively. The two
outputs, D and Bout represent the difference and output borrow, respectively. Although
subtraction is usually achieved by adding the complement of subtrahend to the minuend,
it is of academic interest to work out the Truth Table and logic realization of a full
subtractor; x is the minuend; y is the subtrahend; z is the input borrow; D is the
difference; and B denotes the output borrow. The corresponding maps for logic functions
for outputs of the full subtractor namely difference and borrow.
From a 4-bit adder circuit, we can assemble subtractor circuits of 4-bit or longer.
Figure 10 shows a dual-purpose adder/ subtractor circuit. When Bn-1= “0” additions are
performed and all XOR gates act as buffers. When Bn – 1 = “1” subtractions will be
performed and all XOR gates act as NOT gates. Y inputs use 1’s complemented and adds
a “1” from Cin. The outputs are Cn (carry) and Bn (borrow), Cn and Bn are dependent on
Bn-1.
28
Figure 2.10: Dual-purpose adder/subtractor circuit.
At least two numbers are required to perform any comparison. The simplest form of the
comparator has two inputs. If the two inputs are called A and B, then there are three possible
outputs: A>B, A=B, and A<B. Figure 2.11 shows the schematic and symbol diagrams of a
simple 1-bit comparator circuit.
In actual applications, 4-bit comparators are used most often. In a 4-bit comparator, each
bit represents 20, 21, 22, and 23. Comparison will start from the most significant bit (23), if input
A is greater than input B at the 23 bits, the “A>B” output will be in the high state. If A and B
are equal at the 23 bits, the comparison will be carried out at the next highest bit (22). If there is
still no result at this bit, the process is repeated again at the next bit. At the lowest bit (20), if
29
the inputs are still equal then the “A=B” output will be in the high state. Figure 2.12 shows the
schematic and symbol of a 4-bit comparator.
30
2.5 Procedure
2.5.1 Comparator Circuits
a) Set module IT-3002 block Comparator 1. Insert connection clips according to Figure
2.13 (a). U1, U2, and U3 will be used to construct the 1-bit comparator shown in
Figure 2.13 (b).
b) The inputs are triggered by high-state voltage. Connect inputs A and B to Data
Switches SW1 and SW2. The outputs are triggered by low-state voltage. Connect
outputs F1, F2, F5 to Logic Indicators L1, L2, and L3 respectively.
c) Follow the input sequences and the result in Table 2.1.
Table 2.1: Data for part 2.5.1.1 (c).
INPUTS OUTPUTS
SW2(B) SW1(A) F1 F2 F5
0 0 A=B
0 1 A>B
1 0 A<B
1 1 A=B
31
Figure 2.14: 4-bit Comparator IC (IT-3002 block Comparator 2).
b) Connect input in left side of the block A<B to SW1, A=B to SW2, A>B to SW3.
The inputs A0~A3 and B0~B3 of the 74LS85 are also connected to the BCD rotary
switch and connect output in right side of the blook A<B , A=B and A>B to
L1,L2,L3.
c) Set comparing inputs A0~A3=As, B0~B3=Bs, and As=Bs from the rotary switch,
follow cascading inputs sequences in Table 2.2 and record the outputs.
INPUTS OUTPUTS
A>B A=B A<B A>B A=B A<B
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 1
Compare the results with the function table of 74LS85 (page 2 of the datasheet)1.
Design a three-bit comparator (using the basic comparator) and hand it out to your
TA. (Pre Lab).
Hand out, Design, Boolean function, and truth table of half- and full-adder to your TA.
(Pre Lab).
1
https://www.futurlec.com/74LS/74LS85.shtml
32
a) Set module IT-3003 and locate block Half-Adder. Insert connection clips according to
Figure 2.15 (a), using U5 and U6 to assemble the half-adder circuit of Figure 2.15 (b).
Connect +5V of module IT-3003 to the +5V output of the fixed power supply.
b) Connect inputs A, B to Date Switches SW0, SW1 and connect outputs F1, F2 to logic
indicators L1 and L2. Follow the input sequences for A and B in Table 2.3 and record
the output states.
INPUTS OUTPUTS
SW1 (B) SW0 (A) F1 (CARRY) F2 (SUM)
0 0
0 1
1 0
1 1
c) Reassemble the circuit according to Figure 2.16 (a) to construct the full-adder circuit shown in
Figure 2.16 (b).
d) Connect A, B, C to SW1. SW2 and SW3. A and B are augends while C is the previous
carry. Connect F3 to L1, F5 to L2. Follow the input sequences in Table 2.4 and record
the outputs states.
33
(a) Wiring diagram (IT-3003 Full-Adder block) . (b) Full-Adder circuit.
OUTPUTS OUTPUTS
SW3 (C) SW2 (B) SW1 (A) F3 (CARRY) F5 (SUM)
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
a) Set module IT-3003 and locate block Half-Adder. Insert connection clips according
to Figure 2.17.
34
Figure 2.17: Wiring diagram (Half-subtractor).
c) Follow the input sequences in Table 2.5 and record output states.
INPUTS OUTPUTS
C A B F1 F2 F3 F5
0 0 1
Half-
0 0 0
subtractor 0 1 1
Half-adder 0 1 0
1 0 0
Full-
1 0 1
subtractor 1 1 0
Full-adder 1 1 1
35
“0”; record F1 and Σ in binary numbers.
X = X3X2X1X0
Y = Y3Y2Y1Y0
Σ = Σ3Σ2Σ1Σ0
INPUTS OUTPUTS
Y3 Y2 Y1 Y0 X3 X2 X1 X0 Σ4 Σ3 Σ2 Σ1 F1(CARRY)
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
0 0 0 0 0 1 1 0
0 0 0 0 1 0 0 1
0 0 0 0 1 1 1 1
0 0 0 1 0 0 1 1
0 0 0 1 0 1 1 0
0 0 0 1 1 0 0 0
0 0 1 1 0 1 1 0
0 1 0 0 1 0 0 0
0 1 0 0 1 1 1 1
1 0 0 0 0 1 1 1
1 0 0 1 1 0 0 1
1 0 1 0 1 0 1 1
36
2.5.5 Constructing 4-Bit Full-Subtractor with IC
a) Use Module IT-3003 block Full Adder (Figure 2.22). Connect inputs X3~X0
(minuend) to DIP Switch 1.3~1.0; Y3~Y0 (subtrahend) to DIP 2.3~2.0; Y5 to
SW0.
Connect outputs F1 to L4; F11~F8 to L3~L0. To execute the subtract operation,
set SW0 to “1” (or Cin of U9=1). Follow the input sequences below and record
the output states in Table 2.7.
Figure 2.19: Wiring Diagram for full subtractor (IT-3003 4-bit Full-Adder block)
INPUTS OUTPUTS
X3 X2 X1 X0 Y3 Y2 Y1 Y0 F1 F11 F10 F9 F8
0 1 0 0 0 1 0 0
0 1 0 0 0 0 1 1
1 0 0 0 0 0 1 1
1 0 0 0 0 0 0 1
1 0 0 1 1 0 0 0
1 0 0 1 0 1 1 1
1 0 1 0 0 1 1 0
1 0 1 0 0 1 0 1
1 0 1 1 1 0 1 0
1 1 1 1 1 0 1 0
37
2.5.6 Constructing BCD Adder
a) The circuit shown in Figure 2.20 will act as a BCD adder.
c) F8~F11 are the sum of X0~X3 added to Y0~Y3 while F1 is the carry. Follow
the input sequences for X0~X3 and Y0~Y3 in Table 2.8 and record the output
states.
38
Table 2.8: Data for part 2.5.6 (c)
39
2.5.7 High-Speed Adder Carry Generator Circuit
a) U3 (74182) on block High-Speed Adder of module IT-3003 is used to construct a
carry generator circuit shown in Figure 2.21.
INPUTS OUTPUTS
40
2.6 Post Lab
1. Design 8-bit BCD adder.
3. A 4-inputs, 3-outputs circuit that compares 2-bit unsigned numbers and outputs a ‘1’ on one
of three output lines according to whether the first number is greater than, equal to, or less
than the other number. You can only use two 4×1 multiplexer.
41
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 3 - Encoders, Decoders, Multiplexers, and Demultiplexers
3.1 Objectives
• To understand the operating principles of Encoders/Decoders
42
3.3 Pre Lab
1) Design a circuit which uses an SN74151 to implement a sum-of-products expression, as
follows:
a) Convert the following expression into summation form (i.e., F (A, B, C) =∑ (…)):
𝑌 = 𝑓 (𝐴, 𝐵, 𝐶 ) = 𝐴𝐵 + 𝐵𝐶
b) Sketch on Figure 3.1 the input connections necessary to implement the function in part (a).
Observe that the inputs are connected to 0 or 1 depending on the value of the function for
that min term.
Important: Please note that this way we can implement a 3-input function (A, B, C) using
an 8-to-1 MUX. Later we will see how to implement a 4-input function (A, B, C, D) using
an 8-to-1 MUX. For that we will need to inspect the additional input (say D) with the
corresponding function value. The possible inputs to the MUX are 0, 1, D, D`.
a) Convert the following expression into summation (Sum of Products –SOP-) form (i.e.
F(A,B,C)=∑(…)):
43
3.4 Theory
3.4.1 Decoder
The combinational circuit that changes the binary information into 2N output lines is
known as Decoders. The binary information is passed in the form of N input lines. The output
lines define the 2N-bit code for the binary information. In simple words, the Decoder performs
the reverse operation of the Encoder. At a time, only one input line is activated for simplicity.
The produced 2N-bit output code is equivalent to the binary information. The outputs of the
decoder are nothing, but the min terms of ‘N’ input variables lines as shown in Figure 3.2.
Example show 2 to 4 Decoder. Let 2 to 4 Decoder has two inputs A1 & A0 and four
outputs Y3, Y2, Y1 & Y0. The block diagram of 2 to 4 decoder is shown in the following
figure.
One of these four outputs will be ‘1’ for each combination of inputs when enable, E is
‘1’. The Truth table of 2 to 4 decoder is shown below.
44
Table 3.1: Truth table of 2 to 4 decoder with enable
Each output is having one product term. So, there are four product terms in total. We can
implement these four product terms by using four AND gates having three inputs each & two
inverters. The circuit diagram of 2 to 4 decoder is shown in the following figure.
3.4.2 Encoder
An Encoder is a combinational circuit that performs the reverse operation of Decoder. It
has maximum of 2N input lines and ‘N’ output lines. It will produce a binary code equivalent to
the input, which is active High. Therefore, the encoder encodes 2N input lines with ‘n’ bits. It is
45
optional to represent the enable signal in encoders.
Example show 4 to 2 Encoder. Let 4 to 2 Encoder has four inputs Y3, Y2, Y1 & Y0 and
two outputs A1 & A0. The block diagram of 4 to 2 Encoder is shown in the following figure.
At any time, only one of these 4 inputs can be ‘1’ to get the respective binary code at the
output. The Truth table of 4 to 2 encoder is shown below.
Table 3.2: Truth table of 4 to 2 encoder
Outputs Inputs
Y3 Y2 Y1 Y0 A1 A0
0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1
46
We can implement the above two Boolean functions by using two input OR gates. The
circuit diagram of 4 to 2 encoder is shown in the following figure.
The Priority Encoder solves the problems mentioned above by allocating a priority
level to each input. The priority encoders output corresponds to the currently active input
which has the highest priority. So, when an input with a higher priority is present, all other
inputs with a lower priority will be ignored.
The priority encoder comes in many different forms with an example of an 8-input
priority encoder along with its truth table shown below.
(a) 8 to 3 priority Encoder block diagram. (b): 8 to 3 priority Encoder truth table.
47
3.4.3 Multiplexer
Multiplexer is a combinational circuit that has maximum of 2n data inputs, ‘n’ selection
lines and single output line. One of these data inputs will be connected to the output based on
the values of selection lines. Since there are ‘n’ selection lines, there will be 2n possible
combinations of zeros and ones. So, each combination will select only one data input.
Multiplexer is also called as Mux.
Example show 4 to 1 Mux. 4x1 Multiplexer has four data inputs I3, I2, I1 & I0, two
selection lines s1 & s0 and one output Y. The block diagram of 4x1 Multiplexer is shown in
the following figure.
One of these 4 inputs will be connected to the output based on the combination of inputs
present at these two selection lines. Truth table of 4x1 Multiplexer is shown below.
Selections Outputs
S1 S2 Y
0 0 I0
0 1 I1
0 0 I2
1 1 I3
We can implement this Boolean function using Inverters, AND gates & OR gate. The
circuit diagram of 4x1 multiplexer is shown in the following figure.
48
Figure 3.10: 4 to 1 multiplexer circuit.
3.4.4 De-Multiplexer
De-Multiplexer is a combinational circuit that performs the reverse operation of
Multiplexer. It has single input, ‘n’ selection lines and maximum of 2n outputs. The input will
be connected to one of these outputs based on the values of selection lines. Since there are ‘n’
selection lines, there will be 2n possible combinations of zeros and ones. So, each combination
can select only one output. De-Multiplexer is also called as De-Mux.
Example show 1x4 De-Multiplexer. 1x4 De-Multiplexer has one input I, two selection
lines, s1 & s0 and four outputs Y3, Y2, Y1 &Y0. The block diagram of 1x4 De-Multiplexer is
shown in the following figure.
49
The single input ‘I’ will be connected to one of the four outputs, Y3 to Y0 based on the
values of selection lines s1 & s0. The Truth table of 1x4 De-Multiplexer is shown below.
Selections Outputs
S1 S2 Y3 Y2 Y1 Y0
0 0 0 0 0 I
0 1 0 0 I 0
0 0 0 I 0 0
1 1 I 0 0 0
We can implement these Boolean functions using Inverters & 3-input AND gates. The
circuit diagram of 1x4 De-Multiplexer is shown in the following figure.
50
3.5 Procedure
b) 2. Connect +5V of module IT-3004 to the +5V output of fixed power supply
section of IT-3000.
c) 3.Connect inputs A~D to Data Switches SW0~SW3 respectively; outputs F8
and F9 to Logic Indicator L0 and L1.
d) 4.Follow the input sequences for D, C, B, A; in Table 5 and record the output
states.
Inputs Outputs
D C B A F9 F8
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
51
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
b) As you know, the main kit has 2 sets of DIP switches, with 8 switches each: 1.1-1.8
and 2.1-2.8. Connect inputs A1~A8 to DIP Switches 1.1~1.8 and A9 to 2.1 (or one of
the unused main switches S1-S4). Connect outputs F1~F4 to Logic indicators L1~L4.
Follow the input sequences given in Table 6 and record output states. Be aware of the
active LOW and active HIGH polarity for the inputs/outputs when interpreting the
results.
52
Table 3.6: Data for part 3.5.2 (b)
Inputs Outputs
A9 A8 A7 A6 A5 A4 A3 A2 A1 F4(LSB) F3 F2 F1(MSB)
0 1 1 1 1 1 1 1 1
0 0 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 0 0
1 1 1 1 1 1 0 1 1
1 1 1 1 1 0 0 0 0
1 1 1 1 0 1 1 1 1
1 1 1 1 0 0 0 1 1
1 1 1 0 1 1 1 0 0
1 1 0 1 1 0 1 1 0
1 1 0 0 0 1 1 1 1
1 0 0 0 0 1 1 1 1
b) Connect inputs A, B to Data Switches SW0 and SW1. Connect outputs F1~F4 to Logic
Indicators L0~L3 respectively.
c) Follow the input sequences for A and B in Table 3.7 and record output states.
53
Table 3.7: Data for part 3.5.3 (c)
Inputs Outputs
B A F1 F2 F3 F4
0 0
0 1
1 0
1 1
a) U6 (7442) on block Decoder 2 of module IT-3004 will be used in this section of the
experiment. 7442 is a BCD-to-Decimal decoder IC. BCD: Binary Coded Decimal.
b) Connect inputs A, B, C and D to the Data Switches SW0, SW1, SW2 and SW3,
respectively. Connect 10 outputs to corresponding Indicators L0~L9.
c) Adjust the switches according to Table 3.8. Observe the output states at L0~L9.
Record input and output logic states in Table 8. (Note input is the binary number for
number in first column).
54
Table 3.8: Data for part 3.5.4 (c)
Input Output
D C B A 0 1 2 3 4 5 6 7 8 9
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
55
Table 3.9: Data for part 3.5.5 (c)
Inputs Output
C A B F3
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
b) Refer to the data sheet for specifications of the 74LS151. A, B, C are the control
(selection) inputs: CBA is the value of C then B then A. So, CBA=011 means that
C=0, B=1, A=1. Q is the output of the MUX.
When CBA = “000”, data at D0 is send to output Q.
When CBA = “010”, data at D2 is send to output Q.
⋮
56
When CBA = “111”, data at D7 is send to output Q.
The IC will function properly only when STROBE = “0”.
When STROBE = “1” IC do not change output according to inputs, Q will remain
“1”.
c) Connect inputs D0~D7 to DIP Switch 1.0~1.7; inputs C, B, A to Data Switches SW2,
SW1, SW0. Follow the input sequences in Table 6, adjust D0~D7 and CBA and
record output states. Determine which input among D0~D7 does Q depend on.
Inputs Output
C A B Q
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
57
d) Record output states in Table 3.11.
Table 3.11: Data for part 3.5.7 (d)
Inputs Output
A B C D Y
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
b) Set C to “0” and change data at input A. Observe how F1 and F2 changes. Set C to
“1”, change A and observe how F1 and F2 react to changes of A.
58
Table 3.12: Data for part 3.5.8 (b)
Inputs Outputs
C A F1 F2
0 0
0 1
1 0
1 1
59
Table 3.13: Data for part 3.5.9 (e)
Inputs Outputs
C B A Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
60
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 4 - Digital Circuits Implementation using Breadboard
4.1 Objectives
• Understanding the NAND and NOR gate characteristic and how to implement circuit
• To continue the previous experiment with simple digital devices and their operations using
breadboard.
⮚ IC 7404 (inverter)
⮚ IC 7432(2-input OR)
61
4.3 Pre Lab
1) Watch the video in link bellow to understand what the breadboard is and how it is works and the
way components, including chips are connected to the breadboard as was done in experiment 1.
https://www.youtube.com/watch?v=gwcVr5VfXwA
2) Recall how to identify the pins of a chip. You may find the following presentation useful:
https://www.youtube.com/watch?v=Y9vsZTpnDDI
3) Design and implement the following circuit using the gates on the chips as shown in Figure 4.1(.
Your final circuit must include the IC’s, their pin numbers, and the connections between the
pins.).
62
4.4 Theory
63
Figure 4.1: DIGITAL GATES IN IC PACKAGES.
4.4.2 Breadboard
The breadboard consists of two terminal strips and two bus strips (often broken in the
center). Each bus strip has two rows of contacts. Each of the two rows of contacts are a node.
That is, each contact along a row on a bus strip is connected (inside the breadboard).
Bus strips are used primarily for power supply connections but are also used for any
node requiring a large number of connections. Each terminal strip has 60 rows and 5 columns
of contacts on each side of the center gap. Each row of 5 contacts is a node as shown in Figure
4.2.
You will build your circuits on the terminal strips by inserting the leads of circuit
components into the contact receptacles and making connections with 22–26-gauge wire.
64
There are wire cutter/strippers and a spool of wire in the lab. It is a good practice to wire +5V
and 0V power supply connections to separate bus strips.
The 5V supply MUST NOT BE EXCEEDED since this will damage the ICs (Integrated
circuits) used during the experiments. Incorrect connection of power to the ICs could result in
them exploding or becoming very hot - with the possible serious injury occurring to the people
working on the experiment! Ensure that the power supply polarity and all components and
connections are correct before switching on power. You can learn more about the breadboard by
click in this link https://youtu.be/gwcVr5VfXwA
65
4.5 Procedure
In this experiment, we will use a breadboard to implement different circuits using basic
gates and NAND and NOR gates to build other gates. Before that, there were some instructions
to build a circuit and the common problems.
Building the Circuit:
Throughout these experiments, we will use TTL chips to build circuits. The steps for wiring a
circuit should be completed in the order described below:
1. Turn the power (Trainer Kit) off before you build anything!
2. Make sure the power is off before you build anything!
3. Connect the +5V and ground (GND) leads of the power supply to the power and
ground bus strips on your breadboard.
4. Plug the chips you will be using into the breadboard. Point all the chips in the same
direction, with pin 1 at the upper-left corner. (Pin 1 is often identified by a dot or a
notch next to it on the chip package)
5. Connect +5V and GND pins of each chip to the power and ground bus strips on the
breadboard.
6. Select a connection on your schematic and place a piece of hook-up wire between
the corresponding pins of the chips on your breadboard. It is better to make the short
connections before the longer ones. Mark each connection on your schematic as you
go, so as not to try to make the same connection again at a later stage.
7. Get one of your group members to check the connections before you turn the power
on.
8. If an error is made and is not spotted before you turn the power on, Turn the power
off immediately before you begin to rewire the circuit.
9. At the end of the laboratory session, collect your hook-up wires, chips and all
equipment and return them to the demonstrator.
10. Tidy the area that you were working in and leave it in the same condition as it was
before you started.
66
Common Causes of Problems:
1. Not connecting the ground and/or power pins for all chips.
2. Not turning on the power supply before checking the operation of the circuit.
3. Leaving out wires.
4. wires into the wrong holes.
5. Driving a single gate input with the outputs of two or more gates
Modifying the circuit with the power on.
a) Implement the following circuit in Figure 4.3 using basic gates and fill the truth
table (Table 4.1).
67
Table 4.1: Data for part 4.5.2 (a)
Inputs Outputs
A B F1
0 0
0 1
1 0
1 1
b) Implement the following circuit in Figure 4.4 using basic gates and fill the truth table
(Table 4.2).
Inputs Output
A B C F1
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
68
c) Implement the following circuit in Figure 4.5 using basic gates and fill the truth table
(Table 4.3).
Inputs Outputs
A B F1 F2
0 0
0 1
1 0
1 1
d) (Adder) Use any needed gates shown in Figure 1 and the designs you prepared
as a pre-lab to implement the full adder, test your design by verifying the truth table
of the Full Adder.
69
Figure 4.6: Full Adder.
e) (Decoder) Use any needed gates shown in Figure 1 and the designs you
prepared as a pre-lab to implement the 2x4 decoder. Test your design by verifying
the truth table of the DECODER.
f) (Multiplexer) Use any needed gates shown in Figure 1 and the design you prepared
as a pre-lab to implement the 4x1 multiplexer. Test your design by verifying the
truth table of the MUX.
70
Figure 4.8: 4X1 Multiplexer.
71
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 5 - Sequential Logic Circuits
5.1 Objectives
• To understand the differences between combinational and sequential Logic circuits; and
the applications of various memory units.
• To understand the operating principles of counters and how to construct counters with JK
flip-flops.
72
5.3 Laboratory Regulations and Safety Rules
The following Regulations and Safety Rules must be observed in the laboratory:
1. It is the duty of all concerned who use any electrical laboratory to take all reasonable steps
to safeguard the HEALTH and SAFETY of themselves and all other users and visitors.
2. Be sure that all equipment is properly working before using them for laboratory exercises.
Any defective equipment must be reported immediately to the Lab. Instructors or Lab.
Technical Staff.
3. Students can use only the equipment provided in the experiment manual or used for senior
project laboratory.
4. Power supply terminals connected to any circuit are only energized with the presence of
the Instructor or Lab. Staff.
5. Students should keep a safe distance from the circuit breakers, electric circuits, or any
moving parts during the experiment.
6. Avoid any part of your body to be connected to the energized circuit and ground.
7. Switch off the equipment and disconnect the power supplies from the circuit before leaving
the laboratory.
8. Observe cleanliness and proper laboratory housekeeping of the equipment and other related
accessories.
9. Double check your circuit connections before switching “ON” the power supply.
10. Make sure that the last connection to be made in your circuit is the power supply and first
thing to be disconnected is also the power supply.
11. Equipment should not be removed, transferred to any location without permission from the
laboratory staff.
12. Software installation in any computer laboratory is not allowed without the permission
from the Laboratory Staff.
13. Computer games are prohibited in the computer laboratory.
14. Students are not allowed to use any equipment without proper orientation and actual hands-
on equipment operation.
15. Smoking and drinking in the laboratory are not permitted.
73
5.4 Pre Lab
1. Read all experiment to find the prelab questions
2. For each used IC (Integrated Circuits), search for its datasheet that explains exactly what a
component does and how to use it.
5.5 Introduction
5.5.1 Sequential Circuits
Any digital circuit could be classified as either a combinational or a sequential circuit.
Combinational logic circuits implement Boolean functions. Boolean functions are mappings
of inputs to outputs. These circuits are functions of input only.
Sequential circuits are two-valued networks in which the outputs at any instant are
dependent not only upon the inputs present at that instant, but also upon the history (sequence)
of inputs. The block diagram of a sequential circuit is shown in Figure 5.1. The basic logic
element that provides memory in many sequential circuits is the flip-flop.
5.5.2 Latches
Latches form one class of flip-flops. This class is characterized by the fact that the output
changes' timing is not controlled. Although latches are useful for storing binary information
and for the design of asynchronous sequential circuits, they are not practical for use in
synchronous sequential circuits.
74
5.5.2.1 The SR (Set-Reset) Latch
It is a circuit with two cross-coupled NOR or NAND gates.
a. SR latch with NAND gates:
The one with NAND gates is shown in Figure 5.2. Note that this circuit is active
low set/reset latch; that means the output Q goes to 1 when S (set) input is 0 and goes
to 0 when R (Reset) input is 0 as shown in Table 5.1. The undefined condition is
when both inputs are equal to 0 at the same time.
INPUT OUTPUT
State
S R Q ̅
Q
1 0 0 1 SET
1 1 0 1 No Change/ Memory
0 1 1 0 RESET
1 1 1 0 No Change/ Memory
0 0 1 1 Invalid
75
Figure 5.3: RS latch with control input.
INPUT OUTPUT
State
C S R Qn+1 Qَ
0 X X Qn Qَ No Change/ Memory
1 0 0 Qn Qَ No Change/ Memory
1 0 1 0 1 RESET
1 1 0 1 0 SET
1 1 1 0 0 Indeterminate
INPUT OUTPUT
State
C D Qn+1 Qَ
0 X Qn Qَ No Change/ Memory
1 0 0 1 RESET
1 0 1 0 SET
76
5.5.3 Flip-Flops
Like latches, flip-flops are also used for storing binary information, but the difference is:
The output change in the flip-flop occurs only at the clock edge while in the latch it occurs at
the clock level.
A flip-flop can be implemented using two separate latches. Figure 5.5 shows the D flip-
flop implemented with two D latches.
There are several types of flip-flops, the common ones are D, T, and JK flip flops. Figure
5.6 shows these flip flops and their function tables.
77
5.5.4 Registers
Digital systems use registers to hold binary entities. The register is a collection of flip flops;
N-bit register consists of N flip-flops. Figure 5.7 shows simple 4-bit register implemented
with D- flip flops. All the flip-flops are driven by a common clock, and all are reset
simultaneously.
Shift register is a group of flip-flops connected in a chain so that the output from one flip-
flop becomes the input of the next flip-flop. Figure 5.8 shows 4-bit shift- right register.
5.5.5 Counters
The counter is a special-purpose register; it is a register that goes through a prescribed
sequence of states.
The counters are classified into two categories: Ripple and Synchronous counters. In ripple
counters, there is no common clock; the flip-flop output transition serves as a source for
triggering other flip-flops. In synchronous counters, all flip flops receive a common clock.
Figure 5.9 shows 3-bit ripple and synchronous counters.
78
Figure 5.9: (a) 3-bit ripple counters, (b) 3-bit synchronous counter.
79
5.6 PROCEDURE
5.6.1 Latches and Flip flops:
INPUT OUTPUT
A3 A4 F6 F7
0 0
0 1
1 0
1 1
80
b) Constructing RS latch with control input
INPUT OUTPUT
A1 A5 F6 F7
0 0
0 1
1 0
1 1
81
Figure 5.12: D Latch.
INPUT OUTPUT
CK2 A1 F6
0 0
0 1
0
1
82
Figure 5.13: JK Latch.
CK2 A1 A5 F6
1 0
0 0
1 1
1 0
0 0
0 1
1 1
• Dose the led sequence follow the expected result according to the FF state
table, explain?
The master-slave flip-flop cancels all timing problems by using two SR flip-flops
connected. First flip-flop acts as the “Master” circuit, which triggers on the leading edge of
the clock pulse while the other acts as the “Slave” circuit, which triggers on the falling edge
83
of the clock pulse. This results in the two sections; the master section and the slave section
being enabled during opposite half-cycles of the clock signal. Let us do this part by following
these steps:
INPUT OUTPUT
CK2 K J F1 F2 F6 F7
0 0
0 1
1 0
1 1
1 1
84
5.6.2 Registers
1. Block Shift Register 1 of module IT-3008 will be used to construct the circuit shown
in Figure 5.15.
2. Connect B (clear) to SW0; A (I/P) to SW1; CK to SWA A output; F1, F2, F3, F4 to
L1, L2, L3, L4, respectively.
3. Set SW0 to “0” to clear B and then set SW0 to “1”.
4. Follow the input sequence for A(I/P) below, observe output display at F1, F2, F3 and
F4, and fill Table 5.9:
a) at A= “1”, send in a CK signal from SWA
b) at A= “0”, send in a CK signal from SWA
c) at A= “0”, send in a CK signal from SWA
d) at A= “1”, send in a CK signal from SWA
INPUT OUTPUT
A CK F1 F2 F3 F4
85
0
Use Shift Register 2 module in IT-3008 which is 4-Bit Shift Register with serial and
parallel synchronous operating modes, it has serial input (B1) and four parallel (A-D) Data
inputs, and four Parallel Data outputs (QA–QD) as shown in Figure 5.16.
- Connect Inputs A, B, C, D to SW0, SW1, SW2, SW3 Outputs F1, F2, F3, F4
to L0, L1, L2, L3, respectively.
- B1 (I/P) to DIP2.0
- A1 (MODE) to DIP2.1 as in Table 5.10.
2. Connect CK (C1) to the clock generator TTL level output at 1Hz and change data at B1 with
DIP2.0. Follow the input sequences for A1 in Table 5.11. Observe and record the outputs.
86
Table 5.11: Data for part 5.6.2 (B-2).
INPUT OUTPUT
A1 C1 L3 L2 L1 L0
3. Connect LOAD (D1) to the clock generator TTL level output at 1Hz. Set A1 to “1”
and follow the input sequences for A, B, C and D in Table 5.12. Observe and record
the outputs.
Input Output
D1 D C B A L3 L2 L1 L0
0 0 1 0
1 0 1 0
1 1 1 0
0 1 1 1
0 1 1 0
87
5.6.3 Counters
1. Use IT-3007 module to implement the 2-bit synchronous counter shown in Figure 5.17.
2. Connect +5V of module IT-3007 to the +5V output of fixed power supply and GND
of module IT-3007to GND output of fixed power supply.
3. Connect CLK input to pulser switch SWA.
4. Connect counter outputs Q1 and Q0 to indication lamps L1, L2, respectively.
5. Apply clock pulses to CLK input. Observe and record the outputs (in binary) in
Table 5.13(a).
6. Apply counter outputs Q1 and Q0 to seven segment display. Observe and record the
outputs (in decimal) in Table 11.13(b).
88
Table 5.13: Data for part 5.6.3 (A).
1. Use the IT-3007 module to implement the 3-bit (divide by eight) Ripple counter
shown in Figure 5.18.
2. Connect CLK input to pulser switch.
3. Connect counter outputs Q2, Q1 and Q0 to indication lamps.
4. Apply clock pulses to CLK input. Observe and record the outputs in Table 5.14(a).
5. Apply counter outputs Q2, Q1 and Q0 to seven segment display. Observe and record
the outputs in Table 5.14(b).
89
Figure 5.18: 3-bit Ripple Counter.
Task2: Modify the circuit in Figure 5.17 to be 3-bit Synchronous Counter. Attach the
design with this experiment report.
90
c) BCD Counter
Locate the BCD counter (IC 7490) on IT-3008 module, which is shown in Figure
5.19. Functional block diagram of U1 is shown in Figure 5.20.
1. Connect +5V of module IT-3008 to the +5V output of fixed power supply and GND
of module IT-3008 to GND output of fixed power supply.
2. Connect C3, C4 to SW0 and SW1; D1, D2 to SW2 and SW3; F1~F4 to L1~L4, A2
to SWA A output.
3. Connect F1 to B2, set C3, C4, D1 and D2 to ground and A2 to SWA A pulse.
Measure and record the outputs F1, F2, F3, F4.
4. Set SW2 and SW3 to 0.
91
d) Divide-by-8 counter using BCD chip counter:
1. Change R0(2) (pin3) to +5V, and connect R0(1) (pin2) to QD (pin11) output. This
will make counter reset after 111 (or 7). WHY?
2. Connect clock A2 (pin14) to pulser switch.
3. Connect the outputs A, B, C, and D to indication lamps.
4. Apply clock pulses to A2 and observe the count sequence (0000-0111).
1. 0 – to – 5
2. 0 – to – 4
5.7 DISCUSSION
Answer the following questions:
1. Although latches are useful for storing binary information, they are rarely used in
sequential circuit design, why?
2. What is the disadvantage of the RS flip flop?
3. What is the difference between “synchronous” and “ripple” counters?
92
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 6 - Sequential Logic Circuits using Breadboard and IC’s
6.1 Objectives
• To learn how to use some Integrated Circuits (ICs) such as seven-segment display
driver/decoder (IC7447) and counters (IC7490).
• To understand the function of the seven-segment display and how to find its pin assignment.
1) What is the appropriate display type (common anode/common cathode) that must be used with
7447 display decoders? Explain your answer.
2) Assuming that the turn-on voltage for the LEDs is 1.7v, what is the proper value of the
93
resistors to be connected between the 7447 decoder and the seven-segment display, to limit
the current in the LED segments to 10mA?
3) Assume that the resistors provided in the lab are 220Ω. What would the current flowing into
the LEDs be?
4) Design a decade counter circuit using the 7490 counters, the 7447 decoder and a seven-
segment display. Show the pin numbers on the ICs in your design.
6.4 Theory
Inside the seven-segment display, one end of each LED is connected to a common point,
which is tied either to ground or to the positive supply, depending on the device. If the seven-
segment display is designed to have the common connection tied to the positive supply (+5V),
as shown in Figure 6.2 (left-hand side), it is called a common anode configuration. To turn on
these LED segments, the inputs logic must be set to low.
94
If the seven-segment display is designed to have the common connection tied to the
ground (0V), as shown in Figure 6.2 (right-hand side), it is called a common cathode
configuration. To turn on these LED segments, the inputs logic must be set high.
In both configurations, current-limiting resistors are used to lower the amount of current
that the driver sends into the LEDs. This achieves two goals:
1- Control the brightness of the LEDs.
2- Prevent over-current (that may burn the LEDs).
95
Figure 6.3: 7447 pin assignments.
- LT should be high for normal operation and when pulled low, all seven-segments
will be turned on.
- RBI must be high if blanking of a decimal zero is not desired.
- BI/RBO can be used as input or output. If BI is high, and LT is low, all 7 segments
are on. This function can be used to see if all the LED segments are working. BI is
used to turn off all these segments, when pulled low. If A, B, C, D, and RBI are all
low, and LT is high, then all 7 segments are off. In this situation, -the RBO goes low
(response condition).
96
- For normal operation without blanking, the three inputs: LT, RBI, and BI/RBO
should be connected to +5V (given that they are active low).
6.4.3 Counter
In this lab the IC type 7490 counter will be used. The 7490-pin assignment is shown in
Figure 6.4 and reset/count function table is shown in Table 6.2.
97
6.5 Procedure
98
2. Apply clock pulses to pin 14 of the 7490-counter using Pulser Switch
(SWA).
3. Observe the counting sequence on the display D1 and complete Table 6.3
4. Apply clock pulses to pin 14 using “pulse generator” of the IT-3000 Basic
Electricity Circuit Lab. Observe the count sequence.
D1
99
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 7 - Constructing Memory Circuits Using Flip−Flops
7.1 Objectives
• Understand the basic structure of Random-Access Memory (RAM).
• Understand and test the circuit of 64-bit Random Access Memory (RAM).
7.3 Theory
100
Figure 7.1: (a) One bit memory using a flip flop. (b) Two-bit memory with 1x2 decoder.
- When CS=0, tri-state gates U1 and U2 do not operate, so data input is not
possible, the flip- flop output Q is not sent to the I/O terminal.
- When CS=1, W/R controls the D flip-flop. When W/R' =1, U1 opens but U2
does not, I/O will accept data input. If W/R'=0, the exact opposite will happen
and I/O act as the data output.
- Figure 7.1 (b) shows another connection that will increase the RAM capacity.
When CS1=1, RAM1 I/O1 and I/O2 are selected. Address line A is used to select
between RAM1 and RAM2. Since there is only one address line, we can only
select from 2 RAMs. In Figure 7.1 (b), each CS can only select a 2-bit RAM, so
the total capacity is 2×2.
1) In Figure 7.2, a 2-address (2-bit) RAM circuit has independent input and
output. When Address=0, input D1 is enabled and the content of D1 will be
made available at the output.
101
Figure 7.2: Implementation of the two-bit memory presented in Figure 1 (a).
102
7.3.2 64-BIT RANDOM ACCESS MEMORY (RAM) CIRCUIT
Like ROM, RAM is also a memory element. The data selection process is controlled
by the address selectors. The length of data is related to the number of data variations. For
example, if there are 4 data then 2^4 or 16 data variations exist.
The number of address lines determines the number of locations. If there are 4 address
lines, then 2^4or 16 locations exist. A 4-bit data can be stored in each location, since the total
capacity is 16×4, where the 4 is the number of data while 16 is the number of address lines.
Figure 7.4 shows the 7489 IC, which is a 16×4 memory with 64 memory capacities.
Also, its function table.
- When ME' = 0 and WE' = 0, the memory is enabled, and the input process starts. The
input and output terminals are separated. The output terminals are open-collector type so
resistors “RX×4” must be added to the supply voltage. Since the output terminal of 7489
is open-collector type, the outputs can be connected in parallel, as shown in Figure 7.4.
The operating sequence will be controlled by ME' and WE'.
- When A4A5=00, A is selected, ME' and WE' of B, C and D all equal to “1”. Similarly,
when A4A5=01, B is selected, ME' and WE' of C and D all equal to “1”. E is 2-4
decoders with “0” as its output. The unselected outputs are in high or “1” state.
- Since the outputs will have high impedance when ME' and WE' are both “1”, each
R/W' control of 7489 are connected to an OR gate to ensure that when ME' = “1”, WE'
will be equal to “1” too.
103
- When ME' = “0”, WE' is controlled by external R/W' control so that the “READ”
operation is performed if R/W'= “1”. The “WRITE” operation is performed when
R/W'= “0”.
- The 7488 is a 256-bit open-collector ROM which has similar structure as the 7489.
Their methods of expansion are similar as well.
104
7.4 Procedure
B) Connect E1, S1, D2, D1 to Data Switch SW0~SW3 respectively. Connect outputs F1,
F2, F3 to Logic Indicators L1~L3. Refer to the input sequence in Table 7.1 and record all
outputs. Discuss and explain the results to your TA.
Table 7.1. Extracted data observations and storing process of a 1x2 RAM
Input Output
E1 S1 D2 D1 F3 F2 F1
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
105
C) Then, set module IT-3011 and locate block RAM Circuit. Insert connection clip according
to Figure 7.7, connect +5V, +15V of module IT-3011 to the +5V, 15V output of fixed
power supply respectively.
D) Connect inputs D4~D1 to DIP Switch 1.0~1.3; A3~A0 to DIP 2.0~2.3; S1 (ME) to Pulser
Switch SWAA; S2 to Data Switch SW0. Outputs are indicated by CR1~CR4.
E) Set SW0 (WE') to “0” for the “WRITE” task. Start from address 0000, input data to
A0~A3 by setting the DIP switch. Activate SWA once to write the data into its assigned
address. Repeat this process for all the addresses, ending with 1111. Record what was
written into each address in Table 7.2 under the “WRITE” column.
106
Table 7.2: Data for part 7.4.1 (E).
107
F) Now set SW0 (WE’) to “1” for the “READ” task and connect S1 (ME' ) to Pulser Switch
SWA. Observe states of CR1~CR4 and record under the “READ” column in Table 7.3.
Table 7.3: Data for part 7.4.1 (F).
G) Disconnect SWA and “A” clip, then turn off the main power switch of IT- 3000 for about
10 seconds and turn it on again. Change address and press SWA then attempt to read the
data. Are they still stored in the RAM?
H) Disconnect “B” clip, VCC disappears. Repeat Step 5 to see if the data are still stored in
the RAM.
2. Although D latches are useful for storing binary information, they are not used in RAM circuit design,
why?
108
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 8 - Introduction to QUARTUSII Software
8.1 Objectives
• To learn how to use QUARTUS II and write code using Verilog HDL language.
• To learn how test code and make symbol from code.
• To learn about FPGA and how download code from QUARTUS II to FPGA
109
a) Build half adder on data flow.
b) Build the Ful adder using half adder structural.
c) Build a 2-bit counter on behavioral.
d) Build an 8x1 Multiplexer on behavioral.
e) Build a 2x4 decoder using basic gates (structural).
f) Show the wave form for above parts.
110
8.4 Theory
111
comprehensive multi-core processor.
112
8.5 Procedure
113
Figure 8.4: How to create new project (second way).
● Step3: Then the window in Figure 8.5 will be shown, press next for First
window.
114
Figure 8.5: First Windows.
● Step4: Then Later, a window will appear asking you to enter the project storage
location and the name of the project. After filling out the information, you will be
clicked on the next option at the bottom of the screen. As shown in Figure 8.6. Then
another window will appear asking to enter previously existing files. If there are no
files, click on the Next option.as shown in Figure 8.7.
115
Figure 8.6: Project Folder, Project Name, Top-Level-Entity.
116
Figure 8.7: Add existing files.
● Step5: In Figure 8.8, show the windows where we can choose the family of FPGA
we went to use and the number of FPGA, then select Finish.
117
Figure 8.8: choose family and number for FPGA.
118
Figure 8.9: to create new files.
2. For this lap we choose Verilog HDL File from Figure 8.9. Then a white screen will
appear on which we will write the code. the Figure 8.10 show simple code for half
adder.
119
Figure 8.10: simple code for half adder.
Important note: This file is used to enter your Verilog code; you must save the file as the name of the
module. Look to Figure 8.11.
120
3. To run code Right click on the file name and select option Set as Top-Level Entity
then click (start compilation) select this icon in top of the screen or clicking on
processing> start compilation. If there is any error, you can see in white area in
bottom of screen.
White screen
121
Figure 8.13: Vector waveform File.
2. Then right-click on the left most side of the window (under Name), then click insert
node or bus, as shown below
122
3. Click on Node Finder and then on List (using the Filter pins: all) and note that file name in
look in option as shown in Figure below. Select all inputs and the output by clicking on (>>)
(you can select one by one).
4. You can select the intervals when you want the inputs to be one or zero, either by
shadowing the interval, then press the one level in the tool bar, or by write clicking the
name, then select value > count value, the change the start value, the end value, and the
radix as shown in the following figure:
123
Figure 8.16: put value for inputs.
5. Now save the file with the same name as your project and in the same folder.
6. Then, from Processing > Simulator Tool, the window in Figure 8.14 will appear:
124
Figure 8.17: to show result.
8.5.4 How to make symbol from code, make diagram and Schematic File
1. To start new File, press File > New, the window in Figure 8.9 will appear press
Block Diagram /Schematic File.
2. The window in Figure 8.18 will appear, to enter components of our design double
click anywhere on the schematic window or select the symbol tool (The little and
gate).
125
Figure 8.18: diagram window.
3. This opens the symbol window in which available libraries, including the standard
QUARTUSII library, open this library by clicking on the little plus sign next to it,
then select primitives, and then select logic, then select the gate you want in your
implementation.as shown in Figure 8.19.
126
4. You have to define the inputs and outputs of your implementation, and you do so
by opening the symbol window> primitive> pin, the following figure shows all
the design components that must now be connected, we will build half adder using
gates:
5. To connect the components of the previous figure, select the 90o thin line with the
dots on its ends on the tool bar, this makes your cursor wiring tool that can be
used to connect you circuit. When done, disable the wiring tool by clicking the
arrow on the tool bar.
6. Rename input and output ports to the variable names of our design, to name a pin,
either double click it to open its pin properties window, or right –click it, and
select properties from the pull-down menu that shows up.
7. Save your design, and make sure it is named the same as your project, the
following figure shows the completed block diagram of our design.
127
Use to connect between components
8. To run first Right, click on the file name and select option Set as Top-Level
Entity then click (start compilation) select this icon in top of the screen or
clicking on processing> start compilation. If there is any error, you can see in
white area in bottom of screen.
10. We can make symbol from code first Right click on the file name and select
option Set as Top-Level Entity then right click in name of cade file and choose
Create Symbol File for Current File. as shown in Figure 8.22.
128
Figure 8.22: create symbol.
11. we want to use this symbol in diagram we search name of symbol (code name).as
shown in Figure 8.23.
129
8.5.5 How to Download code in FPGA and choose inputs and outputs in board
1. After verifying that the design works as expected we can install the code on the
hardware (FPGA).
2. To check that the correct device is selected, this can be done using Assignments
> Device.
3. We need 2 switches for A and B (Inputs). 2 LEDs to see the output are needed.
We have to use the user manual of DE1 to figure out the location of the switches
and the LEDs. The Tables below show the location of the switches.
Figure 8.25: Pin Assignment for Switches. Figure 8.26: Pin Assignment for LEDs.
130
4. To select which inputs and outputs we use we select Assignments >
Assignments Editor then the window in below will appear.
5. Assign PINs for the Inputs and Outputs. You can assign them by selecting all
the schematic file then right click Locate > Locate in assignment editor, the
following Figure appears:
6. Select Pin in the category and select a switch for input. After that save the pin
assignment. Then the pins will appear in diagram.as shown in Figure 8.29.
131
Figure 8.29: choose inputs and outputs in board.
7. Re-compile the Project so that the new changes in the PINs take place. If the
project name differs from you block diagram file, then you have to set the file
as top-level entity as mentioned before. Download the Program on the FPGA
Tools >Programmer.
132
Figure 8.31: download code in FPGA.
2. Use Verilog HDL to implement a 2-to-1 MUX. Use Verilog HDL to implement a Full Adder. Create
schematic symbols for both the MUX and the Full adder, then connect them as shown in the figure. Run
a meaningful simulation for this circuit.
133
3. Use Verilog HDL to implement a 2-bit counter with direct reset input (RESET). Use Verilog HDL to
implement a 2-to-4 Decoder. Create schematic symbols for both the counter and the decoder, then
connect them as shown in figure below. Run a meaningful simulation for this circuit.
134
8.7 Post Lab
- Design the following circuit:
135
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 9 - A Simple Security System Using FPGA
9.1 Objectives
• To practice building different digital components using Quartus either by building a Verilog
codes or Block diagrams.
• Learning how to put some of the digital components, you have studied and build in pervious
lab sessions, together to build useful systems.
9.3 Pre Lab (Bring a soft copy of your prelab with you to the lab)
1) Prepare each part of the procedure section where it says (Pre Lab).
2) NOTE: It is important that you come prepared, as this will reflect your work time during the lab
plus it will be a critical variable in the evaluation of your lab report:
136
9.4 Theory
In this experiment, we are going to build a simple security system using Altera Quartus
software. Then we will program and download this system on the FPGA board. This security
system is simply a 2-digit digital lock. The user enters a number of two digits, such that, the
digit ranges from 0 to 3. Thus, every digit has a lower limit of 0 and an upper limit of 3. The
number is entered using a keypad (using the 91 switch keys build in our FPGAs). Each digit is
represented by a 7-segment display and if the total number entered on the displays equals to
XX a green led is on; allowing us to pass. Otherwise, a red LED is always on, blocking us
from passing.
Figure 9.1 depicts this security system architecture.
137
Figure 9.2: High level view of the system.
As Figure 9.1 shows, this security system comprises the following components:
9.4.1 4x2 Priority Encoder
The normal digital encoder is a combinational circuit that encodes 2^n input lines by n
output lines. In other words, it generates the binary code equivalent of the input line, which is
active high. However, this kind of encoders has a problem. It only works when only one of the
inputs is active. In other words, if there is more than one input line active, the encoder will
generate the wrong code.
This issue can be resolved using the priority encoder. This kind of encoders prioritizes the level
of each input. If multiple input lines are active, the output code will correspond to the input line
with the highest priority as shown in Figure 9.3.
The user will use this priority encoder to choose what value to view on a 7-segment display
(values range from 0 to 3 in decimal), for example, if the user switches SW1 to high and keeps
SW2 and SW3 low then the output of the encoder will be b’01.
138
9.4.2 Enable Port
The purpose of this port is to allow the user to select which memory system is active,
and hence which 7- segment display to use, for example, if SW4 is high then the En pin of the
first memory system is enabled and ready to read the user input on the 4x2 priority encoder.
Note: The enable pin of the decoder must be active low while switching between
selection lines of the decoder.
139
Note: For each 7- segment display, we need a memory system block
9.4.5 Comparator
The input of each 7-segment display is connected also to a comparator. every
comparator has a built-in value (reference) which is compared with the value of the 7-segment
display. If both values are equal, then the output of the comparator is 1, and it is 0, otherwise.
For example, if one of the comparators has a reference value equals 5, then its output will be 1
if and only if the input is equal to=7'b0100100 (which is the value of 5 in the 7-segment
display). The purpose of the comparator is to lock/unlock the security system.
140
9.5 Procedure
1. Design a 4 x 2 priority encoder by writing and simulating the Verilog code shown in
Figure 9.6 using Quartus. (Pre LAB).
2. Design the 7-segment display driver by writing and simulating the Verilog code shown in
Figure 7 using Quartus. (Pre Lab).
141
Figure 9.7: 7-Segment Display Driver Verilog Code.
3. Write and simulate the Verilog code of a D- Flip Flop using Quartus (Pre Lab)
4. Write and simulate the Verilog code of a 2x1 MUX using Quartus (Pre Lab).
Note: The MUX should behave as explained in the memory system section (check
back the theory).
5. Use a block diagram to build the design shown in Figure 9.8.
6. Write and simulate the Verilog code of the comparator shown in Figure 9.9 using
Quartus
Note: for simplification, we will build one comparator based on the reference value
X (in this case, it is 5). You can build four different comparators with four different
values to compare with.
142
Figure 9.8: Memory System Block Diagram.
143
Figure (9): Comparator Verilog Code.
7. Build and design the security system using the components you built in the previous
steps. The final block design should look like the one in Figure 9.10. Assign pins
values to the security system design you just built and then download the system on
the FPGA board.
144
Figure 9.10: The Security System Final Block Diagram.
9.6 Do in lab
1. Change in code to make user enter number from 0-7.
2. Make your system take four different password numbers.
145
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 10 - Simple Computer Simulation
10.1 Objectives
In this experiment we are going to design the Verilog HDL control sequence for a simple computer
(SIMCOMP). The SIMCOMP is a very small computer to give the students practice in the ideas of designing
a simple CPU with the Verilog HDL notation.
146
10.4 Theory
147
10.4.2 General Registers
1) One of the CPU registers is called as an accumulator AC or 'A' register. It is the
main operand register of the ALU it is used to store the result generated by ALU.
2) The data register (MDR) acts as a buffer between the CPU and main memory. It is
used as an input operand register with the accumulator.
3) The instruction register (IR) holds the opcode of the current instruction.
4) The address register (MAR) holds the address of the memory in which the operand
resides.
5) The program counter (PC) holds the address of the next instruction to be
fetched/execution.
Additional addressable registers can be provided for storing operands and address. This can be
viewed as replacing the single accumulator by a set of registers. If the registers are used for many
purposes, the resulting computer is said to have general register organization. In the case of
processor registers, a register is selected by the multiplexers that form the buses.
148
10.4.4 Generic CPU Instruction Cycle
The generic instruction cycle for an unspecified CPU consists of the following stages:
1) Fetch instruction:
Read instruction code from address in PC and place in IR. (IR ← Memory [PC])
2) Decode instruction:
Hardware determines what the opcode/function is and determines which registers
or memory addresses contain the operands.
4) Execute:
Perform the function of the instruction. If arithmetic or logic instruction, utilize
the ALU circuits to carry out the operation on data in registers. This is the only stage
of the instruction cycle that is useful from the perspective of the end user. Everything
else is overhead required to make the execute stage happen. One of the major goals of
CPU design is to eliminate overhead and spend a higher percentage of the time in the
execute stage.
149
Below is an example of a full instruction cycle which uses memory addresses for all
three operands:
1- Mull product, x, y
2- Fetch the instruction code from Memory [PC]
3- Decode the instruction. This reveals that it's a multiply instruction, and that the
operands are memory locations x, y, and product.
4- Fetch x and y from memory.
5- Multiply x and y, storing the result in a CPU register.
6- Save the result from the CPU to memory location product.
150
- Memory [MA] <= MBR;
1. The CPU has three registers: an accumulator (AC), a program counter (PC) and an instruction
register (IR).
2. The SIMCOMP has only three instructions: Load, Store, and Add.
3. The size of all instructions is 16 bits; all the instructions are single address instructions and access
a word in memory.
Instruction Format
The opcodes are:
Prelab
1) You must write the basic code shown in Fig 1 at the last page of this experiment in your own
Quartus II file.
2) You have to trace the basic code manually so that you can understand what does the code do. Use
the following table:
151
15 Memory [12] = 16’hB014
18 Memory [32] = 16’d7
19 Memory [32] = 16’d7
22 PC = 10; state = 0
29 MAR <= PC
30 state = 1
33 IR <= Memory [MAR]
34 PC <= PC + 1
35 state = 2
38 MAR <= IR [11:0]
39 state = 3
42 state = 4
43 case (IR [15:12])
load: MBR <= Memory
44
[MAR]
45 add: MBR <= Memory [MAR]
46 store: MBR <= AC
52 AC <= AC + MBR
56 AC <= MBR
60 Memory [MAR] <= MBR
Table 2
3) You have to summarize the objective of Program #1 above, then repeat for Program #2
The Verilog program described by the following table is shown in Fig 1, study, and simulate the
code.
Instructions
Memory in Hex
Instruction assembly Instruction machine code
location
10 Load [32] 0011-0000-0010-0000b 16'h3020
11 Add [33] 0111-0000-0010-0001b 16'h7021h
152
12 Store [20] 1011-0000-0001-0100b 16'hB014h
Data
32 Data 7 Memory [32] 16'h7
33 Data 5 Memory [32] 16'd5
Table 3
Choose any opcode e.g., jump=4'b0001, you have to include the execution of jump which changes the
PC to the specified address in the instruction.
Instructions
Memory in Hex
Instruction assembly Instruction machine code
location
10 Load [32] 0011-0000-0010-0000b 16'h3020
11 Add [33] 0111-0000-0010-0001b 16'h7021h
12 Store [20] 1011-0000-0001-0100b 16'hB014h
13 Jump 11 0001-0000-0000-1011b 16'h100Bh
Data
32 Data 7 Memory [32] 16'h7
33 Data 5 Memory [32] 16'd5
Table 4
Task 2: Write the General form of the instruction set for Prog #1
Task 3: Trace the Modified code as was done in the prelab but this time using the
waveforms
Modify the instruction format so that SIMCOMP can handle four addressing modes and four
registers.
This new SIMCOMP2 has four 16-bit general purpose registers, R[0], R[1], R[2] and R[3] which
replace the AC. In Verilog, you declare R as a bank of registers much like we do Memory.
153
reg [15:0] R [0:3]; // declaration of registers bank
Since registers are usually on the CPU chip, we have no modeling limitations as we do with Memory -
with Memory we have to use the MAR and MBR registers to access the memory. Therefore, in a load
you could use R as follows:
R [IR [9:8]] <= MBR; //where the 2 bits in the IR specify which R register to set.
Instructions
Source
Memory Destinatio
Instruction Register/Memor Instruction set code in binary in Hex
location n register
y
10 Load R1 3 0011-0001-0000-0011b 16'h3103
11 Load R2 4 0011-0010-0000-0100b 16'h3204
12 Add R1 R1, R2 0111-0101-1000-0000b 16'h7580
13 Store R1 5 1011-0001-0000-0101b 16'hB105
Data
3 Data A Memory [3] 16'hA
4 Data 6 Memory [4] 16'd6
Table 5
Task 5: Write the General form of the instruction set for SIMCOMP2.
Task 6: Trace SIMCOMP2 code using the waveforms.
154
Task 7: Add immediate addressing to the SIMCOMP2:
If bit (IR [11]) is a one in a Load, the last eight bits are not an address but an operand. The operand is
in the range -128 to 127.
If immediate addressing is used in a LOAD, the operand is loaded into the register.
Load R1, 8
R1 ← 8
Simulate the following test with handwritten comments explaining what you are doing.
PC = 10
Memory [10]: Load R1,3 // Load immediate
Memory [11]: Load R2, -4 //Use 2's complement to represent (-4) Memory [12] Add R1, R1, R1
Memory [13]: Store R1,5
Instructions
Source
Memory Destinatio
Instruction Register/Memor Instruction set code in binary in Hex
location n register
y
Load
10 Immediat R1 3 0011-1001-0000-0011b 16'h3903
e
Load
11 Immediat R2 -4 0011-1010-1111-1100b 16'h3AFC
e
12 Add R1 R1, R2 0111-0101-1000-0000b 16'h7580
13 Store R1 5 1011-0001-0000-0101b 16'hB105
Data
3 Data A Memory [3] 16'hA
4 Data 6 Memory [4] 16'd6
Table 6
155
Figure 10.4: Basic code.
156
At the end of this experiment, you should have two files:
1- An Accumulator Based Simple Computer with 4 instructions as in program 1
2- A register based simple computer with 3 opcodes (noting that the load opcode can be immediate or
normal) as in program 2.
2. Modify the program in the first part of the post-lab to include the jump instruction with opcode
(jump=4'b1001) and change code to run this code below. (Write the instruction format)
3. Modify the previous program making it sum 10 elements using a jump (loop) opcode to sum
the 10 elements.
Instructions
Source
Memory Destinatio
Instruction Register/Memor Instruction set code in binary in Hex
location n register
y
10 Load R1 3
11 Load R2 4
12 Load R3 -9
13 Add R1 R1, R2, R3
14 Store R1 5
Table 7
157
Faculty of Engineering and Technology
Department of Electrical and Computer Engineering
ENCS 2110
Digital Electronics and Computer Organization Lab
Experiment No. 11 - Arithmetic Elements
11.1 Objectives
• To understand functions and applications of the ALU (arithmetic logic unit).
• To generate parity bit using XOR gates and parity generator IC.
158
11.3 Theory
It consists of two major parts: the arithmetic unit and the logic unit. The output, either
arithmetic or logic which is selected by the selection switches. Figure 11.2 shows the pin
assignment:
The circuit has two 4-bit inputs A and B, as well as a “carry-in” (Cn) input. There is a
mode control input (M) and 4 function-select lines S0, S1, S2, S3 forming logic or arithmetic
operations.
159
Also, it has a 4-bit output (F3~F0); a “carry-out” or “Cn+4” output. The biggest advantage
of the design is its ability to perform arithmetic functions such as addition, subtraction.
multiplication; and logic functions such as AND, XOR functions.
The mode control input (M) and function-select lines (S0~S3) determines which function
it will perform.
160
11.4 Procedure
161
- Set Cn to “1” and add the previous carry.
When S3S2S1S0=0000 perform the addition.
What is the output when A3A2A1A0=0000 and B3B2B1B0=1111?
F3F2F1F0= ____________; Cn+4=____________
What is the output when A3A2A1A0=1001 and B3B2B1B0=0100?
F3F2F1F0= ____________; Cn+4=____________
D) Again set M to “1” to perform the following arithmetic and logic functionns according to Table 1.
Set inputs sequence A0~A3=A, B0~B3=B from DIP switches.
162
11.4.2 BIT PARITY GENERATOR CIRCUIT
A) Bit Parity Generator Construct with XOR Gates (Module IT-3003 block Half-Adder).
1) Insert connection clip according to Figure. 11.5 to construct the even bit parity generator
circuit of Figure 11.6.
163
Table 11.2:Data of part 11.4.2 (A-2)
Input Output
E D C B A F6
0 0 0 0 0
0 0 0 1 0
0 0 0 1 1
0 0 1 0 0
0 0 1 0 1
0 1 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 1 0
1 1 1 1 1
1) U13 on block Bit Parity Generator of module IT-3003 is a bit parity generator Connect inputs
A1, B1, C1, D1, E1, F1, G1, H1 and I1 to DIP Switches 1.0~1.7and DIP 2.0 respectively.
Connect outputs Y0 to L0; Y1 to L1. Follow the input sequences given in Table 11.3 and record
the outputs.
164
Table 11.3:Data of part 11.4.2 (B-1)
Y0 Y1
I H G F E D C B A
(even) (odd)
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 1 1
0 0 0 0 0 0 1 1 1
0 0 0 0 0 1 1 1 1
0 0 0 0 1 1 1 1 1
0 0 0 1 1 1 1 1 1
0 0 1 1 1 1 1 1 1
0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 0 0
1 1 0 0 0 1 1 0 0
165