题解 |使用8线-3线优先编码器Ⅰ实现16线-4线优先编码器

使用8线-3线优先编码器Ⅰ实现16线-4线优先编码器

https://www.nowcoder.com/practice/dcfa838e43de4744bc976abee96dc566

`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 [2:0] L1,L0;
wire GS1,GS0,EO1,EO0;
encoder_83 u1 (.I(A[15:8]),.EI(EI),.Y(L1),.GS(GS1),.EO(EO1));
encoder_83 u0 (.I(A[7:0]),.EI(EI),.Y(L0),.GS(GS0),.EO(EO0));
assign L = ((&L1)|GS1)?L1+8:L0;
assign GS = GS1|GS0;
assign EO = EO1&EO0;
endmodule

当A的高8为都为00000001时,L1不能为0,因为A为0时,L1、L0为0;A为00000000_1xxxxxxx时L1为0,L0为111。

所以L1最小为。

全部评论

相关推荐

酷酷的喜马拉雅山:感觉这比一直在初筛不动的好多了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务