Difference between revisions of "Digital Tutorial Lesson 3: Building a Shift Register Using D Flip-Flops"

From Emagtech Wiki
Jump to: navigation, search
(Testing a D Flip-Flop)
(Building a 4-Bit Shift Register Using D Flip-Flops)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{projectinfo|Tutorial| Exploring Flip-Flops and Sequential Logic Circuits |TUT11-9.png|In this project, the basic concepts of RF.Spice A/D are demonstrated, and a simple voltage divider is modeled and examined.|
+
{{projectinfo|Tutorial| Exploring Flip-Flops and Sequential Logic Circuits |TUT11-7.png|In this project, the basic concepts of RF.Spice A/D are demonstrated, and a simple voltage divider is modeled and examined.|
  
 
*[[CubeCAD]]
 
*[[CubeCAD]]
Line 7: Line 7:
 
*[[EM.Tempo#Far Field Calculations in FDTD | Far Fields]]  
 
*[[EM.Tempo#Far Field Calculations in FDTD | Far Fields]]  
 
*[[Advanced Meshing in EM.Tempo]]  
 
*[[Advanced Meshing in EM.Tempo]]  
|All versions|{{download|http://www.emagtech.com/content/project-file-download-repository|EM.Tempo Lesson 1|[[EM.Cube]] 14.8}} }}
+
|All versions|{{download|http://www.emagtech.com/downloads/ProjectRepo/DigitalLesson3.zip Digital Lesson 3}} }}
  
<b>Exploring Flip-Flops and Sequential Logic Circuits</b>
+
=== What You Will Learn ===
 
+
=== Objective ===
+
  
 
In this tutorial lesson, first you will build SR flip-flop circuits out of logic gates. You will examine their truth table and use them to verify the operation of B2.Spice's own generic SR latch device. Then you will examine B2.Spice's D flip-flop device and will use four D flip-flops to design a 4-bit shift register. Finally, you will examine B2.Spice's JK flip-flop device and will use four JK flip-flops to design a 4-bit binary counter. You will use both the live timing diagrams and transient analysis in this tutorial lesson.   
 
In this tutorial lesson, first you will build SR flip-flop circuits out of logic gates. You will examine their truth table and use them to verify the operation of B2.Spice's own generic SR latch device. Then you will examine B2.Spice's D flip-flop device and will use four D flip-flops to design a 4-bit shift register. Finally, you will examine B2.Spice's JK flip-flop device and will use four JK flip-flops to design a 4-bit binary counter. You will use both the live timing diagrams and transient analysis in this tutorial lesson.   
  
=== Testing a D Flip-Flop ===
+
== Testing a D Flip-Flop ==
  
 
The following is a list of parts needed for this part of the tutorial lesson:
 
The following is a list of parts needed for this part of the tutorial lesson:
Line 41: Line 39:
 
| Period = 100ns, Pulse Width = 50ns
 
| Period = 100ns, Pulse Width = 50ns
 
|-
 
|-
! scope="row"| D1
+
! scope="row"| A1
 
| D-Type Flip-Flop
 
| D-Type Flip-Flop
 
| Defaults
 
| Defaults
 
|}
 
|}
  
This part of the tutorial lesson is very similar to the last part, except for replacing the SR latch with the D flip-flop. You will build a synchronous circuit with a digital clock and a single input as shown in the opposite figure. Set the "Period" of the clock to 100ns and its "Pulse Width" to 50ns. Connect the digital input device to the "D" pin of the flip-flop and the digital output device to its "Q" pin. The D flip-flop transfers the input data at its input to its Q output on the rising edge of the clock pulse. During the rest of the clock cycle, the output remains unchanged (hold state).
+
You will build a synchronous circuit with a digital clock and a single input as shown in the figure below. The keyboard shortcut for digital clock is {{key|Alt+C}}. Set the "Period" of the clock to 100ns and its "Pulse Width" to 50ns. Connect the digital input device to the "D" pin of the flip-flop and the digital output device to its "Q" pin. The D flip-flop transfers the input data at its input to its Q output on the rising edge of the clock pulse. During the rest of the clock cycle, the output remains unchanged (hold state).
  
 
<table>
 
<table>
Line 56: Line 54:
 
</table>
 
</table>
  
To understand the operation of the flip-flop circuit, you will use the "Live Digital Timing Diagram" feature of [[RF.Spice A/D]]. First, click the button labeled "'''...'''" on the '''[[Toolbars#Main_Toolbar| Main Toolbar]]''' on the left of the Run button or use the keyboard shortcut "Ctrl+I" to open the "Simulation Time Options" dialog. Set the step time to 20ns. Set the input initially to In1 = 0. Then, to activate the timing diagram, click the "'''Show/Hide Live Digital Timing Diagrams'''" [[File:b2Timing_Tool.png]] button of the '''[[Toolbars#Schematic_Toolbar |Schematic Toolbar]]'''. Remember that nothing will happen until you start a [[Digital Simulation|digital simulation]]. Click the "'''Step'''" [[File:b2Step_Tool.png]] button of the '''[[Toolbars#Main_Toolbar |Main Toolbar]]''' or use the keyboard shortcut "Ctrl+H" to advance the simulation time one step at a time. Step the simulation time to 60ns and then change the input to In1 = 1. Keep stepping to 160ns and then change the input to In1 = 0 again. Continue stepping to 400ns and change the input to In1 = 1 once again and then proceed to 600ns. The table below summarizes the input entries:   
+
[[File:TUT11-15.png|thumb|500px|The property dialog of the D-Type Flip-Flop device.]]
 
+
To understand the operation of the flip-flop circuit, you will use the "Live Digital Timing Diagram" feature of [[RF.Spice A/D]]. As you earned in the previous tutorial lesson, set the step time to 20ns. Set the input initially to In1 = 0. Then, to activate the timing diagram, click the "'''Show/Hide Live Digital Timing Diagrams'''" [[File:b2Timing_Tool.png]] button of the '''Schematic Toolbar'''. Remember that nothing will happen until you start a digital simulation. Click the "'''Step'''" [[File:b2Step_Tool.png]] button of the '''Main Toolbar''' or use the keyboard shortcut {{key|Ctrl+H}} to advance the simulation time one step at a time. Step the simulation time to 60ns and then change the input to In1 = 1. Keep stepping to 160ns and then change the input to In1 = 0 again. Continue stepping to 400ns and change the input to In1 = 1 once again and then proceed to 600ns. The table below summarizes the input entries:   
 
+
[[File:TUT11-6.png|thumb|800px|The digital timing diagram of the single D-Type Flip-Flop circuit.]]
+
[[File:TUT11-15.png|thumb|400px|The property dialog of the D-Type Flip-Flop device.]]
+
{{Note|The timing diagram updates only when there is a change of states of the inputs.}}
+
 
+
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 83: Line 76:
 
|}
 
|}
  
The timing diagram of your D flip-flop circuit is shown in the above figure. As you can see from the figure, the input first rises from 0 to 1 at t = 160ns. The flip-flop waits until the next rising edge of the clock signal at t = 200ns. The input's high state is transferred to the output Q with a propagation delay of 14ns. According to the property dialog of the D Flip-Flop device, the low-to-high propagation delay of the device is tPLH = 14ns, while its high-to-low propagation delay is tPHL = 1420ns. Therefore, Q rises from 0 to 1 at t = 214ns and stays high for the next several clock cycles. The input next falls from 1 to 0 at t = 260ns. The flip-flop waits until the next rising edge of the clock signal at t = 300ns. The input's low state is transferred to the output Q with a propagation delay of 20ns. Therefore, Q falls from 1 to 0 at t = 320ns and stays low for the next several clock cycles. The input rises again from 0 to 1 at t = 400ns and stay high for the rest of the simulation time. This time the flip-flop has to wait a full clock period until the next rising edge of the clock signal at t = 500ns. The input's high state is transferred to the output Q with a propagation delay of 14ns. Then, Q rises again from 0 to 1 at t = 514ns and stays high for the rest of the simulation time.
+
The timing diagram of your D flip-flop circuit is shown in the figure below. As you can see from the figure, the input first rises from 0 to 1 at t = 160ns. The flip-flop waits until the next rising edge of the clock signal at t = 200ns. The input's high state is transferred to the output Q with a propagation delay of 14ns. According to the property dialog of the D Flip-Flop device, the low-to-high propagation delay of the device is tPLH = 14ns, while its high-to-low propagation delay is tPHL = 1420ns. Therefore, Q rises from 0 to 1 at t = 214ns and stays high for the next several clock cycles. The input next falls from 1 to 0 at t = 260ns. The flip-flop waits until the next rising edge of the clock signal at t = 300ns. The input's low state is transferred to the output Q with a propagation delay of 20ns. Therefore, Q falls from 1 to 0 at t = 320ns and stays low for the next several clock cycles. The input rises again from 0 to 1 at t = 400ns and stay high for the rest of the simulation time. This time the flip-flop has to wait a full clock period until the next rising edge of the clock signal at t = 500ns. The input's high state is transferred to the output Q with a propagation delay of 14ns. Then, Q rises again from 0 to 1 at t = 514ns and stays high for the rest of the simulation time.
  
B2.Spice's digital timing diagrams are live graphs that evolve in real time. When you step the simulation for too long, the diagram exceeds the extents of your screen, and a horizontal scroll bar soon appears at the bottom of the diagram. To see the whole diagram without scrolling, you can zoom out its view horizontally. Click on the tab of the diagram at the bottom window to make its view active. The [[Toolbars#Graph_Toolbar|Graph Toolbar]] appears and replaces the [[Toolbars#Schematic_Toolbar|Schematic Toolbar]]. Click the "Zoom Out Horizontally" [[File:TUT11-16.png]] button of the [[Toolbars#Graph_Toolbar|Graph Toolbar]] to squeeze the timing diagram horizontally to the point it fits in the screen.
+
<table>
 +
<tr>
 +
<td>
 +
[[File:TUT11-6.png|thumb|720px|The digital timing diagram of the single D-Type Flip-Flop circuit.]]
 +
</td>
 +
</tr>
 +
</table>
  
=== Building a 4-Bit Shift Register Using D Flip-Flops ===
+
== Building a 4-Bit Shift Register Using D Flip-Flops ==
  
[[File:TUT11-7.png|thumb|500px|The 4-bit Shift Register circuit.]]
 
 
The following is a list of parts needed for this part of the tutorial lesson:
 
The following is a list of parts needed for this part of the tutorial lesson:
  
----
+
{| border="0"
 +
|-
 +
| valign="top"|
 +
|-
 +
{| class="wikitable"
 +
|-
 +
! scope="col"| Part Name
 +
! scope="col"| Part Type
 +
! scope="col"| Part Value
 +
|-
 +
! scope="row"| Data
 +
| Digital Input
 +
| 1-bit
 +
|-
 +
! scope="row"| B0 - B3
 +
| Digital Output
 +
| N/A
 +
|-
 +
! scope="row"| CLK
 +
| Digital Clock
 +
| Period = 100ns, Pulse Width = 50ns
 +
|-
 +
! scope="row"| A1 - A4
 +
| D-Type Flip-Flop
 +
| Defaults
 +
|}
  
Digital Input: Data (keyboard shortcut: N)
+
A shift register is a multi-output digital circuit that transfer the input data to its outputs sequentially at each clock cycle. Cascade the four D flip-flops as shown on the figure by connecting the Q pin of each to the D pin of the next. All four flip-flops share the same clock signal. Use the same clock settings from the previous part (Period = 100ns and Pulse Width = 50ns). Set the step time to 20ns. Enable the live digital timing diagram. Run a digital simulation and step through 1200ns. Set the value of the input "Data" to 0 and change it to 1 at t = 100ns and change it back to 0 at t = 600ns.
  
Digital Clock: CLK (keyboard shortcut: Alt+C)
+
<table>
 
+
<tr>
Four D-Type Flip-Flops
+
<td>
 
+
[[File:TUT11-7.png|thumb|640px|The 4-bit shift register circuit.]]  
Four Digital Output: B0, B1, B3 and B4 (keyboard shortcut: O)
+
</td>
 
+
</tr>
----
+
</table>
 
+
A shift register is a multi-output digital circuit that transfer the input data to its outputs sequentially at each clock cycle. Cascade the four D flip-flops as shown on the figure by connecting the Q pin of each to the D pin of the next. All four flip-flops share the same clock signal. Use the same clock settings from the previous part (Period = 100ns and Pulse Width = 50ns). Set the step time to 20ns. Enable the live digital timing diagram. Run a [[Digital Simulation|digital simulation]] and step through 1200ns. Set the value of the input "Data" to 0 and change it to 1 at t = 100ns and change it back to 0 at t = 600ns.
+
  
 
Your timing diagram will look like the figure below. As you can see from the figure, after the input is set high at t = 100ns for the first time, it takes the first flip-flop until the clock's next rising edge at t = 200ns to react. The first output B0 rises to 1 at t = 214ns (tPLH = 14ns). As the clock cycles proceed, the other outputs B1, B2 and B3, sequentially rise to 1 at t = 314ns, 414ns, and 514ns, respectively. All four outputs remain high for the next several clock cycles (at hold state).  
 
Your timing diagram will look like the figure below. As you can see from the figure, after the input is set high at t = 100ns for the first time, it takes the first flip-flop until the clock's next rising edge at t = 200ns to react. The first output B0 rises to 1 at t = 214ns (tPLH = 14ns). As the clock cycles proceed, the other outputs B1, B2 and B3, sequentially rise to 1 at t = 314ns, 414ns, and 514ns, respectively. All four outputs remain high for the next several clock cycles (at hold state).  
Line 113: Line 134:
 
<tr>
 
<tr>
 
<td>
 
<td>
[[File:TUT11-8.png|thumb|800px|The timing diagram of the 4-bit shift register circuit.]]  
+
[[File:TUT11-8.png|thumb|720px|The timing diagram of the 4-bit shift register circuit.]]  
 
</td>
 
</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
 
 
<p>&nbsp;</p>
 
<p>&nbsp;</p>
[[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D#RF.Spice_A.2FD_Tutorial | Back to RF.Spice A/D Tutorial Gateway]]'''
+
[[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D#RF.Spice_A.2FD_Tutorials | Back to RF.Spice A/D Tutorial Gateway]]'''

Latest revision as of 13:54, 4 November 2015

Tutorial Project: Exploring Flip-Flops and Sequential Logic Circuits
TUT11-7.png

Objective: In this project, the basic concepts of RF.Spice A/D are demonstrated, and a simple voltage divider is modeled and examined.

Concepts/Features:

Minimum Version Required: All versions

'Download2x.png Download Link: Digital Lesson 3

What You Will Learn

In this tutorial lesson, first you will build SR flip-flop circuits out of logic gates. You will examine their truth table and use them to verify the operation of B2.Spice's own generic SR latch device. Then you will examine B2.Spice's D flip-flop device and will use four D flip-flops to design a 4-bit shift register. Finally, you will examine B2.Spice's JK flip-flop device and will use four JK flip-flops to design a 4-bit binary counter. You will use both the live timing diagrams and transient analysis in this tutorial lesson.

Testing a D Flip-Flop

The following is a list of parts needed for this part of the tutorial lesson:

Part Name Part Type Part Value
In1 Digital Input 1-bit
Out1 Digital Output N/A
CLK Digital Clock Period = 100ns, Pulse Width = 50ns
A1 D-Type Flip-Flop Defaults

You will build a synchronous circuit with a digital clock and a single input as shown in the figure below. The keyboard shortcut for digital clock is Alt+C. Set the "Period" of the clock to 100ns and its "Pulse Width" to 50ns. Connect the digital input device to the "D" pin of the flip-flop and the digital output device to its "Q" pin. The D flip-flop transfers the input data at its input to its Q output on the rising edge of the clock pulse. During the rest of the clock cycle, the output remains unchanged (hold state).

The D-Type Flip-Flop device of RF.Spice A/D.
The property dialog of the D-Type Flip-Flop device.

To understand the operation of the flip-flop circuit, you will use the "Live Digital Timing Diagram" feature of RF.Spice A/D. As you earned in the previous tutorial lesson, set the step time to 20ns. Set the input initially to In1 = 0. Then, to activate the timing diagram, click the "Show/Hide Live Digital Timing Diagrams" B2Timing Tool.png button of the Schematic Toolbar. Remember that nothing will happen until you start a digital simulation. Click the "Step" B2Step Tool.png button of the Main Toolbar or use the keyboard shortcut Ctrl+H to advance the simulation time one step at a time. Step the simulation time to 60ns and then change the input to In1 = 1. Keep stepping to 160ns and then change the input to In1 = 0 again. Continue stepping to 400ns and change the input to In1 = 1 once again and then proceed to 600ns. The table below summarizes the input entries:

Time In1
0ns 0
160ns 1
260ns 0
400ns 1

The timing diagram of your D flip-flop circuit is shown in the figure below. As you can see from the figure, the input first rises from 0 to 1 at t = 160ns. The flip-flop waits until the next rising edge of the clock signal at t = 200ns. The input's high state is transferred to the output Q with a propagation delay of 14ns. According to the property dialog of the D Flip-Flop device, the low-to-high propagation delay of the device is tPLH = 14ns, while its high-to-low propagation delay is tPHL = 1420ns. Therefore, Q rises from 0 to 1 at t = 214ns and stays high for the next several clock cycles. The input next falls from 1 to 0 at t = 260ns. The flip-flop waits until the next rising edge of the clock signal at t = 300ns. The input's low state is transferred to the output Q with a propagation delay of 20ns. Therefore, Q falls from 1 to 0 at t = 320ns and stays low for the next several clock cycles. The input rises again from 0 to 1 at t = 400ns and stay high for the rest of the simulation time. This time the flip-flop has to wait a full clock period until the next rising edge of the clock signal at t = 500ns. The input's high state is transferred to the output Q with a propagation delay of 14ns. Then, Q rises again from 0 to 1 at t = 514ns and stays high for the rest of the simulation time.

The digital timing diagram of the single D-Type Flip-Flop circuit.

Building a 4-Bit Shift Register Using D Flip-Flops

The following is a list of parts needed for this part of the tutorial lesson:

Part Name Part Type Part Value
Data Digital Input 1-bit
B0 - B3 Digital Output N/A
CLK Digital Clock Period = 100ns, Pulse Width = 50ns
A1 - A4 D-Type Flip-Flop Defaults

A shift register is a multi-output digital circuit that transfer the input data to its outputs sequentially at each clock cycle. Cascade the four D flip-flops as shown on the figure by connecting the Q pin of each to the D pin of the next. All four flip-flops share the same clock signal. Use the same clock settings from the previous part (Period = 100ns and Pulse Width = 50ns). Set the step time to 20ns. Enable the live digital timing diagram. Run a digital simulation and step through 1200ns. Set the value of the input "Data" to 0 and change it to 1 at t = 100ns and change it back to 0 at t = 600ns.

The 4-bit shift register circuit.

Your timing diagram will look like the figure below. As you can see from the figure, after the input is set high at t = 100ns for the first time, it takes the first flip-flop until the clock's next rising edge at t = 200ns to react. The first output B0 rises to 1 at t = 214ns (tPLH = 14ns). As the clock cycles proceed, the other outputs B1, B2 and B3, sequentially rise to 1 at t = 314ns, 414ns, and 514ns, respectively. All four outputs remain high for the next several clock cycles (at hold state).

The input "Data" next falls from 1 to 0 at t = 600ns. It takes the first flip-flop until the clock's next rising edge at t = 700ns to react. The first output B0 fall from to 0 at t = 720ns (tPHL = 20ns). As the clock cycles proceed, the other outputs B1, B2 and B3, sequentially fall to 0 at t = 820ns, 902ns, and 1020ns, respectively. All four outputs remain low afterwards (at hold state).

The timing diagram of the 4-bit shift register circuit.

 

Back icon.png Back to RF.Spice A/D Tutorial Gateway