full adder
Create a full adder. A full adder adds three bits (including carry-in) and produces a sum and carry-out.
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

浙公网安备 33010602011771号