5. 3—8译码器 visio框图及仿真

(1)visio:

(2)Verilog代码:

module decoder3_8(in_1,in_2,in_3,out);

    input in_1;
    input in_2;
    input in_3;
    
    output reg [7:0]out;
    
    always@(*)
        case({in_1,in_2,in_3})
            3'd0:  out <= 8'b0000_0001;
            3'd1:  out <= 8'b0000_0010;
            3'd2:  out <= 8'b0000_0100;
            3'd3:  out <= 8'b0000_1000;
            3'd4:  out <= 8'b0001_0000;
            3'd5:  out <= 8'b0010_0000;
            3'd6:  out <= 8'b0100_0000;
            3'd7:  out <= 8'b1000_0000;
        endcase

endmodule

(3)RTL视图:

(4)仿真文件代码:

`timescale 1ns/1ns

module decoder3_8_tb;

    reg in_1;
    reg in_2;
    reg in_3;
    
    wire [7:0] out;
    
    decoder3_8 decoder3_8_inst(
        .in_1(in_1),
        .in_2(in_2),
        .in_3(in_3),
        .out(out)    
    );
    
    initial begin
        in_1 <= 1'd0;
        in_2 <= 1'd0;
        in_3 <= 1'd0;
        #2000;
        $stop;
    end
    
    always #10 in_1 <= {$random} % 2;
    always #10 in_2 <= {$random} % 2;
    always #10 in_3 <= {$random} % 2;
    

endmodule

(5)仿真波形:

  • 12
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值