代码
module encoder_164(
input [15:0] A ,
input EI ,
output wire [3:0] L ,
output wire GS ,
output wire EO
);
wire EO_hi, GS_hi, GS_lo;
wire [2:0] Y_lo, Y_hi;
encoder_83 Encoder_lo(.I(A[7 :0]), .EI(EO_hi), .Y(Y_lo), .GS(GS_lo), .EO(EO) );
encoder_83 Encoder_hi(.I(A[15:8]), .EI(EI), .Y(Y_hi), .GS(GS_hi), .EO(EO_hi));
assign L = {GS_hi, Y_lo|Y_hi};
assign GS = GS_hi | GS_lo;
endmodule
简析
8-3编码器见优先编码器Ⅰ。两片8-3编码器组合成16-4编码器可参考SNx4HC148 8-Line to 3-Line Priority Encoders
注意,本题的编码器逻辑是相反的,要注意更改。