「HDLBits题解」Multiplexers

本专栏的目的是分享可以通过HDLBits仿真的Verilog代码 以提供参考 各位可同时参考我的代码和官方题解代码 或许会有所收益

题目链接:Mux2to1 - HDLBits

module top_module( 
    input a, b, sel,
    output out ); 
    assign out = sel ? b : a ; 
endmodule

题目链接:Mux2to1v - HDLBits

module top_module( 
    input [99:0] a, b,
    input sel,
    output [99:0] out );
    assign out = sel ? b : a ; 
endmodule

题目链接:Mux9to1v - HDLBits

module top_module( 
    input [15:0] a, b, c, d, e, f, g, h, i,
    input [3:0] sel,
    output reg [15:0] out );

    always @(*) begin
        case (sel)
            0 : out = a ; 
            1 : out = b ; 
            2 : out = c ; 
            3 : out = d ; 
            4 : out = e ; 
            5 : out = f ; 
            6 : out = g ; 
            7 : out = h ; 
            8 : out = i ; 
            default : out = '1 ; // Set all bits to 1
        endcase
    end

endmodule

题目链接:Mux256to1 - HDLBits

module top_module( 
    input [255:0] in,
    input [7:0] sel,
    output out );
    assign out = in[sel] ;
endmodule

题目链接:Mux256to1v - HDLBits

module top_module( 
    input [1023:0] in,
    input [7:0] sel,
    output reg [3:0] out );

    always @(*) begin
        integer i ; 
        for (i = 0 ; i <= 3 ; i = i + 1)
            out[i] = in[sel * 4 + i] ;
    end

endmodule

相关推荐

  1. HDLBits题解Multiplexers

    2024-01-16 15:22:05       35 阅读
  2. HDLBits题解」Wire4

    2024-01-16 15:22:05       43 阅读
  3. HDLBits题解」Vector2

    2024-01-16 15:22:05       41 阅读
  4. HDLBits题解」Vector3

    2024-01-16 15:22:05       40 阅读
  5. HDLBits题解」Module

    2024-01-16 15:22:05       41 阅读
  6. HDLBits题解」Module shift

    2024-01-16 15:22:05       42 阅读
  7. HDLBits题解」Module add

    2024-01-16 15:22:05       30 阅读
  8. HDLBits题解」Counters

    2024-01-16 15:22:05       35 阅读
  9. HDLBits题解」Cellular automata

    2024-01-16 15:22:05       37 阅读
  10. HDLBits题解」Shift Registers

    2024-01-16 15:22:05       34 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-16 15:22:05       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-16 15:22:05       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-16 15:22:05       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-16 15:22:05       20 阅读

热门阅读

  1. 期刊会议机构区别

    2024-01-16 15:22:05       38 阅读
  2. 超形象图解Python NumPy

    2024-01-16 15:22:05       38 阅读
  3. 北京多家公司因数据泄露风险被罚

    2024-01-16 15:22:05       35 阅读
  4. 智慧校园云桌面解决方案简述

    2024-01-16 15:22:05       37 阅读
  5. 2024 CKA 题库 | 10、创建 PV

    2024-01-16 15:22:05       36 阅读
  6. Linux篇之Centos中将系统时间设置为本地时间

    2024-01-16 15:22:05       39 阅读
  7. 嵌入式工程师必须掌握的几种系统架构

    2024-01-16 15:22:05       32 阅读