-3
module adder4(
output[3:0] sum,
output c_out, // carry out
input[3:0] a, b, // operands
input c_in); // carry in
wire [2:0] c_o;
full_adder fa1(c_o[0],sum[0],a[0],b[0],c_in);
full_adder fa2(c_o[1],sum[1],a[1],b[1],c_o[0]);
full_adder fa3(c_o[2],sum[2],a[2],b[2],c_o[1]);
full_adder fa4(c_out,sum[3],a[3],b[3],c_o[2]);
endmodule
module full_adder(
output sum,
output c_out, // carry out
input a,
input b,
input c_in); // carry in
wire sum1;
wire c_in1;
wire c_out2;
half_adder ha1(sum1,c_in1,a,b);
half_adder ha2(sum,c_out2,sum1,c_in);
or(c_out,c_out2,c_in1);
endmodule
module half_adder(
output sum,
output c_out, // carry out
input a,
input b);
assign sum=a^b;
assign c_out=a&&b;
endmodule
안녕하세요! 4 개의 가산기에서 4 비트 가산기를 만들려고했지만 잘못된 결과가 계속 나타납니다. a = 3, b = 8 일 때 합계가 11 대신 9가됩니다. 나는 실수를 보지 못합니다. 누군가 내가 여기서 잘못하고있는 것을 알아 낸 것입니까?4 비트 덧셈기가 잘못된 결과를 반환합니다.
감사합니다 : : 또한 인스턴스 배열을 활용할 수있는 D를, 나는하지 않았다 지금까지 그것을 깨달으십시오. –
이제 a = 8, b = 3 및 c_in = 1 일 때 12가됩니다. –
@lulia Dobra : 1) 환영합니다. 2) 12 점을 얻어야합니다. – toolic