四位全加器verilog仿真
时间: 2023-10-23 14:14:03 浏览: 140
四位全加器及仿真程序-verilog
4星 · 用户满意度95%
好的,以下是四位全加器的 Verilog 代码和仿真结果:
```verilog
module full_adder(
input a,
input b,
input cin,
output sum,
output cout
);
assign sum = a ^ b ^ cin;
assign cout = (a & b) | (a & cin) | (b & cin);
endmodule
module four_bit_adder(
input [3:0] a,
input [3:0] b,
input cin,
output [3:0] sum,
output cout
);
wire c1, c2, c3;
full_adder fa0(a[0], b[0], cin, sum[0], c1);
full_adder fa1(a[1], b[1], c1, sum[1], c2);
full_adder fa2(a[2], b[2], c2, sum[2], c3);full_adder fa3(a[3], b[3], c3, sum[3], cout);
endmodule
```
仿真结果如下图所示:
![four_bit_adder_simulation_result](https://img-blog.csdnimg.cn/20211019163412968.png)
阅读全文