Assignment#7
Assignment#7
1 How does a 4-to-2 Encoder function? Provide a truth table and explain.
Block diagram:
INPUTS OUTPUTS
Y3 Y2 Y1 Y0 A1 A0
1 0 0 0 0 0
0 1 0 0 0 1
0 0 1 0 1 0
0 0 0 1 1 1
A1=Y3+Y2
A0=Y3+Y1
S24CSEU0667,KESHAV SHRINGI
2. What is the difference between Decoder and Demultiplexer?
Solution:
Solution:
Verilog code for 2 to 4 line Decoder
module decoder_2_4(a,b,w,x,y,z);
output w,x,y,z;
input a,b;
assign z = a & b;
endmodule
TEST BENCH
module decoder_2_4_test;
reg a,b;
wire w,x,y,z;
decoder_2_4 decoder_2_4_test(a,b,w,x,y,z);
initial
begin
end
initial
begin
$monitor($time,"a=%b,b=%b,w=%b,x=%b,y=%b,z=%b",a,b,w,x,y,z);
End
Endmodule
4. What is priority encoder? Write Verilog code for an 8-to-3 priority encoder.
Solution:
Priority Encoder
The priority encoder is a combinational logic circuit that contains 2^n input
lines and n output line and represents the highest priority input among all the
input lines. When multiple input lines are active high at the same time, then the
input that has the highest priority is considered first to generate the output. It
is used to solve the issues in binary encoders, which generate wrong output
when more than one input line is active high. If more than one input line is
active high (1) at the same time, then this encoder prioritizes every input level
and allocates the priority level to each input.
Verilog code for 8-to-3 Priority Encoder
module priority_encoder_8to3 (
);
endcase
end
endmodule
TEST BENCH
module testbench;
initial begin
$stop;
End
Endmodule
Solution:
Verilog code
module decoder_3to8 (
input [2:0] in,
);
case (in)
Endcase
End
Endmodule
module boolean_function (
output F
);
wire F;
initial begin
$stop;
end
endmodule