STD DLD Mux and de Mux
STD DLD Mux and de Mux
STD DLD Mux and de Mux
Sequential circuit:
comprises both logic gates and the state of
storage elements such as flip-flops.
The output of a sequential circuit depends not
only on present value of inputs but also on
past state of inputs.
MODULE- 4 ECE2003 – DIGITAL LOGIC DESIGN 2
INTRODUCTION TO COMBINATIONAL LOGIC
symbols.
4. Construction of a truth table for the given logic.
STEP3: The input & outputs are assign with letter symbols
Letter symbol for inputs: A, B, C
Letter symbol for output: Y
Inputs Outputs
Enable 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
Truth table
Logic Diagram
MO DULE-4 ECE2003 – DIGITAL LOGIC DESIGN 193
DECODERS
3 : 8 Decoders
A 3-to-8 line decoder has three inputs (A, B, C)
and eight outputs (Y0- Y7). Based on the 3 inputs
one of the eight outputs is selected.
Inputs Outputs
A B C Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
Truth table
Logic Diagram
MO DULE-4 ECE2003 – DIGITAL LOGIC DESIGN 196
DECODERS
Applications
Instruction decoder is the part of the CPU
209
ENCODERS
4 to 2 Priority Encoder
not n1(w[0],a[0]);
not n2(w[1],a[1]);
and (w[2],w[0], w[1]);
and (w[3],w[1], a[0]);
and (w[4],a[1], w[0]);
and (w[5],a[0],a[1]);
and (y[0],en, w[2]);
and (y[1],en, w[3]);
and (y[2],en, w[4]);
and (y[3],en, w[5]);
endmodule
2x4 decoder using Gate level model TB
////////////////////////////////
module decoder2x4gatelevel_tb();
reg [1:0]a;
reg en;
wire [3:0]y;
decoder2x4 uut (.y(y),.a(a),.en(en));
initial
begin
en=0; a= 2'b00; #100;
en=1; a = 2'b00; #100;
en=1; a = 2'b01; #100;
en=1; a = 2'b10; #100;
en=1; a = 2'b11; #100;
end
endmodule
2x4 decoder using Data flow model
module decoder(d0,d1,d2,d3,e,a0,a1);
input e,a0,a1;
output d0,d1,d2,d3;
assign d3= (e&a1&a0);
assign d2= (e&a1&~a0);
assign d1= (e&~a1&a0);
assign d0= (e&~a1&~a0);
endmodule
Decoder 2x4 ( Data flow TB)
//////////////////
module test();
reg e,a0,a1;
wire d0,d1,d2,d3;
decoder mydecoder(d0,d1,d2,d3,e,a0,a1);
initial
begin
e=0; a0= 1'b1;a1=1'b1;
#100
e=1; a0= 1'b0;a1=1'b0;
#100
e=1; a0= 1'b0;a1=1'b1;
#100
e=1; a0= 1'b1;a1=1'b0;
#100
e=1; a0= 1'b1;a1=1'b1;
end
endmodule
Decoder 2x4 using behavioural level
module decoder2x4(y,a,en);
input [1:0]a;
output [3:0]y;
input en;
reg [3:0]y;
always @ (a, en)
if (en==0)
y=1'b0;
else
case (a)
2'b00:y=4'b0001;
2'b01:y=4'b0010;
2'b10:y=4'b0100;
2'b11:y=4'b1000;
default : y=1'bx;
endcase
endmodule
2x4 decoder using behavioural level test bench
////////////
module decoder2x4beh_tb;
reg [1:0]a;
reg en;
wire [3:0]y;
decoder2x4 uut (.y(y),.a(a),.en(en));
initial
begin
en=0; a= 2'b00; #100;
en=0; a = 2'b00; #100;
en=0; a = 2'b01; #100;
en=0; a = 2'b10; #100;
en=0; a = 2'b11; #100;
end
endmodule
3x8 decoder using behavioural level
//Declare the Verilog module - The inputs and output port names.
module decoder3to8( Data_in, Data_out );
//what are the input ports and their sizes.
input [2:0] Data_in;
//what are the output ports and their sizes.
output [7:0] Data_out;
//Internal variables
reg [7:0] Data_out;
//Whenever there is a change in the Data_in, execute the always block.
always @(Data_in)
case (Data_in) //case statement. Check all the 8 combinations.
3'b000 : Data_out = 8'b00000001; 3'b001 : Data_out = 8'b00000010;
3'b010 : Data_out = 8'b00000100; 3'b011 : Data_out = 8'b00001000;
3'b100 : Data_out = 8'b00010000; 3'b101 : Data_out = 8'b00100000;
3'b110 : Data_out = 8'b01000000; 3'b111 : Data_out = 8'b10000000;
//To make sure that latches are not created create a default value for output.
default : Data_out = 8'b00000000;
endcase
endmodule
3x8 decoder using behavioural level test ben
module tb_decoder;
// Declaring Inputs
reg [2:0] Data_in;
// Declaring Outputs
wire [7:0] Data_out;
// Instantiate the Unit Under Test (UUT)
decoder3to8 uut (
.Data_in(Data_in),
.Data_out(Data_out)
);
initial begin
//Apply Input and wait for 100 ns
Data_in = 3'b000; #100; Data_in = 3'b001; #100;
Data_in = 3'b010; #100; Data_in = 3'b011; #100;
Data_in = 3'b100; #100; Data_in = 3'b101; #100;
Data_in = 3'b110; #100; Data_in = 3'b111; #100;
end
endmodule
8x3 decoder using behavioural level
module encoder8to31122( Data_in,Data_out);
always @(Data_in)
case (Data_in)
8'h01 : Data_out = 3'b000;
8'h02 : Data_out = 3'b001;
8'h04 : Data_out = 3'b010;
8'h08 : Data_out = 3'b011;
8'h10 : Data_out = 3'b100;
8'h20 : Data_out = 3'b101 ;
8'h40 : Data_out = 3'b110;
8'h80 : Data_out = 3'b111;
default : Data_out = 3'bxxx;
endcase
endmodule
Multiple Sources Selector Single Destination
MP3 Player
Docking Station
D0
Laptop
D1
MUX
Sound Card Y
D2
D3
Surround Sound System