- Construct a truth table for a full adder and derive the Boolean equations of the outputs Cout and Sum.
- Based on the above results, design a full adder and verify the design with simulation.
[full_adder.v]
// Full Adder 정의
module full_adder(Sum, C_out, A, B, C_in);
// 포트 선언
input A, B;
input C_in;
output Sum;
output C_out;
/* output에 연산 결과를 연결하여 출력하도록 설정
앞의 문제에서 구한 Boolean Equation과 같이 연산하도록 입력*/
assign C_out = (A&B) | (A&C_in) | (B&C_in);
assign Sum = A ^ B ^ C_in; //
endmodule
[tb_full_adder.v]
// 시뮬레이션을 위한 testbench
module tb_full_adder;
// input을 reg, output을 wire로 선언
reg A, B;
reg C_in;
wire SUM;
wire C_out;
//full_adder 모듈 호출
full_adder u_full_adder(sum, C_out, A, B, C_in);
/* 시뮬레이션 결과 확인을 위해 모니터로 출력
$monitor는 신호의 값이 변할 때마다 출력 */
initial begin
$monitor($time, "A= %b, B= %b, C_in= %b, --- C_out= %b, sum = %b\n", A, B, C_in, C_out, sum);
end
initial begin
// A, B, C_in 모두 1비트 Binary, 0으로 초기값 설정
A = 1'b0; B = 1'b0; C_in = 1'b0;
/* 5만큼의 delay를 주면서 입력값 입력
앞의 문제에서 구한 Truth Table의 입력값을 모두 입력 */
#5 A = 1'b0; B = 1'b0; C_in=1'b1;
#5 A = 1'b0; B = 1'b1; C_in=1'b0;
#5 A = 1'b0; B = 1'b1; C_in=1'b1;
#5 A = 1'b1; B = 1'b0; C_in=1'b0;
#5 A = 1'b1; B = 1'b0; C_in=1'b1;
#5 A = 1'b1; B = 1'b1; C_in=1'b0;
#5 A = 1'b1; B = 1'b1; C_in=1'b1;
end
endmodule
아래의 입력값과 출력된 결과값을 확인해보면 앞의 문제에서 구한 Truth Table과 동일한 것을 알 수 있다.
본 프로젝트는 1-Bit Full Adder를 구현하는 프로젝트이다. 경우의 수가 2의 세제곱 즉, 8개이기 때문에 Truth Table을 그려서 Carry Out과 Sum의 결과값을 확인해 볼 수 있다.
또한 Truth Table을 토대로 Boolean Equation을 작성하여 결과값을 식으로 단순화하여 파악할 수 있다.
이 1-Bit Full Adder를 이용하여 1비트 이상의 수많은 Adder를 구현할 수 있다.
'Personal Project > Binary Adder 구현' 카테고리의 다른 글
04 4-Bit Adder with Carry-Lookahead 구현 (0) | 2023.06.21 |
---|---|
03 Parallel Adder Composed of Four Full Adders 구현 (0) | 2023.06.21 |
01 프로젝트 소개 / 이론 (0) | 2023.06.21 |
댓글