المنطق التوافقي
مقدمة في الدوائر التوافقية، إجراءات التحليل والتصميم، تحويل الأكواد، والجامعات الثنائية (نصف الجامع والجامع الكامل).
Combinational Logic
Introduction to combinational circuits, analysis and design procedures, code conversion, and binary adders (Half Adder and Full Adder).
أهداف التعلم
- وصف الدوائر التوافقية وخصائصها.
- تحليل الدوائر التوافقية واستنتاج دوالها البولينية.
- تصميم الدوائر التوافقية بناءً على المواصفات المطلوبة.
- تحليل دائرة منطقية توافقية من خلال مخططها المنطقي.
- تصميم الجامع والطرح الثنائي (نصف الجامع).
- Describe Combinational Circuits.
- Analyze Combinational Circuits.
- Design Combinational Circuits.
- Given its logic diagram, know how to analyze a combinational logic circuit.
- Design Binary Adder-Subtractor (Half-adder).
1 الدوائر التوافقية
1 Combinational Circuits
دوائر منطقية تعتمد مخرجاتها فقط على المدخلات الحالية، مثل آلة حاسبة بسيطة لا تتذكر العمليات السابقة.
Logic circuits whose outputs depend ONLY on the present combination of inputs, like a simple calculator with no memory.
تتكون الدائرة التوافقية من بوابات منطقية تتفاعل مع قيم الإشارات عند مدخلاتها لإنتاج قيمة إشارة المخرج، مما يحول المعلومات الثنائية من بيانات الإدخال المعطاة إلى بيانات الإخراج المطلوبة.
لا تحتوي هذه الدوائر على مسارات تغذية راجعة (Feedback paths) أو عناصر ذاكرة.
بالنسبة لـ n من متغيرات الإدخال، هناك 2^n من المجموعات الممكنة، ويمكن تحديد الدائرة باستخدام جدول الحقيقة أو m من الدوال البولينية.
A combinational circuit consists of logic gates whose outputs at any time are determined from only the present combination of inputs.
It performs an operation that can be specified logically by a set of Boolean functions.
It has no feedback paths or memory elements.
For n input variables, there are 2^n possible combinations, and the circuit can be specified with a truth table or m Boolean functions.
الغياب التام لمسارات التغذية الراجعة هو ما يميز الدوائر التوافقية عن الدوائر التتابعية.
في الواقع المادي، توجد الإشارات كإشارات تناظرية، ولكن يتم تفسيرها كإشارات ثنائية (0 و 1).
أجهزة المحاكاة المنطقية تظهر فقط الأصفار والآحاد ولا تظهر الإشارات التناظرية الفعلية.
The strict absence of feedback paths is what distinguishes combinational circuits from sequential ones.
Physically, inputs and outputs exist as analog signals, but they are interpreted as binary logic 1 and 0.
Logic simulators abstract this away, showing only 0s and 1s.
| الدوائر التوافقية Combinational Circuits | الدوائر التتابعية Sequential Circuits | |
|---|---|---|
| الاعتمادية على المدخلات Input Dependency | تعتمد على المدخلات الحالية فقط Depends ONLY on present inputs | تعتمد على المدخلات الحالية والحالة السابقة Depends on present inputs AND past state |
| مسارات التغذية الراجعة Feedback Paths | لا توجد None | موجودة Present |
| عناصر الذاكرة Memory Elements | لا تحتوي على ذاكرة No memory | تحتوي على ذاكرة Contains memory |
لماذا لا يمكن استخدام الدوائر التوافقية لبناء عداد (Counter)؟ Why can't combinational circuits be used to build a counter?
لأن العداد يحتاج إلى تذكر حالته السابقة لزيادة القيمة، والدوائر التوافقية لا تحتوي على ذاكرة أو مسارات تغذية راجعة.
Because a counter needs to remember its previous state to increment it, and combinational circuits lack memory or feedback paths.
2 إجراءات التحليل
2 Analysis Procedure
عملية هندسة عكسية تبدأ من المخطط المنطقي للوصول إلى الدوال البولينية وجدول الحقيقة لفهم وظيفة الدائرة.
A reverse-engineering process starting from a logic diagram to derive Boolean functions and truth tables to understand the circuit's behavior.
الخطوة الأولى في التحليل هي التأكد من أن الدائرة توافقية وليست تتابعية (لا توجد مسارات تغذية راجعة). ثم يتم اتباع الخطوات التالية:
- تسمية جميع مخرجات البوابات التي تعتمد على المدخلات بأسماء ذات معنى وإيجاد دوالها.
- تسمية البوابات التي تعتمد على المدخلات والبوابات السابقة وإيجاد دوالها.
- تكرار العملية حتى يتم الحصول على مخرجات الدائرة النهائية.
- التعويض المتكرر للحصول على دوال المخرجات بدلالة متغيرات الإدخال فقط.
The first step is to ensure the circuit is combinational (no feedback paths). Then:
- Label all gate outputs that are a function of input variables.
- Label gates that are a function of inputs and previously labeled gates.
- Repeat until circuit outputs are obtained.
- By repeated substitution, obtain output Boolean functions in terms of input variables.
مجرد إيجاد الدالة البولينية لا يوفر دائمًا رؤية واضحة لسلوك الدائرة، لذا يُفضل استنتاج جدول الحقيقة مباشرة من المخطط المنطقي عن طريق تقييم المخرجات لكل مجموعة ممكنة من المدخلات.
Merely finding a Boolean representation doesn't always provide insight into behavior.
Obtaining the truth table directly from the logic diagram by evaluating outputs for all 2^n input combinations gives a complete behavioral map.
ماذا يحدث إذا اكتشفت مسار تغذية راجعة أثناء الخطوة الأولى من التحليل؟ What happens if you discover a feedback path during the first step of analysis?
يجب التوقف عن استخدام إجراءات تحليل الدوائر التوافقية، لأن الدائرة في هذه الحالة هي دائرة تتابعية تتطلب طرق تحليل مختلفة.
You must stop using combinational analysis procedures, as the circuit is sequential and requires different analysis methods involving state tables.
3 إجراءات التصميم
3 Design Procedure
تحويل المواصفات المطلوبة إلى مخطط منطقي فعلي ينجز المهمة.
Transforming required specifications into an actual logic diagram that performs the task.
يبدأ تصميم الدوائر التوافقية من تحديد الهدف وينتهي بمخطط الدائرة المنطقية. الخطوات هي:
- من المواصفات، حدد عدد المدخلات والمخرجات المطلوبة وقم بتعيين رمز لكل منها.
- استنتج جدول الحقيقة الذي يحدد العلاقة المطلوبة بين المدخلات والمخرجات.
- احصل على الدوال البولينية المبسطة لكل مخرج بدلالة متغيرات الإدخال.
- ارسم المخطط المنطقي وتحقق من صحة التصميم (يدويًا أو بالمحاكاة).
The design starts from specifications and culminates in a logic diagram. Steps:
- Determine required number of inputs and outputs and assign symbols.
- Derive the truth table defining the relationship.
- Obtain simplified Boolean functions for each output.
- Draw the logic diagram and verify correctness.
الخطوة الثالثة (التبسيط) حاسمة لتقليل تكلفة الأجهزة (Hardware cost).
استخدام خرائط كارنوف (K-maps) أو الطرق الجبرية يضمن استخدام أقل عدد ممكن من البوابات المنطقية.
Step 3 (simplification) is critical for minimizing hardware cost.
Utilizing K-maps or algebraic methods ensures the logic diagram uses the minimum number of gates and literals.
لماذا نعتبر خطوة التحقق (Verification) ضرورية في نهاية التصميم؟ Why is the verification step essential at the end of the design?
لضمان أن التبسيط الجبري أو رسم البوابات لم يغير الوظيفة الأصلية المحددة في جدول الحقيقة.
To ensure that algebraic simplification or gate drawing did not alter the original functionality specified in the truth table.
4 تحويل الأكواد (مثال: BCD إلى Excess-3)
4 Code Conversion (BCD to Excess-3)
دائرة تترجم البيانات من لغة ثنائية (مثل BCD) إلى لغة ثنائية أخرى (مثل Excess-3).
A circuit that translates data from one binary code (like BCD) to another (like Excess-3).
للتحويل من كود ثنائي A إلى كود ثنائي B، يجب أن توفر خطوط الإدخال تركيبة البتات للكود A وتولد خطوط الإخراج تركيبة البتات للكود B.
في مثال تحويل BCD إلى Excess-3، نستخدم 4 متغيرات إدخال (A, B, C, D) و 4 متغيرات إخراج (w, x, y, z).
نظرًا لأن BCD يستخدم فقط الأرقام من 0 إلى 9، فإن الحالات الست المتبقية (10 إلى 15) تعتبر حالات عدم اكتراث (Don't-care conditions).
To convert from code A to code B, input lines supply the bit combination of code A, and output lines generate code B.
In the BCD to Excess-3 example, there are 4 inputs (A, B, C, D) and 4 outputs (w, x, y, z).
Since BCD only represents decimal digits 0-9, the remaining 6 combinations (10-15) are don't-care conditions.
استخدام حالات عدم الاكتراث (X) في خرائط كارنوف يسمح بتبسيط الدوال البولينية بشكل كبير، حيث يمكن افتراض قيمتها 1 أو 0 بما يخدم تكوين مجموعات أكبر في الخريطة، مما يقلل من عدد البوابات المطلوبة.
Leveraging don't-care conditions (X) in K-maps allows for significant simplification of the Boolean functions.
By treating X as 1 or 0 strategically, larger groupings can be formed, reducing the final gate count.
ماذا سيحدث إذا اعتبرنا الحالات من 10 إلى 15 أصفارًا بدلاً من حالات عدم اكتراث؟ What would happen if we treated combinations 10-15 as zeros instead of don't-cares?
ستصبح الدوال البولينية أكثر تعقيدًا وستتطلب الدائرة بوابات منطقية أكثر، مما يزيد من التكلفة.
The Boolean functions would be more complex, requiring more logic gates and increasing hardware cost.
5 الجامع-الطرح الثنائي (نصف الجامع والجامع الكامل)
5 Binary Adder-Subtractor (Half & Full Adder)
نصف الجامع يجمع بتين فقط، بينما الجامع الكامل يجمع ثلاثة بتات (بتين + حمل سابق).
A Half Adder adds two bits, while a Full Adder adds three bits (two bits + previous carry).
العملية الحسابية الأساسية هي جمع رقمين ثنائيين.
الدائرة التوافقية التي تقوم بجمع بتين تسمى نصف الجامع (Half Adder). تحتاج إلى مدخلين (x, y) ومخرجين: المجموع (S) والحمل (C). المخرج C يكون 1 فقط عندما يكون كلا المدخلين 1.
الدائرة التي تجمع ثلاثة بتات (بتين أساسيين وحمل سابق) تسمى الجامع الكامل (Full Adder).
The most basic arithmetic operation is the addition of two binary digits.
A combinational circuit that performs the addition of two bits is a Half Adder. It has two inputs (x, y) and two outputs: Sum (S) and Carry (C). C is 1 only when both inputs are 1.
A circuit that adds three bits (two significant bits and a previous carry) is a Full Adder.
يمكن تنفيذ نصف الجامع باستخدام بوابة XOR للمجموع (S = x ⊕ y) وبوابة AND للحمل (C = xy).
هذا التنفيذ هو الأكثر كفاءة من حيث عدد البوابات مقارنة باستخدام بوابات AND و OR و NOT الأساسية.
The Half Adder can be efficiently implemented using an XOR gate for the Sum (S = x ⊕ y) and an AND gate for the Carry (C = xy).
This is much more hardware-efficient than using standard sum-of-products with AND/OR/NOT gates.
لماذا لا يمكننا بناء آلة حاسبة لجمع أرقام من 8 بت باستخدام أنصاف الجامعات فقط؟ Why can't we build an 8-bit calculator using only Half Adders?
لأن نصف الجامع لا يمتلك مدخلاً لاستقبال الحمل (Carry-in) من الخانة السابقة، وهو أمر ضروري عند جمع أرقام متعددة البتات.
Because a Half Adder lacks a carry-in input to receive the carry from the previous lower-order bit addition, which is necessary for multi-bit addition.