Theory:
The 8 to 3 line Encoder is also known as Octal to Binary Encoder. In 8 to 3 line encoder, there is a total of eight inputs, i.e., Y0, Y1, Y2, Y3, Y4, Y5, Y6, and Y7 and three outputs, i.e., A0, A1, and A2. In 8-input lines, one input-line is set to true at a time to get the respective binary code in the output side. Below are the block diagram and the truth table of the 8 to 3 line encoder.
Block diagram:
Truth table:
BOOLEAN EXPRESSION FOR 8X3 ENCODER :
Verilog code:
module encoder_8_3( input[7:0]in, output reg[2:0]out ); always@(in) begin
input[7:0]i;
output[2;0]y;
assign y[2]=i[4]\i[5]\i[6]\i[7];
assign y[1]=i[2]\i[3]\i[6]\i[7];
assign y[0]=i[1]\i[3]\i[5]\i[7];
end endmodule
Test bench:
module testbench; reg [7:0] in; wire [2:0] out;
encoder_8_3
dut(.in(in), .out(out));
Initial begin
#0 in=8'b10000000;
#10 in=8'b01000000;
#10 in=8'b00100000;
#10 in=8'b00010000;
#10 in=8'b00001000;
#10 in=8'b00000100;
#10 in=8'b00000010;
#10 in=8'b00000001;
#10 in=8'b00000000;
end
initial
begin $monitor("in: %b out: %b ",in, out);
#100 $finish;
end endmodule
output:
Pin assignment:
RTL schematic:
Device utilization:
Timing analysis: