full adder

Create a full adder. A full adder adds three bits (including carry-in) and produces a sum and carry-out.

Fadd - HDLBits (01xz.net)

1 module top_module( 
2     input a, b, cin,
3     output cout, sum );
4 assign {cout,sum} = a + b + cin;
5     /*实现一个全加器。全加器将两位比特相加(带进位)并产生一个1bit结果和一个进位*/
6 endmodule

 也可以这么写,那就是一个门电路逻辑,一个是抽象代码的区别

module top_module( 
    input a, b, cin,
    output cout, sum );
    assign sum=a^b^cin;
    assign cout=(a&b)|(a&cin)|(cin&b);
endmodule

 

posted @ 2023-04-22 12:14  江左子固  阅读(12)  评论(0)    收藏  举报