1. 用Verilog HDL的行为描述设计一个带进位输入,输出的1位全加器

端口:A、B为加数,CI为进位输入,S为和,CO为进位输出

参考代码如下,
module add_1bit (a, b, ci, s, co)
input a, b, ci; //Ci为上个进位。
output reg s, co; //co为当前的进位,s为加结果
always@(*)
begin
co = (a&b) | (b&ci) | (ci&a);

if (ci)
s = ! (a^b);
else
s = (a^b);
end

endmodule
温馨提示:答案为网友推荐,仅供参考
相似回答