8:3 ENCODER with priority
(5TH SEM ECE HDL)
An encoder is a circuit that changes a set of signals into a code. Let’s begin making a 2-to-1 line encoder truth table by reversing the 1-to-2 decoder truth table
VERILOG CODE (ECE HDL )
module encoder8_3(en, a_in, y_op);
input en;
input [7:0] a_in;
output [2:0] y_op;
reg [2:0] y_op;
always @ (a_in,en)
begin
if(en==1 )
y_op =3’bzzz;
else
case (a_in)
8'b00000001: y_op = 3'b000;
8'b00000010: y_op = 3'b001;
8'b00000100: y_op = 3'b010;
8'b00001000: y_op = 3'b011;
8'b00010000: y_op = 3'b100;
8'b00100000: y_op = 3'b101;
8'b01000000: y_op = 3'b110;
8'b10000000: y_op = 3'b111;
default: y_op =3'bxxx;
endcase
end
endmodule
TRUTH TABLE


No comments:
Post a Comment