题解 | #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        eo_msb;
wire        gs_msb,gs_lsb;
wire [2:0]  l_msb,l_lsb  ;

encoder_83 u_83_msb(
    .I (A[15:8]),
    .EI(EI),
    .Y (l_msb),
    .GS(gs_msb),
    .EO(eo_msb)
);

encoder_83 u_83_lsb(
    .I (A[7:0]),
    .EI(eo_msb),
    .Y (l_lsb),
    .GS(gs_lsb),
    .EO(eo_lsb)
);

assign L  = {gs_msb,l_msb|l_lsb};
assign GS = |(gs_msb||gs_lsb);
assign EO = &(eo_msb && eo_lsb);
endmodule
全部评论

相关推荐

02-16 01:39
南昌大学 Java
重剑Ds:感觉不太可能 后端都减飞了 根本不缺人
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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