7 或非门 —— 中科大 Verilog OJ
1 题目链接
https://verilogoj.ustc.edu.cn/oj/problem/54
2 题目要求
2.1 题目要求
创建一个 Verilog 模块,实现或非门的逻辑功能。模块名为 top_module,有两个 1 位输入 a 和 b,一个 1 位输出 out。要求使用 assign 语句实现逻辑。

2.2 题目代码模板
module top_module(
input a,
input b,
output out );
// 请用户在下方编辑代码
// 用户编辑到此为止
endmodule
3 题解
以下是实现或非门的 Verilog 代码,使用 assign 语句直接赋值逻辑表达式。
module top_module(
input a,
input b,
output out );
// 请用户在下方编辑代码
assign out = ~(a | b);
// 用户编辑到此为止
endmodule
代码解释:
assign out = ~(a | b);这一行实现了或非门逻辑。a | b表示 a 和 b 的或操作,~表示取反,因此整体是或非操作。- 该代码符合题目要求,使用
assign语句进行连续赋值。
留下评论