Ug937 Vivado Design Suite Simulation Tutorial
Ug937 Vivado Design Suite Simulation Tutorial
of this document
Logic Simulation
UG937 (v2024.1) June 12, 2024
Introduction
This AMD Vivado™ Design Suite tutorial provides designers with an in-depth introduction to the
Vivado simulator.
VIDEO: You can also learn more about the Vivado simulator by viewing the quick take video at Vivado
Logic Simulation.
TRAINING: AMD provides training courses that can help you learn more about the concepts presented in
this document. Use these links to explore related courses:
The Vivado simulator is a Hardware Description Language (HDL) simulator that lets you perform
behavioral, functional, and timing simulations for VHDL, System Verilog, and mixed-language
designs. The Vivado simulator environment includes the following key elements:
• xvhdl and xvlog: Parsers for VHDL and Verilog/SV files, respectively, that store the parsed
files into an HDL library on disk.
• xelab: HDL elaborator and linker command. For a given top-level unit, xelab loads up all sub-
design units, translates the design units into executable code, and links the generated
executable code with the simulation kernel to create an executable simulation snapshot.
• xsim: Vivado simulation command that loads a simulation snapshot to effect a batch mode
simulation, or a GUI or Tcl-based interactive simulation environment.
Tutorial Description
This tutorial demonstrates a design flow in which you can use the AMD Vivado™ simulator for
performing behavioral, functional, or timing simulation from the Vivado Integrated Design
Environment (IDE).
IMPORTANT! Tutorial files are configured to run the Vivado simulator in a Windows environment. To run
elements of this tutorial under the Linux operating system, some file modifications might be necessary.
You can run the Vivado simulator in both Project Mode (using a Vivado design project to manage
design sources and the design flow) and in Non-Project mode (managing the design more
directly). For more information about Project Mode and Non-Project Mode, refer to the Vivado
Design Suite User Guide: Design Flows Overview (UG892).
• A sine wave generator that generates high, medium, and low frequency sine waves; plus an
amplitude sine wave (sinegen.vhd).
• DDS compilers that generate low, middle, and high frequency waves: (sine_low.vhd,
sine_mid.vhd, and sine_high.vhd).
• A Finite State Machine (FSM) to select one of the four sine waves (fsm.vhd).
• A debouncer that enables switch-selection between the raw and the debounced version of
the sine wave selector (debounce.vhd).
• A design top module that resets FSM and the sine wave generator, and then multiplexes the
sine select results to the LED output (sinegen_demo.vhd).
• A simple test bench (testbench.v) to initiate the sine wave generator design that:
○ Generates a 200 MHz input clock for the design system clock, sys_clk_p.
Note: For more information about testbenches, see Writing Efficient Test Benches (XAPP199).
RECOMMENDED: You modify the tutorial design data while working through this tutorial. Use a new
copy of the design files each time you start this tutorial.
Directories/Files Description
/completed Contains the completed files, and a Vivado 2024.x project of
the tutorial design for reference.
(x denotes the latest version of Vivado 2024 IDE)
/scripts Contains the scripts you run during the tutorial.
/sim Contains the testbench.v file.
/sources Contains the HDL files necessary for the functional
simulation.
Directories/Files Description
readme.txt readme.txt is a readme file about the contents and
version history of this tutorial design.
/uvm UVM example needed for Lab 5
Refer to the Vivado Design Suite User Guide: Release Notes, Installation, and Licensing (UG973) for a
complete list and description of the system and software requirements.
Lab 1
Create a new project for managing source files, add IP to the design, and run behavioral
simulation:
1. On Windows, launch the Vivado IDE by selecting Start → All Programs → Xilinx Design Tools
→ Vivado 2024.x → Vivado 2024.x.
(x denotes the latest version of Vivado 2024 IDE)
Note: Your Vivado ML Editions installation might be called something other than AMD Design Tools on
the Start menu.
3. In the New Project wizard, click Next and enter a project name: project_xsim.
4. For the Project location, browse to the folder containing the extracted tutorial data,
<Extract_Dir>. Make sure to check the Create project subdirectory option and click Next.
5. In the Project Type page, select RTL Project and click Next.
6. In the Add Source page, click Add Directories and add the extracted tutorial design data:
• <Extract_Dir>/sources
• <Extract_Dir>/sim
Note: You can press the Ctrl key to click and select multiple files or directories.
7. Set the Target Language to Verilog to indicate the netlist language for synthesis.
8. Set the Simulator language to Mixed as shown in the following figure.
The Simulator language indicates languages which the logic simulator supports or requires.
Vivado Design Suite ensures the availability of simulation models of any IP cores in the
design by using the available synthesis files to generate the required language-specific
structural simulation model when generating output targets. For more information on
working with IP cores and the AMD IP catalog, refer to the Vivado Design Suite User Guide:
Designing with IP (UG896). You can also work through the Vivado Design Suite Tutorial:
Designing with IP (UG939).
9. Click Next.
10. Click Next to bypass the Add Constraints page.
In the Default Part page shown in the following figure, select Boards, and then select either
AMD Kintex™ 7 KC705 Evaluation Platform for 7 series or Kintex-UltraScale KCU105
Evaluation Platform for UltraScale devices and click Next.
Vivado opens the new project in the Vivado IDE, using the default view layout.
1. Click the icon in the Sources window to expand the folders as shown in the following
figure. Expand all button can be used to view all the files at all levels of hierarchy.
Notice that the Sine wave generator (sinegen.vhd) references cells that are not found in
the current design sources. In the Sources window, the missing design sources are marked by
the missing source icon .
Note: The missing source icon is used to view only the missing sources. This is useful in viewing the
missing sources in larger designs.
Now, add the sine_high, sine_mid, and sine_low modules to the project from the
AMD IP catalog.
4. In the IP Symbol tab on the left, ensure that Show disabled ports is unchecked.
5. Specify the following on the Configuration tab:
• Component Name: type sine_high
• Configuration Options: select SIN COS LUT only
• Noise Shaping: select None
• Under Hardware Parameters, set Phase Width to 16 and Output Width to 20
6. On the Implementation tab, set Output Selection to Sine.
7. On the Detailed Implementation tab, set Control Signals to ARESETn (active-Low).
8. On the Summary tab, review the settings and click OK.
When the sine_high IP core is added to the design, the output products required to
support the IP in the design must be generated. The Generate Output Products dialog box
displays, as shown in the following figure.
The output products allow the IP to be synthesized, simulated, and implemented as part of
the design. For more information on working with IP cores and the AMD IP catalog, refer to
the Vivado Design Suite User Guide: Designing with IP (UG896). You can also work through the
Vivado Design Suite Tutorial: Designing with IP (UG939).
9. Click Generate to generate the default output products for sine_high. A dialog box opens
with a message that reads the Out of context module run was launched for generating output
products. Click OK.
When the sine_mid IP core is added to the design, the Generate Output Products dialog
box displays to generate the output products required to support the IP in the design.
6. Click Generate to generate the default output products for sine_mid. A dialog box opens
with a message that reads the Out of context module run was launched for generating output
products. Click OK.
When the sine_low IP core is added to the design, the Generate Output Products dialog box
displays to generate the output products required to support the IP in the design.
6. Click Generate to generate the default output products for sine_low. A dialog box opens
with a message that reads the Out of context module run was launched for generating output
products. Click OK.
1. In the Flow Navigator, right-click Simulation and then click Simulation Settings. Alternatively,
click Settings in the Flow Navigator under Project Manager to open the Settings window.
Select Simulation from the Settings window. The following defaults are automatically set:
• Simulation set: select sim_1
• Simulation top-module name: set testbench
2. In the Elaboration tab, as shown in the following figure, ensure that the debug level is set to
typical which is the default value.
3. In the Simulation tab, observe that the Simulation Run Time is 1000 ns.
4. Click OK.
With the simulation settings properly configured, you can launch the Vivado simulator to
perform a behavioral simulation of the design.
5. In the Flow Navigator, click Run Simulation → Run Behavioral Simulation.
Functional and timing simulations are available post-synthesis and post-implementation.
Those simulations are outside the scope of this tutorial.
When you launch the Run Behavioral Simulation command, the Vivado tool runs xvlog and
xvhdl to analyze the design and xelab in the background to elaborate and compile the
design into a simulation snapshot, which the Vivado simulator can run. When that process is
complete, the Vivado tool launches xsim to run the simulation.
In the Vivado IDE, the simulator GUI opens after successfully parsing and compiling the
design as shown in the following figure. By default, the top-level HDL objects display in the
Waveform window.
Conclusion
In this lab, you have created a new AMD Vivado™ Design Suite project, added HDL design
sources, added IP from the AMD IP catalog and generated IP outputs needed for simulation, and
then run behavioral simulation on the elaborated RTL design.
This concludes Lab 1. You can continue Lab 2 at this time by starting at Step 2: Displaying Signal
Waveforms.
You can also close the simulation, project, and the Vivado IDE to start Lab 2 at a later time.
Lab 2
Start by loading the Vivado Integrated Design Environment (IDE) by selecting Start → All
Programs → Xilinx Design Tools → Vivado 2024.x → Vivado 2024.x.
Note:
1. Your Vivado ML Editions installation might be called something other than AMD Design Tools on the
Start menu.
2. As an alternative, click the Vivado 2024.x Desktop icon to start the Vivado IDE.
The Vivado IDE opens. Now, open the project from Lab 1, and run the behavioral simulation.
1. From the main menu, click File → Project → Open Recent and select project_xsim that
you saved in Lab 1.
2. After the project has opened, from the Flow Navigator click Run Simulation → Run
Behavioral Simulation.
The Vivado simulator compiles your design and loads the simulation snapshot.
• Running and restarting the simulation to review the design functionality, using signals in the
Waveform window and messages from the testbench shown in the Tcl console.
• Adding signals from the testbench and other design units to the Waveform window so you
can monitor their status.
• Adding groups and dividers to better identify signals in the Waveform window.
• Changing signal and wave properties to better interpret and review the signals in the
Waveform window.
• Using markers and cursors to highlight key events in the simulation and to perform zoom and
time measurement features.
• Using multiple waveform configurations.
By default, the AMD Vivado™ simulator adds simulation objects from the testbench to the
Waveform window. In the case of this tutorial, the following testbench signals load automatically:
• Differential clock signals (sys_clk_p and sys_clk_n). This is a 200 MHz clock generated
by the testbench and is the input clock for the complete design.
• Reset signal (reset). Provides control to reset the circuit.
• GPIO buttons (gpio_buttons[1:0]). Provides control signals to select different frequency
sine waves.
• GPIO switch (gpio_switch). Provides a control switch to enable or disable debouncer logic.
• LEDs (leds_n[3:0]). A placeholder bus to display the results of the simulation.
You add some new signals to this list to monitor those signals as well.
If necessary, in the Scopes window, click the sign to expand the testbench. (It might be
expanded by default.)
An HDL scope, or scope, is defined by a declarative region in the HDL code, such as a module,
function, task, process, or named blocks in Verilog. VHDL scopes include entity/architecture
definitions, blocks, functions, procedures, and processes.
Note: You can select multiple signals by holding down the CTRL key during selection.
3. Right-click to open the popup menu again, and select Radix → Signed Decimal as shown in
the figure below.
In the Scope window, right-click on dut under testbench. Click Log to Wave Database from
the options list. Select Objects in Scope option. The specified signals are written to a waveform
database.
Note: See the Vivado Design Suite Tcl Command Reference Guide (UG835) for more information on the
log_wave command.
This command enables signal dumping for the specified HDL objects, /testbench/dut/*
and /testbench/dut/U_SINEGEN/*.
The log_wave command writes the specified signals to a waveform database, which is written
to the simulation folder of the current project:
<project_name>/<project_name>.sim/sim_1/behav/xsim
Notice that the low frequency sine output is incorrect. You can view the waveform in detail by
zooming into the Waveform window. When you zoom into the waveform, you can use the
horizontal and vertical scroll bars to pan down the full waveform.
Figure 2: Waveform
As seen in the figure above, when the value of sineSel is 0, which indicates a low frequency sine
selection, the analog sine[19:0] output is not a proper sine wave, indicating a problem in the
design or the testbench.
Grouping Signals
Next, you add signals from other design units to better analyze the functionality of the whole
design. When you add signals to the Waveform window, the limited size of the window makes it
difficult to display all signals at the same time. Reviewing all signals would require the use of the
vertical scroll bar, making the review process difficult.
You can group related signals together to make viewing them easier. With a group, you can
display or hide associated signals to make the Waveform window less cluttered, and easier to
understand.
1. In the Waveform window, select all signals in the testbench unit: sys_clk_p, sys_clk_n,
reset, gpio_buttons, gpio_switch, and leds_n.
Note: Press and hold the Ctrl key or Shift key to select multiple signals.
2. With the signals selected right-click to open the popup menu and select New Group. Rename
it as TB Signals.
The AMD Vivado™ simulator creates a collapsed group in the waveform configuration
window. To expand the group, click to the left of the group name.
3. Create another signal group called DUT Signals to group signals sine[19:0] and
sine_sel[1:0].
You can add or remove signals from a group as needed. Cut and paste signals from the list of
signals in the Waveform window, or drag and drop a signal from one group into another.
You can also drag and drop a signal from the Objects window into the Waveform window, or
into a group.
You can ungroup all signals, thereby eliminating the group. Select a group, right-click to open
the popup menu, and select Ungroup.
To better visualize signals corresponding to each design, add dividers to separate the signals
by design unit.
Adding Dividers
Dividers let you create visual breaks between signals or groups of signals to identify related
objects easily.
1. In the Waveform window, right-click to open the popup menu and select New Divider. The
Name dialog box opens to let you name the divider you are adding to the Waveform window.
2. Add two dividers named:
• Testbench
• SineGen
3. Move the SineGen divider above the DUT Signals group.
TIP: You can change divider names at any time by highlighting the divider name and selecting the Rename
command from the popup menu, or changing the color with Divider Color.
Add signals from the instantiated sine_gen_demo module (DUT) and the sinegen module
(U_SINEGEN).
1. In the Scopes window, select and expand the Testbench, then select and expand DUT.
Simulation objects associated with the currently selected scope display in the Objects
window.
By default, all types of simulation objects display in the Objects window. However, you can
limit the types of objects displayed by selecting the object filters at the top of the Objects
window. The following figure shows the Objects window with the Input and Output port
objects enabled, and the other object types are disabled. Move the cursor to hover over a
button to see the tooltip for the object type.
2. Use the Objects window toolbar to enable and disable the different object types.
The types of objects that can be filtered in the Objects window include Input, Output, Inout
ports, Internal Signals, Constants, and Variables.
3. In the Scopes window, select the U_SINEGEN design unit.
4. In the Waveform window, right-click in the empty space below the signal names, and use the
New Group command to create three new groups called Inputs, Outputs, and Internal
Signals.
TIP: If you create the group on top of, or containing, any of the current objects in the Waveform
window, simply drag and drop the objects to separate them as needed.
5. In the Objects window, select the Input filter to display the Input objects.
6. Select the Input objects in the Objects window, and drag and drop them onto the Input group
you created in the Waveform window.
Repeat steps 5 and 6 above to filter the Output objects and drag them onto the Output group,
and filter the Internal Signals and drag them onto the Internal Signals group, as shown in the
following figure.
1. In the Waveform window, hold Ctrl and click to select the sine[19:0] and
sineSel[1:0] signals listed in the DUT signals group, under the SineGen divider.
2. Hold Ctrl, and click to select the sine[19:0] signals listed in the Outputs group, under the
SineGen divider.
3. Right-click in the Waveform window to open the popup menu, and select the Name → Long
command.
The displayed name changes to include the hierarchical path of the signal. You can now see
that the sine[19:0] signals under the DUT Signals group refers to different objects in the
design hierarchy than the sine[19:0] signals listed under the Outputs group. See the
figure below.
Supported radix values are Binary, Hexadecimal, Octal, ASCII, Signed, and Unsigned decimal. You
can set any of the above values as Default using the Default Radix option.
1. In the Waveform window, click the Settings button on the title bar menu.
The Waveform Options dialog box opens to the General tab.
2. Ensure the Default Radix is set to Hexadecimal.
This defines the default number format for all signals in the Waveform window. The radix can
also be set for individual objects in the Waveform window to override the default.
3. Select the Draw Waveform Shadow, as shown in the following figure, to enable or disable the
shading under the signal waveform.
By default, a waveform is shaded under the high transitions to make it easier to recognize the
transitions and states in the Waveform window.
You can also enable or disable signal indices so that each signal or group of signals is
identified with an index number in the Waveform window.
4. Check or uncheck the Show signal indices check box to enable or disable the signal list
numbering.
5. Check or uncheck the Show grid lines check box to enable or disable the grid lines in the
waveform window.
6. Check the Snap to Transition check box to snap the cursor to transition edges.
7. In the Waveform Options dialog box, select the Colors view.
Examine the Waveform Color Options dialog box. You can configure the coloring for
elements of the Waveform window to customize the look and feel. You can specify custom
colors to display waveforms of certain values, so you can quickly identify signals in an
unknown state or an uninitialized state.
The Waveform window configures your preferences. You can save the current waveform
configuration so it is available for use in future AMD Vivado™ simulation sessions.
By default, the Vivado simulator saves the current waveform configuration setting as
testbench_behav.wcfg.
8. In the Waveform window sidebar menu, select the Save Wave Configuration button .
9. Save the Wave Configuration into the project folder with the filename tutorial_1.wcfg.
10. Click Yes. The file is added to the project simulation fileset, sim_1, for archive purposes.
TIP: You can also load a previously saved waveform configuration file using the File → Simulation
Waveform → Open Configuration command.
1. To add a new Waveform window, select File → Simulation Waveform → New Configuration.
An untitled Waveform window opens with a default name. You can add signals, define
groups, add dividers, and set properties and colors that are unique to this Waveform window.
2. Select signal groups in the first Waveform window by pressing and holding the Ctrl key, and
selecting the following groups: Inputs, Outputs, and Internal Signals.
3. Right-click to open the popup menu, and select Copy, or use the shortcut Ctrl+C on the
selected groups to copy them from the current Waveform window.
4. Select the new Waveform window to make it active.
5. Right-click in the Waveform window and select Paste, or use the shortcut Ctrl+V to paste the
signal groups into the prior Waveform window.
6. Select File → Simulation Waveform → Save Configuration or click the Save Wave
Configuration button, and save the waveform configuration to a file called
tutorial_2.wcfg.
7. When prompted to add the waveform configuration to the project, select No.
8. Click the icon to close the new Waveform window.
1. Click the Restart button to reset the circuit to its initial state.
The simulation runs for about 7005 ns. If you do not restart the simulator prior to executing
the Run All command, the simulator runs continuously until interrupted.
3. After the simulation is complete, click the Zoom Fit button to see the whole simulation
timeline in the Waveform window. Figure below shows the current simulation results.
4. From the waveform toolbar menu, click the Next Transition button .
The current marker moves to the first value change of the selected sineSel[1:0] signal, at
3.5225 microseconds.
With markers identifying the transitions on sineSel, the Waveform window should look
similar to the following figure. As previously observed, the low-frequency signals are
incorrect when the sinSel signal value is 0.
You can also use the main Waveform window cursor to navigate to different simulation times
or locate value changes. In the next steps, you use this cursor to zoom into the Waveform
window when the sineSel is 0 to review the status of the output signal, sine[19:0], and
identify where the incorrect behavior initiates. You also use the cursor to measure the period
of low-frequency wave control.
TIP: By default, the Waveform window displays the time unit in microseconds. However, you can use
any measurement you prefer while running or changing the current simulation time, and the
Waveform window adjusts accordingly.
7. In the Waveform window, click the Go to Time 0 button , then click the Zoom in button
repeatedly to zoom into the beginning of the simulation run.
8. Continue to zoom in the Waveform window as needed, until you can see the reset signal
asserted low, and you can see the waveform of the clock signals, sys_clk_p and
sys_clk_n, as seen in the following figure.
The Waveform window zooms in or out around the area centered on the cursor.
9. Place the main Waveform window cursor on the area by clicking at a specific time or point in
the waveform.
You can also click on the main cursor, and drag it to the desired time.
10. Because 0 is the initial or default FSM output, move the cursor to the first posedge of
sys_clk_p after reset is asserted low, at time 102.5 ns, as seen in the following figure.
You can use the Waveform window to measure the time between two points on the timeline.
11. Place a marker at the time of interest, 102.5 ns, by clicking the Add Marker button .
12. Click to select the marker.
The Floating Ruler option that is available in the General tab of waveform Settings displays a
ruler at the bottom of the Waveform window useful for measuring the time between two
points. Use the floating ruler to measure the sineSel control signal period, and the
corresponding output_sine[19:0] values during this time frame.
When you select the marker, a floating ruler opens at the bottom of the Waveform window,
with time 0 on the ruler positioned at the selected marker. As you move the cursor along the
timeline, the ruler measures the time difference between the cursor and the marker.
TIP: Enable the Floating Ruler checkbox from the General tab of Waveform Settings, if the ruler does
not appear when you select the marker.
You can move the cursor along the timeline in a number of ways. You can scroll the horizontal
scroll bar at the bottom of the Waveform window. You can zoom out, or zoom fit to view
more of the timeline, reposition the cursor as needed, and then zoom in for greater detail.
13. Select sineSel from the list of signals in the Waveform window and use the Next Transition
command to move to the specific transition of interest.
As shown in above figure, the ruler measures a time period of 3.420 ns as the period that
FSM selected the low frequency output.
1. First, open the tutorial design test bench to learn how the simulator generates each design
input.
2. Open the testbench.v file by double-clicking the file in the Sources window, if it is not
already open.
The source file opens in the Vivado IDE Text Editor, as shown in the following figure.
Note: You can also select File → Text Editor → Open File from the main menu, or Open File from the
popup menu in the Sources window. You can also select an appropriate design object in the Scopes
window or Objects window, right-click and select Go to Source Code.
Using Breakpoints
A breakpoint is a user-determined stopping point in the source code used for debugging the
design. When simulating a design with set breakpoints, simulation of the design stops at each
breakpoint to verify the design behavior. After the simulation stops, an indicator shows in the
text editor next to the line in the source file where the breakpoint is set, so you can compare the
Wave window results with a particular event in the HDL source.
You use breakpoints to debug the error with the low frequency signal output that you previously
observed. The erroneous sine[19:0] output is driven from the sineGen VHDL block. Start
your debugging with this block.
1. Select the U_SINEGEN scope in the Scope window to list the objects of that scope in the
Objects window.
2. In the Objects window, right-click sine[19:0] and use Go to Source Code to open the
sinegen.vhd source file in the Text Editor.
TIP: If you do not see the sine[19:0] signal in the Objects window, make sure that the filters at the
top of the Objects window are set properly to include Output objects.
Looking through the HDL code, the clk, reset, and sel inputs are correct as expected. Set
your first breakpoint after the reset asserts low at line 137.
3. Scroll to line 137 in the file.
Add a breakpoint at line 137 in sinegen.vhd. Note that the breakpoint can be set only on
the executable lines. The AMD Vivado™ simulator marks the executable lines with an empty
red circle , on the left hand margin of the Text Editor, beside the line numbers.
Setting a breakpoint causes the simulator to stop at that point, every time the simulator
processes that code, or every time the counter is incremented by one.
4. Click the red circle in the left margin, to set a breakpoint, as shown in the following figure.
Observe that the empty circle becomes a red dot to indicate that a breakpoint is set on
this line. Clicking on the red dot removes the breakpoint and reverts it to the empty circle
.
Note: To delete all breakpoints in the file, right-click on one of the breakpoints and select Delete All
Breakpoints.
Debugging in the Vivado simulator, with breakpoints and line stepping, works best when you
can view the Tcl Console, the Waveform window, and the HDL source file at the same time,
as shown in the following figure.
5. Resize the windows, and use the window Float command or the New Vertical Group
command to arrange the various windows so that you can see them all.
TIP: When you have arranged windows to perform a specific task, such as simulation debug in this
case, you can save the view layout to reuse it when needed. Use the Layout → Save Layout As
command from the main menu to save view layouts. See the Vivado Design Suite User Guide: Using
the Vivado IDE (UG893) for more information on arranging windows and using view layouts.
Step through the source code line-by-line and examine how the low-frequency wave is selected,
and whether the DDS compiler output is correct.
2. Continue to Step through the design, until the code returns to line 144 of sinegen.vhd.
You have stepped through one complete cycle of the circuit. Notice in the Waveform window
that while sel is 0, signal sine_l is assigned as a low-frequency sine wave to the output
sine. Also, note that sine_l remains uninitialized.
3. For debug purposes, initialize the value of sine_l by entering the following add_force
command in the Tcl console:
add_force /testbench/dut/U_SINEGEN/sine_l 0110011011001010
This command forces the value of sine_l into a specific known condition, and can provide a
repeating set of values to exercise the signal more vigorously if needed. Refer to the Vivado
Design Suite User Guide: Logic Simulation (UG900) for more information on using add_force.
4. Continue the simulation by clicking the Run All button a few more times.
In the Waveform window, notice that the value of sine_l[15:0] is now set to the value
specified by the add_force command, and this value is assigned to the output signal
sine[19:0] because the value of sel is still 0.
Trace the sine_l signal in the HDL source files, and identify the input for sine_l.
5. In the Text Editor, right-click to open the popup menu and select the Find in files option to
search for sine_l.
6. Select the Match whole word and Enabled design sources checkboxes, as shown in the
following figure, and click Find.
The Find in Files results display at the bottom of the Vivado IDE, with all occurrences of
sine_l found in the sinegen.vhd file.
7. Expand the Find in Files results to view the results in the sinegen.vhd file.
The second result, on line 111, identifies a problem with the design. At line 111 in the
sinegen.vhd file, the m_axis_data_tdata_sine_low signal is assigned to sine_l.
Since line 111 is commented out, the sine_l signal is not connected to the low frequency
DDS compiler output, or any other input.
8. Uncomment line 111 in the sinegen.vhd file, and click the Save File button .
9. In the Tcl Console, remove the force on sine_l: remove_forces -all
Because you modified the source files associated with the design, you must recompile the HDL
source and build a new simulation snapshot. Do not just restart the simulation at time 0 in this
case but rebuild the simulation from scratch.
1. In sinegen.vhd, select one of the breakpoints, right-click, and select Delete All
Breakpoints.
2. Click the Relaunch button on the main toolbar menu.
Note: If prompted to save the Wave Config file, click yes.
The AMD Vivado™ simulator recompiles the source files with xelab and re-creates the simulation
snapshot. Now you are ready to simulate with the corrected design files. The relaunch button will be
active only after one successful run of Vivado Simulator using launch_simulation. If you run the
simulation in a Batch/Scripted mode, the relaunch button would be grayed out.
Conclusion
After reviewing the simulation results, you might close the simulation and the project. This
completes Lab 2. Up to this point in the tutorial, between Lab 1 and Lab 2, you have:
• Run the AMD Vivado™ simulator using the Project Mode flow in AMD Vivado™ IDE
• Created a project, added source files, and added IP
• Added a simulation-only file (testbench.v)
• Set simulation properties and launched behavioral simulation
• Added signals to the Waveform window
• Configured and saved the Waveform Configuration file
• Debugged the design bug using breakpoints and line stepping.
• Corrected an error, re-launched the simulation, and verified the design
Lab 3
• Prepare the simulation project manually by creating a Vivado simulator project script.
• Create a simulation snapshot file using the Vivado simulator xelab utility.
• Start the Vivado simulator GUI by running the xsim command with the resulting snapshot.
You can compile the HDL files in a design, and create a simulation snapshot by either:
• Creating a Vivado simulator project script, specifying all HDL files to be compiled, and using
the xelab command to create a simulation snapshot, or
• Using specific Vivado simulator parser commands, xvlog and xvhdl, to parse individual source
files and write the parsed files into an HDL library on disk, and then using xelab to create a
simulation snapshot from the parsed files.
The format for a Vivado simulator project script (prj file) is as follows:
where,
• verilog | vhdl | sv specifies whether the design source is a Verilog, VHDL, or SV file.
• <library_name> specifies the library into which you can compile the source file. If
unspecified, the default library for compilation is work.
• <file_name>.v|.vhd|.sv specifies the name of the design source file to compile.
IMPORTANT! While you can specify one or more Verilog source files on a single command line, you can
only specify one VHDL source on a single command line.
In this step, you build a Vivado simulator project script by editing an existing project script to add
missing source files. The command lines for the project script should be constructed using the
syntax described above.
You do not need to list the sources based on any specific order of dependency. The xelab
command resolves the order of dependencies, and automatically processes the files accordingly.
TIP: For your reference, a completed version of the tutorial files can be found in the ug937-design-
files/completed folder.
Parse individual or multiple Verilog files using the xvlog command with the following syntax
format:
Parse individual VHDL files using the xvhdl command with the following syntax format:
For a complete list of available xvlog and xvhdl command options, see the Vivado Design Suite
User Guide: Logic Simulation (UG900). The parse_standalone.bat file in <Extract_Dir>/
scripts or <Extract_Dir>/completed provide examples of running xvlog and xvhdl
directly.
where,
• -prj <project_file>: Specifies a Vivado simulation project script to use for input.
• -s <simulation_snapshot>: Specifies the name of the output simulation snapshot.
• <library>.<top_unit>: Specifies the library and top-level module of the design.
Running xelab
In this step, you use the xelab command with the project file completed in Step 1 to elaborate,
compile, and link all the design sources to create the simulation snapshot. To run the xelab
command, open and configure a command window.
1. On Windows, open a Command Prompt window. On Linux, simply skip to the next step.
2. Change the directory to the AMD installation area, and run settings64.bat as needed to set
up the AMD tool paths for your computer:
cd install_path\Vivado\2024.x\
settings64.bat
Note: The settings64.bat file configures the path on your computer to run the Vivado ML
Editions.
TIP: When running the xelab , xsc , xsim , xvhdl , or xvlog commands in batch files or scripts, it
might also be necessary to define the XILINX_VIVADO environment variable to point to the
installation hierarchy of the Vivado ML Editions. To set the XILINX_VIVADO variable, you can add one
of the following to your script or batch file:
On Windows -
set XILINX_VIVADO=<Vivado_install_area>/Vivado/2024.x
On Linux -
or
export XILINX_VIVADO=<Vivado_install_area>/Vivado/2024.x
TIP: You can also use the xelab command after the xvlog and xvhdl commands have parsed
the HDL design sources to read the specified simulation libraries. The xelab command would be the
same as described here, except that it would not require the -prj option since there would be no
simulation project file.
In the same command window that you used for Step 2, type the following command:
where:
• run_sineGen -gui: Specifies the simulation snapshot that you generated using xelab,
and launches Vivado simulator in GUI mode.
• -wdb: Specifies the file name of the simulation waveform database file to output, or write,
upon completion of the simulation run.
• -view: Opens the specified waveform configuration file within the Vivado simulator GUI.
Note: You can use the waveform configuration file specified above, or use the tutorial_1.wcfg file that
you created in Lab 2 of this tutorial.
The Vivado Simulator GUI opens and loads the design (see the following figure). The simulator
time remains at 0 ns until you specify a run time. Run the simulation and explore the design by
typing : run -all.
Conclusion
In this tutorial, you:
Lab 4
3. You will create an AXI-VIP example design that includes the following features:
• Random Constraint
• Dynamic Types and Class
• Virtual Interface
• Assertion
• Clocking Block
4. Invoke the following commands in Tcl Console:
a. create_ip -name axi_vip -vendor xilinx.com -library ip -version
1.1 -module_name axi_vip_0
b. open_example_project -force [get_ips axi_vip_0]
Now you have created an example design for AXI-VIP with the name axi_vip_0_ex.
Launching Simulation
You have an example project ready. Next, you will run the behavioral simulation. By default, the
simulation runs in a pre-compiled mode where the source code for static IP is not added in the
project. Run the simulation in a non-precompiled mode for a better understanding of the feature.
Invoke the following commands in Tcl Console:
• Scope Window
• Object Window
• Tcl Console
Scope Window
System Verilog has a building block called interface. It differs in functionality when you compare
it with the module.
Object Window
In System Verilog, all the net/variables are static type. They exist throughout the simulation. In
System Verilog, dynamic type is a new type along with static type. Class, Queue, and Associative
Array are some examples of dynamic type.
Unlike static type variables (int a; wire [7:0] b;), dynamic type variables do not have a fixed size
throughout the simulation. Variables keep changing during run-time. Through Object window,
you can view the value of a dynamic type variable during the simulation.
3. Maximize the Objects window. As the simulation is yet to start, observe the Queue and Class
dynamic type in the Data Type column. The Value for Queue appears empty while for class it
appears null.
5. On the text editor window, click the circle on line number 95 to add a break point.
6. Click Run All button, the simulation will stop at line number 95. In the Object window,
master_monitor_transaction_queue value appears empty.
7. On the AMD Vivado™ simulator toolbar menu, click the Step button . It executes the
current statement that is on line number 95 where the simulation is currently waiting. At this
statement, you are pushing an element after the execution. Your queue will be populated
with a single element.
8. In the Object window, the master_monitor_transaction_queue value is populated.
This way you can view the value of any dynamic type on the Object window.
Tcl Console
Like the Objects window, you can view the value of any dynamic type variable from Tcl Console
as well.
3. In Tcl console, invoke the report_objects command to display all objects present in the
selected scope. Also, the Queue and Class appear as object type.
4. Invoke the get_value command to find the current value of an object. The get value of
mst_monitor_transaction is returning null as its Class type while an empty parenthesis
appears for master_monitor_transaction_queue, which is a Queue type.
5. Click Run All button . The simulation stops at the line where you have added the
breakpoint.
6. Invoke get_value master_moniter_transaction_queue command and note that it
is still empty.
7. On the AMD Vivado™ simulator toolbar menu, click the Step button . It executes the
current statement that is on line number 95 where the simulation is currently waiting. In this
statement, you are pushing an element after the execution. Your queue will be populated
with a single element.
8. Invoke the get_value master_moniter_transaction_queue command and note 1
entry in the Queue. Like the Objects window, you can read the value of any dynamic type
variable in Tcl Console.
Functional Coverage
Functional coverage is a user defined metric that measures the extent to which the design
specification, as enumerated by features in the test plan, is exercised. It can be used to measure
whether interesting scenarios, corner cases, specification invariants, or other applicable design
conditions are captured as features of the test plan that are observed, validated, and tested.
The AMD Vivado™ simulator supports functional coverage. If your design contains any functional
coverage statement, the tool will generate a database (coverage database). To view coverage
database, Vivado simulator provides a utility named as xcrg (Xilinx Coverage Report Generator).
Refer to the Vivado Design Suite User Guide: Logic Simulation (UG900) for more information on
functional coverage and xcrg.
In the present example design, you will add a functional coverage code to view the utility of xcrg.
In this example, you are declaring a covergroup named my_cover_group and the sampling event
as posedge aclk. This covergroup contains three coverpoints. You will add the cover group
declaration code in the example design.
3. The following file path will appear in the text editor, then add the cover group declaration
before endmodule and save it.
axi_vip_0_ex/axi_vip_0_ex.ip_user_files/bd/ex_sim/ip/
ex_sim_axi_vip_mst_0/sim/ex_sim_axi_vip_mst_0.sv
4. In Tcl console, invoke the close_sim command to close the simulation running previously.
5. In Tcl console, invoke the reset_simulation command to clean the simulation directory.
6. In Tcl console, invoke the launch_simulation command to run the simulation.
The simulation will stop after reaching the $finish statement. The AMD Vivado™ simulator has
generated the coverage database at the following location with the name (default name)
xsim.covdb:
./axi_vip_0_ex.sim/sim_adv_mst_active__pt_passive__slv_comb/behav/xsim/
1. Open dashboard.html file. The file contains details such as command, version, date, and
coverage summary that shows only 9.375% of total bins are covered.
This way you can view the coverage and change your test bench/seed value to improve the
coverage.
Assertion
In System Verilog, you have the following two types of assertion:
• Immediate assertion
• Concurrent Assertion
Immediate Assertion
Evaluated like an expression in ‘if’ statement.
always@(posedge clk)
assert(data == 4’b1010);
Concurrent Assertion
This assertion is based on clock semantic and use sampled value of their expression. These
assertions can expand over multiple cycle.
In AMD Vivado™ simulator, the concurrent assertion of the second form that is used outside the
procedural block is supported.
1. In Tcl Console, invoke close_sim command to close the simulation running previously.
2. In Tcl Console, invoke reset_simulation command to clean the simulation directory.
3. In Tcl Console, invoke launch_simulation command to run the simulation.
4. In Tcl Console, invoke the following command:
current_scope /axi_vip_0__exdes_adv_mst_active_pt_mem__slv_passive/DUT/
ex_design/axi_vip_passthrough/inst/IF/PC
Code Coverage
Code coverage is a measure of how well the RTL code has been exercised by the test bench.
Code coverage is automatically extracted by the simulator when enabled. Vivado Simulator
currently supports four types of code coverage, that is, line, branch, condition, and toggle. When
you enable code coverage for any of the code coverage types, the tool automatically generates
the code coverage database. To view the coverage of the design, Vivado simulator provides a
standalone executable named as xcrg (Xilinx Coverage Report Generator) that can be used to
generate coverage reports by reading the coverage database.
Note: Currently, Vivado Simulator supports the above features for System Verilog/Verilog. VHDL code
coverage is not supported yet.
In the present example design, add a code coverage switch at elaboration to view the utility using
xcrg.
1. Under elaboration tab in settings menu, add coverage types, coverage directory, and
coverage database name as shown below and select OK.
You should be able to see the following Tcl commands set in Tcl console after the previous
step:
set_property -name {xsim.elaborate.coverage.name} -value {DB1} -objects
[get_filesets sim_adv_mst_active__pt_passive__slv_comb]
2. Invoke the close_sim command in the Tcl console to close the simulation running
previously.
3. Invoke the reset_simulation command in the Tcl console to clean the simulation
directory.
4. Invoke the launch_simulation command in the Tcl console to run the simulation.
5. Invoke the following command in the Tcl console to dump the current coverage database into
the disk.
write_xsim_coverage -cov_db_dir cRun1 -cov_db_name DB1
6. Invoke the following command in the Tcl console to read the coverage database generated by
Vivado simulator and export it as an HTML report.
export_xsim_coverage -cov_db_name DB1 -cov_db_dir cRun1 -output_dir
cReport1 -open_html true
7. Now you can see the HTML report opened in the default browser as shown below.
8. Click on Files in the top right corner to see the File Specific Information.
9. Click on Modules in the top right corner to see Module Specific Information.
11. Select branch coverage to see the branch coverage of the module.
12. Select condition coverage to see the condition coverage of the module.
13. Select toggle coverage to see the toggle coverage of the module.
Random Constraint
System Verilog has a random constraint, which is used to generate a random value. Using this
feature, you can even set the constraint on a random variable.
For each simulation, the simulator is supposed to generate a fixed set of values. In this example,
randomize call is happening 10 times so each time the simulator is expected to assign a different
value on variable ‘b1.' If we close the simulation and run it again, the simulator is expected to give
the same 10 sets of values as the previous run. This is called random stability.
module top();
class c1;
rand bit [3:0] b1;
endclass
c1 obj1 = new();
initial
begin
for(int i = 0; i < 10; i++)
begin
#5 obj1.randomize();
$display("At time %t the value is %p", $time, obj1);
end
end
endmodule
If you want different set of values, you should change the random seed value. In AMD Vivado™
simulator, it is done by passing -sv_seed option to xsim. In Tcl Console, you need to invoke the
following command:
With seed, you have to provide any integer value. So just by changing a ‘seed’ value, you can get
a different value. You do not need to do compilation and elaboration again.
3. Type in "exit" to leave the simulation and then re-run step 2c and notice the value is similar to
the previous one.
Note: If you are running this in the AMD Vivado™ GUI, exiting will exit all of Vivado and you will need
to do all of step two again, not just 2c.
4. Simulate the code with different SV seed xsim top -sv_seed 5000 and observe that the
value is different. Thus, you can generate different values without going through compile and
elaboration steps.
Lab 5
Through this tutorial, let us take a UVM-based example and run it in Vivado Simulator.
5. For UVM, you need to provide test name, here the test name is
adder_4_bit_basic_test. For this add -testplusarg
UVM_TESTNAME=adder_4_bit_basic_test -testplusarg
UVM_VERBOSITY=UVM_LOW to xsim.more_options
6. Launch simulation.
This can run simulation for 1000 ns by default. Click run all to complete the simulation.
You can see following in Tcl console.
1. To run the simulation in non-project mode, change the current working directory to the run
folder. cd ./Adder_4_bit/run
2. For standalone simulation in Vivado you can source run_xsim.csh on Linux and
run_xsim.bat on windows or source run.tcl using the below command in Linux/
Windows. Vivado –mode batch –source run.tcl
3. Once the simulation gets finished you can observe the UVM test results in the Shell or
command prompt as shown in the following figure.
Lab 6
Overview
PAM4 encodes 2-bits of binary data into four voltage levels. Through this tutorial, we can create
an example to verify designs with PAM4 signals.
Since four voltage levels are not supported by implementation tools. So, the PAM4 connections
are created as regular single-bit wires. For simulation purposes, the PAM4 signals of the design
are made accessible in the testbench via integer ports of a special module (xil_dut_bypass)
that gets generated as part of this flow. The generated bypass module is not part of the DUT but
has direct access to the PAM4 signals of the DUT. This module can be instantiated in the
testbench to directly drive/observe PAM4 signals.
Feature Covered
The following features are covered in the GTM-Wizard:
1. Detection of designs with PAM4 signals, designs instantiating GTM_DUAL and automatic
generation bypass module (xil_dut_bypass).
2. Simple sanity check for the design that should instantiate bypass module.
3. A mechanism to view PAM4 signals in Waveform Viewer for XSim users.
4. Provide a way to generate a bypass module for export simulation flow.
In this tutorial, we would generate a GTM-Wizard example design, which uses a PAM4 signal. To
generate that, follow the steps below:
1. Create a project in Vivado 2024.x without adding a source/constraint file Create project →
next → next → next → next → next.
2. In the Default Part page, select Virtex UltraScale+ 58G and select parts as shown in the
following figure, and click Next.
4. Under Project Manager, click on IP Catalog and search for gtm_wizard and then double-
click Virtex UltraScale+ FPGAs Transceivers Wizard.
5. Click OK on default configuration and click Skip on Generate Output Product dialog box.
6. On Sources window, right-click the generated XCI file, click Open IP Example Design, and
specify the location.
Before heading towards simulation, here are a few things from the PAM4 point of view:
Note: For old behavior, uncheck Configure Design for Hierarchical Access.
• Launch_simulation:
1. Click Run Behavioral Simulation. This will run the simulation with Vivado Simulator.
2. Once the snapshot is created and loaded, the simulation will stop after 1000 ns. Let us
look at xil_dut_bypass definition. Double-click xil_dut_bypass in the Scope window to see
the source file. Note the hierarchical reference from the top module to the leaf-level
instance.
6. Go to analog setting under waveform style and change the value like below for better
waveform.
Note: For running the same design with third-party simulators, refer to Vivado Design Suite User
Guide: Logic Simulation (UG900)
• Export_simulation: The following are the two flows for export simulation:
4. Follow step-3 to step-7 under launch_simulation and you will be able to see the same
waveform/output as launch_simulation.
8. Follow step-3 to step-7 under launch_simulation and you can see same waveform/
output as launch_simulation.
Appendix A
The AMD Technical Information Portal is an online tool that provides robust search and
navigation for documentation using your web browser. To access the Technical Information
Portal, go to https://docs.amd.com.
Documentation Navigator
Documentation Navigator (DocNav) is an installed tool that provides access to AMD Adaptive
Computing documents, videos, and support resources, which you can filter and search to find
information. To open DocNav:
• From the AMD Vivado™ IDE, select Help → Documentation and Tutorials.
• On Windows, click the Start button and select Xilinx Design Tools → DocNav.
• At the Linux command prompt, enter docnav.
Note: For more information on DocNav, refer to the Documentation Navigator User Guide (UG968).
Design Hubs
AMD Design Hubs provide links to documentation organized by design tasks and other topics,
which you can use to learn key concepts and address frequently asked questions. To access the
Design Hubs:
Support Resources
For support resources such as Answers, Documentation, Downloads, and Forums, see Support.
Revision History
The following table shows the revision history for this document.
Copyright
© Copyright 2012-2024 Advanced Micro Devices, Inc. AMD, the AMD Arrow logo, Kintex,
Vivado, UltraScale, and combinations thereof are trademarks of Advanced Micro Devices, Inc.
Other product names used in this publication are for identification purposes only and may be
trademarks of their respective companies.