DSDV Lab Manual Ay 2024-25
DSDV Lab Manual Ay 2024-25
DSDV Lab Manual Ay 2024-25
Prepared by,
Mrs. MEGHANA M N
Assistant Professor
Dept. of ECE
MIT Thandavapura
STUDENT NAME :
USN :
ACADEMIC YEAR : 2024-25
“To be recognized as a premier institute in creating competent graduates driven towards socio-technical
needs”
1. To exhibit quality in the processes of teaching and learning evolved through continual feedback.
2. To create an ecosystem of greater learning through research and innovation.
3. To engage in self-learning through interaction with industry and alumni.
4. To maintain professional and ethical approach in dealing with stakeholders.
“To be at the forefront in producing envisioning minds and build competencies in the field of electronics
and communication engineering to deliver quality solutions to societal problems”
Within few years of graduation, the Electronics and Communication Engineering program will enable its
graduates to:
1. Exhibit competencies relevant for industry and reason the findings towards better performance of self
and the system.
2. Explore technological developments through inquisition of greater knowledge and their applicability.
3. Develop solutions to solve societal problems in a team or as an individual.
PO 9: Individual and team work: Function effectively as an individual, and as a member or leader
in diverse teams, and in multidisciplinary settings.
LAB INSTRUCTIONS
General instructions
1. Uniform and ID card is must.
2. Students must bring laboratory manual - observationand recordalong with pen, pencil, calculator etc.
no borrowing from others.
3. Maintain silence in the lab. Keep laboratory clean.
4. Keep your belongings in the appropriate place provided to you.
5. Do not come late to the laboratory.
6. Work only on the computers allotted to you.
7. Computers and peripherals are not to be moved or reconfigured without approval of Lab instructor
or In-charge faculty.
8. Students may not install software on lab computers.
9. Playing of games on computer in the lab is strictly prohibited.
10. Before leaving the lab, student must close all programs positively and shutdown the computers.
Record
1. Draw truth tables and other necessary block diagrams neatly and label correctly.
2. Enter readings in the tabulation.
3. Units are to be written for various quantities.
4. Complete the record before you come to next lab session.
5. Bring the record for submission during next lab session.
Attendance
1. You have to give your attendance, submitting records, and show the updated results in laboratory
manual - observation and get it signed.
2. You have to occupy the respective computer systems which is assigned by signing in the log book.
@#12102023
Flip-Flops and its Applications: The Master-Slave Flip-flops(Pulse-Triggered flip-flops):SR flip-
flops, JK flip flops, Characteristic equations, Registers, Binary Ripple Counters, Synchronous
Binary Counters, Counters based on Shift Registers, Design of Synchronous mod-n Counter using
clocked T, J K, D and SR flip-flops.(Section 6.4, 6.6 to 6.9 (Excluding 6.9.3)of Text2)
MODULE-4
Introduction to Verilog: Structure of Verilog module, Operators, Data Types, Styles of
Description. (Section1.1to1.6.2, 1.6.4 (only Verilog),2 of Text 3)
Verilog Data flow description: Highlights of Data flow description, Structure of Data flow
description.(Section2.1to2.2(only Verilog) of Text3)
MODULE-5
Verilog Behavioral description: Structure, Variable Assignment Statement, Sequential
Statements, Loop Statements, Verilog Behavioral Description of Multiplexers (2:1, 4:1, 8:1).
(Section 3.1 to 3.4 (onlyVerilog)of Text 3)
Verilog Structural description: Highlights of Structural description, Organization of structural
description, Structural description of ripple carry adder.(Section4.1 to 4.2 of Text 3)
PRACTICAL COMPONENT OF IPCC (Experiments can be conducted either using any circuit simulation
software or discrete components)
Sl.N Experiments
1 To simplify the given Boolean expressions and realize using Verilog program
2 To realize Adder/Subtractor(Full/half)circuits using Verilog data flow description.
3 To realize 4-bit ALU using Verilog program.
4 To realize the following Code converters using Verilog Behavioral description
a)Gray to binary and vice versa b)Binary to excess3 and vice versa
5 To realize using Verilog Behavioral description:8:1mux, 8:3encoder, Priority encoder
6 To realize using Verilog Behavioral description:1:8Demux, 3:8 decoder,2 –bit Comparator
7 To realize using Verilog Behavioral description:
Flip-flops: a)JK type b)SR type c)T type and d)D type
8 To realize Counters-up/down (BCD and binary)using Verilog Behavioral description.
Demonstration Experiments (For CIE only–not to be included for SEE)
Use FPGA/CPLD kits for down loading Verilog codes and check the output for interfacing
experiments.
9 Verilog Program to interface a Stepper motor to the FPGA/CPLD and rotate the motor
in the specified direction (by N steps).
10 Verilog programs to interface Switches and LEDs to the FPGA/CPLD and demonstrate
its working.
Course outcomes (Course Skill Set):
At the end of the course the student will be able to:
1. Simplify Boolean functions using K-map and Quine-McCluskey minimization technique.
2. Analyze and design for combinational logic circuits.
3. Analyze the concepts of Flip Flops(SR, D,T and JK) and to design the synchronous sequential
circuits using Flip Flops.
4. Model Combinational circuits (adders, subtractors, multiplexers) and sequential circuits using
Verilog descriptions.
@#12102023
Assessment Details (both CIE and SEE)
The weightage of Continuous Internal Evaluation (CIE) is 50% and for Semester End Exam (SEE) is
50%. The minimum passing mark for the CIE is 40% of the maximum marks (20 marks out of 50)
and for the SEE minimum passing mark is 35% of the maximum marks (18 out of 50 marks). The
student is declared as a pass in the course if he/she secures a minimum of 40% (40 marks out of 100)
in the sum total of the CIE (Continuous Internal Evaluation) and SEE (Semester End Examination)
taken together.
The IPCC means the practical portion integrated with the theory of the course. CIE marks for the
theory component are 25 marks and that for the practical component is 25 marks.
CIE for the theory component of the IPCC
25 marks for the theory component are split into 15 marks for two Internal Assessment Tests
(Two Tests, each of 15 Marks with 01-hour duration, are to be conducted) and 10 marks for other
assessment methods mentioned in 22OB4.2. The first test at the end of 40-50% coverage of the
syllabus and the second test after covering 85-90% of the syllabus.
Scaled-down marks of the sum of two tests and other assessment methods will be CIE marks for
the theory component of IPCC (that is for 25 marks).
The student has to secure 40% of 25 marks to qualify in the CIE of the theory component of
IPCC.
CIE for the practical component of the IPCC
15 marks for the conduction of the experiment and preparation of laboratory record, and 10
marks for the test to be conducted after the completion of all the laboratory sessions.
On completion of every experiment/program in the laboratory, the students shall be evaluated
including viva-voce and marks shall be awarded on the same day.
The CIE marks awarded in the case of the Practical component shall be based on the continuous
evaluation of the laboratory report. Each experiment report can be evaluated for 10 marks. Marks
of all experiments’ write-ups are added and scaled down to 15 marks.
The laboratory test (duration 02/03 hours) after completion of all the experiments shall be
conducted for 50 marks and scaled down to 10 marks.
Scaled-down marks of write-up evaluations and tests added will be CIE marks for the laboratory
component of IPCC for 25 marks.
The student has to secure 40% of 25 marks to qualify in the CIE of the practical component of the
IPCC.
The theory portion of the IPCC shall be for both CIE and SEE, whereas the practical portion
will have a CIE component only. Questions mentioned in the SEE paper may include questions
from the practical component.
The minimum marks to be secured in CIE to appear for SEE shall be 10 (40% of maximum
marks-25) in the theory component and 10 (40% of maximum marks -25) in the practical
component. The laboratory component of the IPCC shall be for CIE only. However, in SEE,
the questions from the laboratory component shall be included. The maximum of 04/05 sub-
questions are to be set from the practical component of IPCC, the total marks of all questions
@#12102023
should not be more than 20 marks.
SEE will be conducted for 100 marks and students shall secure 35% of the maximum marks to
qualify for the SEE. Marks secured will be scaled down to 50.
The student is declared as a pass in the course if he/she secures a minimum of 40% (40 marks
out of 100) in the sum total of the CIE (Continuous Internal Evaluation) and SEE (Semester
End Examination) taken together.
Suggested Learning Resources:
Books
1. Digital Logic Applications and Design by John MYarbrough,Thomson Learning,2001.
2. Digital Principles and Design by Donald DGivone,McGrawHill, 2002.
3. HDL Programming VHDL and Verilog by Nazeih M Botros, 2009 reprint, Dream techpress.
ReferenceBooks:
1. Fundamentals of logic design, by Charles H Roth Jr., Cengage Learning
2. Logic Design, by Sudhakar Samuel, Pearson/Sanguine, 2007
3. Fundamentals of HDL,by Cyril PR, Pearson/Sanguine2010
Web links and Video Lectures (e-Resources):
@#12102023
BEC302 DSDV practical component of IPCC Academic Year 2024-25
CONTENTS
3. 4-bit ALU 23 - 25
4. Code converters 26 - 35
7. Flip-flops 49 - 56
DEMOSTRATION EXPIREMENTS
9. Stepper motor
INTRODUCTION
INTRODUCTION TO HDL
INTRODUCTION TO XILINX
ISE Xilinx (Integrated Software Environment (ISE)), i.e. programmable logic design tool in
electronics industry. This Xilinx design software suite allows taking design from design entry
through Xilinx device programming. The ISE Project Navigator manages and processes design
through several steps in the ISE design flow. These steps are Design Entry, Synthesis,
Implementation, Simulation/Verification, and Device Configuration. Xilinx is one of most popular
software tool used to synthesize VHDL code.
Release version : 14.7
STEP 2:
STEP 3:
6. In the Design window (Left most top corner) Select available device (Ex. Xc6slx4-
3csg225), right click on it. Select the new source, select Verilog module, give file name,
enable the Add Project and click on next.
7. Specify the ports (Input, Output and Inout). Then click on Next and Finish.
STEP 4:
9. In the process window (Left most bottom corner), expand synthesize XST and double click
on check syntax.
STEP 5:
11. In the Design window (Left most top corner), select .v file, click on new source.
12. In new source window select Verilog Test Fixture and give file name and enable the option
Add to Project, click on next, next and finish.
STEP 6:
13. Give the inputs (between initial begin and end) in the Test bench (TB) file and click on
save.
14. In the Design window (Left most top corner), Change the view to Simulation, select the test
bench (TB) file.
15. In the Process window (Left most bottom corner), elaborate ISim Simulator. Double click
on Behavioral Check Syntax to check for errors and double click on Simulate Behavioral
Model to observe the output waveform.
16. Select the measure marker option in the Toolbar to verify the simulation output.
Dept. of ECE, MIT Thandavapura page 9
BEC302 DSDV practical component of IPCC Academic Year 2024-25
PROGRAM 1
REALIZATION OF BOOLEAN EXPRESSIONS
AIM: To simplify the given Boolean expressions and realize using Verilog program using
dataflow and structural module.
BOOLEAN EXPRESSION: 𝒀 = 𝑨𝑩 + 𝑩𝑪 + 𝑨𝑪
TRUTH TABLE:
INPUTS OUTPUT
A B C Y
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0
VERILOG CODE:
DESIGN BLOCK [DATAFLOW DESCRIPTION]
module boolean (A, B, C, Y);
input A, B, C;
output Y;
assign Y = (A&(~B)) | ((~B)&C) | ((~A)&C);
endmodule
WAVEFORM:
RESULT: The given Boolean expression is simplified and realized using Verilog description.
PROGRAM 2
HALF/FULL ADDER/SUBTRACTOR
AIM: To realize Adder/Subtractor (Full/half) circuits using Verilog dataflow and structural
description.
THEORY:
1. Half Adder: A half adder is a combinational logic circuit that performs binary addition of two
single-bit binary numbers. It has two inputs, A and B, and two outputs, SUM (S) and CARRY
OUT (Cout). The S output is the least significant bit (LSB) of the result, while the Cout output
is the most significant bit (MSB) of the result, indicating whether there was a carry-over from
the addition of the two inputs.
LOGIC SYMBOL:
LOGIC DIAGRAM:
TRUTH TABLE:
INPUTS CARRY
A B S Cout
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
LOGIC EXPRESSION:
𝑺𝑼𝑴 ∶ 𝑺 = 𝑨 ⊕ 𝑩; 𝑪𝑨𝑹𝑹𝒀 ∶ 𝑪𝒐𝒖𝒕 = 𝑨. 𝑩
Dept. of ECE, MIT Thandavapura page 14
BEC302 DSDV practical component of IPCC Academic Year 2024-25
VERILOG CODE:
DESIGN BLOCK [DATAFLOW DESCRIPTION]
module HalfAdder (A,B,S,Cout);
input A,B;
output S,Cout;
assign S=A^B;
assign Cout=A&B;
endmodule
THEORY:
2. FULL Adder: A full adder is a combinational logic circuit that performs binary addition of
three single-bit binary numbers. It has three inputs, A,B and Cin and two outputs, SUM (S) and
CARRY OUT (Cout). The S output is the least significant bit (LSB) of the result, while the
Cout output is the most significant bit (MSB) of the result, indicating whether there was a carry-
over from the addition of the two inputs.
LOGIC SYMBOL:
LOGIC DIAGRAM:
TRUTH TABLE:
INPUTS CARRY
A B Cin S Cout
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
LOGIC EXPRESSION:
𝑺𝑼𝑴 ∶ 𝑺 = 𝑨 ⊕ 𝑩⨁𝑪𝒊𝒏; 𝑪𝑨𝑹𝑹𝒀 𝑶𝑼𝑻 ∶ 𝑪𝒐𝒖𝒕 = 𝑨. 𝑩 + 𝑩. 𝑪𝒊𝒏 + 𝑨. 𝑪𝒊𝒏
VERILOG CODE:
DESIGN BLOCK [DATAFLOW DESCRIPTION]
module FullAdder (A,B,Cin,S,Cout);
input A, B, Cin;
output S, Cout;
assign S = A^B^Cin;
endmodule
Dept. of ECE, MIT Thandavapura page 16
BEC302 DSDV practical component of IPCC Academic Year 2024-25
input A, B, Cin;
output S, Cout;
endmodule
3. Half Subtractor: A half subtractor is a combinational logic circuit that performs binary
difference of two single-bit binary numbers. It has two inputs, A and B, and two outputs,
DIFFERENCE (D) and BORROW OUT (Bout). The D output is the least significant bit (LSB)
of the result, while the Bout output is the most significant bit (MSB) of the result, indicating
whether there was a borrow-over from the subtractor of the two inputs.
LOGIC SYMBOL:
LOGIC DIAGRAM:
TRUTH TABLE:
INPUTS CARRY
A B D Bout
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
LOGIC EXPRESSION:
𝑫𝑰𝑭𝑭𝑬𝑹𝑬𝑵𝑪𝑬 ∶ 𝑫 = 𝑨 ⊕ 𝑩; 𝑩𝑶𝑹𝑹𝑶𝑾 𝑶𝑼𝑻 ∶ 𝑩𝒐𝒖𝒕 = 𝑨. 𝑩
VERILOG CODE
wire S1;
xor a1 (D, A, B);
not a2 (S1, A);
and a3 (Bout, S1, B);
endmodule
4. FULL SUBTRACTOR: A full subtractor is a combinational logic circuit that performs binary
difference of three single-bit binary numbers. It has three inputs, A,B and Bin and two outputs,
DIFFERENCE (D) and BORROW OUT (Bout). The D output is the least significant bit (LSB)
of the result, while the Bout output is the most significant bit (MSB) of the result, indicating
whether there was a borrow-over from the subtractor of the two inputs.
LOGIC SYMBOL:
LOGIC DIAGRAM:
TRUTH TABLE:
INPUTS CARRY
A B Bin D Bout
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
LOGIC EXPRESSION:
𝑫𝑰𝑭𝑭𝑬𝑹𝑬𝑵𝑪𝑬 ∶ 𝑫 = 𝑨 ⊕ 𝑩 ⨁𝑩𝒊𝒏; 𝑩𝑶𝑹𝑹𝑶𝑾 𝑶𝑼𝑻 ∶ 𝑩𝒐𝒖𝒕 = 𝑨. 𝑩 + 𝑩. 𝑩𝒊𝒏 + 𝑨. 𝑩𝒊𝒏
VERILOG CODE:
DESIGN BLOCK [DATAFLOW MODELLING]
module FullSubtractor (A, B, Bin, D, Bout);
input A, B, Bin;
output D, Bout;
assign D = A^B^Bin;
assign Bout = ((~A)&B)|(B&Bin)|((~A)&Bin);
endmodule
WAVEFORM :
HALF ADDER:
FULL ADDER:
HALF SUBTRACTOR:
FULL SUBTRACTOR:
PROGRAM 3
4 BIT ALU
AIM: To realize 4 bit ALU using Verilog program.
THOERY: ALU is a combinational logic circuit that performs arithmetic and logical operations
on integer binary numbers. It's a key component of a computer's central processing unit
(CPU). ALUs perform tasks like addition, subtraction, bitwise operations, and comparisons. The
inputs to an ALU called operands, and a operation indicating the operation to be performed;
Opcode determines the desired arithmetic or logic operation to be performed by the ALU.
LOGIC SYMBOL:
TRUTH TABLE:
Inputs Output
E opcode operation
A B Y
1 000 Addition 0100 0010 0110
1 001 Subtraction 0100 0010 0010
1 010 Multiplication 0100 0010 1000
1 011 Division 0100 0010 0010
1 100 AND gate 0100 0010 0000
1 101 OR gate 0100 0010 0110
1 110 EX-OR gate 0100 0010 0110
1 111 NOT gate 0100 0010 1011
0 - - - - ZZZZ
Dept. of ECE, MIT Thandavapura page 23
BEC302 DSDV practical component of IPCC Academic Year 2024-25
VERILOG CODE:
DESIGN BLOCK [BEHAVIORAL MODELLING]
module alu (A, B, E, opcode, Y);
input [3:0] A, B;
input E;
input [2:0] opcode;
output [3:0] Y;
reg [3:0] Y;
always @ (A, B, E, opcode)
begin
if (E = = 0)
y = 4’bZ;
else
case(opcode)
3'b000 : Y = A + B;
3'b001 : Y = A - B;
3'b010 : Y = A * B ;
3'b011 : Y = A / B;
3'b100 : Y = A & B;
3'b101 : Y = A | B;
3'b110 : Y = A ^ B;
3'b111 : Y = ~A;
endcase
end
endmodule
WAVEFORM:
PROGRAM 4
CODE CONVERTERS
AIM: To realize the code converters using Verilog dataflow and behavioral description.
THEORY: The logical circuit which converts binary code to equivalent gray code is known as
binary to gray code converter. The gray code is a non-weighted code. The successive gray code
differs in one bit position only that means it is a unit distance code. It is also referred as cyclic code.
It is not suitable for arithmetic operations. An n-bit Gray code can be obtained by reflecting an n-1
bit code about an axis after 2n-1 rows, and putting the MSB of 0 above the axis and the MSB of 1
below the axis.
LOGIC SYMBOL:
LOGIC DIAGRAM:
TRUTH TABLE:
VERILOG CODE:
THEORY:
The Binary code consists of two Symbols which are 0 and 1.In binary code each digit is
represented by power of 2. Gray Code system is a binary number system in which every
successive pair of numbers differs by only one bit. Binary Numbers is default way to store
numbers, but in many applications binary numbers are difficult to use and a variation of binary
numbers is needed. Gray code is an ordering of the binary numeral system such that two
successive values differ in only one bit (binary digit). Gray codes are very useful in the normal
sequence of binary numbers generated by the hardware that may cause an error or ambiguity
during the transition from one number to the next. So, the Gray code can eliminate this problem
easily since only one bit changes its value during any transition between two numbers.
LOGIC SYMBOL:
LOGIC DIAGRAM:
TRUTH TABLE:
Decimal Gray code Binary code
number G3G2G1G0 B3B2B1B0
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0111
5 0101 0110
6 0110 0100
7 0111 0101
8 1000 1111
9 1001 1110
10 1010 1100
11 1011 1101
12 1100 1000
13 1101 1001
14 1110 1011
15 1111 1010
VERILOG CODE:
assign b[0]=g[0]^b[1];
endmodule
always @ (g)
begin
b[3]=g[3];
b[2]=g[2] ^b[3];
b[1]=g[1]^b[2];
b[0]=g[0]^b[1];
end
endmodule
THEORY: The Excess-3 code can be calculated by adding 3, i.e., 0011 to each four-digit
BCD code. Below is the truth table for the conversion of BCD to Excess-3 code. In the below
table, the variables A, B, C, and D represent the bits of the binary numbers. The variable 'D'
represents the LSB, and the variable 'A' represents the MSB. In the same way, the variables w, x,
y, and z represent the bits of the Excess-3 code.
VERILOG CODE:
THEORY: BCD to Excess-3 conversion is just the reverse operation of excess-3 to BCD. The
process BCD to Excess-3 conversion is like subtracting by 3. As 4 bit excess-3 code start from 3
and end at 12 (input 0,1,2,13,14,15 not possible). Now subtract 3 from our excess-3 code. for
impossible inputs of 4 bit Excess-3 code, use output as Don’t care conditions.
VERILOG CODE:
WAVEFORM:
BINARY TO GRAY
GRAY TO BINARY
BINARY TO EXCESS-3
EXCESS-3 TO BINARY
PROGRAM 5
8:1 MUX, AND 8:3 ENCODER WITH AND WITHOUT
PRIORITY
AIM: To realize the 8:1 MUX, and 8:3 encoder with and without priority using Verilog
behavioral description.
1. 8:1 MULTIPLEXER
THEORY: An 8-to-1 multiplexer consists of eight data inputs D0 through D7, three input select
lines S2, S1, S0 and a single output line Y. Depending on the select lines combinations, multiplexer
decodes the inputs. Since the number data bits given to the MUX are eight then 3 bits (23=8) are
needed to select one of the eight data bits.
LOGIC SYMBOL:
TRUTH TABLE:
VERILOG CODE:
DESIGN BLOCK [BEHAVIORAL MODELLING]
module mux8to1 (s, i, y);
input [2:0] s;
input [7:0] i;
output y;
reg y;
always @ (i, s)
begin
case(s)
3'b000: y = i[0];
3'b001: y = i[1];
3'b010: y = i[2];
3'b011: y = i[3];
3'b100: y = i[4];
3'b101: y = i[5];
3'b110: y = i[6];
3'b111: y = i[7];
endcase
end
endmodule
8:3 ENCODERS: It is a combinational logic circuit that converts 8-bit binary input lines into
3-bit binary output lines. If the priority concept is applied to the encoder, the highest priority input
among the entire input variable will be given the highest priority.
LOGIC SYMBOL:
TRUTH TABLE:
1. 8:3 ENCODER WITHOUT PRIORITY
INPUTS OUTPUTS
en I7 I6 I5 I4 I3 I2 I1 I0 Y2 Y1 Y0
1 0 0 0 0 0 0 0 1 0 0 0
1 0 0 0 0 0 0 1 0 0 0 1
1 0 0 0 0 0 1 0 0 0 1 0
1 0 0 0 0 1 0 0 0 0 1 1
1 0 0 0 1 0 0 0 0 1 0 0
1 0 0 1 0 0 0 0 0 1 0 1
1 0 1 0 0 0 0 0 0 1 1 0
1 1 0 0 0 0 0 0 0 1 1 1
0 X X X X X X X X 0 0 0
2. 8:3 ENCODER WITH PRIORITY (Lower indices given the highest priority)
INPUTS OUTPUTS
en I7 I6 I5 I4 I3 I2 I1 I0 Y2 Y1 Y0
1 X X X X X X X 1 0 0 0
1 X X X X X X 1 0 0 0 1
1 X X X X X 1 0 0 0 1 0
1 X X X X 1 0 0 0 0 1 1
1 X X X 1 0 0 0 0 1 0 0
1 X X 1 0 0 0 0 0 1 0 1
1 X 1 0 0 0 0 0 0 1 1 0
1 1 0 0 0 0 0 0 0 1 1 1
0 X X X X X X X X 0 0 0
VERILOG CODE:
endmodule
WAVEFORM:
8:1 MUX
RESULT: 8:1 MUX, and 8:3 encoder with and without priority are realized using Verilog
description.
PROGRAM 6
1:8 DEMUX, AND 3:8 DECODER, AND 2 BIT COMPARATOR
AIM: To realize the 1:8DEMUX, and 3:8decoder, and 2 bit comparator using Verilog
behavioral description.
1. 1:8 DEMUX
THEORY: DEMUX or De-Multiplexer is a data distributor combinational circuit. It works in a
reverse way of the Multiplexer. The DEMUX has 1 input port and 2 n output lines. Here n signifies
the selection line for a DEMUX. A 1:8 DEMUX consists of one input line, 8 output lines and 3
select lines. Let the input be D, S0, S1, and S2 are 3 select lines and eight outputs from Y0 to Y7.
LOGIC SYMBOL:
TRUTH TABLE:
INPUTS OUTPUTS
en S2 S1 S0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
0 X X X Z Z Z Z Z Z Z Z
1 0 0 0 0 0 0 0 0 0 0 A
1 0 0 1 0 0 0 0 0 0 A 0
1 0 1 0 0 0 0 0 0 A 0 0
1 0 1 1 0 0 0 0 A 0 0 0
1 1 0 0 0 0 0 A 0 0 0 0
1 1 0 1 0 0 A 0 0 0 0 0
1 1 1 0 0 A 0 0 0 0 0 0
1 1 1 1 A 0 0 0 0 0 0 0
VERILOG CODE:
DESIGN BLOCK [BEHAVIORAL MODELLING]
2. 3:8 DECODER
THEORY: Decoder is a combinational logic circuit that converts n input lines to 2n output lines.
It is the reverse process of an encoder. It converts coded signal into original signal. In addition to
input pins, the decoder has a enable pin. 3:8 decoder has 3 input lines and 8 output lines.
LOGIC SYMBOL:
TRUTH TABLE:
INPUTS OUTPUTS
en I2 I1 I0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
0 X X X Z Z Z Z Z Z Z Z
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 1 0 0 0 0 0 0 1 0
1 0 1 0 0 0 0 0 0 1 0 0
1 0 1 1 0 0 0 0 1 0 0 0
1 1 0 0 0 0 0 1 0 0 0 0
1 1 0 1 0 0 1 0 0 0 0 0
1 1 1 0 0 1 0 0 0 0 0 0
1 1 1 1 1 0 0 0 0 0 0 0
VERILOG CODE:
DESIGN BLOCK [BEHAVIORAL MODELLING]
module decoder3_to_8(en, I, y);
input [2:0] I;
input en;
output [7:0] y;
reg [7:0] y;
always @( I, en)
begin
if (en = = 0)
y=8’bz;
else
begin
case (I)
3'b000: y = 8’b00000001;
3'b001: y = 8’b00000010;
3'b010: y = 8’b00000100;
3'b011: y = 8’b00001000;
3'b100: y = 8’b00010000;
3'b101: y = 8’b00100000;
3'b110: y = 8’b01000000;
3'b111: y = 8’b10000000;
endcase
end
end
endmodule
LOGIC SYMBOL:
TRUTH TABLE:
INPUTS OUTPUTS
L=A<B E=A=B G=A>B
A B
Lesser than Equal Greater than
A1 A0 B1 B0 L E G
0 0 0 0 0 1 0
0 0 0 1 1 0 0
0 0 1 0 1 0 0
0 0 1 1 1 0 0
0 1 0 0 0 0 1
0 1 0 1 0 1 0
0 1 1 0 1 0 0
0 1 1 1 1 0 0
1 0 0 0 0 0 1
1 0 0 1 0 0 1
1 0 1 0 0 1 0
1 0 1 1 1 0 0
1 1 0 0 0 0 1
1 1 0 1 0 0 1
1 1 1 0 0 0 1
1 1 1 1 0 1 0
else if (a == b)
begin
l = 0;
e = 1;
g=0;
end
else
begin
l =0;
e = 0;
g=1;
end
end
endmodule
WAVEFORM:
1:8 DEMUX
3:8 DECODER
2 BIT COMPARATOR
RESULT: 1:8 DEMUX, and 3:8 decoder, and 2 bit comparator are realized using Verilog
description.
PROGRAM 7
FLIP FLOPS
AIM: To realize using Verilog Behavioral description: Flip-flops: a) SR type b) JK type c) T
type and d) D type
1. SR FLIP FLOP
THEORY: SR flip flop is a simple circuit has a set input (S) and a reset input (R) inputs. The set
input causes the output of 0 (top output) and 1 (bottom output). The reset input causes the opposite
to happen (top = 1, bottom =0).
LOGIC SYMBOL:
TRUTH TABLE:
INPUTS OUTPUTS
RESET CLK S R Q Qb CONDITION
1 X X X 0 1 Reset
0 1 0 0 Q Qb No change
0 1 0 1 0 1 Reset
0 1 1 0 1 0 Set
0 1 1 1 X X Invalid
2. JK FLIP FLOP
THEORY: The JK flip flop is basically a gated SR flip-flop with the addition of a clock input
circuitry that prevents the illegal or invalid output condition that can occur when both inputs S and
R are equal to logic level “1”.
LOGIC SYMBOL:
TRUTH TABLE:
INPUTS OUTPUTS
RESET CLK J K Q Qb CONDITION
1 X X X 0 1 Reset
0 1 0 0 Q Qb No change
0 1 0 1 0 1 Reset
0 1 1 0 1 0 Set
0 1 1 1 X X Invalid
case(JK)
2'b00 : Q = Q;
2'b01 : Q = 0;
2'b10 : Q = 1;
2'b11 : Q = ~Q;
endcase
end
Qb = ~Q;
end
endmodule
3. D FLIP FLOP
THEORY: The D stands for "data", this flip-flop stores the value that is on the data line. It can
be thought of as a basic memory cell. A D flip-flop can be made from a set/reset flip-flop by tying
the set to the reset through an inverter.
LOGIC SYMBOL:
TRUTH TABLE:
INPUTS OUTPUTS
1 X X 0 1 Reset
0 1 0 0 1 Reset
0 1 1 1 0 Set
4. T FLIP FLOP
THEORY: The T stands for "toggle", this flip-flop stores the value that is on the data line. It can
be thought of as a basic memory cell. A D flip-flop can be made from a set/reset flip-flop by tying
the set to the reset through an inverter.
LOGIC SYMBOL:
TRUTH TABLE:
INPUTS OUTPUTS
RESET CLK T Q Qb ACTION
1 X X 0 1 Reset
0 1 0 Q 𝑄 No change
0 1 1 𝑄 Q Toggle
WAVEFORM:
SR FLIP FLOP
JK FLIP FLOP
D FLIP FLOP
T FLIP FLOP
RESULT: SR, JK, D and T flip flop are realized using Verilog description.
Dept. of ECE, MIT Thandavapura page 55
BEC302 DSDV practical component of IPCC Academic Year 2024-25
PROGRAM 8
COUNTERS
AIM: To realize Counters - up/down (BCD and binary) using Verilog Behavioral description
THEORY: A binary coded decimal (BCD) is a serial digital counter that counts ten digits and it
resets for every new clock input. As it can go through 10 unique combinations of output, it is also
called as “Decade counter”. A BCD counter can count 0000 to 1001 and so on. The counter which
counts the sequence from 0000 to 1111 is called 4 bit binary counter.
Up counter counts from '0' to the highest number of counts. Down counter counts from the highest
value to the '0' value.
TRUTH TABLE:
1. BCD UP COUNTER
INPUTS OUTPUTS
4 BIT BCD UP COUNTER OUTPUTS DECIMAL
CLK RESET
Q3 Q2 Q1 Q0 EQUIVALENT
1 1 0 0 0 0 0
1 0 0 0 0 1 1
1 0 0 0 1 0 2
1 0 0 0 1 1 3
1 0 0 1 0 0 4
1 0 0 1 0 1 5
1 0 0 1 1 0 6
1 0 0 1 1 1 7
1 0 1 0 0 0 8
1 0 1 0 0 1 9
1 0 0 0 0 0 0
3. BINARY UP COUNTER
4 BIT BINARY UP COUNTER
OUTPUTS DECIMAL
CLK RESET
EQUIVALENT
Q3 Q2 Q1 Q0
1 1 0 0 0 0 0
1 0 0 0 0 1 1
1 0 0 0 1 0 2
1 0 0 0 1 1 3
1 0 0 1 0 0 4
1 0 0 1 0 1 5
1 0 0 1 1 0 6
1 0 0 1 1 1 7
1 0 1 0 0 0 8
1 0 1 0 0 1 9
1 0 1 0 1 0 10
1 0 1 0 1 1 11
1 0 1 1 0 0 12
1 0 1 1 0 1 13
1 0 1 1 1 0 14
1 0 1 1 1 1 15
1 0 0 0 0 0 0
3. BINARY UP COUNTER
DESIGN BLOCK [BEHAVIOURAL MODELLING]
module bcd_counter (clk, reset, q);
input clk, reset;
output [3:0]q;
reg [3:0]q;
initial q = 4’b0000;
always @ (posedge clk)
begin
if (reset = = 1)
q = 4’b0000;
else
q=q+1;
end
endmodule
Dept. of ECE, MIT Thandavapura page 60
BEC302 DSDV practical component of IPCC Academic Year 2024-25
WAVEFORM:
BCD UP COUNTER
BINARY UP COUNTER
RESULT: Binary and BCD up/down counters are realized using Verilog description.
1. Define counter.
2. Explain the 2 main types of counters.
3. What are the 2 ways of counting sequence in counter.
4. Define synchronous and asynchronous counter.
5. Explain the design of synchronous counter.
6. Give a another name of asynchronous counter.
7. List some of the applications of counter.
8. Counters have how many possible counting sequence.