HDLBits-9-to-1 multiplexer

本文档详细介绍了如何使用Verilog设计一个16位宽度的9-to-1多路复用器模块,当sel=0选择输入a,sel=1选择b,对于未使用的sel值(9-15),确保输出全部设置为1十六进制。在代码实现中,错误地尝试将所有输出设为16'd1,但正确做法应为16'hffff。
摘要由CSDN通过智能技术生成

Create a 16-bit wide, 9-to-1 multiplexer. sel=0 chooses a, sel=1 chooses b, etc. For the unused cases (sel=9 to 15), set all output bits to '1'.

module top_module( 
    input [15:0] a, b, c, d, e, f, g, h, i,
    input [3:0] sel,
    output [15:0] out );
    
    always @ (*) begin
        case(sel)
        	4'd0:out = a;
            4'd1:out = b;
            4'd2:out = c;
            4'd3:out = d;
            4'd4:out = e;
            4'd5:out = f;
            4'd6:out = g;
            4'd7:out = h;
            4'd8:out = i;
            default:out = 16'hffff;    
            //Error: out = 16'd1;  16'd1 is NOT equal to 16'hffff!!!
        endcase
    end

endmodule

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值