专栏/HDLBits (48) — 两个门

HDLBits (48) — 两个门

2022年02月21日 16:54--浏览 · --点赞 · --评论
粉丝:3402文章:240

本题链接:

https://hdlbits.01xz.net/wiki/Exams/m2014_q4g

面的电路实现:

题目

module top_module (
    input in1,
    input in2,
    input in3,
    output out);

答案

module top_module (
    input in1,
    input in2,
    input in3,
    output out);
    assign out = ~(in1 ^ in2) ^ in3;
endmodule

按位操作符包括:取反(~),与(&),或(|),异或(^),同或(~^)。

按位操作符对 2 个操作数的每 1bit 数据进行按位操作。

如果 2 个操作数位宽不相等,则用 0 向左扩展补充较短的操作数。

取反操作符只有一个操作数,它对操作数的每 1bit 数据进行取反操作。

下图给出了按位操作符的逻辑规则。

参考内容:

2.4 Verilog 表达式 | 菜鸟教程:

https://www.runoob.com/w3cnote/verilog-expression.html

投诉或建议