DC Lab 4

Updated 4 Oct 2026

  • ไม่มีอะไรมาก ก็สอน VHDL ให้ลองใช้งานใน Logic Works 5
  • A Programmable Logic Device (PLD) is an integrated circuit (IC) designed to execute combinational and sequential logic circuits

The Half-Adders

Recall the basic rules for binary addition as stated in 02 Numbering Systems.

0+0=00+1=11+0=11+1=10\begin{align} 0+0&=0 \\ 0+1&=1 \\ 1+0&=1 \\ 1+1&=10 \end{align}

The operations are performed by a logic circuit called a half-adder.

A half-adder adds two bits and produces a sum and an output carry.

Half-Adder Logic

  • Expressions can be derived for the s um and the output carry as functions of the inputs.
    • สังเกตเอาง่าย ๆ ว่า CoutC_{out} จะเป็น 1 ก็ตอน both AA และ BB เป็น 1 Cout=ABC_{out}=AB
    • สังเกต Sum output (∑\sum) จะเป็น 1 ก็ตอเมื่อ AA และ BB ต้องไม่ใช่ตัวเดียวกัน (ต่างกันจริง) เหมือนอะไร ใช่แล้ววว XOR Gates ∑=A⊕B\sum = A\oplus B
    พอได้แบบนี้แล้ว ก็สามารถเขียน VHDL ได้เลยยย!

The Full-Adder

A full-adder has an input carry while the half-adder does not.

  • The basic difference between a full-adder and a half-adder is that the full-adder accepts an input carry.

Full-Adder Logic

  • The full-adder must add the two input bits and the input carry.
    • From the half-adder you know that the sum of the input bits AA and BB is the exclusive-ORof those two variables, A⊕BA\oplus B
    • The equation for the sum output of the full-adder (หรือถ้าไม่รู้วิธีการ หรือ มองไม่ออก ก็ทำ K-map เอา) ∑=(A⊕B)⊕Cin\sum = (A\oplus B)\oplus C_{in}
    • สำหรับ CoutC_{out}
      • ถ้าใช้ K-map ออกมาก็จะได้เป็น Cout=AC+BC+ABC_{out}=AC+BC+AB
      • หรือว่าจะมองจากคำตอบว่า CoutC_{out} จะเป็น 1 ก็ต่อเมื่อ first XOR gate เป็น 1, หรือ second XOR gate เป็น 1 จะได้ว่า Cout=AB+(A⊕B)CinC_{out}=AB+(A\oplus B)C_{in}
  • Arrangement of two half-adders to form a full-adder
  • ถ้าจะทำเป็น 4-bit adder เหมือนใน Lab 4 ก็ต้องใช้
    • Half 1 ตัว และ Full 3 ตัว
    • หรือ Full 4 ตัวเลยก็ได้
    • แต่จริง ๆ 4-bit adder ก็มี IC เป็นของตัวเองเลย คือ IC 7483 ซึ่งจะได้ใช้ใน DC Lab 5