Digital Logic Fundamentals · Lecture 1
Introduction, Number Conversions & Binary Arithmetic
مقدمة، تحويلات الأرقام، والحساب الثنائي
Analog vs Digital Number Systems Binary Arithmetic ملزمة ثنائية اللغة
ACADEZI
www.acadezi.com
Detailed Teaching Guide · دليل تدريس مفصّل
طرق التقييم وسياسة الدرجات Assessment Methods and Grading Policy §1
الموضوع Topic الدرجات Point النسبة Percent
Midterm Exam2020%
Quizzes1515%
Laboratory2525%
Assignments1010%
Final exam (Theory and Lab)3030%
Total100100%
الكميات التناظرية والرقمية Digital and Analog Quantities §2
في العلوم والتكنولوجيا نتعامل باستمرار مع الكميات، ومن المهم تمثيل قيمها بكفاءة ودقة. هناك طريقتان أساسيتان لتمثيل القيم العددية: التناظرية (Analog) والرقمية (Digital).
In science and technology, we constantly deal with quantities, and it is important to represent their values efficiently and accurately. There are basically two ways of representing numerical values: analog and digital.
Analog Quantities
الكميات التناظرية
  • تُمثل بمؤشر متغير باستمرار وبشكل متناسب (Continuous). يمكن أن تتغير عبر نطاق مستمر من القيم.
  • مثال: عداد سرعة السيارة (يتغير مع زيادة السرعة أو تباطؤها).
  • مثال: درجة الحرارة في مقياس الزئبق.
Represented by a continuously variable, proportional indicator. Can vary over a continuous range of values.
Examples:
• Car speedometer.
• Temperature on a mercury thermometer.
Digital Quantities
الكميات الرقمية
  • لا تُمثل بمؤشرات متغيرة باستمرار، بل برموز تُسمى الأرقام (Digits) في خطوات متقطعة (Discrete steps).
  • مثال: الساعة الرقمية (تتغير في خطوات متقطعة كل دقيقة/ثانية).
  • لا يوجد لبس عند قراءة القيمة الرقمية مقارنة بالتناظرية.
Represented not by continuously variable indicators but by symbols called digits in discrete steps.
Examples:
• Digital clock reading.
There is no confusion when reading a digital quantity compared to analog.
التحويل من تناظري إلى رقمي (A-D Conversion): في الواقع، عند أخذ قياس لكمية تناظرية، نقوم بتقريبه لمستوى دقة مناسب (نقوم برقمَنته Digitize). التمثيل الرقمي هو نتيجة تعيين عدد ذو دقة محدودة لكمية متغيرة باستمرار.
A-D Conversion: In practice, when measuring an analog quantity, we "round" to a convenient precision level (we digitize it). Digital representation assigns a number of limited precision to a continuously variable quantity.
الأرقام الثنائية، المستويات المنطقية والموجات Binary Digits, Logic Levels and Digital Waveforms §3
تُستخدم مستويات الجهد لتمثيل الأرقام الثنائية، حيث نُمثل المنطق العالي بـ HIGH (1) والمنطق المنخفض بـ LOW (0). تتكون الموجات الرقمية من نبضات (Pulses) لها حافة صاعدة (Rising edge) وحافة هابطة (Falling edge).
Voltage levels represent binary numbers: HIGH (binary 1) and LOW (binary 0). Digital waveforms consist of pulses with a rising/leading edge and a falling/trailing edge.
Waveform Characteristics
خصائص الموجات
  • الموجة الدورية (Periodic): تتكرر بانتظام. التردد (Frequency) يساوي 1 مقسوماً على الزمن الدوري (Period T).
  • الموجة غير الدورية (Nonperiodic): لا تتكرر بانتظام.
  • زمن البت (Bit time): الفترة الزمنية المخصصة لبت واحد في موجة الساعة (Clock).
Periodic: Repeats regularly. Frequency = 1 / Period (T).
Nonperiodic: Does not repeat regularly.
Bit time: The duration of one bit in a clock waveform.
A-D / D-A Process (Audio Example)
عملية التحويل (مثال: الصوت)
  • يمر الصوت (موجات تناظرية) عبر الميكروفون إلى محول رقمي (ADC) ليصبح بيانات رقمية تُخزن على القرص.
  • عند التشغيل، يمر عبر محول تناظري (DAC) ليخرج كصوت عبر المكبر.
Sound waves go through a Microphone -> ADC -> Digital data on CD. On playback: CD -> DAC -> Analog reproduction -> Speaker.
الدوال المنطقية الأساسية (Basic Logic Functions) Basic Logic Functions §4
البوابة Gate الدالة المنطقية Logic Function الحالات States
NOT تَعكس المدخل (العكس).Inverts the input. HIGH (1) → LOW (0)
LOW (0) → HIGH (1)
AND تُعطي 1 فقط إذا كانت جميع المداخل 1.Outputs 1 only if ALL inputs are 1. HIGH + HIGH = HIGH
HIGH + LOW = LOW
OR تُعطي 1 إذا كان أي مدخل 1.Outputs 1 if ANY input is 1. LOW + LOW = LOW
HIGH + LOW = HIGH
أنظمة الأرقام (Number Systems) Number Systems Overview §5
في جميع أنظمة الأرقام، يُستخدم التدوين الموضعي (Positional notation)، حيث يُضرب كل رقم في قوة الأساس المناسبة بناءً على موقعه. الرمز (R) هو الأساس (Base) ويجب أن يكون رقماً موجباً.
In all number systems, a positional notation is used, where each digit is multiplied by a power of the base depending on its position. R is the radix or base (must be a positive number).
Binary (Base 2)
Digits: [0, 1]
Octal (Base 8)
Digits: [0 .. 7]
Decimal (Base 10)
Digits: [0 .. 9]
Hex (Base 16)
Digits: [0..9, A..F]
تحويل الثنائي إلى عشري (Binary to Decimal) Binary to Decimal Conversion §6
يتم بجمع أوزان (Sum of weights) الخانات التي تحتوي على رقم 1. أوزان الأعداد الصحيحة هي قوى موجبة للعدد 2 (20, 21...) وأوزان الكسور هي قوى سالبة (2-1, 2-2...).
Determine the weight of each bit that is a 1, and sum the weights. Whole numbers use positive powers of 2, fractions use negative powers of 2.
Example: 1101101_2 to Decimal
Weight: 26 25 24 23 22 21 20 Binary: 1 1 0 1 1 0 1 = 26 + 25 + 23 + 22 + 20 = 64 + 32 + 8 + 4 + 1 = 10910
Example: Fractional Binary 0.1011_2 to Decimal
Weight: 2-1 2-2 2-3 2-4 Binary: 0. 1 0 1 1 = 2-1 + 2-3 + 2-4 = 0.5 + 0.125 + 0.0625 = 0.687510
تحويل العشري إلى ثنائي (Decimal to Binary) Decimal to Binary Conversion §7
  • للأعداد الصحيحة: نقسم العدد العشري تباعاً على 2 ونسجل الباقي (Remainder)، ونقرأ البواقي بترتيب عكسي.
  • للكسور: نضرب الكسر في 2 تباعاً ونسجل الرقم الصحيح (Carry) حتى نصل لصفر أو للدقة المطلوبة.
Whole numbers: Divide successively by 2 and note the remainder, read in reverse order.
Fractions: Repeatedly multiply by 2 and record the carry until fractional part is zero or desired precision is met.
Example: 19_10 to Binary
19 / 2 = 9 Remainder 1 (LSB) 9 / 2 = 4 Remainder 1 4 / 2 = 2 Remainder 0 2 / 2 = 1 Remainder 0 1 / 2 = 0 Remainder 1 (MSB) Result: 100112
النظام السداسي عشري (Hexadecimal) Hexadecimal Number System §8
يُستخدم الأحرف من A إلى F لتمثيل الأرقام العشرية من 10 إلى 15. للتحويل من ثنائي إلى سداسي عشري، نقسم الرقم الثنائي إلى مجموعات من 4 بت (من اليمين لليسار) ونستبدل كل مجموعة بالرقم المقابل.
Letters A through F represent decimal numbers 10 through 15. To convert Binary to Hex, group bits into sets of 4 (from right to left) and replace each with its hex equivalent.
Binary to Hexadecimal
Binary: 1100 1010 0101 0111
Hex: C A 5 7 = CA5716
Hexadecimal to Binary
Hex: 1 0 A 4
Binary: 0001 0000 1010 0100
Hex to Decimal & Decimal to Hex
# Hex to Decimal: Multiply by powers of 16 E516 = (14 × 16) + (5 × 1) = 224 + 5 = 22910 # Decimal to Hex: Repeated division by 16 650 / 16 = 40.625 → 0.625 × 16 = 10 → A (LSD) 40 / 16 = 2.5 → 0.5 × 16 = 8 → 8 2 / 16 = 0.125 → 0.125 × 16 = 2 → 2 (MSD) Result: 28A16
النظام الثماني (Octal Number System) Octal Number System §9
الأرقام المسموحة في الثماني هي من 0 إلى 7 (أساس 8). التحويل بين الثنائي والثماني يشبه السداسي عشري، ولكن نقسم البتات إلى مجموعات من 3 بت.
Allowed digits are 0 through 7 (Base 8). Converting between binary and octal is similar to hex, but we group bits into sets of 3 bits.
Binary to Octal
Binary: 110 101
Octal: 6 5 = 658
Octal to Binary
Octal: 1 3
Binary: 001 011
Octal to Decimal & Decimal to Octal
# Octal to Decimal: Multiply by powers of 8 23748 = (2 × 83) + (3 × 82) + (7 × 81) + (4 × 80) = 1024 + 192 + 56 + 4 = 127610 # Decimal to Octal: Repeated division by 8 359 / 8 = 44.875 → 0.875 × 8 = 7 (LSD) 44 / 8 = 5.5 → 0.5 × 8 = 4 5 / 8 = 0.625 → 0.625 × 8 = 5 (MSD) Result: 5478
نظام BCD (الرقم العشري المشفر ثنائياً) Binary-Coded-Decimal (BCD) §10
في نظام BCD، يُستبدل كل رقم عشري (من 0 إلى 9) بالمكافئ الثنائي المكون من 4 بتات مباشرة.
In BCD, each decimal digit (0 through 9) is replaced directly with its 4-bit binary equivalent.
Decimal to BCD Example
Decimal: 35 3 → 0011 5 → 0101 BCD: 0011 0101
كود غراي (Gray Code) Gray Code §11
عندما تتغير عدة بتات في نفس الوقت، قد تُفسر الدوائر الرقمية ذلك بشكل خاطئ. الجانب الفريد في كود Gray هو أن بت واحد فقط يتغير بين أي رقمين متتاليين.
When multiple bits change at the same time, digital circuits might misinterpret it. The unique aspect of Gray code is that only one bit ever changes between two successive numbers.
طريقة التحويل من ثنائي إلى Gray:
  • انسخ البت الأكثر أهمية (MSB) كما هو.
  • قارن كل بت مع البت الذي يليه: إذا كانا متشابهين، فالنتيجة 0. إذا كانا مختلفين، فالنتيجة 1.
Binary to Gray Conversion:
1. Keep the Most Significant Bit (MSB) the same.
2. Compare the MSB with the next bit: If same, output is 0. If different, output is 1.
كود ASCII (للأحرف) ASCII Code §12
هو الكود الأبجدي الرقمي الأكثر استخداماً لتبادل المعلومات. يتكون من 7 بتات، لذا يوفر 128 مجموعة رموز ممكنة لتمثيل أحرف لوحة المفاتيح والوظائف المختلفة.
The most widely used alphanumeric code for information interchange. It is a 7-bit code, so it has 128 possible code groups to represent all keyboard characters and functions.
وحدات البيانات الثنائية وتمثيل الجهد Binary Units & Voltage Representation §13
Bit, Nibble & Byte
البت وأجزاؤه
  • الرقم الثنائي الفردي يُسمى Bit.
  • مجموعة من 4 بت تُسمى Nibble.
  • مجموعة من 8 بت تُسمى Byte.
A single binary digit is a Bit. A 4-bit number is a Nibble. An 8-bit number is a Byte.
Word
الكلمة
الوحدة الكاملة للمعلومات تُسمى Word (تتكون عادة من 2 بايت أو أكثر).
A complete unit of information is a Word (generally consists of two or more bytes).
Voltage Levels
مستويات الجهد
سلك واحد يُحمل مستوى جهد لتمثيل البت. في نظام شائع: 0 فولت تعني '0' و +5 فولت تعني '1'.
A single wire assumes a voltage level to represent a bit. Common system: 0 volts = '0' and +5 volts = '1'.
الجمع الثنائي (Binary Addition) Binary Addition §14
قواعد الجمع للبتات الثنائية مع الحمل (Carry):
Addition rules for binary bits (with Carry):
عملية الجمع Additionالنتيجة Resultالتفسير Explanation
0 + 00Sum of 0 with a carry of 0
0 + 1 / 1 + 01Sum of 1 with a carry of 0
1 + 110Sum of 0 with a carry of 1
1 + 1 + 111Sum of 1 with a carry of 1
الطرح الثنائي (Binary Subtraction) Binary Subtraction §15
قواعد الطرح للبتات الثنائية مع الاستلاف (Borrow):
Subtraction rules for binary bits (with Borrow):
عملية الطرح Subtractionالنتيجة Resultالتفسير Explanation
0 - 00No borrow needed
1 - 10No borrow needed
1 - 01No borrow needed
10 - 110 - 1 with a borrow of 1
الضرب الثنائي (Binary Multiplication) Binary Multiplication §16
الضرب الثنائي يشبه الضرب العشري المعتاد، ولكن أسهل بكثير لأننا نضرب فقط في 0 أو 1.
Binary multiplication is similar to standard decimal multiplication but much simpler since we only multiply by 0 or 1.
Multiplication Rules
0 × 0 = 0 0 × 1 = 0 1 × 0 = 0 1 × 1 = 1
Example: 11_2 x 11_2
1 1 x 1 1 ----- 1 1 (Partial product 1) 1 1 (Partial product 2, shifted) ----- 1 0 0 1 (Result = 9 in decimal)
مكملات الأرقام الثنائية (Complements) Complements of Binary Numbers §17
تُستخدم المكملات في الأنظمة الرقمية لتمثيل الأرقام السالبة وتبسيط عمليات الطرح.
Complements are used in digital systems to represent negative numbers and simplify subtraction operations.
1's Complement
المكمل الأول
يتم الحصول عليه ببساطة عن طريق عكس كل بت (تغيير 1 إلى 0 و 0 إلى 1).
Obtained simply by inverting each bit (change 1s to 0s and 0s to 1s).
2's Complement
المكمل الثاني
يتم الحصول عليه عن طريق إيجاد المكمل الأول ثم إضافة 1 إلى البت الأقل أهمية (LSB).
Obtained by finding the 1's complement and then adding 1 to the Least Significant Bit (LSB).
Example: Find 2's Complement of 10110010
Binary number: 1 0 1 1 0 0 1 0 1's Complement: 0 1 0 0 1 1 0 1 (Invert all bits) Add 1: + 1 ----------------- 2's Complement: 0 1 0 0 1 1 1 0