没说寄存器和门的数量或者总类,你看这样行不行:
module add1(clk,carryin,cstage,carryout,nstage);
input carryin;
input cstage;
input clk;
output carryout;
output nstage;
wire carryout;
wire nstage;
reg carryout_reg;
reg nstage_reg;
always@(posedge clk)
begin
case({carryin,cstage})
2'b00: {carryout_reg,nstage_reg} <= 00;
2'b01: {carryout_reg,nstage_reg} <= 01;
2'b10: {carryout_reg,nstage_reg} <= 01;
2'b11: {carryout_reg,nstage_reg} <= 10;
default: {carryout_reg,nstage_reg} <= {carryout_reg,nstage_reg};
endcase
end
assign carryout = carryout_reg;
assign nstage = nstage_reg;
endmodule
附 quartus综合RTL
|