Sample DSD Lab Manual
Sample DSD Lab Manual
Expt. Page
No
Experiment title No.
Introduction to Digital Laboratory Equipments & IC’s 11
12. Design and Simulate PISO Shift Register and Up/Down 104
Counters
(a). Identify appropriate logic gate required to design a bank safety locker
system. The locker opens only if both finger PIN number and finger print of the
account holder matches. Otherwise, locker remains in locked state.(Hint: AND)
(c). Construct and verify the logic of NOT gate using its truth table.
(d). Two tanks store certain liquid chemicals that are required in a
manufacturing process. Each tank has a sensor that detects when the
chemical level drops to 25% of full. The sensors produce a HIGH level of 5 V
when the tanks are more than one-quarter full. When the volume of chemical
in a tank drops to one-quarter full, the sensor puts out a LOW level of 0 V.
Identify an appropriate logic gate required to design this system.(Hint: NAND)
(e). Construct and verify the logic of 2-input NOR gate using its truth table.
(f). Construct and verify the logic of 2-input XOR gate using its truth table.
(g). Construct and verify the logic of 3-input AND gate using its truth table.
(h). Construct and verify the logic of 3-input NAND gate using its truth table.
(i). Realize the Boolean expression Y=A.B’+A.C’ using basic logic gates.
(a). Design a half adder circuits & verify the truth table using basic logic gates.
(b). Design a half subtractor circuits & verify the truth table using basic logic
gates.
(c). Design a partial simplified Arithmetic Logic Unit (ALU) using basic logic
gates, which is capable of performing the 1-bit addition operation with the
inclusion of carry as an additional input. (Hint: Full Adder)
(d). Design a partial simplified Arithmetic Logic Unit (ALU) using basic logic
gates, which is capable of performing the 1-bit subtraction operation with the
inclusion of borrow as an additional input. (Hint: Full Subtractor)
3. Design and Implementation of 4:1 Mux & 4:2 Decoder
(b). Control & timing unit of a Microprocessor has a decoding unit to decode
the program instructions in order to activate the specific control lines such
that different operations in the ALU are carried out as shown below. Assume
program instructions are represented in 2-bit format. (Hint: 4:2 Decoder)
(a). Design a control unit for a sea salt packing machine to pack a salt bag
of 2kg each. Current weight of the bag is measured and represented in 2-bit
binary number then compared with the reference value (2kg). If the salt bag
is less/greater than 2kg control signal generated to add/remove excess salt
to/from salt bag. If the salt bag weight is exactly 2kg then control signal
generated to make a pack. Design and Implement an appropriate digital
circuit using basic logic gates to meet this requirement. (Hint: 2-Bit Magnitude
comparator)
(a). Construct SR Flip-Flops using basic logic gates and verify its logic using
truth table.
(b). Construct JK Flip-Flops using basic logic gates and verify its logic using
truth table.
(c). In a Microprocessor design, signals that flow through different paths arrive
at different time. This could cause many problems when these signals have to
interact with each other. Identify and implement a suitable flop-flop required
to synchronize these signals using basic logic gates. (Hint: D-FF)
(d). Counters are the digital circuits, which are used to count the number of
events. Identify and implement the most suitable Flip-flip required to design a
counter unit using basic logic gates. (Hint: T-FF)
(a). To understand the basics of Verilog HDL and concepts of various Verilog
modelling such as Gate-level, Dataflow, Behavioural and Switch-level
modelling.
(a). Construct SR Flip-Flops using basic logic gates and verify its output logic
by simulation using Xilinx ISE Simulator.
(b). Construct JK Flip-Flops using basic logic gates and verify its output logic
by simulation using Xilinx ISE Simulator.
(c). In a Microprocessor design, signals that flow through different paths arrive
at different time. This could cause many problems when these signals have to
interact with each other. Identify and implement a suitable flop-flop required
to synchronize these signals using basic logic gates. Verify its output logic by
simulation using Xilinx ISE Simulator. (Hint: D-FF)
(d). Counters are the digital circuits, which are used to count the number of
events. Identify and implement the most suitable Flip-flip required to design a
counter unit using basic logic gates. Verify its output logic by simulation using
Xilinx ISE Simulator. (Hint: T-FF)
12. Design and Simulate PISO Shift Register and Up/Down Counters
Design and simulate a simple 8-bit microprocessor’s ALU unit which performs
arithmetic and logical operations (shown in below table) on two 8-bit inputs
[7:0]A and [7:0]B. Write the Verilog HDL code in behavioural modelling for the
above mentioned design and verify the output using sample test cases.
14. Design and Simulate Chocolate Vending Machine using Finite State Machine
The Breadboard
The breadboard consists of two terminal strips and two bus strips. 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 together (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 centre gap. Each row of five contacts is a node.
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. 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.
Safety Instructions
The experiments in this lab manual are designed for low voltage, which minimizes
the electrical shock hazard, but it only takes several milli-amperes of current to cause a
harmful electrical shock. Safety must always be first. Below are several general safety
rules for all digital experiments and activities in the laboratory.
1. Avoid direct contact with any power source. Turn off all power sources when not
needed.
2. When hooking up a circuit, connect to the power source last, while power is off.
3. Before making changes in a circuit, turn off or disconnect the power first.
4. Never work alone in the laboratory. Perform the experiment under instructor or lab
technician supervision.
5. When changing a powered up connection, use only one hand. Never touch two
points in the circuit that are at different voltages.
6. Know that the circuit and connections are correct before applying power to the
circuit. If needed have the instructor review the circuit before applying power.
7. Know the location of the emergency power-off switch at each bench.
8. Keep the work area around the circuit and test equipment neat and free of clutter.
9. Remove all jewellery that can be seen before working on any experiment.
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. Make sure the Trainer Kit power is off before you build anything!
2. Connect the +5V and ground (GND) leads of the power supply to the power and
ground bus strips on your breadboard.
3. 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)
4. Connect +5V and GND pins of each chip to the power and ground bus strips on
the breadboard.
5. Select a connection on your schematic and place a piece of hook-up wire
between 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.
6. Get one of your group members to check the connections, before you turn the
power on.
7. 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.
8. At the end of the laboratory session, collect you hook-up wires, chips and all
equipment and return them to the demonstrator.
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. Plugging wires into the wrong holes.
5. Driving a single gate input with the outputs of two or more gates
6. Modifying the circuit with the power on.
AIM:
(a). Identify appropriate logic gate required to design a bank safety locker system. The
locker opens only if both finger PIN number and finger print of the account holder
matches. Otherwise, locker remains in locked state (Hint: AND Gate)
(b). Identify an appropriate logic gate required to design a simple intruder detection
system. The system consist of two PIR sensors to detect intruders. One of the sensor is
placed at main door and other is placed at back door. If either one of the sensor detects
human presence then it activate alarm unit. (Hint: OR Gate)
(c). Construct and verify the logic of NOT gate using its truth table.
(d). Two tanks store certain liquid chemicals that are required in a manufacturing process.
Each tank has a sensor that detects when the chemical level drops to 25% of full. The
sensors produce a HIGH level of five V when the tanks are more than one-quarter full.
When the volume of chemical in a tank drops to one-quarter full, the sensor puts out a
LOW level of 0 V. Identify an appropriate logic gate required to design this system.(Hint:
NAND Gate)
(e). Construct and verify the logic of 2-input NOR gate using its truth table.
(f). Construct and verify the logic of 2-input XOR gate using its truth table.
(g). Construct and verify the logic of 3-input AND gate using its truth table.
(h). Construct and verify the logic of 3-input NAND gate using its truth table.
(i). Realize the simple Boolean expression using basic logic gates. Y=A.B’+A.C’
COMPONENTS REQUIRED:
PIN DIAGRAM
(b). OR GATE:
The OR gate is an electronic circuit that gives a high output (1) if one or more of its
inputs are high. A plus (+) is used to show the OR operation. IC 7432 is the two Input OR
gate IC.
PIN DIAGRAM
(c). NOT GATE:
The NOT gate is an electronic circuit that produces an inverted version of the
input at its output. The output is high when the input is low. The output is low when the
input is high. It is also known as an inverter. IC 7404 is a NOT gate IC.
SYMBOL TRUTH TABLE
PIN DIAGRAM
PIN DIAGRAM
(e). NOR GATE:
This is a NOT-OR gate which is equal to an OR gate followed by a NOT gate. The
outputs of all NOR gates are low if any of the inputs are high. The output is high when all
inputs are low. IC 7402 is a two input NOR gate.
SYMBOL TRUTH TABLE
PIN DIAGRAM
(f). XOR GATE:
The 'Exclusive-OR' gate is a circuit which will give the output is high only when odd
number of is high. The output is low when both the inputs are low and both the inputs are
high. IC 7486 is two input XOR gate.
PIN DIAGRAM
PIN DIAGRAM
(i). REALIZATION OF SIMPLE BOOLEAN EXPRESSION: Y=A.B’+A.C’
TRUTH TABLE:
LOGIC DIAGRAM:
PROCEDURE:
RESULT:
Thus, various basic logic gates and simple Boolean expressions are constructed
and their truth tables are verified.
VIVA QUESTIONS WITH ANSWERS:
2. Under what conditions the output of three input NOR gate is LOW?
If any one of the input is at HIGH state
3. How many 2-input AND & 2-input OR gates required to realize Y = BD + CE + AB?
This expression require 3 2-input AND gate, 2 2-input OR gate required
5. How many truth table entries are necessary for a four-input circuit?
24 = 16 entries
7. The output will be a LOW for any case when one or more inputs are HIGH in a(n)__
NOR gate
8. What input values will cause 3-input AND logic gate to produce a HIGH output?
All inputs are HIGH
9. How many inputs of 3-input NAND gate must be LOW in order for the output of
the logic gate to go HIGH?
Atleast one of the input must be LOW
10. Write a logical expression for the output Q of below logic diagram.
Q=ABC+A. (B’+C’)
Expt.
Design and Implementation of Adder & Subtractor
No. 2
AIM:
(a). Design and construct half adder circuits and verify the truth table using logic gates.
(b). Do design and construct half subtractor circuits and verify the truth table using logic
gates.
(c). Design a partial simplified Arithmetic Logic Unit (ALU) using basic logic gates, which
is capable of performing the 1-bit arithmetic addition operation with the inclusion of carry
as an additional input.
(d). Design a partial simplified Arithmetic Logic Unit (ALU) using basic logic gates, which
is capable of performing the 1-bit arithmetic subtraction operation with the inclusion of
borrow as an additional input.
COMPONENTS REQUIRED:
Half adder is a combinational arithmetic circuit that adds two one-bit numbers and
produces a sum bit (S) and carry bit (C) as the output. If A and B are the input bits, then
sum bit (S) is the X-OR of A and B, the carry bit (C) will be the AND of A and B. Half adder
is the simplest of all adder circuit, but it has a major disadvantage. The half adder can
add only two input bits (A and B) and has nothing to do with the carry if there is any and
that’s why it is called a half adder.
TRUTH TABLE:
INPUTS OUTPUTS
A B SUM CARRY
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
K-MAP:
LOGIC DIAGRAM:
THEORY:
A half-subtractor is mainly used to subtract one binary digit from another to
produce a DIFFERENCE output and a BORROW output. The BORROW output here
specifies whether a '1' has been borrowed to perform the subtraction. As in binary
number system, 1 is the largest digit, we only produce borrow when the subtrahend 1 is
greater than minuend 0 and due to this, borrow will require.
TRUTH TABLE:
INPUTS OUTPUTS
A B DIFFERENCE BORROW
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
K-MAP:
LOGIC DIAGRAM:
THEORY:
A full adder is a digital circuit that adds three one-bit binary numbers, two
operands and a carry bit. The adder outputs two numbers, a sum and a carry bit. Full
adders are made from XOR, AND, OR gates in hardware. When a full-adder logic is
designed, string eight of them together to create a byte-wide adder and cascade the
carry bit from one adder to the next.
TRUTH TABLE:
INPUTS OUTPUTS
A B Cin SUM CARRY
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
K-MAP:
SIMPLIFICATION:
= Cin (A’B+AB’)
THEORY:
Full subtractor is an electronic device or logic circuit, which performs subtraction
of two binary digits. The foremost disadvantage of the half subtractor is, we cannot make
a Borrow bit in this subtractor. Whereas in full subtractor design, actually we can make a
Borrow bit in the circuit & can subtract with remaining two inputs. Here A is minuend, B is
subtrahend & Bin is borrow in. There are two outputs that are DIFFERENCE and BORROW
output. The BORROW output indicates that the minuend bit requires borrow '1' from the
next minuend bit. .
TRUTH TABLE:
INPUTS OUTPUTS
A B Bin DIFFERNECE BORROW
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
K-MAP:
= Bin (A’B+AB’)
LOGIC DIAGRAM:
PROCEDURE:
4. Connect the inputs to the input switches provided in the IC trainer kit
7. Observe the condition of output LED’s and verify the truth table
RESULT:
Thus, various data path elements such as half adder, half subtractor, full adder and
full subtractor logic circuits are constructed using basic logic gates and their truth tables
are verified.
VIVA QUESTIONS WITH ANSWERS:
4. State the output of DIFFERENCE and BORROW if full subtractor accepts input A=0,
B=1 and Bin=1.
DIFFERENCE=0, BORROW=1
5. How many AND, OR and EXOR gates are required for the configuration of full
adder?
2-AND, 1-OR and 2-XOR
6. Let A, B and C is the input of a subtractor then the difference output will be____.
A XOR B XOR C
7. Let the input of a half subtractor is A and B then what the difference output will be
if A = B?
0
AIM:
(a) In a communication system, multiple signals are transmitted on a single transmission
line. Assume audio, image, data and video are four signal to be transmitted on a single
transmission line by using appropriate signal selection line. Implement a digital circuit
using basic logic gates to meet this requirement.
(b) Control & timing unit of a Microprocessor has a decoding unit to decode the program
instructions in order to activate the specific control lines such that different operations in
the ALU are carried out as shown below. Assume program instructions are represented in
2-bit format.
COMPONENTS REQUIRED:
TRUTH TABLE:
BLOCK DIGRAM:
TRUTH TABLE:
INPUTS OUTPUTS
E A B Y3 Y2 Y1 Y0
0 X X 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0
PROCEDURE:
4. Connect the inputs to the input switches provided in the IC trainer kit
7. Observe the condition of output LED’s and verify the truth table
RESULT:
Thus, basic combinational logic circuits 4:1 Multiplexer and 2:4 Decoder are
constructed using basic logic gates and their truth tables are verified.
VIVA QUESTIONS WITH ANSWERS:
2. How many number of selection lines are required to construct 32:1 multiplexer
logic?
“5” selection lines
4. What is the number of output lines for a decoder with four input lines?
“16” Output lines
6. How many NOT gates are required for the construction of an 8-to-1 multiplexer?
3
7. In the given 4-to-1 multiplexer, if selection line S1S0=01 and input D3D2D1D0=1010
then, the output Y is ________.
1
AIM:
(a). Design a control unit for a sea salt packing machine to pack a salt bag of 2kg each.
Current weight of the bag is measured and represented in 2-bit binary number then
compared with the reference value. If the salt bag is less/greater than 2kg control signal
generated to add/remove excess salt to/from salt bag. If the salt bag weight is exactly
2kg then control signal generated to make a pack. Design and Implement an
appropriate digital circuit using basic logic gates to meet this requirement. (Hint: 2-Bit
Magnitude comparator)
(b). Bluetooth module is interfaced with Arduino Uno board and transmitting its 4-bit data
continuously to the receiver section. This 4-bit data comprises of 3-bit temperature sensor
data and 1-bit for parity (even). Since this system operating under a noisy environment,
there is a possibility of error prone into the actual values of transmitting data. Design a
suitable combinational logic circuit in the transmitter and receiver section to detect the
data is valid or not. (Hint: Parity or and Checker)
COMPONENTS REQUIRED:
TRUTH TABLE:
INPUTS OUTPUT
A1 A0 B1 B0 A>B A=B A<B
0 0 0 0 0 1 0
0 0 0 1 0 0 1
0 0 1 0 0 0 1
0 0 1 1 0 0 1
0 1 0 0 1 0 0
0 1 0 1 0 1 0
0 1 1 0 0 0 1
0 1 1 1 0 0 1
1 0 0 0 1 0 0
1 0 0 1 1 0 0
1 0 1 0 0 1 0
1 0 1 1 0 0 1
1 1 0 0 1 0 0
1 1 0 1 1 0 0
1 1 1 0 1 0 0
1 1 1 1 0 1 0
K-MAP:
LOGIC DIAGRAM:
(b). PARITY (EVEN) GENERATOR & CHECKER:
THEORY:
A Parity is a very useful tool in information processing in digital computers to
indicate any presence of error in bit information. External noise and loss of signal strength
causes loss of data bit information while transporting data from one device to other
device, located inside the computer or externally. To indicate any occurrence of error,
an extra bit is included with the message according to the total number of 1s in a set of
data, which is called parity. If the extra bit is considered 0 if the total number of 1s is even
and 1 for odd quantities of 1s in a set of data, then it is called even parity. On the other
hand, if the extra bit is 1 for even quantities of 1s and 0 for an odd number of 1s, then it is
called odd parity. The message including the parity is transmitted and then checked at
the receiving end for errors. An error is detected if the checked parity does not
correspond with the one transmitted. The circuit that generates the parity bit in the
transmitter is called a parity generator and the circuit that checks the parity in the
receiver is called a parity checker. The message bits with the parity bit are transmitted to
their destination, where they are applied to a parity checker circuit. The parity checker
circuit produces a check bit and is very similar to the parity generator circuit. If the check
bit is 1, then it is assumed that the received data is incorrect. The check bit will be 0 if the
received data is correct.
TRUTH TABLE:
3-BIT MESSAGE INPUT EVEN PARITY BIT
A B C Pe
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
K-MAP:
LOGIC DIAGRAM:
4-BIT EVEN PARITY CHECKER:
TRUTH TABLE:
4-BIT RECEIVED MESSAGE PARITY ERROR
A B C Pe CHECK (PEC)
0 0 0 0 0
0 0 0 1 1
0 0 1 0 1
0 0 1 1 0
0 1 0 0 1
0 1 0 1 0
0 1 1 0 0
0 1 1 1 1
1 0 0 0 1
1 0 0 1 0
1 0 1 0 0
1 0 1 1 1
1 1 0 0 0
1 1 0 1 1
1 1 1 0 1
1 1 1 1 0
K-MAP:
PEC = A’B’ (C’D+ CD’) + A’B (C’D’+ CD) + AB (C’D+ CD’) + AB’ (C’D’+ CD)
= A’B’ (C D) + A’B (C D)’ + AB (C D) + AB’ (C D)’
= (A’B’+ AB) (C D) + (A’B+ AB’) (C D)’
= (A B)’ (C D) + (A B) (C D)’
PEC = (A B) (C D)
LOGIC DIAGRAM:
PROCEDURE:
4. Connect the inputs to the input switches provided in the IC trainer kit
7. Observe the condition of output LED’s and verify the truth table
RESULT:
Thus combinational logic circuits such as 2-bit magnitude comparator, 3-bit even
parity checker and 4-bit even parity checker are constructed using basic logic gates
and their truth tables are verified.
VIVA QUESTIONS WITH ANSWERS:
2. Magnitude comparator always produces only ____ output (s) as HIGH among its
possible ____ number of outputs.
1, 3
4. Which combination of logic gates are ideal realizing “equal” condition in 2-bit
magnitude comparator?
XNOR, AND
8. Which logic gate is most appropriate to modify the even parity generator logic
circuit into odd parity generator logic circuit?
Adding NOT gate at the output end of even parity generator
AIM:
(a). Construct SR Flip-Flops using basic logic gates and verify its logic using truth table.
(b). Construct JK Flip-Flops using basic logic gates and verify its logic using truth table.
(c). In a Microprocessor design, signals that flow through different paths arrive at different
time. This could cause many problems when these signals have to interact with each
other. Identify and implement a suitable flop-flop required to synchronize these signals
using basic logic gates. (Hint: D-FF)
(d). Counters are the digital circuits, which are used to count the number of events.
Identify and implement the most suitable Flip-flip required to design a counter unit using
basic logic gates. (Hint: T-FF)
COMPONENTS REQUIRED:
The SR flip-flop, stands for “Set-Reset” flip-flop. This simple flip-flop is basically a one-
bit memory bistable device that has two inputs, one which will “SET” the device (meaning
the output = “1”), and is labelled S and one which will “RESET” the device (meaning the
output = “0”), labelled R. The reset input resets the flip-flop back to its original state with
an output Q. A basic NAND gate SR flip-flop circuit provides feedback from both of its
outputs back to its opposing inputs and is commonly used in memory circuits to store a
single data bit. Then the SR flip-flop actually has three inputs, Set, Reset and its current
output Q relating to it’s current state or history. When S and R at HIGH state both outputs
tries to get into HIGH state and not of them get into state output state. This state is called
intermediate or invalid state.
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
(b). JK (JACK KILBY) FLIP-FLOP:
THEORY:
The JK Flip Flop is the most widely used flip flop. It is considered to be a universal
flip-flop circuit. The sequential operation of the JK Flip Flop is same as for the RS flip-flop
with the same SET and RESET input. The difference is that the JK Flip Flop does not the
invalid input states when S and R are both 1. A JK Flip-Flop can be obtained from the
clocked SR Flip-Flop by augmenting two AND gates. If the circuit is in the “SET” condition,
the J input is inhibited by the status 0 of Q through the lower NAND gate. Similarly, the
input K is inhibited by 0 status of Q through the upper NAND gate in the “RESET” condition.
When both J and K are at logic “1”, the JK Flip Flop toggle.
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
(c). D (DATA/DELAY) FLIP-FLOP:
THEORY:
This flip-flop, called a Data flip-flop because of its ability to ‘latch’ and remember
data, or a Delay flip-flop because latching and remembering data can be used to
create a delay in the progress of that data through a circuit. A D flip–flop is constructed
by modifying an SR flip – flop. The S input is given with D input and the R input is given with
inverted D input. Hence a D flip – flop is similar to SR flip – flop in which the two inputs are
complement to each other, so there will be no chance of any intermediate state occurs.
The major drawback of SR flip – flop is the race around condition which in D flip – flop is
eliminated (because of the inverted inputs). When we don’t apply any clock input to the
D flip flop or during the falling edge of the clock signal, there will be no change in the
output. It will retain its previous value at the output Q. If the clock signal is high and if D
input is high, then the output is also high and if D input is low, then the output will become
low. Hence the output Q follows the input D in the presence of clock signal.
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
(d). T (TOGGLE) FLIP-FLOP:
THEORY:
T flip – flop is also known as “Toggle Flip – flop”. To avoid the occurrence of
intermediate state in SR flip – flop, we should provide only one input to the flip – flop called
Trigger input or Toggle input (T). Then the flip – flop acts as a Toggle switch. Toggling
means ‘Changing the next state output to complement of the present state output’. The
T (Toggle) Flip-Flop is a modification of the JK Flip-Flop. It is obtained from JK Flip-Flop by
connecting both inputs J and K together, i.e., single input. Regardless of the present state,
the Flip-Flop complements its output when the clock pulse occurs while input T= 1.
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
PROCEDURE:
4. Connect the inputs to the input switches provided in the IC trainer kit
7. Observe the condition of output LED’s and verify the truth table
RESULT:
Thus, basic flip-flops such as SR, JK, D and T are constructed using basic logic gates
and their truth tables are verified.
VIVA QUESTIONS WITH ANSWERS:
2. A basic S-R flip-flop can be constructed by cross coupling of which basic logic
gates?
NAND and NOR
6. On a positive edge-triggered flip-flop circuit, the outputs reflect the input condition
only when?
The clock pulse transitions from LOW to HIGH.
AIM:
(a). In modern computer system, it is essential to operating the computing unit in
optimized manner. Especially, shift registers are extensively used to perform optimized
binary multiplication and division. This is due to the fact that the shift of data bit by one
position towards right causes the number to be divided by 2 while the left-shift of the data
bit by one place in the shift register multiplies the number by 2. For example, consider a
4-bit shift register with the content 0110, which is equal to 6 in decimal. If the number shifts
left by one-bit, then one gets 1100, which is 12 (= 6 × 2) in decimal. Similarly is the number
shifts towards right by one bit, then the register contents will become 0011, which is
nothing but 3 (=6/2) in decimal. Design and implement the suitable 4-bit shift register logic
circuit for the given requirement using appropriate flip flop.(Hint: SISO)
(c). A free-running analog-to-digital converter is one that updates its digital output(for
the given analog signal) as often as it can, not waiting for any prompting from another
device. If we were to connect a free-running ADC to a computer (microprocessor or
microcontroller), we would need some way to sample the ADC’s output at times
specified by the computer, and hold that binary number long enough for the computer
to register it. Otherwise, the ADC may update its output in the middle of one of the
computer’s “input” cycles, possibly resulting in corrupted data. We could build such a
sample-and-hold circuit out of flip-flops, which could shift register inputs multiple bits of
data all at once, and transfers that data to its output lines all at once, at the command
of a clock pulse. Design and implement the suitable 4-bit shift register to serve for the
sample and hold circuit requirement using appropriate flip-flop. (Hint: PIPO)
COMPONENTS REQUIRED:
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
BLOCK DIAGRAM:
TRUTH TABLE:
CLOCK SERIAL DATA PARALLEL DATA OUTPUT
PULSE NO. INPUT (D) Q3 Q2 Q1 Q0
0 0 0 0 0 0
1 1 1 0 0 0
2 1 1 1 0 0
3 0 0 1 1 0
4 1 1 0 1 1
5 0 0 1 0 1
6 0 0 0 1 0
7 0 0 0 0 1
8 0 0 0 0 0
LOGIC DIAGRAM:
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
PROCEDURE:
4. Connect the inputs to the input switches provided in the IC trainer kit
7. Observe the condition of output LED’s and verify the truth table
RESULT:
Thus, 4-bit shift registers such as SISO, SIPO and PIPO are constructed using D-flip
flop (IC7474), and their truth tables are verified.
VIVA QUESTIONS WITH ANSWERS:
3. How much storage capacity (in bit(s)) does each stage in a shift register represent?
1-bit
6. How many clock pulses will be required to completely load serially a 5-bit shift
register?
5
7. The group of bits 11001 is serially shifted (right-most bit first) into a 5-bit parallel
output shift register with an initial state 01110. After three clock pulses, the register
contains ________.
00101
8. A serial in parallel out, 4-bit shift register initially contains all 1s. The data nibble
0111 is waiting to enter. After three clock pulses, the register contains ________.
1111
9. An 8-bit serial in/serial out shift register is used with a clock frequency of 2 MHz to
achieve a time delay (td) of ____.
4 µs
AIM:
(a). In the packaging department of a cricket ball manufacturing company, the balls
roll down on a conveyor and get filled into the empty boxes for shipment. Capacity of
each box is 16 balls. Each ball is allowed to pass through IR scanner, which generates
one-clock pulse for every ball that crosses the scanner. Design an appropriate counter
using Flip Flops to count the clock pulse generated from scanner to indicate whether the
box is full or not, so that next empty box can be moved into the position.
(b). A simple human counter system for an elevator overload indication module
constructed using optical IR sensor, buzzer, microcontroller and seven segment LED
display. Number of persons entering into elevator is detected by IR sensor, which
generates one-clock pulse per person while entering into elevator. By default, it must
display value 0 and increment the number on the display by one for every time a human
enters into the elevator. Assume the maximum capacity of the elevator as 12 persons
and if it exceed it alarm buzzer. Design an appropriate counter using Flip Flops to indicate
overload condition.
COMPONENTS REQUIRED:
SEQUENCE DIAGRAM:
`TRUTH TABLE:
CLOCK COUNTER OUTPUT AT Q
PULSE NO. QD QC QB QA
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
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1
LOGIC DIAGRAM:
SEQUENCE DIAGRAM:
TRUTH TABLE:
CLOCK COUNTER OUTPUT AT Q
PULSE NO. QD QC QB QA
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
10 1 0 1 0
11 1 0 1 1
LOGIC DIAGRAM:
PROCEDURE:
1. To construct the digital counter circuit, the J-K flip-flop must be configured with J=__
and K=___.
1, 1
2. Number of flip-flops required to construct 8-bit counter is ____ and it can count upto
_____ decimal values.
8, 255
3. Number of flip-flops needed to construct MOD-46 counter is _____ and it can count
from ____ to ____ in decimal values.
6, 0 to 45
6. Mod-24 counter reaches reset state(0000) for every ______ clock pulses
24
7. A 4-bit ripple counter is holding the count (1001)2. What will the count be after 31
clock pulses?
(1000)2
INTRODUCTION:
This tutorial will give the procedural steps involved in implementing any digital
design with the Xilinx ISE software. Step-by-step instructions will be given to guide the
reader through generating a project, creating a design file, compiling the project,
simulating the designed file and downloading the design to an FPGA board. This tutorial
will show how to:
Before proceeding with the tutorial please make sure that your computer machine
installed with “Xilinx ISE 14.1”. Some of the following procedures may be different
depending on the version of ISE.
0. To start the ISE Design Suite, double-click the Project Navigator icon on your desktop,
or select Start > All Programs > Xilinx ISE Design Suite > Xilinx Design Suite 14 > ISE Design
Tools > Project Navigator.
1. Create a new project. To create a new project use either click on New Project tab or
select File → New Project and change the Name and Location to whatever you like.
[Note: Xilinx does not allow spaces in path or file names! For example “C:\ECE 3700
will not work, same for the file name! Use the under_score for spaces if you need to]
The selected Top Level Source Type is HDL because first we will discuss the procedure
for verilog HDL design. The dialog box for the project wizard looks like:
2. Click NEXT and Device Properties page appears, Select the following options in the
fields of project settings on the Device Properties page:
Product Category: All
Family: Spartan3E
Device: XC3S250E
Package: TQ144
Speed: -4
Synthesis Tool: XST (VHDL/Verilog)
Simulator: ISim (VHDL/Verilog)
Preferred Language: Verilog
Other properties can be left at default values. This is a details of FPGA device used
for implementation
[Note: If you fail to set the correct options in this part, you will not be able to
implement your design and program it on the FPGA device]
3. Click NEXT and review the project summary page and then click FINISH, it is always
good to double check the project summary to prevent the problems while
implementing the design.
PART II: IMPLEMENT A DESIGN USING VERILOG HDL
1. Now we will explore the implementation of the function F=(A& (!B))|(B & C) using a
“Verilog” module. First we need to add a new source file on the created project. For
adding a new source file choose Project → New Source or right click on the Hierarchy
section of the design windows to get the new source wizard dialog box and then
choose “Verilog Module” and give it a file name.
[Note: Remember to only use “Verilog Module” for Implementation and “Verilog Test
Fixture” for simulation purposes]
2. Click NEXT and you should see the define module box. Here you can setup I/O names
with correct polarity and a choice for buses and the width. Note that you do not have
to add anything here right away and you can always add the I/O definitions to the
module’s header when it is created. So here no I/O names are specified to proceed
further click NEXT. After you’re done click NEXT and then observe the summary page
for a quick review of your I/O list.
3. Now you can notice that the Verilog module file is added to the hierarchy section as
a part of the project. You can also notice that a tab for the Verilog file opened in the
ISE main pane. Type the Verilog HDL code for F=(A& (!B))|(B & C) in the main pane.
4. For implementing the function F we can write the Verilog code in any one of following
three modelling.
The Structural model: This is done using gate primitives that are automatically taken
from the Xilinx libraries by calling their name and passing parameters.
The Data flow model: Using the “assign” keyword to assign the results of the function
expression to the output.
The Behavioural model: Using “Always” keyword we can implement the same
function using behavioural modelling. The difference is that it only wakes up and
assign the output when any of the inputs are changes, hence the (*) which means,
“any change”. One thing to notice is that any output being assigned inside of an
always block needs to be declared as a “reg” for synthesis purposes, and that you
cannot use the “assign” keyword inside of such block.
5. Next process is to perform check syntax operation available under synthesis-XST option
in the process window. Once the green tick mark present in check syntax option then
it indicate no error in the typed Verilog code. We will get Red Cross mark on the check
syntax option for the indication of error in the program. To solve the errors in the
program select the errors tab in the transcript window, look at the errors in the program
and solve one by one until check syntax option gets green tick mark.
6. Once check syntax operation got over, make a double click on “View RTL Schematic”
option under the synthesis-XST process. To verify the logic diagram created for the
written logic in Verilog code, select the created Verilog module (In our case it is
“simple_verilog”) and add it to the selected element window, then click on create
schematic option. Again, double click on the RTC diagram to see the internal parts of
the created logic.
Now the circuit is ready for simulation or implementation on the Xilinx FPGA board.
But, before doing implementation of the design it is better to verify the logic using
behavioural simulation process (optional). In the next part will discuss about how the
same function F=(A&(!B))|(B&C) can be implemented using schematic logic.
PART III: SIMULATE THE SCHEMATIC / VERILOG DESIGN USING ISIM & VERILOG TEST FIXTURE
Now that you have a saved Verilog module and schematic, you need to simulate its
behaviour. The ISIM is the build in simulator of the XILINX ISE software, which is essentially
a Verilog simulator. In order to simulate the circuit you need:
Test bench: It is a file that becomes a top module to your design and applies inputs to
your circuit, and potentially checks that the outputs are correct. This will be another
Verilog file written slightly differently than circuit implementation. The test bench will
instantiate one copy of your circuit, and call it UUT for “Unit Under Test”. You will then write
the Verilog statements that set the inputs to your circuit (the UUT), and looks at the outputs
produced by your circuit.
1. First you need to ensure that the ISE is changed to “Simulation” from implementation.
Go to the top left pane and change the “View” field to simulation. The design window
will then change slightly with different options. Referring back to the same step in
creating a “New Source” create a “Verilog Test Fixture” to create a Verilog file that
will contain the test code.
2. Click NEXT and choose which design you want to associate the test bench with. This
is very important as you will have multiple modules or schematics in the future and you
need to be sure which design is under test using the test bench. In this case I will just
choose the “simple_verilog” module to be tested.
3. Click NEXT and after observing the summary click FINISH. Now a new piece of
Verilog code generated for you. This Verilog code instantiates the “simple_verilog”
module as the UUT, and includes some other stuff related to how the UUT is
connected to the test bench. It looks like this:
4. You can now write your test bench code as an initial block right before the end
module. Basically you set the values of your inputs, and tell the simulator how long to
wait between each change on the inputs. The results will eventually be plotted on a
waveform for you. Verilog syntax for setting a variable is very simple, and the #50
notation just means for the simulation to wait for 50 ticks of the simulation clock before
moving on to the next statement. A very simple test bench for this circuit looks like the
following.
Add the lines between initial and end to drive the inputs with different values so that
we can see what the circuit result is. Note that each statement in Verilog ends with a
semicolon, and you can put multiple statements on a line if you like.
5. We usually want to test all possible inputs to be able to draw a better conclusion on
whether the circuit is functioning correctly. After you’re satisfied with the input setting
of your test bench, make sure to save. Always observe the console window to look
out for errors after saving. Now you are ready to simulate your Verilog circuit.
Observe that the test bench Verilog file is now the top module to your “simple_verilog”
module in the simulation design view. It is very important to have the test bench file
selected for simulation or things will go wrong. After selecting and highlighting the test
bench file in the design windows, double-click the “Simulate Behavioural Model” to
see the waveform generated by the ISim.
6. The output will be displayed as waveforms as shown. Note that the simulator is by
default set up to simulate for 1000ns, at the beginning of the simulation. I had to zoom
out a little to see this view. The values reported for A, B, S, and F are the values seen
at the blue bar. You can pick up (with the mouse) and move the blue bar to see the
values at different points in the simulation.
By looking at the waveform, we can see that all three different forms of expressing the
function in Verilog (structural, functional, and behavioural) are all holding the same
behaviour throughout the simulation. You can click on the waveform in different
places (the yellow line is where in the range of time in the waveform it was clicked)
and you can see values quickly for all I/O in the “Name” and “Value” sections to the
left of the waveform. The simulation is now done.
Expt. Introduction to Verilog HDL and Verification of Simple
No. 8 Boolean Expression
AIM:
(a). To understand the basics of Verilog HDL and concepts of various Verilog modelling
such as Gate-level, Dataflow, Behavioural and Switch-level modelling.
THEORY:
Gate-level modelling:
At gate level, the circuit is described in terms of gates (e.g., and, nand, or). All logic
circuits can be designed by using basic gates. Verilog supports basic logic gates as
predefined primitives. There are three classes of basic gates.
These primitives are instantiated like modules except that they are predefined in Verilog
and do not need a module definition. Logic gates can be used in design using gate
instantiation. Basic syntax for multiple-input gates is:
Data-flow modelling:
Data flow level description of a digital circuit is at higher level, it makes the circuit
description more compact as compared to design through gate primitives. Design
implement using data flow modeling uses a continuous assignment statement and
Verilog provides different operators to perform a function. The assignment statement start
with the keyword assign and results are assigned to nets. In general dataflow modelling,
various logical and arithmetic operators used to realize the required logic. Some of the
logical operators are & (bitwise AND), |(bitwise OR), ~(bitwise NOT), ^ ( bitwise XOR etc.,
TRUTH TABLE:
INPUTS INTERMEDIATE OUTPUTS OUTPUT
A B C AB AC BC Y = AB+AC+BC
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 0 0 0 0
0 1 1 0 0 1 1
1 0 0 0 0 0 0
1 0 1 0 1 0 1
1 1 0 1 0 0 1
1 1 1 1 1 1 1
LOGIC DIAGRAM:
SIMULATION OUTPUT:
RESULT:
Thus, the basics of Verilog HDL studied and simple Boolean expression realized in
Verilog HDL gate level modelling and its truth table is verified by simulation using Xilinx ISE
Simulator.
VIVA QUESTIONS WITH ANSWERS:
3. In Verilog HDL module, port list section describes list of ____ and _____ of the design.
Inputs, outputs
7. In data-flow modelling the continuous assignment statement start with the keyword
_________ and results are assigned to ________.
Assign, nets
8. Which Verilog modelling enables you to describe the system at a higher level of
abstraction?
Behavioural modelling
AIM:
A digital circuit designer needs to design a partial simplified Arithmetic Logic Unit (ALU)
in Verilog HDL to perform a 4-bit addition operation on two operands, but he had already
created a full adder logic for another application. Help him to realize partial simplified
ALU design to perform 4-bit addition by instantiating full adder logic. Verify the output
logic by simulation using Xilinx ISE Simulator. (Hint: 4-bit Parallel Adder using Full adder)
PROCEDURE:
1. Launch Xilinx ISE 14.1 and create a new project by selecting File → New Project.
2. Create a Verilog source file for the project by clicking on Project → New Source
from the menu.
3. Type the Verilog HDL program for the given logic
4. To check the syntax errors in the design, double-click on “check syntax” option
under process window.
5. Then run “Synthesize XST” option to convert your Verilog HDL code into logic circuit
and visualize under “RTL Schematic” option.
6. Create a Verilog test fixture module to verify the functionality of the design by
selecting Project → New Source.
7. Based on the logic chosen for implementation all possible set of inputs must be
provided with proper delay values in test bench program.
8. Select “Simulation” option in project window, then double click on the simulate
behavioural model to open an ISIM Simulator.
9. The output the designed logic will be displayed in the forms of waveforms.
10. Place the mouse cursor on the waveforms area; simultaneously verify the state
value of the inputs and outputs as per truth table.
4-BIT PARALLEL ADDER USING FULL ADDER:
THEORY:
An adder is a digital logic circuit in electronics that implements addition of
numbers. In many computers and other types of processors, adders/Subtractors are used
to calculate addresses, similar operations and table indices in the ALU also in other parts
of the processors. A typical adder circuit produces a sum bit (denoted by S) and a carry
bit (denoted by C) as the output. A full adder is a digital circuit that adds three one-bit
binary numbers, two operands and a carry bit. The adder outputs two numbers, a sum
and a carry bit. Full adders are made from XOR, AND, OR gates.
Parallel Adder is a digital circuit capable of finding the arithmetic sum of two binary
numbers that is greater than one bit in length by operating on corresponding pairs of bits
in parallel. It consists of full adders connected in a chain where the output carry from
each full adder is connected to the carry input of the next higher order full adder in the
chain. A “n” bit parallel adder requires “n” full adders to perform the operation. So for
the two-bit number, two adders are needed while for four bit number, four adders are
needed and so on. Consider the example that two 4-bit binary numbers B3 B2 B1 B0 and
A3 A2 A1 A0 are to be added with a carry input Cin. This can be done by cascading four
full adder circuits as shown in logic diagram section. The least significant bits A0, B0, and
Cin are added to the produce sum output S0 and carry output C1. Carry output C1 is then
added to the next significant bits A1 and B1producing sum output S1 and carry output C2.
C2 is then added to A2 and B2 and so on. Thus finally producing the four-bit sum output
S3 S2 S1 S0 and final carry output Cout.
FULL ADDER:
TRUTH TABLE:
INPUTS OUTPUTS
A B Cin SUM CARRY
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
K-MAP:
RTL SCHEMATIC:
TEST BENCH:
module FullAdder_tb;
// Inputs
reg A;
reg B;
reg Cin;
// Outputs
wire SUM;
wire CARRY;
// Instantiate the Unit Under Test (UUT)
FullAdder uut (
.SUM(SUM),
.CARRY(CARRY),
.A(A),
.B(B),
.Cin(Cin)
);
initial begin
// Initialize Inputs
A = 0; B = 0; Cin = 0;
#100;
A = 0; B = 0; Cin = 1;
#100;
A = 0; B = 1; Cin = 0;
#100;
A = 0; B = 1; Cin = 1;
#100;
A = 1; B = 0; Cin = 0;
#100;
A =1; B = 0; Cin = 1;
#100;
A = 1; B = 1; Cin = 0;
#100;
A = 1; B = 1; Cin = 1;
#100;
end
endmodule
SIMULATION OUTPUT:
4-BIT PARALLEL ADDER:
TEST CASES:
Case-1: 5 + 5 = (?) Case-2: 15 + 12 = (?)
LOGIC DIAGRAM:
SIMULATION OUTPUT:
RESULT:
Thus, 4-bit parallel adder is constructed using four full adder using instantiation and
its logical functions is verified by simulation using Xilinx ISE Simulator.
VIVA QUESTIONS WITH ANSWERS:
7. While writing test bench, original Verilog module inputs are reassigned as ________
and outputs are reassigned as _______________.
Reg, wire
8. If two 16-bit inputs are added using 16-bit parallel adder then size of the final sum
output will be _______.
16-bit
10. While using module instantiation, Instance name should be unique but the size and
order of each port can be different. True or False?
False
Expt.
Design and Simulate 4x4 Binary Multiplier
No. 10
AIM:
Multiplication is one of the essential operation to be carried out by ALU of a 4004
microprocessor. Design and simulate multiplier unit for 4-bit ALU unit with the help of basic
logic gates and 4-bit parallel adders. Verify the output logic by simulation using Xilinx ISE
Simulator.
PROCEDURE:
1. Launch Xilinx ISE 14.1 and create a new project by selecting File → New Project.
2. Create a Verilog source file for the project by clicking on Project → New Source
from the menu.
3. Type the Verilog HDL program for the given logic
4. To check the syntax errors in the design, double-click on “check syntax” option
under process window.
5. Then run “Synthesize XST” option to convert your Verilog HDL code into logic circuit
and visualize under “RTL Schematic” option.
6. Create a Verilog test fixture module to verify the functionality of the design by
selecting Project → New Source.
7. Based on the logic chosen for implementation all possible set of inputs must be
provided with proper delay values in test bench program.
8. Select “Simulation” option in project window, then double click on the simulate
behavioural model to open an ISIM Simulator.
9. The output the designed logic will be displayed in the forms of waveforms.
10. Place the mouse cursor on the waveforms area; simultaneously verify the state
value of the inputs and outputs as per truth table.
4 x 4 BINARY MULTIPLIER:
THEORY:
A binary multiplier is a combinational logic circuit used in digital systems to perform
the multiplication of two binary numbers. These are most commonly used in various
applications especially in the field of digital signal processing to perform the various
algorithms. Similar to the multiplication of decimal numbers, binary multiplication follows
the same process for producing a product result of the two binary numbers. Let us
consider two unsigned 4 bit numbers multiplication in which the multiplicand, A is equal
to A3 A2 A1 A0 and the multiplier B is equal to B3 B2 B1B0. The partial products are
produced depending on each multiplier bit multiplied by the multiplicand. Each partial
product consists of four product terms and these are shifted to the left relative to the
previous partial product as shown in figure. All these partial products are added to
produce the 8 bit product.
The logic circuit for the 4×4 binary multiplication can be implemented by using
three 4-bit parallel adders along with AND gates. The first partial product is obtained by
multiplying B0 with A3 A2 A1A0, the second partial product is formed by multiplying B1
with A3 A2 A1A0, likewise for 3rd and 4th partial products. So these partial products can
be implemented with AND gates as shown in logic diagram. These partial products are
then added by using 4-bit parallel adder. The three most significant bits of first partial
product with carry (considered as zero) are added with second partial term in the first full
adder. Then the result is added to the next partial product with carry out and it goes on
until the final partial product, finally it produces 8-bit sum, which indicates the
multiplication value of the two binary numbers.
TEST CASES:
LOGIC DIAGRAM:
VERILOG HDL CODE – 4x4 BINARY MULTIPLIER (Gate-level):
//instantiate 4-bit adder and full adder module from previous experiment
module multiplier_4x4(P,A,B);
//inputs
input [3:0]A,B;
//outputs
output [7:0]P;
//wires
wire [23:1]W;
//andgate instantiations
and a1(P[0],A[0],B[0]);
and a2(W[1],A[1],B[0]);
and a3(W[2],A[2],B[0]);
and a4(W[3],A[3],B[0]);
and a5(W[4],A[0],B[1]);
and a6(W[5],A[1],B[1]);
and a7(W[6],A[2],B[1]);
and a8(W[7],A[3],B[1]);
and a9(W[8],A[0],B[2]);
and a10(W[9],A[1],B[2]);
and a11(W[10],A[2],B[2]);
and a12(W[11],A[3],B[2]);
and a13(W[12],A[0],B[3]);
and a14(W[13],A[1],B[3]);
and a15(W[14],A[2],B[3]);
and a16(W[15],A[3],B[3]);
endmodule
TEST BENCH FOR 4x4 BINARY MULTIPLIER:
module multiplier_4x4_tb;
reg [3:0] A;
reg [3:0] B;
wire [7:0] P;
multiplier_4x4 uut ( .P(P), .A(A), .B(B));
initial begin
A = 13; B = 11; #100;
A = 10; B = 11; #100;
end
SIMULATION OUTPUT:
RESULT:
Thus, multiplication unit of 4-bit ALU is designed using basic logic gates and 4-bit
parallel adder and its logical operation is verified by simulation using Xilinx ISE Simulator.
VIVA QUESTIONS WITH ANSWERS:
1. For an M x N binary multiplier how many AND gates and 4-bit adders are
needed?
(M x N)AND gates and (N-1) 4-bit adders
3. For 4x3 binary multiplier how many AND gates and 4-bit adders are needed?
12 AND gates and 3 4-bit adders
6. Number of bits required to represent the final product output of 5x4 multiplier.
9
8. Application of multipliers?
Most commonly used in digital signal processing to perform the various
algorithms.
Commercial applications like computers, mobiles, high-speed calculators
and some general purpose processors also require binary multipliers.
9. Which operator is used in Verilog HDL to combine multiple bits into single
number?
Concatenate operator { }
AIM:
(a). Construct SR Flip-Flops using basic logic gates and verify its output logic by simulation
using Xilinx ISE Simulator.
(b). Construct JK Flip-Flops using basic logic gates and verify its output logic by simulation
using Xilinx ISE Simulator.
(c). In a Microprocessor design, signals that flow through different paths arrive at different
time. This could cause many problems when these signals have to interact with each
other. Identify & implement a suitable flop-flop required to synchronize these signals using
basic logic gates. Verify its output logic by simulation using Xilinx ISE Simulator. (Hint: D-FF)
(d). Counters are the digital circuits, which are used to count the number of events.
Identify and implement the most suitable Flip-flip required to design a counter unit using
basic logic gates. Verify its output logic by simulation using Xilinx ISE Simulator. (Hint: T-FF)
PROCEDURE:
1. Launch Xilinx ISE 14.1 and create a new project by selecting File → New Project.
2. Create a Verilog source file for the project by clicking on Project → New Source
from the menu.
3. Type the Verilog HDL program for the given logic
4. To check the syntax errors in the design, double-click on “check syntax” option
under process window.
5. Then run “Synthesize XST” option to convert your Verilog HDL code into logic circuit
and visualize under “RTL Schematic” option.
6. Create a Verilog test fixture module to verify the functionality of the design by
selecting Project → New Source.
7. Based on the logic chosen for implementation all possible set of inputs must be
provided with proper delay values in test bench program.
8. Select “Simulation” option in project window, then double click on the simulate
behavioural model to open an ISIM Simulator.
9. The output the designed logic will be displayed in the forms of waveforms.
10. Place the mouse cursor on the waveforms area; simultaneously verify the state
value of the inputs and outputs as per truth table.
(a). SR(SET RESET) Flip-Flop:
THEORY:
The SR flip-flop, stands for “Set-Reset” flip-flop. This simple flip-flop is basically a one-
bit memory bistable device that has two inputs, one which will “SET” the device (meaning
the output = “1”), and is labelled S and one which will “RESET” the device (meaning the
output = “0”), labelled R. The reset input resets the flip-flop back to its original state with
an output Q. A basic NAND gate SR flip-flop circuit provides feedback from both of its
outputs back to its opposing inputs and is commonly used in memory circuits to store a
single data bit. Then the SR flip-flop actually has three inputs, Set, Reset and its current
output Q relating to it’s current state or history. When S and R at HIGH state both outputs
tries to get into HIGH state and not of them get into state output state. This state is called
intermediate or invalid state.
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
VERILOG HDL CODE (Behavioural):
module SR_FF(Q,QB,S,R,CLK);
input S,R,CLK;
output Q,QB;
reg Q,QB;
always @(posedge CLK)
begin
case({S,R})
2'b00:Q=Q;
2'b01:Q=0;
2'b10:Q=1;
2'b11:Q=1'bx;
endcase
QB=~Q;
end
endmodule
TEST BENCH:
module SR_FF_TB;
// Inputs
reg S;
reg R;
reg CLK;
// Outputs
wire Q;
wire QB;
// Instantiate the Unit Under Test (UUT)
SR_FF uut (
.Q(Q),
.QB(QB),
.S(S),
.R(R),
.CLK(CLK)
);
SIMULATION OUTPUT:
TRUTH TABLE:
LOGIC DIAGRAM:
VERILOG HDL CODE:
module JK_FF(Q,QB,J,K,CLK);
input J,K,CLK;
output Q,QB;
reg Q,QB;
always @(posedge CLK)
begin
case({J,K})
2'b00:Q=Q;
2'b01:Q=0;
2'b10:Q=1;
2'b11:Q=~Q;
endcase
QB=~Q;
end
endmodule
TEST BENCH:
module JK_FF_TB;
// Inputs
reg J;
reg K;
reg CLK;
// Outputs
wire Q;
wire QB;
// Instantiate the Unit Under Test (UUT)
JK_FF uut (
.Q(Q),
.QB(QB),
.J(J),
.K(K),
.CLK(CLK)
);
always #100 CLK=~CLK;
initial begin
// Initialize Inputs
CLK=1;
#200 J=1;K=0;
#200 J=0; K=0;
#200 J=0; K=1;
#200 J=1; K=1;
end
endmodule
RTL SCHEMATIC:
SIMULATION OUTPUT:
TRUTH TABLE:
LOGIC DIAGRAM:
module D_FF(Q,QB,D,CLK);
input D,CLK;
output Q,QB;
reg Q,QB;
always @(posedge CLK)
begin
Q=D;
QB=~Q;
end
endmodule
TEST BENCH:
module D_FF_TB;
reg D;
reg CLK;
wire Q;
wire QB;
D_FF uut (
.Q(Q),
.QB(QB),
.D(D),
.CLK(CLK)
);
always #100 CLK=~CLK;
initial begin
// Initialize Inputs
CLK=1;
#200 D=1;
#200 D=0;
end
endmodule
RTL SCHEMATIC:
SIMULATION OUTPUT:
(d). T (TOGGLE) FLIP-FLOP:
THEORY:
T flip – flop is also known as “Toggle Flip – flop”. To avoid the occurrence of
intermediate state in SR flip – flop, we should provide only one input to the flip – flop called
Trigger input or Toggle input (T). Then the flip – flop acts as a Toggle switch. Toggling
means ‘Changing the next state output to complement of the present state output’. The
T (Toggle) Flip-Flop is a modification of the JK Flip-Flop. It is obtained from JK Flip-Flop by
connecting both inputs J and K together, i.e., single input. Regardless of the present state,
the Flip-Flop complements its output when the clock pulse occurs while input T= 1.
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
VERILOG HDL CODE:
module T_FF(Q,QB,T,CLK);
input T,CLK;
output Q,QB;
reg Q=0,QB;
always @(posedge CLK)
begin
case(T)
1'b0:Q=Q;
1'b1:Q=~Q;
endcase
QB=~Q;
end
endmodule
TEST BENCH:
module T_FF_TB;
// Inputs
reg T;
reg CLK;
// Outputs
wire Q;
wire QB;
// Instantiate the Unit Under Test (UUT)
T_FF uut (
.Q(Q),
.QB(QB),
.T(T),
.CLK(CLK)
);
always #100 CLK=~CLK;
initial begin
// Initialize Inputs
CLK=1;
#200 T=0;
#200 T=1;
#200 T=0;
#200 T=1;
end
endmodule
RTL SCHEMATIC:
SIMULATION OUTPUT:
RESULT:
Thus, various types of flip-flops such as SR, JK, D and T are designed under Verilog
HDL in behavioural modelling and its logical operation is verified by simulation using Xilinx
ISE Simulator.
VIVA QUESTIONS WITH ANSWERS:
6. On a positive edge-triggered flip-flop circuit, the outputs reflect the input condition
only when?
The clock pulse transitions from LOW to HIGH
AIM:
(a). In many communication systems, Serial data transmission is preferred for long
distance communication due to its economical value in terms of the wires used. This
necessitates parallel-to-serial conversion at the sender-end for which shift registers can
be used. Design and implement the suitable 4-bit parallel to serial converter logic circuit
for the given requirement using appropriate flip-flop. (Hint: PISO)
(b). A Microcontroller based bidirectional visitor counter is shown in figure-1 to count the
number of visitors to the college library. Depending upon the signal from the IR sensors,
this system detects the entry and exit of the visitor. Figure-2 shows sensor setup at the
library entrance for bidirectional visitor counter. The logic control circuit block shown in
figure – 1 keeps the record on of number of visitor entered and number of visitor exited.
Microcontroller calculate number of person present in the library by subtracting number
of people exited from number of people entered. Then, it displays the number of visitors
present in the library on the display device-using microcontroller. For simplicity assume
the system can count maximum of 16 people.
PROCEDURE:
1. Launch Xilinx ISE 14.1 and create a new project by selecting File → New Project.
2. Create a Verilog source file for the project by clicking on Project → New Source
from the menu.
3. Type the Verilog HDL program for the given logic
4. To check the syntax errors in the design, double-click on “check syntax” option
under process window.
5. Then run “Synthesize XST” option to convert your Verilog HDL code into logic circuit
and visualize under “RTL Schematic” option.
6. Create a Verilog test fixture module to verify the functionality of the design by
selecting Project → New Source.
7. Based on the logic chosen for implementation all possible set of inputs must be
provided with proper delay values in test bench program.
8. Select “Simulation” option in project window, then double click on the simulate
behavioural model to open an ISIM Simulator.
9. The output the designed logic will be displayed in the forms of waveforms.
10. Place the mouse cursor on the waveforms area; simultaneously verify the state
value of the inputs and outputs as per truth table.
There are four data-input lines, D0,D1,D2,D3 and a SHIFT / LOAD’ input, which
allows four bits of data to load-in parallel into the register. When SHIFT / LOAD is LOW,
gates G1through G4 are enabled, allowing each data bit to be applied to the D input
of its respective flip-flop. When a clock pulse is applied, the flip-flops with D = 1 will set
and those with D = 0 will reset, thereby storing all four bits simultaneously.
When SHIFT / LOAD’ is HIGH, gates G1 through G4 are disabled and gates G5
through G7 are enabled, allowing the data bits to shift right from one stage to the next.
The OR gates allow either the normal shifting operation or the parallel data-entry
operation, depending on which AND gates are enabled by the level on the SHIFT / LOAD’
input. Notice that FF3 has a single AND to disable the parallel input, D3. It does not require
an AND/OR arrangement because there is no serial data in.
BLOCK DIAGRAM:
TRUTH TABLE:
LOGIC DIAGRAM:
VERILOG HDL CODE (Behavioural):
module PISO(CLK,D,Q,SHIFT_LOAD);
input CLK, SHIFT_LOAD;
input [3:0]D;
output Q;
reg Q;
reg [3:0]TEMP;
always@(posedge CLK)
begin
if(SHIFT_LOAD==1'b0)
begin
Q<=1'b0;
TEMP<=D;
end
else
begin
Q<=TEMP[0];
TEMP<= TEMP>>1'b1;
end
end
endmodule
TEST BENCH:
module PISO_tb;
reg CLK, SHIFT_LOAD;
reg [3:0] D;
wire Q;
PISO uut (.CLK(CLK),
.D(D),
.Q(Q),
.SHIFT_LOAD(SHIFT_LOAD) );
initial CLK=1'b1;
always #100 CLK=~CLK;
initial begin
D=4'b1101; SHIFT_LOAD = 1'b0;
#200 ;
SHIFT_LOAD = 1'b1;
#1200;
D=4'b1001; SHIFT_LOAD = 1'b0;
#200 ;
SHIFT_LOAD = 1'b1;
#1000 $stop;
end
endmodule
RTL SCHEMATIC:
SIMULATION OUTPUT:
TRUTH TABLE:
CLOCK COUNTER OUTPUT AT Q
PULSE NO. QD QC QB QA
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
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1
LOGIC DIAGRAM:
VERILOG HDL CODE (Behavioural):
module UP_DOWN_COUNTER(COUNT, CLK, UP_DOWN, RESET);
input CLK, UP_DOWN, RESET;
output [3 : 0] COUNT;
reg [3:0] COUNT = 0;
always @(posedge CLK or posedge RESET)
begin
if(RESET==1)
COUNT<=0;
else
if(UP_DOWN == 1) //Up mode selected
if(COUNT == 15)
COUNT <= 0;
else
COUNT <= COUNT + 1; //Incremend Counter
else //Down mode selected
if(COUNT == 0)
COUNT <= 15;
else
COUNT <= COUNT - 1; //Decrement counter
end
endmodule
TEST BENCH:
module UP_DOWN_COUNTER_TB;
reg CLK, RESET;
reg UP_DOWN;
reg;
wire [3:0] COUNT;
// Instantiate the Unit Under Test (UUT)
UP_DOWN_COUNTER uut (
.COUNT(COUNT),
.CLK(CLK),
.UP_DOWN(UP_DOWN),
.RESET(RESET));
initial CLK = 0;
always #10 CLK = ~CLK;
initial begin
RESET = 0; UP_DOWN = 1;
#400;
UP_DOWN = 0;
#400;
end
endmodule
RTL SCHEMATIC:
SIMULATION OUTPUT:
RESULT:
Thus, 4-Bit Parallel-In Serial-Out shift registers and 4-Bit Up/Down Counters are
designed under Verilog HDL in behavioural modelling and its logical operation is verified
by simulation using Xilinx ISE Simulator.
VIVA QUESTIONS WITH ANSWERS:
1. How much storage capacity does each stage in a shift register represent?
1-bit
2. How many clock pulses will be required to completely load the parallel input of a
5-bit PISO shift register?
1
3. What type of register would have a complete binary number shifted in one bit at a
time and have all the stored bits shifted out one at a time?
Serial-in parallel-out
4. The bit sequence 1100 is loaded simultaneously into a 4-bit PISO shift register using
LOAD option. What will be the value of serial out bit after six clock pulses?
0 (bit)
6. Number of basic logic gates and Flip-flops required to construct 3-bit UP/DOWN
counter are _______
Four 2-input AND Gate, two 2-input OR Gate, three JK-Flip flops
7. If 4-bit UP/DOWN counter operating under UP mode, then each flip-flop is triggered
by the ________ output of the preceding flip-flop.
Q or Normal
8. Once an UP/DOWN counter begins its count sequence, it can’t be altered. True or
False?
False
9. If 4-bit UP/DOWN counter operating under DOWN mode and currently counter
holding a value 1100 then what will be the value hold by counter after 5 clock
pulses?
0111
AIM:
Design and simulate a simple 8-bit microprocessor’s ALU unit which performs arithmetic
and logical operations (shown in below table) on two 8-bit inputs [7:0]A and [7:0]B. Write
the Verilog HDL code in behavioural modelling for the above mentioned design and
verify the output using sample test cases.
1. Launch Xilinx ISE 14.1 and create a new project by selecting File → New Project.
2. Create a Verilog source file for the project by clicking on Project → New Source
from the menu.
3. Type the Verilog HDL program for the given logic
4. To check the syntax errors in the design, double-click on “check syntax” option
under process window.
5. Then run “Synthesize XST” option to convert your Verilog HDL code into logic circuit
and visualize under “RTL Schematic” option.
6. Create a Verilog test fixture module to verify the functionality of the design by
selecting Project → New Source.
7. Based on the logic chosen for implementation all possible set of inputs must be
provided with proper delay values in test bench program.
8. Select “Simulation” option in project window, then double click on the “simulate
behavioural model” to open an ISIM Simulator.
9. The output the designed logic will be displayed in the forms of waveforms.
10. Place the mouse cursor on the waveforms area; simultaneously verify the state
value of the inputs and outputs as per sample test case.
TEST CASE:
[7:0] A = 10101111 [7:0] B=01001011
module ALU(ALU_Out,A,B,ALU_Sel);
input[7:0]A,B;
input[3:0] ALU_Sel;
output[7:0]ALU_Out;
reg [7:0]ALU_Out;
always@(ALU_Sel)
begin
case(ALU_Sel)
4'b0000: ALU_Out=A+1; //Increment by 1
4'b0001: ALU_Out=A+B; //Addition
4'b0010: ALU_Out=A-1; //Decrement by 1
4'b0011: ALU_Out=A-B; //Subtrattion
4'b0100: ALU_Out=A*B; //Multiplication
4'b0101: ALU_Out=A==B; //Equality
4'b0110: ALU_Out=A>B; //Greater than
4'b0111: ALU_Out=A<B; //Lesser than
4'b1000: ALU_Out=~A; //Logical NOT
4'b1001: ALU_Out=A&B; //Logical AND
4'b1010: ALU_Out=A|B; //Logical OR
4'b1011: ALU_Out=~(A&B);//Logical NAND
4'b1100: ALU_Out=~(A|B);//Logical NOR
4'b1101: ALU_Out=A^B; //Logical XOR
4'b1110: ALU_Out=A>>1; //Right Shift by 1
4'b1111: ALU_Out=A<<1; //dLeft Shift by 1
default:ALU_Out=8'bXXXXXXXX;
endcase
end
endmodule
TEST BENCH:
module ALU_TB;
// Inputs
reg [7:0] A;
reg [7:0] B;
reg [3:0] ALU_Sel;
// Outputs
wire [7:0] ALU_Out;
// Instantiate the Unit Under Test (UUT)
ALU uut (
.ALU_Out(ALU_Out),
.A(A),
.B(B),
.ALU_Sel(ALU_Sel)
);
initial
begin
// Initialize Inputs
A = 8'b10101111;
B = 8'b01001011;
#100; ALU_Sel = 0;
#100; ALU_Sel = 1;
#100; ALU_Sel = 2;
#100; ALU_Sel = 3;
#100; ALU_Sel = 4;
#100; ALU_Sel = 5;
#100; ALU_Sel = 6;
#100; ALU_Sel = 7;
#100; ALU_Sel = 8;
#100; ALU_Sel = 9;
#100; ALU_Sel = 10;
#100; ALU_Sel = 11;
#100; ALU_Sel = 12;
#100; ALU_Sel = 13;
#100; ALU_Sel = 14;
#100; ALU_Sel = 15;
#100;
$stop;
end
endmodule
RTL SCHEMATIC:
SIMULATION OUTPUT:
RESULT:
Thus, the simple 8-bit ALU of a Microprocessor is designed using Verilog HDL in
behavioural modelling and its functionality is verified using test case.
VIVA QUESTIONS WITH ANSWERS:
5. Consider a laptop with 64-bit Intel core-i5 processor then, its ALU size is?
64-Bit
6. ALU is the place where the actual executions of instructions take place during the
processing operation. True or False?
True
8. The ALU gives the output of the operations and the output is stored in the _____?
Registers
9. In ALU, all operations are performed only on two input operands. True or false?
False
10. A single CPU, FPU or GPU may contain multiple ALUs. True or False?
True
Expt. Design and Simulate Chocolate Vending Machine using
No. 14 Finite State Machine
AIM:
PROCEDURE:
1. Launch Xilinx ISE 14.1 and create a new project by selecting File → New Project.
2. Create a Verilog source file for the project by clicking on Project → New Source
from the menu.
3. Type the Verilog HDL program for the given logic
4. To check the syntax errors in the design, double-click on “check syntax” option
under process window.
5. Then run “Synthesize XST” option to convert your Verilog HDL code into logic circuit
and visualize under “RTL Schematic” option.
6. Create a Verilog test fixture module to verify the functionality of the design by
selecting Project → New Source.
7. Based on the logic chosen for implementation all possible set of inputs must be
provided with proper delay values in test bench program.
8. Select “Simulation” option in project window, then double click on the simulate
behavioural model to open an ISIM Simulator.
9. The output the designed logic will be displayed in the forms of waveforms.
10. Place the mouse cursor on the waveforms area; simultaneously verify the state
value of the inputs and outputs as per state transition table.
VENDING MACHINE USING FINITE STATE MACHINE:
THEORY:
A finite state machine is a form of abstraction and it models the behaviour of a
system by showing each state it can be in and the transitions between each state. A
state machine will change state dependent upon its current state also current factors
influencing the system, namely, inputs. One state is designated the initial (or start) state.
Beginning with this state, the inputs are sampled periodically, and the machine changes
state dependent on both the inputs and its present state. This state may be observed
and treated as an output; the present input may also influence the output.
To understand the workings of a finite state machine, you must understand how it
changes state. In a given state, a given output produces a change of state (perhaps to
the same state). We can represent the finite state machine, then, as a function mapping
an input and state to a state. A state transition table is essentially a truth table in which
some of the inputs are the current state, and the outputs include the next state, along
with other outputs. In a digital circuit, the inputs will be binary values, the transition
function will be implemented by using the inputs and the outputs of the flip-flops at a
given clock pulse to affect the state of the flip-flops, and the new state will be the new
state of the flip-flops after the clock pulse.
Mealy State Machine: A Finite State Machine is said to be Mealy state machine, if
outputs depend on both present inputs & present states.
Moore State Machine: A Finite State Machine is said to be Moore state machine, if
outputs depend only on present states.
In general, the number of states required in Moore state machine is more than or equal
to the number of states required in Mealy state machine. Vending Machine is a practical
example where FSM is used. The ticket dispatcher unit at the stations, the can drinks,
chocolate dispatcher at the shops are some examples of Vending machines.
DESIGN SPECIFICATION:
STATE TABLE:
S0 S0 S5 S10 S0 0 0 0 X
S5 S1 S10 S15 S0 0 0 0 X
S10 S10 S15 S15 S0 0 0 0 X
S15 S0 S0 S0 S0 1 1 1 X
input [1:0]coin;
input clk,rst;
output out;
reg out;
reg [1:0]state,next_state;
parameter s0=2'd0,s5=2'd1,s10=2'd2,s15=2'd3;
parameter x0=2'd0,x5=2'd1,x10=2'd2,x15=2'd3;
always @ (state,coin)
begin
case(state)
s0:begin
if(coin==x0)
begin
next_state=s0; out=0;
end
else if(coin==x5)
begin
next_state=s5; out=0;
end
else if(coin==x10)
begin
next_state=s10; out=0;
end
else if(coin==x15)
begin
next_state=s0; out=1'bx;
end
end // case: s0
s5:begin
if(coin==x0)
begin
next_state=s5; out=0;
end
else if(coin==x5)
begin
next_state=s10; out=0;
end
else if(coin==x10)
begin
next_state=s15; out=0;
end
else if(coin==x15)
begin
next_state=s0; out=1'bx;
end
end // case: s5
s10:begin
if(coin==x0)
begin
next_state=s10; out=0;
end
else if(coin==x5)
begin
next_state=s15; out=0;
end
else if(coin==x10)
begin
next_state=s15; out=0;
end
else if(coin==x15)
begin
next_state=s0; out=1'bx;
end
end // case: s10
s15:
begin
out=1;
next_state=s0;
end
endcase
end // always @ (state,coin)
endmodule
TEST BENCH:
module VENDING_MACHINE_TB;
// Inputs
reg [1:0] coin;
reg clk;
reg rst;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
VENDING_MACHINE uut (
.out(out),
.coin(coin),
.clk(clk),
.rst(rst));
initial clk=1;
always #100 clk = ~clk;
initial begin
//CASE:1 5+5+5=15
coin = 0; rst = 1; #200;
coin = 1; rst = 0; #200;
coin = 1; rst = 0; #200;
coin = 1; rst = 0; #200;
//CASE:2 5+10=15
coin = 0; rst = 1; #200;
coin = 1; rst = 0; #200;
coin = 2; rst = 0; #200;
//CASE:3 10+5=15
coin = 0; rst = 1; #200;
coin = 2; rst = 0; #200;
coin = 1; rst = 0; #200;
//CASE:4 5+15=15 No change
coin = 1; rst = 1; #200;
coin = 1; rst = 0; #200;
coin = 3; rst = 0; #200;
//CASE:5 15=15
coin = 0; rst = 1; #200;
coin = 3; rst = 0; #200;
//CASE:6 10+15=15 No change
coin = 0; rst = 1; #200;
coin = 2; rst = 0; #200;
coin = 3; rst = 0; #200;
end
endmodule
RTL SCHEMATIC:
SIMULATION OUTPUT:
RESULT:
Thus, the chocolate vending machine controllers is designed using Finite state
machine and realized with the help of Verilog HDL in behavioural modelling and the its
logical function is verified using state transition table.
VIVA QUESTIONS WITH ANSWERS:
3. A Finite State Machine is said to be ________ state machine, if outputs depend only
on present states.
Moore
6. Finite state machine will initially state with a state called initial state. True or false?
True