题解 | #实现3-8译码器①#

实现3-8译码器①

https://www.nowcoder.com/practice/89659f98cb124362b1c816f06d5235d0

`timescale 1ns/1ns

module decoder_38(
   input             E1_n   ,
   input             E2_n   ,
   input             E3     ,
   input             A0     ,
   input             A1     ,
   input             A2     ,
   
   output wire       Y0_n   ,  
   output wire       Y1_n   , 
   output wire       Y2_n   , 
   output wire       Y3_n   , 
   output wire       Y4_n   , 
   output wire       Y5_n   , 
   output wire       Y6_n   , 
   output wire       Y7_n   
);

reg Y0;
reg Y1;
reg Y2;
reg Y3;
reg Y4;
reg Y5;
reg Y6;
reg Y7;

always @ (*) begin
    if(~E3 | E2_n | E1_n) begin
        {Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b11111111;
    end
    else begin
        case({A2,A1,A0})
        3'b000:{Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b11111110;
        3'b001:{Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b11111101;
        3'b010:{Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b11111011;
        3'b011:{Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b11110111;
        3'b100:{Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b11101111;
        3'b101:{Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b11011111;
        3'b110:{Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b10111111;
        3'b111:{Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0} = 8'b01111111;
        endcase
    end
end

assign {Y7_n,Y6_n,Y5_n,Y4_n,Y3_n,Y2_n,Y1_n,Y0_n} ={Y7,Y6,Y5,Y4,Y3,Y2,Y1,Y0};

endmodule

全部评论

相关推荐

我在朝九晚六双休的联想等你:如果我是你,身体素质好我会去参军,然后走士兵计划考研211只需要200多分。
点赞 评论 收藏
分享
与火:这不接? 留子的钱不挣白不挣
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务