Diamond 3 14 Tutorial
Diamond 3 14 Tutorial
14 Tutorial
Trademarks
All Lattice trademarks are as listed at www.latticesemi.com/legal. Synopsys and
Synplify Pro are trademarks of Synopsys, Inc. Aldec and Active-HDL are trademarks
of Aldec, Inc. QuestaSim is a trademark or registered trademark of Siemens Industry
Software Inc. or its subsidiaries in the United States or other countries. All other
trademarks are the property of their respective owners.
Disclaimers
NO WARRANTIES: THE INFORMATION PROVIDED IN THIS DOCUMENT IS “AS IS”
WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING
WARRANTIES OF ACCURACY, COMPLETENESS, MERCHANTABILITY,
NONINFRINGEMENT OF INTELLECTUAL PROPERTY, OR FITNESS FOR ANY
PARTICULAR PURPOSE. IN NO EVENT WILL LATTICE OR ITS SUPPLIERS BE
LIABLE FOR ANY DAMAGES WHATSOEVER (WHETHER DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL, INCLUDING, WITHOUT
LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR
LOSS OF INFORMATION) ARISING OUT OF THE USE OF OR INABILITY TO USE
THE INFORMATION PROVIDED IN THIS DOCUMENT, EVEN IF LATTICE HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME
JURISDICTIONS PROHIBIT THE EXCLUSION OR LIMITATION OF CERTAIN
LIABILITY, SOME OF THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
Bold Items in the user interface that you select or click. Text that you type
into the user interface.
Courier Code examples. Messages, reports, and prompts from the software.
Revision History 46
This tutorial leads you through all the basic steps of designing and
implementing a mixed VHDL and Verilog design targeted to the MachXO3L
device family. It shows you how to use several processes, tools, and reports
from the Lattice Diamond™ software to import sources, run design analysis,
view design hierarchy, and inspect strategy settings. The tutorial then
proceeds to step through the processes of examining the device resources,
setting timing and location assignments, programming the device, and adding
a logic analyzer to the design.
About 90 minutes.
You can stop at the end of any task and restart at the beginning of the next
task. When you restart the Diamond software, it shows a Recent Projects list.
Just click the name of your project.
System Requirements
You need:
Lattice Diamond software, version 3.14, free or subscription version
To download Diamond software, go to:
http://www.latticesemi.com/Products/DesignSoftwareAndIP/
FPGAandLDS/LatticeDiamond.aspx
MachXO3L Starter Kit (Optional)
Many of the tasks in this tutorial can be performed without an actual
MachXO3L Starter Kit, but the low-cost MachXO3L Starter Kit is
recommended to perform all of the tasks in this tutorial.
To purchase a MachXO3L Starter Kit, go to:
http://http://www.latticesemi.com/en/Products/
DevelopmentBoardsAndKits/MachXO3LStarterKit.aspx
Online Help
You can find additional information on any tool included in the tutorial at any
time by choosing Help > Lattice Diamond Help or Help > <tool name>. The
Help also provides easy access to many other information sources.
The design in this tutorial consists of four Verilog HDL modules and two VHDL
modules. The design that you create is targeted to the MachXO3L device
family.
Figure 1 illustrates the tutorial data flow through the system. You may find it
helpful to refer to this diagram as you move through the tutorial tasks.
Create Project
Inspect Strategy
Settings
Translate and
Map Design
Improve Hardware
Reveal Inserter/Analyzer
Note
Some of the screen captures in this tutorial may have been taken from a version of
Lattice Diamond that differs from the one you are using. There may be slight
differences in the graphical user interface (GUI), but the software functions the same.
The initial layout provides the Start Page, which provides a list of common
project actions like Open to open a pre-existing project and New to run
the New Project wizard. Links in the right pane of the Start Page provide
access to user guides, reference material, and online resources available
from www.latticesemi.com.
For almost all questions, the place to start is the Lattice Diamond Help. It
describes the FPGA design flow using Diamond, the libraries of logic
design elements, and the details of the Diamond design tools. The Help
also provides easy access to many other information sources. The Help
can be accessed from Help > Lattice Diamond Help.
2. Open a new project in one of the following ways:
In the Start Page, under Project, click New.
Choose File > New > Project.
In the toolbar, click the down arrow in the New button and then
choose Project.
The New Project wizard opens.
3. Click Next.
The Project Name page opens.
4. Specify the project name: LEDtest.
Note
File names for Diamond projects and project source files must start with a
letter (A-Z, a-z) and must contain only alphanumeric characters (A-Z, a-z,
0-9) and underscores (_).
5. Click Browse. In the Project Location dialog box, browse to where you
want to store the project’s files, such as C:/my_diamond_tutorial, as
shown in Figure 3. Click Select Folder.
6. Specify the implementation name: LEDtest.
The directory to store the implementation is automatically displayed in the
Location box. We will talk about creating a new implementation later in
this tutorial.
7. Click Next.
The Add Source dialog box appears.
8. Click Add Source.
The Import File dialog box appears.
9. Browse to: <diamond_install_directory>/docs/tutorial/Diamond_tutorial.
10. Select the following files (you can use Control+A):
count8.vhd
count32.v
testbench.v
topcount.v
typepackage.vhd
Click Open.
The Add Source step of the Wizard appears with all the selected source
files added.
11. Select Copy source to implementation directory.
12. Click Next.
The Device Selector dialog box appears.
13. Select the following device options:
Family: MachXO3L
Device: LCMXO3L-6900C
Performance grade: 5
Package type: CABGA256
Operating conditions: Commercial
Part Names, at the bottom, changes as you make selections.
The dialog box should resemble Figure 4.
The File List view displays the components of the project. The imported
VHDL and Verilog files appear in the Input Files folder in the File List view.
The File List view organizes project files by categories: Strategies, and
Implementation including Input Files, Constraint Files, Debug Files, Script
Files, and Analysis Files. You may adjust file order by dragging and
dropping filenames in the list. Properties of each file are accessed by
right-clicking the file and selecting Properties from the pop-up menu.
Note
You can also see Area, I/O Assistant, Quick, and Timing listed in the Strategies
folder in the File List view. These are predefined strategies supplied by Lattice
Semiconductor that solve particular design requirements. For details of these
predefined strategies, refer to the Diamond Help.
When you create a new project in Diamond, a logical preference file (.lpf)
is automatically generated and assigned the same name as the FPGA
project.
For this tutorial, a logical preference file named pin_assignments.lpf is
provided and contains all the pin assignments needed to program this
design project onto the MachXO3L FPGA. All changes that you make to
logical constraints will be saved in this file until you create a new logical
preference file or add another existing one.
18. In the File List, right-click LPF Constraint Files and choose Add >
Existing File.
The Add Existing File dialog box appears.
19. Navigate to <diamond_install_directory>/docs/tutorial/Diamond_tutorial
and select pin_assignments.lpf.
Select Copy file to Implementation’s Source directory and click Add.
20. In the File List view, right-click pin_assignments.lpf and choose Set as
Active Preference File.
21. Under Input Files, right-click testbench.v and choose Include for >
Simulation.
The Process view, shown in Figure 5, lists all the processes available, such
as Synthesize Design, Translate Design, Map Design, Place & Route Design,
and Export Files.
The Reports view allows you to examine and print process reports. There are
two panes in the Reports view. The left pane lists the reports. The right pane
displays the reports.
Log messages are displayed in the Output frame of the Diamond main
window.
In this task, you will generate a phase lock loop (PLL) module to import into
your design.
3. In the Configuration tab, all information is filled in from the design project
except for File Name and Module Output. For this tutorial:
Enter my_pll as the File Name.
Choose Verilog as the Module Output.
IPexpress should appear similar to Figure 6.
4. Click Customize.
The Lattice FPGA Module — PLL dialog box appears.
5. In the Configuration tab:
Select Frequency Mode.
For CLKI Frequency, enter 20.
For CLKOP Desired Frequency, enter 80.
For CLKOP Tolerance, choose 1.0.
Select Provide PLL Lock signal.
6. Click Calculate.
7. Select Import IPX to Diamond project.
8. Click Generate.
The IPexpress .ipx file is generated.
9. The Generated Log tab appears, as shown in Figure 7.
In this tutorial, we will just do the RTL simulation. For the other stages, the
process is similar.
For a simulator, this tutorial uses the Mentor® ModelSim® Lattice FPGA
Edition simulator that comes with Diamond on Windows.
If you are not using an HDL simulator that is integrated with Diamond, you can
skip this task. “Integrated” means that you can run the simulator from
Diamond. What is available depends on your operating system. You can use
other simulators outside of Diamond.
If you are not using the ModelSim that comes with Diamond, you need to
compile the primitive library. For instructions, open the Diamond Help and see
User Guides > Simulating the Design > Third-Party Simulators.
This tutorial comes with a simple testbench. You will probably create your
own testbenches using your simulator. Simulators usually include tools for
creating testbenches.
10. Make sure that the Run simulator, Add top-level signals to waveform
display, and Run simulation options are all selected.
11. Click Finish.
The selected simulator launches and the simulation starts automatically.
After completing the simulation, the waveform appears. This takes several
moments. Wait for the waveform to appear.
If you see the Welcome to ModelSim dialog box, select Don’t show this
again, at the bottom of the dialog box, and click Close. Do not click
Jumpstart.
12. Look at the File List view in the Diamond window. Under Script Files, you
see sim_test/sim_test.spf.
You can rerun the simulation by double-clicking the .spf file. The Simulation
Wizard will open with a Skip to End button. Click it to jump to the last page of
the wizard. Then click Finish to start the simulation running.
Now that you have run the simulation, you can see what happened on the top-
level signals of the testbench as shown in Figure 8. ModelSim stopped
automatically after the first microsecond of simulation time. The testbench is
set to run longer, over 5 µs, but this is enough to see the startup.
The values shown in the Objects and Wave views change to hexadecimal.
5. Choose Wave > Zoom > Zoom Full or click the Zoom Full button in
the toolbar to see the whole waveform. The Zoom toolbar looks like this:
In the Wave view, you see the reset signal activated by the testbench.
After reset is released, count2 and count3 start counting up.
6. The values of count2 may not be visible. Click the Zoom In button in
the toolbar until you can see the values.
7. Choose Simulate > Run > Run 100 or click the Run button to see
more of the simulation. The Run toolbar looks like this:
Another 100 ns is added to the waveforms. This is the time you set in the
Runtime Options dialog box. You can change this amount in the box next
to the Run button.
8. Click anywhere to see what the values are at that moment.
The nearest cursor (a vertical yellow line) jumps to where you clicked. The
value column shows all the values at that moment.
You can click on the cursor and drag it to other positions on the timeline.
You can also return to the cursor after scrolling away by clicking the Zoom
In on Active Cursor button.
Warning
Do not click Yes. If you do, the $finish statement in the testbench causes
ModelSim to exit.
If this happens, go to the File List view in the Radiant window and look under the
Script Files folder. Double-click sim_test/sim_test.spf to restart ModelSim.
Active Strategy
Active Implementation
5. In the Find box at the top of the Device View, enter EBR_R13C21
(Embedded Block RAM Row 13, Column 21).
The EBR design symbol is highlighted, as shown in Figure 11.
You will be using Synopsis Synplify Pro for Lattice to synthesize your design
for the MachXO3L FPGA. If you are designing for most devices, you can use
Lattice Synthesis Engine or another third-party synthesis tool instead of
Synplify Pro for Lattice. LSE is not available with LatticeEC, LatticeECP,
LatticeSC/M, or LatticeXP. To change the synthesis tool, from the Diamond
main window, choose Project > Active Implementation > Select Synthesis
Tool.
In the Hierarchy table shown in Figure 13, topcount is the top module
displaying the resource utilization.
PFU Registers – 48 represents the total PFU register utilization
throughout the design and 0 represents the PFU registers used only in the
design module topcount. Similar utilization is shown for the I/O registers
and carry cells.
my_pll_uniq_1, count8_uniq_0, and count32_uniq_1 are the sub-modules
(instances) of the design. For example, for the sub-module
count32_uniq_1, 32(32) under PFU Registers represents the total PFU
registers used in the sub-module.
Hence, the total number of logic resources (adding the resources from the
individual module) is reflected in the top level module topcount.
13. Select the Port Assignments tab from the Spreadsheet View.
This tab shows the port assignments that came with the
pin_assignments.lpf file and specifications for each port. You could make
changes here if you needed to.
14. Choose File > Save pin_assignments.lpf from the Spreadsheet View.
15. Close Spreadsheet View.
16. In the File List view, under the LPF Constraint Files folder, double-click
pin_assignments.lpf.
Source Editor appears. Note the timing and location preferences defined.
17. Close Source Editor.
18. In the Process view, double-click Map Design.
The batch interface to logic synthesis, EDIF translation, and the design
mapper run. Report files appears in the Reports view. To view each
process report, select the process in the Design Summary pane.
19. From the Design Summary pane of the Reports view, select Process
Reports > Map.
The Map Report appears in the right pane.
20. Right-click in the right pane of the Reports view.
21. Choose Find in Text.
A box labeled “Find” appears at the bottom of the Reports view.
22. In the Find box, enter Design Summary.
The report highlights the Design Summary section of the report.
In the Design Summary pane, there is the report icon . If a report has been
generated, the icon appears as . If the report is not the most recent version,
the icon appears as . To view the contents of the entire report, click on the
report to be viewed. The entire report is then displayed in the right pane of the
Reports view. Use the scroll bar to navigate through the report. Some of the
reports are divided into sections (for example, Map, Place & Route, and
Signal/Pad). Click the arrow before the report name to display the sections in
a list. Choose the desired section. The whole report will be displayed with the
selected section displayed at the top of the right pane of the Reports view.
11. Right-click on the Floorplan View tab and choose Move to Another Tab
Group.
Now both tabs are merged into a single group as before.
12. Close Floorplan View and Physical View.
Note
If you do not have a MachXO3L Starter Kit, skip this task.
9. Click OK.
10. Click the Program button on the Programmer toolbar to initiate the
download.
9. Drag the directionR signal from the Design Tree pane to the Signals
(MSB:LSB) box in row 2 of the Trigger Unit pane.
10. In the Operator box, choose <=.
11. In the Radix box, choose the default of Bin.
12. In the Value box, enter 1.
Note
If you do not have a MachXO3L Starter Kit, skip the rest of the tutorial. Go to
“Summary of Accomplishments” on page 44.
To generate a bitstream:
1. In the Process view, click Bitstream File under Export Files.
2. Click the Run button on the Diamond toolbar.
Diamond reruns all processes, generating the selected files and saving
them in your project directory.
3. Choose Tools > Programmer.
Programmer opens using the LEDtest.xcf file.
4. Click the Program button on the Programmer toolbar to initiate the
download.
If the programming process succeeds, you will see a green-shaded PASS
in the Programmer Status column.
5. Close Programmer.
This task assumes that the MachXO3L Starter Kit board is connected to your
computer with a USB cable.
8. Click OK.
The Reveal Logic Analyzer main window now appears with the LA Trigger
tab selected, as shown in Figure 23. It contains the same trigger units and
trigger expressions that you set up in Reveal Inserter.
9. In the Trigger Options section, for Samples Per Trigger, choose 64.
10. In the Trigger Position section, choose Post-Trigger.
In the Trigger Position section, you can specify the trigger position relative
to the trace data. The numbers in the section title show the current
position.The two options to choose from include:
Pre-selected allows you to choose one of the standard positions.
To capture data:
1. Click the Run button in the Reveal Analyzer toolbar.
The Run button changes into the Stop button and the status bar next to
the button shows the progress.
Reveal Analyzer first configures the modules selected for the correct
trigger condition, then waits for the trigger conditions to occur. When a
trigger occurs, the data is uploaded to your computer. The resulting
waveforms appear in the LA Waveform tab.
Since the “countbi” trigger was set to <= 88 and the “dir” trigger was set to
<= 1, any DIP switch setting will immediately set off a trigger. The trigger
expression can now evaluate the next trigger unit and generate a trigger
for data to be captured.
Summary of Accomplishments
You have completed the Lattice Diamond 3.14 Tutorial. In this tutorial, you
have learned how to:
Create a new Lattice Diamond project.
Create an IPexpress module.
Check Hardware Description Language (HDL).
Verify functionality with simulation.
Inspect strategy settings.
Examine resources.
Set timing and location assignments.
Process the design.
Examine static timing analysis results.
Analyze power consumption.
Run export utility programs.
Download a bitstream to an FPGA.
Use Reveal Inserter to add on-chip debug logic.
Use Reveal Logic Analyzer to perform logic analysis.
Recommended References
You can find additional information on the subjects covered by this tutorial in
the Diamond software online Help, and in the Diamond User Guide.
Revision History
The following table gives the revision history for this document.