Professional Documents
Culture Documents
OBJECTIVES
INTRODUCTION
A number of standard combinational logic functions have been developed for digital circuits
that represent many of the useful tasks that can be performed with digital circuits.
Decoders detect the presence of particular binary states and can activate other circuits
based on their input values or can convert an input code to a different output code.
Encoders generate a binary or binary coded decimal (BCD) code corresponding to an active
input.
Multiplexers and de-multiplexers are used for data routing. They select a transmission path
for incoming or outgoing data, based on a selection made by a set of binary-related inputs.
DECODERS
The general function of a decoder is to activate one or more circuit outputs upon detection
of a particular digital state. The simplest decoder is a single logic gate, such as a NAND or
AND, hose output activates when all its inputs are HIGH. When combined with one or more
inverters, a NAND or AND can detect any unique combination of binary input values. An
extension of this type of decoder is a device containing several such gates, each of which
responds to a different input state. Usually, for an n-bit input, there are 2n logic gates, each
of which decodes a different combination of input variables. Some types of decoders
translate binary inputs to other forms, such as the decoders that drive seven-segment
numerical displays. The decoder has one output for every segment in the display. These
segments illuminate in unique combinations for each input code
Page | 22
Digital System Design LAB 2
Figure 1 shows the logic circuit of a 2-line-to-4-line decoder. The circuit detects the
presence of a particular state of the 2-bit input D1D0, as shown by the truth table in Table
1. One and only one output is HIGH for any input combination, provided the enable input G
is LOW.
G(activelow) D0 D1 Y0 Y1 Y2 Y3
0 0 0 1 0 0 0
0 0 1 0 1 0 0
0 1 0 0 0 1 0
0 1 1 0 0 0 1
1 X X 0 0 0 0
Page | 23
Digital System Design LAB 2
Task1
A Verilog module is shown below. Create a new project using Xilinx ISE. Add this module to
project and verify it by simulating its behavior.
Begin
Case (sel)
End case
End
End module
Page | 24
Digital System Design LAB 2
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
Draw results from Test bench for 3 to 8 decoder? Indicate Input & Output signals?
Page | 25
Digital System Design LAB 2
Task2
A Verilog module is shown below. Create a new project using Xilinx ISE. Add this module to
project and verify it by simulating its behavior.
Always @ (sel)
Begin
Case (sel)
Encase
End
End module
Page | 26
Digital System Design LAB 2
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
Explain and record results for above Verilog module? How this module will be
implemented at hardware level?
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
Draw results from Test bench for 3 to 8 decoder? Indicate Input & Output signals?
Page | 27
Digital System Design LAB 2
PRIORITY ENCODER
Priority Encoder One solution to this problem is to assign a priority level to each input and, if
two or more are active, make the output code correspond to the highest-priority input. This
is called a priority encoder. Highest priority is assigned to the input whose subscript has the
logical value.
Always @ (sel)
Begin
End
End module
Page | 28
Digital System Design LAB 2
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
Page | 29
Digital System Design LAB 2
MULTIPLEXER
Multiplexers are used for a variety of applications, including selection of one data stream out
of several choices, switching multiple-bit data from several channels to one multiple bit
output, sharing data on one output over time, and generating bit patterns or waveforms.
In Verilog, you must be aware that Case statements can be full or not full, and they can
also be parallel or not parallel. A Case statement is:
Page | 30
Digital System Design LAB 2
Tasks
For each of the module given below create a project in Xilinx ISE .Add module to the
project. Now simulate this file using ISE Simulator. Next synthesize this file using XST.
Begin
Case (sel)
2'b00: o1 = i1;
2'b01: o1 = i2;
2'b10: o1 = i3;
2'b11: o1 = i4;
End case
End
End module
Page | 31
Digital System Design LAB 2
Begin
Case (sel)
2'b00: o1 = i1;
2'b01: o1 = i2;
2'b10: o1 = i3;
End case
End
End module
Begin
Case (2'b00)
sel1: o1 = i1;
sel2: o1 = i2;
End case
End
End module
Page | 32
Digital System Design LAB 2
4-to-1 1-Bit MUX Using IF Statement
Module v_multiplexers_1 (a, b, c, d, s, o);
Input a, b, c, d;
Input [1:0] s;
Output o;
Reg o;
Always @ (a or b or c or d or s)
Begin
If (s == 2'b00) o = a;
Else if (s == 2'b01) o = b;
Else if (s == 2'b10) o = c;
Else o = d;
End
End module
Input a, b, c, d;
Input [1:0] s;
Output o;
Reg o;
Always @ (a or b or c or d or s)
Begin
Case (s)
2’b00: o = a;
2’b01: o = b;
2’b10: o = c;
Page | 33
Digital System Design LAB 2
Default: o = d;
End case
End
End module
Input a, b, c, d;
Input [3:0] s;
Output o;
end module
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
Page | 34
Observations/Comments/Explanation of Results