المنطق التتابعي
مقدمة في الدوائر التتابعية، المواسك (Latches)، والنطاطات (Flip-Flops) بما في ذلك تصميمها ومبادئ عملها.
Sequential Logic
Introduction to sequential circuits, latches, and flip-flops including their design and working principles.
أهداف التعلم
- التمييز بين الدائرة التتابعية والدائرة التوافقية.
- فهم وظيفة ماسك SR، الماسك الشفاف، ونطاط D.
- معرفة كيفية استخدام الجدول المميز والمعادلة المميزة للنطاط.
- Know how to distinguish a sequential circuit from a combinational circuit.
- Understand the functionality of a SR latch, transparent latch, and D flip-flop.
- Know how to use the characteristic table and characteristic equation of a flip-flop.
1 الدوائر التتابعية
1 Sequential Circuits
دوائر رقمية تمتلك ذاكرة؛ تعتمد مخرجاتها على المدخلات الحالية والحالة السابقة.
Digital circuits with memory; their outputs depend on both current inputs and past states.
على عكس الدوائر التوافقية التي تعتمد مخرجاتها فورياً على المدخلات فقط، تعمل الدوائر التتابعية كعناصر تخزين تمتلك ذاكرة.
تتكون من دائرة توافقية متصلة بعناصر تخزين لتشكيل مسار تغذية راجعة (Feedback path).
المعلومات الثنائية المخزنة في هذه العناصر في أي وقت معين تحدد 'حالة' (State) الدائرة التتابعية.
Unlike combinational circuits whose outputs depend only and immediately on their inputs, sequential circuits act as storage elements and have memory.
They consist of a combinational circuit to which storage elements are connected to form a feedback path.
The binary information stored in these elements at any given time defines the 'state' of the sequential circuit.
تُصنف الدوائر التتابعية إلى متزامنة (Synchronous) وغير متزامنة (Asynchronous).
الدوائر المتزامنة تستخدم إشارة توقيت (Clock) لتحديث الحالة في لحظات زمنية محددة، مما يسهل تصميمها وتحليلها ويمنع مشاكل التزامن التي قد تحدث في الدوائر غير المتزامنة التي تتأثر بترتيب تغير المدخلات في أي لحظة.
Sequential circuits are classified into synchronous and asynchronous.
- Synchronous circuits use a timing device called a clock generator to update states at discrete instants of time, making them easier to design and analyze.
- Asynchronous circuits depend on input signals at any instant and the order in which they change, which can lead to race conditions.
| Combinational Circuits | Sequential Circuits | |
|---|---|---|
| الاعتمادية على المخرجات Output Dependence | تعتمد على المدخلات الحالية فقط Depends only on current inputs | تعتمد على المدخلات الحالية والحالة السابقة Depends on current inputs and past state |
| الذاكرة Memory | لا توجد ذاكرة No memory | تحتوي على عناصر تخزين (ذاكرة) Contains storage elements (memory) |
| مسار التغذية الراجعة Feedback Path | غير موجود Absent | موجود Present |
لماذا لا يمكننا بناء جهاز حاسوب باستخدام الدوائر التوافقية فقط؟ Why can't we build a computer using only combinational circuits?
لأن الحواسيب تحتاج إلى تخزين البيانات والتعليمات (الذاكرة) وتتبع تسلسل العمليات، وهو ما يتطلب دوائر تتابعية تحتفظ بالحالة.
Because computers need to store data and instructions (memory) and keep track of the sequence of operations, which requires sequential circuits that retain state.
2 المواسك (Latches)
2 Latches
عناصر تخزين أساسية تعمل بمستوى الإشارة (Level-sensitive) بدلاً من حافة النبضة.
Basic storage elements that operate with signal levels (level-sensitive) rather than clock transitions.
الماسك هو عنصر تخزين يمكنه الحفاظ على حالة ثنائية إلى أجل غير مسمى (طالما توفرت الطاقة) حتى يتم توجيهه بواسطة إشارة إدخال لتغيير حالته.
المواسك هي اللبنات الأساسية لبناء النطاطات (Flip-flops).
من أشهر أنواعها ماسك SR الذي يُبنى باستخدام بوابتي NOR أو NAND متقاطعتين.
A latch is a storage element that can maintain a binary state indefinitely (as long as power is delivered) until directed by an input signal to switch states.
Latches are the building blocks for flip-flops.
A common type is the SR latch, constructed with two cross-coupled NOR or NAND gates.
المشكلة الرئيسية في المواسك هي أنها تستجيب لتغيرات المدخلات طوال فترة تفعيل إشارة التمكين (Enable) أو مستوى الساعة.
هذا يعني أن أي تغيير في المدخلات خلال هذه الفترة سينعكس فوراً على المخرجات، مما يجعلها غير مناسبة للدوائر التتابعية المعقدة التي تتطلب تزامناً دقيقاً.
The main issue with latches is that they respond to input changes as long as the enable signal or clock level is active.
This transparency means any input change during this period immediately affects the output, making them unsuitable for complex sequential circuits that require precise synchronization.
| NOR SR Latch | NAND SR Latch | |
|---|---|---|
| المدخلات النشطة Active Inputs | نشط عند المستوى العالي (1) Active High (1) | نشط عند المستوى المنخفض (0) - يُسمى S'R' Active Low (0) - called S'R' |
| الحالة غير المحددة (الممنوعة) Indeterminate (Forbidden) State | S=1, R=1 S=1, R=1 | S=0, R=0 S=0, R=0 |
ماذا يحدث في ماسك SR (المبني بـ NOR) إذا كانت المدخلات S=1 و R=1؟ What happens in a NOR-based SR latch if inputs S=1 and R=1?
تحدث حالة غير محددة (Indeterminate state) حيث يصبح كل من Q و Q' صفراً، وهو ما ينتهك قاعدة أن أحدهما يجب أن يكون عكس الآخر.
An indeterminate state occurs where both Q and Q' become 0, violating the rule that they must be complements of each other.
3 ماسك D (D Latch)
3 D Latch
ماسك يمنع الحالة غير المحددة عن طريق ضمان عدم تساوي مدخلي S و R أبداً.
A latch that eliminates the indeterminate state by ensuring S and R inputs are never equal.
لحل مشكلة الحالة غير المحددة في ماسك SR، تم ابتكار ماسك D. يحتوي هذا الماسك على مدخلين فقط:
- D (البيانات)
- و En (التمكين).
يذهب المدخل D مباشرة إلى مدخل S، بينما يمر عبر بوابة نفي (Inverter) ليذهب إلى مدخل R.
- عندما يكون En=1، فإن المخرج Q يتبع المدخل D.
- وعندما يكون En=0، يحتفظ الماسك بحالته السابقة.
To eliminate the undesirable indeterminate state in the SR latch, the D latch ensures inputs S and R are never equal to 1 at the same time. It has two inputs:
- D (data)
- and En (enable).
The D input goes directly to S, and its complement goes to R.
- When En=1, output Q follows D.
- When En=0, it retains its previous state.
يُعرف ماسك D أيضاً بالماسك الشفاف (Transparent Latch) لأنه عندما يكون التمكين نشطاً، تظهر التغييرات في D مباشرة على Q.
هذه الشفافية مفيدة في بعض التطبيقات ولكنها تسبب مشاكل (Race conditions) إذا تم استخدامها في مسارات التغذية الراجعة المتزامنة، مما يستدعي استخدام النطاطات التي تعمل بحافة النبضة.
The D latch is also known as a transparent latch because when the enable is active, changes in D flow directly to Q.
While useful in certain applications, this transparency causes race conditions in synchronous feedback loops, necessitating the use of edge-triggered flip-flops.
كيف يحل ماسك D مشكلة الحالة غير المحددة الموجودة في ماسك SR؟ How does the D latch solve the indeterminate state problem of the SR latch?
باستخدام بوابة نفي (Inverter) بين مدخلي S و R، يضمن ماسك D أن المدخلين لا يمكن أن يكونا 1 في نفس الوقت أبداً.
By using an inverter between the S and R inputs, the D latch ensures that both inputs can never be 1 simultaneously.
4 النطاطات التي تعمل بحافة النبضة (Edge-Triggered Flip-Flops)
4 Edge-Triggered Flip-Flops
عناصر ذاكرة تغير حالتها فقط عند لحظة انتقال إشارة الساعة (من 0 إلى 1 أو العكس).
Memory elements that change state only during a clock signal transition (0 to 1, or 1 to 0).
النطاط (Flip-Flop) هو جهاز تخزين ثنائي مصمم للعمل بشكل صحيح داخل الدوائر التتابعية المتزامنة. مفتاح عمله هو أنه يُستفز (Triggered) فقط خلال انتقال الإشارة (حافة النبضة).
- الانتقال من 0 إلى 1 يسمى الحافة الموجبة (Positive edge)،
- والانتقال من 1 إلى 0 يسمى الحافة السالبة (Negative edge).
A flip-flop is a binary storage device designed to operate properly in synchronous sequential circuits. The key to its operation is that it triggers only during a signal transition (edge).
- The transition from 0 to 1 is the positive edge,
- and from 1 to 0 is the negative edge.
إحدى طرق بناء نطاط D يعمل بالحافة هي تكوين 'السيد والتابع' (Master-Slave). يتكون من ماسكي D وعاكس لإشارة الساعة.
- عندما تكون الساعة 1، يُفعل السيد ويأخذ قيمة D، بينما يُعطل التابع.
- وعندما تنزل الساعة إلى 0 (الحافة السالبة)، يُعطل السيد وتُنقل قيمته إلى التابع ليظهر على المخرج Q.
هذا يعزل المخرج عن المدخل أثناء تغير الإشارة.
One way to build an edge-triggered D flip-flop is the Master-Slave configuration, using two D latches and an inverter on the clock.
- When Clk=1, the master is enabled and tracks D, while the slave is disabled.
- On the negative edge (Clk goes to 0), the master is disabled (locking its value) and the slave is enabled, transferring the master's value to output Q.
This isolates input from output.
| Latches | Flip-Flops | |
|---|---|---|
| طريقة الاستجابة (Triggering) Triggering Method | حساسة لمستوى الإشارة (Level-sensitive) Level-sensitive | حساسة لحافة النبضة (Edge-triggered) Edge-triggered |
| الاستخدام في الدوائر المتزامنة Use in Synchronous Circuits | صعبة الإدارة بسبب الشفافية Difficult to manage due to transparency | مثالية للدوائر المتزامنة Ideal for synchronous circuits |
في نطاط D من نوع السيد والتابع (يعمل بالحافة السالبة)، هل يمكن أن يتغير المخرج Q إذا تغير المدخل D بينما إشارة الساعة تساوي 0؟ In a negative-edge triggered Master-Slave D flip-flop, can output Q change if input D changes while the clock is 0?
لا، لأن عندما تكون الساعة 0، يكون ماسك السيد معطلاً (معزولاً عن المدخل D)، وبالتالي لا يمكن لأي تغيير في D أن يصل إلى التابع أو المخرج Q.
No, because when the clock is 0, the master latch is disabled (isolated from input D), so no changes in D can reach the slave or output Q.