题解 | #优先编码器Ⅰ#

优先编码器Ⅰ

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

`timescale 1ns/1ns

module encoder_83(
   input      [7:0]       I   ,
   input                  EI  ,
   
   output wire [2:0]      Y   ,
   output wire            GS  ,
   output wire            EO    
);

//从功能表中可以看到,当EI 为0的时候,输出为0,
//当EI为1的时候,如果I==8'h0,则输出依旧为0
//当8-3译码,输入为8’h01的时候,输出同样为0,
//于是需要标志位EO以及GS,来表示何种情况,
//如果是EI==1,且I==8'h0,此时EO=1表示
//如果EI==1,且I!=0,此时GS=1;

reg[3:0] Y_temp;
always@(*)begin
    casez(I)
    8'h00:Y_temp=3'h0;
    8'b1???_????:Y_temp=3'h7;
    8'b01??_????:Y_temp=3'h6;
    8'b001?_????:Y_temp=3'h5;
    8'b0001_????:Y_temp=3'h4;
    8'b0000_1???:Y_temp=3'h3;
    8'b0000_01??:Y_temp=3'h2;
    8'b0000_001?:Y_temp=3'h1;
    8'b0000_0001:Y_temp=3'h0;
    endcase
end

assign Y=EI?Y_temp:3'h0;
assign GS=EI==1 && I!=0;
assign EO=EI==1 && I==0;







endmodule

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 11:30
点赞 评论 收藏
分享
06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
07-07 11:33
江南大学 Java
已经在暑假实习了 ,没有明确说有hc,纠结实习到八月份会不会有点影响秋招毕竟感觉今年好多提前批
程序员小白条:92的话准备提前批,其他没必要,没面试机会的,而且你要准备充分,尤其八股和算法题
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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