Difference between revisions of "Digital Tutorial Lesson 1: Examining Logic Gates"

From Emagtech Wiki
Jump to: navigation, search
(Placing Digital Parts)
(Analyzing the Propagation Delays)
 
(41 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{projectinfo|Tutorial| Building a Three-Input Digital AND Function |b2TUT4_1.png|In this project, the basic concepts of digital circuit simulation in RF.Spice A/D are demonstrated, and simple logic AND circuits are built and examined.|
+
{{projectinfo|Tutorial| Building a Three-Input Digital AND Function |DigiTUT1_5.png|In this project, the basic concepts of digital circuit simulation in RF.Spice A/D are demonstrated, and a simple logical AND circuit is built and examined.|
  
 
*Digital Circuit
 
*Digital Circuit
Line 5: Line 5:
 
*Live Simulation
 
*Live Simulation
 
*Live Digital Timing Diagram  
 
*Live Digital Timing Diagram  
|All versions|{{download|http://www.emagtech.com/content/project-file-download-repository|Digital Tutorial Lesson 1|[[RF.Spice A/D]] R15}} }}
+
*Binary State Transition
 +
*Propagation Delay
 +
|All versions|{{download|http://www.emagtech.com/downloads/ProjectRepo/DigitalLesson1.zip Digital Lesson 1}} }}
  
 
=== What You Will Learn ===
 
=== What You Will Learn ===
  
In this tutorial you will use generic inverter gates and two-input NAND gates to build two-input and three-input AND circuits. You will learn how to define digital inputs and outputs and use [[RF.Spice]]'s live digital timing diagrams. It is assumed that by this time you have already completed the first few analog tutorial lessons and are comfortable with navigating the [[RF.Spice A/D]] Workshop.
+
In this tutorial you will use generic inverter gates and two-input NAND gates to build a three-input AND circuit. You will learn how to define digital inputs and outputs and use RF.Spice's live digital timing diagrams. It is assumed that by this time you have already completed the first few analog tutorial lessons and are comfortable with navigating the [[RF.Spice A/D]] Workshop.
  
=== Placing Digital Parts ===
+
== Placing Digital Parts ==
  
 
To build your first digital circuit, you need the following parts:
 
To build your first digital circuit, you need the following parts:
Line 30: Line 32:
 
|-
 
|-
 
! scope="row"| In2
 
! scope="row"| In2
 +
| Digital Input
 +
| 1-bit
 +
|-
 +
! scope="row"| In3
 
| Digital Input
 
| Digital Input
 
| 1-bit
 
| 1-bit
Line 35: Line 41:
 
! scope="row"| Out1
 
! scope="row"| Out1
 
| Digital Output
 
| Digital Output
| 1-bit
+
| N/A
 
|-
 
|-
! scope="row"| A1
+
! scope="row"| A1 - A2
 
| Generic NAND Gate
 
| Generic NAND Gate
 
| Defaults
 
| Defaults
 
|-
 
|-
! scope="row"| A2
+
! scope="row"| A3 - A4
 
| Generic Inverter Gate
 
| Generic Inverter Gate
 
| Defaults
 
| Defaults
 
|}
 
|}
  
Open the "'''Parts Bin'''" by selecting the "'''Add Part'''" tab of the "'''Toolbox'''" or the left side panel. By default, the "'''Function'''" tab of the Part Bin is active. This means that parts are sorted based on their function. Open the "'''Digital Components'''" menu and select the "'''Gates...'''" item as shown below. All the logic gate parts and devices are listed in the Part Bin. Scroll down the list and find and select “'''74LS10D'''”, which is a three-input NAND gate. Either double-click the part's name or click the "'''Place Part'''" button at the bottom of the Parts Bin to place the device on your schematic. The program may ask which section of the package you want to select. Accept all the defaults. Repeat the same procedure as above and find and select “'''74LS04D'''”, which is an logic inverter.
+
{{Note|Unlike analog circuits that are excited using voltage or current sources, digital circuits require "'''Digital Input Ports'''", which can take either binary or hexadecimal data. In analog circuits, you measure node voltages and device currents. In digital circuits, you probe binary or hexadecimal data at "'''Digital Output Ports'''".}}
  
You can also locate parts by filtering. Click the button labeled "'''Extended Filter...'''" in the middle of the Add Part tab of the Toolbox. This opens up the '''Select Device Dialog'''. Type in part of the device's name into the "Name" field of the Filters. For instance, typing "74LS" or "LS10" will show only devices that contain that text somewhere in the name.
+
Digital input and output ports are generic and virtual parts. You can get them from the "'''Digital I/O'''" submenu of the "'''Parts Menu'''". Or you can easily place them in your circuit by typing the keyboard shortcut {{key|N}} for '''Digital Input''' and the keyboard shortcut {{key|O}} for '''Digital Output'''. Similar to all other parts or devices, digital input and output ports have property dialogs that can be accessed by double-clicking on them. By default, the digital input and output takes 1-bit binary data in decimal format (rather then hexadecimal). The keyboard shortcut for the NAND gate is {{key|Alt+A}}, and keyboard shortcut for the inverter gate is {{key|Alt+O}}.
  
{| border="0"
+
{{Note|You can use the keyboard's {{key|Space}} bar to "Repeat Place Device".}
|-
+
| valign="top"|
+
[[File:b2TUT4_2.png|thumb|left|300px]]
+
| valign="bottom"|
+
[[File:b2TUT4_3.png|thumb|left|300px]]
+
|-
+
|}
+
  
=== Defining Inputs/Outputs & Connecting the Parts ===
+
<table>
 +
<tr>
 +
<td> [[File:b2TUT4_4.png|thumb|360px|Digital Input Dialog.]] </td>
 +
<td> [[File:b2TUT4_6.png|thumb|360px|Digital Output Dialog.]] </td>
 +
</tr>
 +
</table>
  
[[File:b2TUT4_4.png|thumb|300px|Digital Input Dialog]]
+
Your project workspace at this point should like the figure below:
[[File:b2TUT4_6.png|thumb|300px|Digital Output Dialog]]
+
{{Note|Unlike analog and mixed-mode circuits that are excited using voltage or current sources, digital circuits require "'''Digital Input Ports'''" which can only take either binary or hexadecimal data.}}
+
  
Digital input and output ports are generic and virtual parts. You can get them from the "'''Digital I/O'''" submenu of the the "'''Parts Menu'''". Or you can easily place them in your circuit by typing the keyboard shortcut "'''N'''" for '''Digital Input''' and the keyboard shortcut "'''O'''" for '''Digital Output'''. Use the keyboard shortcut "N" to place your first input port to the left of the NAND gate. Then press the keyboard's "'''SPACE'''" bar to "Repeat Place Device" and place your second input port and repeat one more time to define the third input. Next, use the keyboard shortcut "O" to place your output port to the right of the inverter gate.  
+
<table>
 +
<tr>
 +
<td> [[File:DigiTUT1 1.png|thumb|500px|The digital parts placed in the Schematic Editor.]] </td>
 +
</tr>
 +
</table>
 +
 
 +
Finally, use one the wiring methods you learned in the earlier analog tutorial lessons to connect all the parts and I/O ports. At the end, you should have a digital circuit similar to the figure shown below. Straight wires can always be drawn by simply clicking on device pins and dragging a line out of the pins. For drawing bent lines and multi-segment lines, you have to use the '''Wire Tool'''.
  
{{Note|In analog and mixed-mode circuits, you measure node voltages and device currents. In digital circuits, you probe only binary or hexadecimal data at "'''Digital Output Ports'''".}}
+
<table>
 +
<tr>
 +
<td> [[File:DigiTUT1 2.png|thumb|550px|The finished digital circuit.]] </td>
 +
</tr>
 +
</table>
  
Similar to all other parts or device, digital input and output ports have property dialogs that can be accessed by double-clicking on them. The figure below shows the property dialog of the digital input and output, respectively. By default, the digital input takes 1-bit binary data in decimal format (rather then hexadecimal).
+
== Testing the Digital Circuit by Stepping Manually ==
  
Your circuit at this point should like the figure below:
+
Digital circuit simulation is a time domain simulation. Furthermore, it is an event-driven simulation. It means that the simulation engine waits for changes in the input(s) of the circuit and then updates the digital state of various nodes in response to those state changes. You can run a time domain simulation in three different modes: '''Step''', '''Walk''' or '''Run'''. "Stepping" increments time a single time step at a time. "Walking" is faster than stepping and increments time by multiple steps at a time determined using a "Walk Factor". "Running" is equivalent to the analog live simulation and continues indefinitely until you pause it or stop it and reset. The first thing you always do in a digital simulation is to set the time step size.  
{| border="0"
+
|-
+
| valign="top"|
+
[[File:b2TUT4_5.png|420px]]
+
|-
+
|}
+
 
+
Finally, use one the wiring methods you learned in the earlier tutorial lessons to connect all the parts and I/O ports. At the end, you should have a digital circuit similar to the figure shown at the beginning of this lesson. Straight wires can always be drawn by simply clicking on device pins and dragging a line out of the pins. For drawing bent lines and multi-segment lines, sometimes you have to use the '''Wire Tool'''.
+
  
=== Testing the Digital Circuit by Stepping Manually ===
 
 
{{Note|In digital circuit simulations, device propagation delays are typically in the order of nanoseconds. It is important to set the step size of the simulation so that each step still allows you to see the resulting changes without slowing the simulation too much. A step size of 20ns is suggested but can be adjusted from there.}}
 
{{Note|In digital circuit simulations, device propagation delays are typically in the order of nanoseconds. It is important to set the step size of the simulation so that each step still allows you to see the resulting changes without slowing the simulation too much. A step size of 20ns is suggested but can be adjusted from there.}}
  
Digital circuit simulation is a time domain simulation. Furthermore, it is an event-driven simulation. It means that the simulation engine waits for changes in the input(s) of the circuit and then updates the digital state of various nodes in response to those state changes. You can run a time domain simulation in three different modes: '''Step''', '''Walk''' or '''Run'''. "Stepping" increments time a single time step at a time. "Walking" is faster than stepping and increments time by multiple steps at a time determined using a "Walk Factor". "Running" is equivalent to the analog live simulation and continues indefinitely until you pause it or stop it and reset. The first thing you always do in a [[Digital Simulation|digital simulation]] is to set the time step size. Note that "'''Step Size'''" is different from "'''Step Ceiling'''". Step size specifies how large each time step of the simulation is when using the "Simulation Stepping" feature. Step Size does not factor into the simulation when running the engine in "'''Walk'''" or "'''Run'''" modes, where the simulation engine itself decides how large a step to take. On the other hand, Step Ceiling is the maximum value that you specify for the automatically calculated time step when a simulation is "Walked" or "Run".
+
[[File:b2TUT4_8.png|thumb|300px|The Simulation Time Options dialog.]]
 +
Also note that "'''Step Size'''" is different from "'''Step Ceiling'''". Step size specifies how large each time step of the simulation is when using the "Simulation Stepping" feature. Step Size does not factor into the simulation when running the engine in "'''Walk'''" or "'''Run'''" modes, where the simulation engine itself decides how large a step to take. On the other hand, Step Ceiling is the maximum value that you specify for the automatically calculated time step when a simulation is "Walked" or "Run".
  
To set the step size, go to '''Simulate Menu''' and select the "'''Time Options...'''" to open the Simulation Time Options Dialog. Or click the button labeled "'''...'''" on the '''[[Toolbars#Main_Toolbar|Main Toolbar]]''' on the left of the Run button as shown in the figure below. You can also use the keyboard shortcut "Ctrl+I" to open this dialog, which is shown below:  
+
To set the step size, go to '''Simulate Menu''' and select the "'''Time Options...'''" to open the Simulation Time Options Dialog. Or click the button labeled {{key|...}} on the '''Main Toolbat''' on the left of the Run button as shown in the figure below. You can also use the keyboard shortcut "Ctrl+I" to open this dialog, which is shown below:  
  
{| border="0"
+
<table>
|-
+
<tr>
| valign="top"|
+
<td>
[[File:b2TUT4_7.png|thumb|left|480px|Simulation Portion of Main Menu]]
+
[[File:b2TUT4_7.png|thumb|640px|The "Simulation" portion of Main Menu.]]
| valign="bottom"|
+
</td>
[[File:b2TUT4_8.png|thumb|left|270px|Simulation Time Options Dialog]]
+
</tr>
|-
+
</table>
|}
+
 
+
Set the "'''Time Step'''" to 20n, leave the "'''Walk Factor'''" at the default value of 2 and close the dialog. Now start the [[Digital Simulation|digital simulation]] by "Stepping" your digital circuit. Click the "'''Step'''" [[File:b2Step_Tool.png]] button of the '''[[Main toolbar|Main Toolbar]]''' or select "Step" from the "'''Simulate Menu'''" or simply use the keyboard shortcut "'''Ctrl+H'''". The simulation time will increase to 20ns, and the output’s value will change to 0. Note that all your three input have initial values of 0. The state of your circuit is shown in the figure below on the left. Next, change the value of Input 1 to 1 and leave the Input 2 and Input 3 at 0. During a live simulation, you can change the values of inputs by clicking on their "'''Up'''" and "'''Down'''" arrow buttons at their right end. Note that by changing the input values, the output doesn't change immediately. This is because you the engine is waiting for you to step the time to compute the next state of the circuit. Click the "'''Step'''" [[File:b2Step_Tool.png]] button or type "'''Ctrl+H'''" one more time. The simulation time increases to 40ns, but the output’s value stays at 0. This is expected as a three-input AND circuit requires all three inputs to be 1 to have an output of 1. The state of the circuit at t = 40s is shown below in the middle figure. Finally, change the values of Input 2 and Input 3 to 1. Step the simulation to 60ns. This time, the output changes to 1 as shown below in the figure on the right.       
+
 
+
{| border="0"
+
|-
+
| valign="bottom"|
+
[[File:b2TUT4_9.png|thumb|left|360px|State of Circuit at t = 20ns]]
+
| valign="bottom"|
+
[[File:b2TUT4_10.png|thumb|left|360px|State of Circuit at t = 40ns]]
+
| valign="bottom"|
+
[[File:b2TUT4_11.png|thumb|left|360px|State of Circuit at t = 60ns]]
+
|-
+
|}
+
 
+
Note that at each time step, the state of all the wire including the output of the NAND gate is displayed on the circuit.
+
  
=== Using Live Digital Timing Diagrams ===
+
Set the "'''Time Step'''" to 20n, leave the "'''Walk Factor'''" at the default value of 2 and close the dialog. Now start the digital simulation by "Stepping" your digital circuit. Click the "'''Step'''" [[File:b2Step_Tool.png]] button of the '''Main Toolbar''' or select "Step" from the "'''Simulate Menu'''" or simply use the keyboard shortcut {{key|Ctrl+H}}. The simulation time will increase to 20ns, and the output’s value will change to 0. Note that all your three inputs have initial values of 0. The state of your circuit is shown in the figure below on the left. Next, change the value of Input 1 to 1 and leave the Input 2 and Input 3 at 0. During a live simulation, you can change the values of inputs by clicking on their {{key|Up Arrow}} and {{key|Down Arrow}} buttons at their right end. Note that by changing the input values, the output doesn't change immediately. This is because the engine is waiting for you to step the time to compute the next state of the circuit. Click the "'''Step'''" [[File:b2Step_Tool.png]] button or type {{key|Ctrl+H}} one more time. The simulation time increases to 40ns, but the output’s value stays at 0. This is expected as a three-input AND circuit requires all three inputs to be 1 to have an output of 1. The state of the circuit at t = 40s is shown below in the middle figure. Finally, change the values of Input 2 and Input 3 to 1. Step the simulation to 60ns. This time, the output changes to 1 as shown below in the figure on the right. Note that at each time step, the state of all the wires including the output of the NAND gate is displayed on the circuit. The binary states are shown in small black box labels. You can also tell the state of a wire from its color. Blue is 0 and red is 1.
  
[[B2.Spice A/D]] allows you to view the state of your digital inputs and outputs graphically in real time using "'''Live Timing Diagrams'''". The timing diagrams appear at the bottom of the Workshop just like a regular graph. However, these are interactive "live" graphs that change and expand with every time step. For this part of the lesson, you keep the value of "Time Step" at 20ns. First, reset your simulation engine by clicking the "'''Stop/Reset'''" [[File:b2Stop_Tool.png]] button of the [[Main toolbar|Main Toolbar]], or using the keyboard shortcut "'''Ctrl+E'''". Also reset the values of all the three inputs to 0.  
+
<table>
 +
<tr>
 +
<td>
 +
[[File:DigiTUT1_3.png|thumb|550px|State of the digital circuit at t = 20ns with In1 = In2 = In3 = 0.]]
 +
</td>
 +
</tr>
 +
<tr>
 +
<td>
 +
[[File:DigiTUT1_4.png|thumb|550px|State of the digital circuit at t = 40ns with In1 = 1 and In2 = In3 = 0.]]
 +
</td>
 +
</tr>
 +
<tr>
 +
<td>
 +
[[File:DigiTUT1_5.png|thumb|550px|State of the digital circuit at t = 60ns with In1 = In2 = In3 = 1.]]
 +
</td>
 +
</tr>
 +
</table>
  
To activate the timing diagrams, click the "'''Show/Hide Live Digital Timing Diagrams'''" [[File:b2Timing_Tool.png]] button of the '''[[Schematic toolbar|Schematic Toolbar]]'''. Nothing happens immediately because you haven't started a [[Digital Simulation|digital simulation]] yet. Here is the game plan that you will follow next. You will set the values of each input to 1 sequentially, one at a time. You will increment three time steps between any two actions or events. Then, you will revert the values of the three inputs back to 0 sequentially, one at a time, in the reverse order, until all the three inputs are 0 again. The following table shows the timing of the events:
+
== Using Live Digital Timing Diagrams ==
  
[[File:b2TUT4_13.png|thumb|800px]]
+
[[RF.Spice A/D]] allows you to view the state of your digital inputs and outputs graphically in real time using "'''Live Timing Diagrams'''". The digital timing diagram appears at the bottom of the Workshop just like a regular graph. However, these are interactive "live" graphs that change and expand with every time step. For this part of the lesson, you keep the value of "Time Step" at 20ns. First, reset your simulation engine by clicking the "'''Stop/Reset'''" [[File:b2Stop_Tool.png]] button of the Main Toolbar. Also reset the values of all the three inputs to 0.
  
[[File:b2TUT4_14.png|thumb|400px|Property Dialog of the NAND Gate]]
+
To activate the timing diagrams, click the "'''Show/Hide Live Digital Timing Diagrams'''" [[File:b2Timing_Tool.png]] button of the '''Schematic Toolbar'''. Nothing happens immediately because you haven't started a digital simulation yet. Here is the game plan that you will follow next. You will set the values of each input to 1 sequentially, one at a time. You will increment three time steps between any two actions or events. Then, you will revert the values of the three inputs back to 0 sequentially, one at a time, in the reverse order, until all the three inputs are 0 again. The following table shows the timing of the events:
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 165: Line 169:
 
|}
 
|}
  
Start the [[Digital Simulation|digital simulation]] with all zero inputs and increment three time steps to 60ns. You will see that four timing diagrams appear at the bottom of the Workshop, one for each input and one for the output. In general every input and output port will have a timing diagram. Then, change the value of Input 1 to 1. Step again and you will see that the timing diagrams immediately get updated because the input states have now changed. Increment two more time steps to 120ns. Then, change the value of Input 2 to 1. Follow this recipe according to the above event table with 60ns intervals until all inputs are set to 0 again. The timing diagrams get updated after each change of state and the final diagrams are shown in the figure above. With a closer look at the output timing diagram, you will be able to see the propagation delay between the input and output ports. For example, at t = 180ns, when all three inputs are 1, you would expect to see the output to jump at 1. However, it take about 20ns for this to happen (at t = 200ns). To understand this, double-click on the NAND gate to open up its property dialog as shown above. You will see that 74LS10D has a "'''Low-to-High Propagation Delay'''" of 9ns and a "'''High-to-Low Propagation Delay'''" of 10ns. The 74LS04D Inverter has similar propagation delays. When Input 3 jumps to 1 at t = 180ns, it takes the NAND gate a propagation delay of 10ns to fall from its 1 state down to 0. Similarly, it takes the Inverter gate an additional  propagation delay of 9ns to rise from its 0 state up to 1. This makes a total delay of 19ns as you can see from the graph.        
+
Start the digital simulation with all zero inputs and increment three time steps to 60ns. You will see that four timing diagrams appear at the bottom of the Workshop, one for each input and one for the output. In general every input and output port will have a timing diagram. Then, change the value of Input 1 to 1. Step again and you will see that the timing diagrams immediately get updated because the input states have now changed. Increment two more time steps to 120ns. Then, change the value of Input 2 to 1. Follow this recipe according to the above event table with 60ns intervals until all inputs are set to 0 again. The timing diagrams get updated after each change of state and the final diagrams are shown in the figure below. Note that your timing diagram may expand too long to fit into the bottom graph window. In that case, click on the title of the graph window tab to make it the active window. The toolbar changes accordingly. Then click the "'''Zoom Out Horizontal'''" [[File:b2ZoomOutHoriz_Tool.png]] button of the Graph Toolbar to shrink the diagram until it has the right size for viewing.  
+
 
 
{{Note|The timing diagram updates only when there is a change of states of the inputs.}}
 
{{Note|The timing diagram updates only when there is a change of states of the inputs.}}
  
=== Running a Transient Test of the Digital Circuit ===
+
<table>
 +
<tr>
 +
<td> [[File:DigiTUT1 7.png|thumb|720px|The live digital timing diagram.]] </td>
 +
</tr>
 +
</table>
  
[[File:b2TUT4_16.png|thumb|400px]]
+
== Analyzing the Propagation Delays ==
[[File:b2TUT4_15.png|thumb|360px|Property Dialog of Digital Source]]
+
Since digital simulations take place in the time domain, you can also run a transient test on them. Recall from previous tutorial lessons that unlike live simulations, [[tests]] are preplanned simulation. In other words, in a test, the inputs are completely known and will not change during the period of time when the simulation engine is doing its job. At the end of a test, you will see the final results. Contrast this to a live [[Digital Simulation|digital simulation]], when the engine waits for you to make your next move. Then it responds to your action. For transient test of digital circuit, [[B2.Spice A/D]] offers another type of digital input called a "'''Digital Source'''". A digital source is indeed the same as a digital input except for the fact that it contains a preloaded "'''Time-Value Array'''". This means that a digital source knows in advance what values it will take at certain times during the simulation.
+
  
At this point, go back to your circuit and delete all the three digital inputs. Select each part and press the keyboard's '''Delete Key'''. Next, from the '''Parts Menu''', select the '''Digital I/O''' submenu and then select "'''Digital Source'''". Place the source in your circuit at the location where you used to have Input 1 and connect it to the same wire. Use the keyboard's '''SPACE Bar''' to duplicate the digital source twice and place them at the locations of the old Input 2 and 3. Your digital circuit should now look like the opposite figure.
+
With a closer look at the output timing diagram, you will be able to see the propagation delay between the input and output ports. For example, at t = 180ns, when all three inputs are 1, you would expect to see the output to jump at 1. However, it takes about 19ns for this to happen (at t = 199ns). To understand this, double-click on the NAND gate A2 and inverter gate A4 to open up their property dialogs as shown below. You will see that the generic NAND gate has a "'''Low-to-High Propagation Delay'''" of 11ns and a "'''High-to-Low Propagation Delay'''" of 7ns. The generic inverter gate has a "'''Low-to-High Propagation Delay'''" of 12ns and a "'''High-to-Low Propagation Delay'''" of 8ns.
  
Double-click the first digital source to open its property dialog as shown below. In the table titled "'''Edit Time-Value Array'''", enter the binary values of the source as a function of time according to the state table shown in the previous section. Enter time in nanoseconds and use the values in "Input 1" column for the first digital source. Similarly, open the property dialogs of the second and third digital sources and enter their time-value arrays using the values in the "Input 2" and "Input 3" columns of the above table, respectively.
+
<table>
 +
<tr>
 +
<td> [[File:DigiTUT1 6.png|thumb|540px|The property dialog of the generic NAND gate.]] </td>
 +
</tr>
 +
<tr>
 +
<td> [[File:DigiTUT1 8.png|thumb|540px|The property dialog of the generic inverter gate.]] </td>
 +
</tr>
 +
</table>
  
{{Note|The "Time-Value" array of a digital source can be conveniently loaded from a text file.}}         
+
When Input 3 jumps to 1 at t = 180ns, it takes the NAND gate A2 a propagation delay of 7ns to fall from its 1 state down to 0. Similarly, it takes the Inverter gate A4 an additional propagation delay of 12ns to rise from its 0 state up to 1. This makes a total delay of 19ns as you can see from the graph. At t = 240ns, the reverse of these events happens and gate A2 and A4 undergo the opposite transition types. The total propagation delay is still 19ns, and therefore, the output drops from 1 to 0 at t = 259ns. These events are summarized in the table below.           
 
+
{| border="0"
+
{| class="wikitable"
 
|-
 
|-
| valign="bottom"|
+
! scope="col"| Time
[[File:b2TUT4_17.png|thumb|left|220px|Edit Graph Dialog]]
+
! scope="col"| A2 Transition Type
| valign="bottom"|
+
! scope="col"| A2 Transition Delay
[[File:b2TUT4_18.png|thumb|left|220px|Edit Axis Dialog]]
+
! scope="col"| A4 Transition Type
 +
! scope="col"| A4 Transition Delay
 +
! scope="col"| Total Delay
 
|-
 
|-
 +
| t = 180ns
 +
| H -> L
 +
| 7ns
 +
| L -> H
 +
| 12ns
 +
| 19ns
 +
|-
 +
| t = 240ns
 +
| L -> H
 +
| 11ns
 +
| H -> L
 +
| 8ns
 +
| 19ns
 
|}
 
|}
 
[[File:b2TUT4_19.png|thumb|640px| The output graph of transient analysis of the digital circuit.]]
 
 
Next, bring up the '''Transient Test''' from the '''[[Tests]] Toolbox''', and set the [[parameters]] for the test as follows:
 
 
Start Time: 0
 
 
Stop Time: 420n
 
 
Linearize Step: 1n
 
 
Step Ceiling: 1n
 
 
Click the Run button to run the transient test. The following graph will appear at the bottom of the Workshop. This is indeed identical to the timing diagram you viewed in the previous step of the lesson. However, this digital graph is a regular [[B2.Spice A/D]] graph with full analysis and customization capability. For example, you can zoom in on the rising and falling edges of the pulses and examine the propagation delays.
 
 
 
=== Saving the Circuit ===
 
 
Save your first digital circuit using the keyboard shortcut "'''Ctrl+S'''" or by selecting "'''Save'''" from the '''File Menu'''. Since your circuit does not have a name yet, the program will prompt you for a name. Then quit the [[B2.Spice A/D]] and take a break. Congratulations! You have built a 3-input And function, similar to the 74LS11.
 
  
 
<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: Building a Three-Input Digital AND Function
DigiTUT1 5.png

Objective: In this project, the basic concepts of digital circuit simulation in RF.Spice A/D are demonstrated, and a simple logical AND circuit is built and examined.

Concepts/Features:

  • Digital Circuit
  • Logic Gate
  • Live Simulation
  • Live Digital Timing Diagram
  • Binary State Transition
  • Propagation Delay

Minimum Version Required: All versions

'Download2x.png Download Link: Digital Lesson 1

What You Will Learn

In this tutorial you will use generic inverter gates and two-input NAND gates to build a three-input AND circuit. You will learn how to define digital inputs and outputs and use RF.Spice's live digital timing diagrams. It is assumed that by this time you have already completed the first few analog tutorial lessons and are comfortable with navigating the RF.Spice A/D Workshop.

Placing Digital Parts

To build your first digital circuit, you need the following parts:

Part Name Part Type Part Value
In1 Digital Input 1-bit
In2 Digital Input 1-bit
In3 Digital Input 1-bit
Out1 Digital Output N/A
A1 - A2 Generic NAND Gate Defaults
A3 - A4 Generic Inverter Gate Defaults
Attention icon.png Unlike analog circuits that are excited using voltage or current sources, digital circuits require "Digital Input Ports", which can take either binary or hexadecimal data. In analog circuits, you measure node voltages and device currents. In digital circuits, you probe binary or hexadecimal data at "Digital Output Ports".

Digital input and output ports are generic and virtual parts. You can get them from the "Digital I/O" submenu of the "Parts Menu". Or you can easily place them in your circuit by typing the keyboard shortcut N for Digital Input and the keyboard shortcut O for Digital Output. Similar to all other parts or devices, digital input and output ports have property dialogs that can be accessed by double-clicking on them. By default, the digital input and output takes 1-bit binary data in decimal format (rather then hexadecimal). The keyboard shortcut for the NAND gate is Alt+A, and keyboard shortcut for the inverter gate is Alt+O.

Attention icon.png You can use the keyboard's Space bar to "Repeat Place Device".
Digital Input Dialog.
Digital Output Dialog.

Your project workspace at this point should like the figure below:

The digital parts placed in the Schematic Editor.

Finally, use one the wiring methods you learned in the earlier analog tutorial lessons to connect all the parts and I/O ports. At the end, you should have a digital circuit similar to the figure shown below. Straight wires can always be drawn by simply clicking on device pins and dragging a line out of the pins. For drawing bent lines and multi-segment lines, you have to use the Wire Tool.

The finished digital circuit.

Testing the Digital Circuit by Stepping Manually

Digital circuit simulation is a time domain simulation. Furthermore, it is an event-driven simulation. It means that the simulation engine waits for changes in the input(s) of the circuit and then updates the digital state of various nodes in response to those state changes. You can run a time domain simulation in three different modes: Step, Walk or Run. "Stepping" increments time a single time step at a time. "Walking" is faster than stepping and increments time by multiple steps at a time determined using a "Walk Factor". "Running" is equivalent to the analog live simulation and continues indefinitely until you pause it or stop it and reset. The first thing you always do in a digital simulation is to set the time step size.

Attention icon.png In digital circuit simulations, device propagation delays are typically in the order of nanoseconds. It is important to set the step size of the simulation so that each step still allows you to see the resulting changes without slowing the simulation too much. A step size of 20ns is suggested but can be adjusted from there.
The Simulation Time Options dialog.

Also note that "Step Size" is different from "Step Ceiling". Step size specifies how large each time step of the simulation is when using the "Simulation Stepping" feature. Step Size does not factor into the simulation when running the engine in "Walk" or "Run" modes, where the simulation engine itself decides how large a step to take. On the other hand, Step Ceiling is the maximum value that you specify for the automatically calculated time step when a simulation is "Walked" or "Run".

To set the step size, go to Simulate Menu and select the "Time Options..." to open the Simulation Time Options Dialog. Or click the button labeled ... on the Main Toolbat on the left of the Run button as shown in the figure below. You can also use the keyboard shortcut "Ctrl+I" to open this dialog, which is shown below:

The "Simulation" portion of Main Menu.

Set the "Time Step" to 20n, leave the "Walk Factor" at the default value of 2 and close the dialog. Now start the digital simulation by "Stepping" your digital circuit. Click the "Step" B2Step Tool.png button of the Main Toolbar or select "Step" from the "Simulate Menu" or simply use the keyboard shortcut Ctrl+H. The simulation time will increase to 20ns, and the output’s value will change to 0. Note that all your three inputs have initial values of 0. The state of your circuit is shown in the figure below on the left. Next, change the value of Input 1 to 1 and leave the Input 2 and Input 3 at 0. During a live simulation, you can change the values of inputs by clicking on their Up Arrow and Down Arrow buttons at their right end. Note that by changing the input values, the output doesn't change immediately. This is because the engine is waiting for you to step the time to compute the next state of the circuit. Click the "Step" B2Step Tool.png button or type Ctrl+H one more time. The simulation time increases to 40ns, but the output’s value stays at 0. This is expected as a three-input AND circuit requires all three inputs to be 1 to have an output of 1. The state of the circuit at t = 40s is shown below in the middle figure. Finally, change the values of Input 2 and Input 3 to 1. Step the simulation to 60ns. This time, the output changes to 1 as shown below in the figure on the right. Note that at each time step, the state of all the wires including the output of the NAND gate is displayed on the circuit. The binary states are shown in small black box labels. You can also tell the state of a wire from its color. Blue is 0 and red is 1.

State of the digital circuit at t = 20ns with In1 = In2 = In3 = 0.
State of the digital circuit at t = 40ns with In1 = 1 and In2 = In3 = 0.
State of the digital circuit at t = 60ns with In1 = In2 = In3 = 1.

Using Live Digital Timing Diagrams

RF.Spice A/D allows you to view the state of your digital inputs and outputs graphically in real time using "Live Timing Diagrams". The digital timing diagram appears at the bottom of the Workshop just like a regular graph. However, these are interactive "live" graphs that change and expand with every time step. For this part of the lesson, you keep the value of "Time Step" at 20ns. First, reset your simulation engine by clicking the "Stop/Reset" B2Stop Tool.png button of the Main Toolbar. Also reset the values of all the three inputs to 0.

To activate the timing diagrams, click the "Show/Hide Live Digital Timing Diagrams" B2Timing Tool.png button of the Schematic Toolbar. Nothing happens immediately because you haven't started a digital simulation yet. Here is the game plan that you will follow next. You will set the values of each input to 1 sequentially, one at a time. You will increment three time steps between any two actions or events. Then, you will revert the values of the three inputs back to 0 sequentially, one at a time, in the reverse order, until all the three inputs are 0 again. The following table shows the timing of the events:

Time Input 1 Input 2 Input 3
0ns 0 0 0
60ns 1 0 0
120ns 1 1 0
180ns 1 1 1
240ns 1 1 0
300ns 1 0 0
360ns 0 0 0

Start the digital simulation with all zero inputs and increment three time steps to 60ns. You will see that four timing diagrams appear at the bottom of the Workshop, one for each input and one for the output. In general every input and output port will have a timing diagram. Then, change the value of Input 1 to 1. Step again and you will see that the timing diagrams immediately get updated because the input states have now changed. Increment two more time steps to 120ns. Then, change the value of Input 2 to 1. Follow this recipe according to the above event table with 60ns intervals until all inputs are set to 0 again. The timing diagrams get updated after each change of state and the final diagrams are shown in the figure below. Note that your timing diagram may expand too long to fit into the bottom graph window. In that case, click on the title of the graph window tab to make it the active window. The toolbar changes accordingly. Then click the "Zoom Out Horizontal" B2ZoomOutHoriz Tool.png button of the Graph Toolbar to shrink the diagram until it has the right size for viewing.

Attention icon.png The timing diagram updates only when there is a change of states of the inputs.
The live digital timing diagram.

Analyzing the Propagation Delays

With a closer look at the output timing diagram, you will be able to see the propagation delay between the input and output ports. For example, at t = 180ns, when all three inputs are 1, you would expect to see the output to jump at 1. However, it takes about 19ns for this to happen (at t = 199ns). To understand this, double-click on the NAND gate A2 and inverter gate A4 to open up their property dialogs as shown below. You will see that the generic NAND gate has a "Low-to-High Propagation Delay" of 11ns and a "High-to-Low Propagation Delay" of 7ns. The generic inverter gate has a "Low-to-High Propagation Delay" of 12ns and a "High-to-Low Propagation Delay" of 8ns.

The property dialog of the generic NAND gate.
The property dialog of the generic inverter gate.

When Input 3 jumps to 1 at t = 180ns, it takes the NAND gate A2 a propagation delay of 7ns to fall from its 1 state down to 0. Similarly, it takes the Inverter gate A4 an additional propagation delay of 12ns to rise from its 0 state up to 1. This makes a total delay of 19ns as you can see from the graph. At t = 240ns, the reverse of these events happens and gate A2 and A4 undergo the opposite transition types. The total propagation delay is still 19ns, and therefore, the output drops from 1 to 0 at t = 259ns. These events are summarized in the table below.

Time A2 Transition Type A2 Transition Delay A4 Transition Type A4 Transition Delay Total Delay
t = 180ns H -> L 7ns L -> H 12ns 19ns
t = 240ns L -> H 11ns H -> L 8ns 19ns

 

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