วันศุกร์ที่ 26 กุมภาพันธ์ พ.ศ. 2559

Full adder

Full adder  คือ การบวกเลขฐานสอง
                          0 + 0 = 0
                          1 + 0 = 1
                          0 + 1 = 1
                          1 + 1 =  0 (ทด1)
                                  
                           เช่น 
                                         1 1                         
                                      0 0 1 1
                                                +
                                      1 0 0 1
                                      1 1 0 0    (3 + 9 = 12)

สมการ full adder


ตารางความจริง full adder


cr. https://en.wikipedia.org/wiki/Adder_(electronics)

code full-adder :
library ieee;
use ieee.std_logic_1164.all;
entity full_add is
port(
 a , b, c_in : in std_logic;
 c_out, sum : out std_logic);
end full_add;
architecture data_flow of full_add is
begin
 c_out <= ((a xor b) and c_in) or (a and b); -- ตามสมการfull adder หา carry out
 sum <= (a xor b) xor c_in; -- ตามสมการfull adder หาผลรวม
end data_flow;










ไม่มีความคิดเห็น:

แสดงความคิดเห็น