`timescale 1ns/1ns
module encoder_83(
input [7:0] I ,
input EI ,
output wire [2:0] Y ,
output wire GS ,
output wire EO
);
assign Y[2] = EI & (I[7] | I[6] | I[5] | I[4]);
assign Y[1] = EI & (I[7] | I[6] | ~I[5]&~I[4]&I[3] | ~I[5]&~I[4]&I[2]);
assign Y[0] = EI & (I[7] | ~I[6]&I[5] | ~I[6]&~I[4]&I[3] | ~I[6]&~I[4]&~I[2]&I[1]);
assign EO = EI&~I[7]&~I[6]&~I[5]&~I[4]&~I[3]&~I[2]&~I[1]&~I[0];
assign GS = EI&(I[7] | I[6] | I[5] | I[4] | I[3] | I[2] | I[1] | I[0]);
//assign GS = EI&(| I);
endmodule
module encoder_164(
input [15:0] A ,
input EI ,
output wire [3:0] L ,
output wire GS ,
output wire EO
);
wire [7:0] in1,in2;
wire [2:0] temp1,temp2;
wire gs1,gs2,eo1,eo2;
assign in1=A[7:0];
assign in2=A[15:8];
encoder_83 u2(.I(in2),.EI(EI),.Y(temp2),.GS(gs2),.EO(eo2));
encoder_83 u1(.I(in1),.EI(eo2),.Y(temp1),.GS(gs1),.EO(eo1));
assign L[3]=gs2;
assign L[2:0]=temp1|temp2;
assign EO=eo1&eo2;
assign GS=gs1|gs2;
endmodule