Professional Documents
Culture Documents
FALLSEM2022-23 BECE102L TH VL2022230104585 Reference Material I 10-09-2022 Module-3 PDF
FALLSEM2022-23 BECE102L TH VL2022230104585 Reference Material I 10-09-2022 Module-3 PDF
diagram
• From the truth table, the minterms are obtained for each
outputs(E3, E2, E1, E0).
• E3 = ∑m(5, 6, 7, 8, 9),
• E2 = ∑m(1, 2, 3, 4, 9),
• E1 = ∑m(0, 3, 4, 7, 8),
• E0 = ∑m(0, 2, 4, 6, 8,)
The minterms of each output in plotted in k-map and simplified
expression is obtained.
Multiplexers
MUX types
• 2-to-1 (1 selection line)
• 4-to-1 (2 selection line)
• 8-to-1 (3 selection line)
• 16-to-1 (4 selection line)
module m21(Y, D0, D1, S);
output Y;
endmodule
module m21(D0, D1, S, Y);
output Y;
assign Y=(S)?D1:D0;
endmodule
VIT UNIVERSITY 15
8 :1 Multiplexers
16
VIT UNIVERSITY 17
Multiplexer IC Package
▪ A 16-to-1 multiplexer
can be constructed from
five 4-to-1 multiplexers:
Problem: Construct a 16x1 multiplexer with two
8x1 and one 2x1 multiplexers. Use block diagrams
De-multiplexer
1:2 demux
1:8 Demux
1:16 demux
Encoder
17-09-2022 36
4 to 2 line Encoder
D0 D2
X X
D1 4:2 D3
D2 Encoder
Y
D3
Y
D1
X = D2 + D3
Y = D1 + D3
Verilog Code for 4- 2 Encoder:
// a 4-to-2 Encoder using Data Flow Modeling
// a 4-to-2 Encoder using Behavior Level Modeling
module encoder_4to2(x, y);
module encoder_4to2(x, y); input [3:0] x;
input [3:0] x; output reg [1:0] y;
output reg [1:0] y;
assign A= x[2] + x[3];
// the body of the 4-to-2 Encoder assign B = x[1] + x[3];
always @ (x)
begin endmodule
case (x)
4'b0001 : y = 2'b00;
4'b0010 : y = 2'b01; // a 4-to-2 Encoder using Structured Modeling
4'b0100 : y = 2'b10;
module encoder_4to2(x, y);
4'b1000 : y = 2'b11;
input [3:0] x;
endcase
output reg [1:0] y;
end
or(y[0], x[2],x[3]);
endmodule
or(y[1], x[1],x[3]);
endmodule
Test Bench for 4-2 Encoder:
endmodule
X= D4 + D5 + D6 + D7
Y= D2 + D3 + D6 + D7
Z= D1 + D3 + D5 + D7
Verilog Code for 8- 3 Encoder:
// a 8-to-3 Encoder using Behavior Level Modeling // a 8-to-3 Encoder using Data Flow Modeling
module encoder_8to3(x, y);
input [7:0] x; module encoder_8to3(x, y);
output reg [2:0] y; input [7:0] x;
output reg [2:0] y;
// the body of the 8-to-3 Encoder
always @ (x) assign A= x[4] + x[5]+x[6]+x[7];
begin assign B = x[2] + x[3]+x[6]+x[7];
case (x) assign C = x[1] + x[3]+x[5]+x[7];
8'h01 : y = 3'b000;
8'h02 : y = 3'b001; endmodule
8'h04 : y = 3'b010;
8'h08 : y = 3'b011;
8'h10 : y = 3'b100; // a 4-to-2 Encoder using Structured Modeling
8'h20 : y = 3'b101; module encoder_8to3(x, y);
8'h40 : y = 3'b110; input [7:0] x;
8'h80 : y = 3'b111; output reg [2:0] y;
default:y = 3'bxxx; or(y[0], x[4],x[5],x[6],x[7]);
endcase or(y[1], x[2],x[3],x[6],x[7]);
end or(y[1], x[1],x[3],x[5],x[7]);
endmodule endmodule
Test Bench for 8-3 Encoder:
endmodule
Types of Encoder:
Priority Encoder
Decimal to BCD Encoder:
Decimal to BCD Encoder:
Truth Table:
D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 A B C D
0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 1
0 0 0 0 0 0 0 1 0 0 0 0 1 0
0 0 0 0 0 0 1 0 0 0 0 0 1 1
0 0 0 0 0 1 0 0 0 0 0 1 0 0
0 0 0 0 1 0 0 0 0 0 0 1 0 1
0 0 0 1 0 0 0 0 0 0 0 1 1 0
0 0 1 0 0 0 0 0 0 0 0 1 1 1
0 1 0 0 0 0 0 0 0 0 1 0 0 0
1 0 0 0 0 0 0 0 0 0 1 0 0 1
Decimal to BCD Encoder:
Drawbacks of Encoder:
D0-bit skipped during encoding operation.
17-09-2022 48
4 to 2 Priority Encoder:
Where,
V Valid Bit
• The name decoderis also used in conjunction with some code converters
such as a BCD-to-seven segment decoder
Verilog Code for 2 - 4 Decoder:
endmodule
Verilog Code for 3- 8 Decoder:
// a 3-to-8 decoder with active-high output
module decoder_3to8_high(x,enable,y); // Test Bench for 3-to-8 Decoder
input [2:0] x; module decoder_3to8_Test;
input enable; reg [2:0] x;
output reg [7:0] y; wire [7:0] y;
// the body of the 3-to-8 decoder
always @ (x or enable) decoder_3to8_high d1(x, y);
initial
if (!enable) y = 8'h00; begin
x= 0;
else # 5 x = 3'b000;
case (x) #5 x = 3'b001;
3'b000 : y = 8'h01; #5 x = 3'b010;
3'b001 : y = 8'h02; #5 x = 3'b011;
3'b010 : y = 8'h04; # 5 x = 3'b100;
3'b011 : y = 8'h08; #5 x = 3'b101;
3'b100 : y = 8'h10; #5 x = 3'b110;
3'b101 : y = 8'h20; #5 x = 3'b111;
3'b110 : y = 8'h40;
3'b111 : y = 8'h80; end
endcase endmodule
endmodule
4:16 decoder
Implement the boolean expression F(A, B, C) = ∑ m(2, 3, 6, 7) using a
multiplexer.
Implement the boolean expression F(A, B, C) = ∑ m(0, 1, 3, 5, 7) using a
multiplexer.
• If the two minterms in a column are not circled, apply 0 to the
corresponding multiplexer input.
• If the two min terms are circled, apply 1 to the corresponding multiplexer
input.
• If the bottom minterm is circled and the top is not circled, apply A to the
corresponding multiplexer input.
• If the top minterm is circled and the bottom is not circled, apply A' to the
corresponding multiplexer input.
Implement the boolean expression F(A, B, C) = ∑ m(0, 2, 5, 6) using 4 : 1 multiplexer.
Implement F(A, B, C, D) = ∑ m(0, 1, 5, 6, 8, 10, 12, 15) using 8 : 1 multiplexer.
Implement a full-adder circuit with a decoder and two OR gates.
S(x, y, z) = Σ(1, 2, 4, 7)
C(x, y, z) = Σ(3, 5, 6, 7)
Example-01:
Implement Full Adder using 4x1 MUX
Sol:
Truth Table – Full Adder
Full Adder using 4x1 MUX:
4x1 MUX for Sum:
K-Map for Sum:
S1 = A S0 = B Sum (S)
0 0 I0 = Ci
0 1 I1 = Ci’
1 0 I2 = Ci’
1 1 I3 = Ci
Full Adder using 4x1 MUX:
K-Map for Carry(C0): 4x1 MUX for Carry:
S1 = A S0 = B Sum (S)
0 0 I0 = 0
0 1 I1 = Ci
1 0 I2 = Ci
1 1 I3 = 1
Example-02:
Obtain Logical Expression from 4x1 MUX
Truth Table:
A B Y1
0 0 I0 = C
0 1 I1 = C
1 0 I2 = 1
1 1 I3 = 0
Boolean Expression:
Example-03:
Implement Logic Gates using 2x1 MUX
Truth Table:
A Y
0 d0
1 d1
Note:
In given Data, Assign LSB for Select Lines & MSB for Input Data Lines
2) AND Gate using 2x1 MUX:
Y = A’ D0 + A D1
Truth Table:
3) OR Gate using 2x1 MUX:
Boolean Expression:
Y = A’ D0 + A D1
Implementation table
Apply variables B and C to the select lines. The procedures for implementing the function
are:
i. List the input of the multiplexer
ii. List under them all the minterms in two rows as shown below.
The first half of the minterms is associated with A’ and the second half with A. The given
function is implemented by encircling the minterms of the function and applying the
following rules to find the values for the inputs of the multiplexer.
1. If both the minterms in the column are not circled, apply 0 to the corresponding
input.
2. If both the minterms in the column are circled, apply 1 to the corresponding input.
3. If the bottom minterm is circled and the top is not circled, apply A to the input.
4. If the top minterm is circled and the bottom is not circled, apply A’ to the input.
Example-4
Implement the following Boolean function using 8:1 multiplexer.
F( P, Q, R, S)= ∑m (0, 1, 3, 4, 8, 9, 15)
Example-5
Sol:
Numbers display on 7-Segment Display: 7-Segment display:
7-Segment Display Decoder:
Truth Table for 7-Segment Display Decoder:
Obtain Simplified Boolean Expression for 7-Segment Decoder outputs by using K-Map:
Simplified Boolean Expression for 7-Segment Decoder outputs by using K-Map:
g = b3+b1b0’+b2’b1+b2b1’