题解 | #使用8线-3线优先编码器Ⅰ实现16线-4线优先编码器#
使用8线-3线优先编码器Ⅰ实现16线-4线优先编码器
http://www.nowcoder.com/practice/dcfa838e43de4744bc976abee96dc566
两片8-3优先编码器实现16-4优先编码,考虑使用低八位EO控制第八位EI,当高八位进行八线三线编码时,低八位输出始终为000,当高八位输入为0时,低八位进行八线三线编码,高八位输出始终为000,因此输出L[2:0]即为高低输出按位相或,L[3]即为GS1。
`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 EO1,EO2,GS1,GS2;
wire [2:0] Y1,Y2;
encoder_83 u1
(.I(A[15:8]),
.EI(EI),
.Y(Y1),
.GS(GS1),
.EO(EO1)
);
encoder_83 u2
(.I(A[7:0]),
.EI(EO1),
.Y(Y2),
.GS(GS2),
.EO(EO2)
);
assign L = {GS1,Y1 | Y2};
assign GS = GS1 || GS2;
assign EO = EI & (~(|A));
endmodule
查看21道真题和解析