HDLBits练习(六)Verilog Language_More Verilog Features

Conditional

要求:给定四个无符号数,运用条件运算符得出最小的数。

条件运算符: ?:(问号前是条件判断式,若判断为真,则执行冒号前的语句;若为假,则执行冒号后的语句)

module top_module (
    input [7:0] a, b, c, d,
    output [7:0] min);
    
    wire [7:0] a_b, c_d;
    
    assign a_b = a < b ? a : b;
    assign c_d = c < d ? c : d;
    assign min = a_b < c_d ? a_b : c_d;

endmodule

Reduction

要求:进行偶校验,对输入进行按位异或即可。

module top_module (
    input [7:0] in,
    output parity); 

    assign parity = ^ in;

endmodule

Gates100

要求:分别实现100输入的and门,or门和xor门。

使用按位运算符即可。

module top_module( 
    input [99:0] in,
    output out_and,
    output out_or,
    output out_xor 
);
    assign out_and = & in;
    assign out_or = | in;
    assign out_xor = ^ in;

endmodule

Vec

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值