OpenCores
URL https://opencores.org/ocsvn/radiohdl/radiohdl/trunk

Subversion Repositories radiohdl

[/] [radiohdl/] [trunk/] [doc/] [radiohdl_hdl_tool_modelsim.md] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 danv
# RadioHDL tool settings for Modelsim
2
 
3
---
4
#### Document history:
5
|Revision|Date|Author|Affiliation|Modification|
6
|:---|:---|:---|:---|:---|
7
|1.0|27 jan 2020|E. Kooistra|ASTRON |Created.|
8
 
9
---
10
#### Contents:
11
1       Introduction
12
1.1     Preconditions
13
2       Creating Modelsim project files
14
3       Using Modelsim
15
3.1     Starting the Modelsim GUI
16
3.2     Compiling the HDL
17
3.3     Simulating the HDL
18
3.4     Developing the HDL
19
4       Appendix: Configuration files
20
4.1     hdl_tool_modelsim.cfg
21
4.2     hdllib.cfg keys for Modelsim
22
5 Appendix: hdl_tool_modelsim.cfg
23
 
24
---
25
#### Terminology:
26
 
27
- FPGA = Field Programmable Gate Array
28
- GUI = Graphical User Interface
29
- HDL = Hardware Description Language
30
- IP = Intellectual Property
31
- MPF = Modelsim Project File
32
 
33
---
34
#### References:
35
[1] radiohdl_user_guide.md
36
[2] radiohdl_hdl_library_key_descriptions.md
37
 
38
---
39
## 1 Introduction
40
The RadioHDL package consists of a set of scripts that interpret configuration files and that setup or run other tools for HDL code development [1]. This document describes how to use the following RadioHDL tools for compiling and simulating HDL code with Mentor/Modelsim:
41
 
42
* **modelsim_config** : to create Modelsim project files (mpf) for simulation of HDL code
43
* **run_modelsim** : to start the Modelsim GUI and make and compile HDL code in Modelsim and hierarchically add signals to the Modelsim wave window
44
 
45
### 1.1 Preconditions
46
Setup the RadioHDL environment as explained in [1].
47
 
48
The RadioHDL for Modelsim is configured using a hdl_tool_.cfg = hdl_tool_modelsim.cfg configuration file (see appendix), where the tool_name = modelsim is defined in a hdl_buildset_.cfg configuration file. Here assume we use the quick start example from [1], so with hdl_buildset_qs.cfg and hdl_tool_modelsim.cfg. The HDL source is grouped into one or more HDL libraries that are described by hdllib.cfg configuration files.
49
 
50
---
51
## 2 Creating Modelsim project files
52
The binaries for Modelsim are built in a separate directory tree under $RADIOHDL_BUILD_DIR.
53
Use modelsim_config to create the Modelsim project files (mpf) for all your HDL libraries. In this example the quick start buildset 'qs' is used:
54
 
55
> \> modelsim_config -h
56
> \> modelsim_config qs
57
 
58
The modelsim_config script puts the created files and copied files in the build directory, at:
59
 
60
$RADIOHDL_BUILD_DIR///
61
 
62
> For 'buildset_name = qs' and 'sim_tool_name = modelsim' defined in hdl_buildset_qs.cfg this is at:
63
 
64
> $RADIOHDL_BUILD_DIR/qs/modelsim
65
 
66
The  sub directories follow from the 'hdl_lib_name' key that is defined in the hdllib.cfg configuration files per HDL library. The modelsim_config script finds all hdllib.cfg files within 'lib_root_dirs = ${RADIOHDL_WORK}' that is defined in hdl_buildset_qs.cfg. The lib_root_dirs  can list one or more search trees.
67
 
68
Optionally you can clear this directory before running modelsim_config because everything is recreated:
69
 
70
> \> rm -rf $RADIOHDL_BUILD_DIR/qs/modelsim
71
 
72
If the HDL library dependencies change, e.g. because a new VHDL file is added to a library, or if a filename is changed, then it is necessary to rerun the modelsim_config.
73
 
74
In addition to the Modelsim project files the modelsim_config also generates some auxiliary files that are used by commands.do in run_modelsim as quick reference to all HDL libraries. The central modelsim_project_files.txt at $RADIOHDL_BUILD_DIR/qs/modelsim/ contains a list of the paths to all HDL libraries. Per HDL library there is a _lib_order.txt file that contains a list of all HDL libraries  that this HDL library depends on in order.
75
 
76
---
77
## 3 Using Modelsim
78
 
79
### 3.1 Starting the Modelsim GUI
80
 
81
To support your work inside Modelsim, RadioHDL comes with a **command.do** file that adds the following useful commands to the Modelsim Transcript command line window:
82
 
83
* lp = load project
84
* mk = make project
85
* as = add signals to the wave window
86
* ds = delete signals from wave window
87
 
88
To use these commands with your buildset start the Modelsim GUI with your buildset_name using run_modelsim:
89
 
90
> \> run_modelsim qs &
91
 
92
### 3.2 Compiling the HDL
93
First compile the dp_repack_data library and the libraries that it depends on.In the Modelsim Transcript window load Modelsim project file for HDL library dp_repack_data:
94
> ModelSim> lp dp_repack_data
95
 
96
Report current library:
97
> ModelSim> lp
98
 
99
Report all libraries in order that dp_repack_data depends on:
100
> ModelSim> lp all
101
 
102
Compile all libraries in order that dp_repack_data depends on:
103
> ModelSim> mk compile all
104
 
105
Compile only this dp_repack_data library:
106
> ModelSim> mk compile
107
 
108
To load another HDL library project e.g. common_pkg, do:
109
> ModelSim> lp common_pkg
110
 
111
Report all libraries in order that common_pkg depends on:
112
> ModelSim> lp all
113
 
114
Instead of 'mk compile' one can use GNU 'make' for Unix (or make.exe on Windows) and Modelsim 'vmake' via the 'mk' command from **commands.do**. The advantage is that after an initial successful compile of all, any subsequent recompiles after editing a HDL source file only will require recompilation of the HDL source files that depend on it.
115
 
116
Load Modelsim project file for HDL library dp_repack_data:
117
> ModelSim> lp dp_repack_data
118
 
119
Clean build directories and makefiles in $RADIOHDL_BUILD_DIR that were made for dp_repack_data:
120
> ModelSim> mk clean all
121
 
122
Make all libraries in order that dp_repack_data depends on and create the makefiles for those libraries:
123
> ModelSim> mk all
124
 
125
To make only this dp_repack_data library do:
126
> ModelSim> mk
127
 
128
To make only the specific common_pkg library do:
129
> ModelSim> mk common_pkg
130
 
131
The first time 'mk all' is called the libraries are compiled and the library makefiles are made. The library makefiles are stored in the library build directories in $RADIOHDL_BUILD_DIR. It is important that all libraries compile OK, because otherwise the library makefiles are not created properly. Therefore if a library fails to compile, then load that library project with 'lp' and keep on doing 'mk compile' until the library compiles OK. Then when it compiles OK do 'mk clean' to clear the library build directory at $RADIOHDL_BUILD_DIR, and then do 'mk' or 'mk all' to compile the library again and create a proper makefile. Repeat this process until also the top level HDL library compiles OK.
132
 
133
With the proper makefiles for all HDL libraries it is sufficient to use 'mk' to automatically recompile only the HDL source files that changed or that depend on the changed file. Similar with 'mk all' a change in some lower level library HDL file will only cause that the HDL files that depend on it will be recompiled. For a big project with many libraries using 'mk all' is much easier and faster to use than 'mk compile all'. Doing 'mk all' and again 'mk all' should show that the second 'mk all' did not need to recompile any HDL again.
134
 
135
Note that the dp_repack_data library also depends on the common_pkg library. Therefore when doing the following:
136
 
137
> ModelSim> lp common_pkg
138
> ModelSim> mk clean all
139
> ModelSim> mk all
140
> ModelSim> lp dp_repack_data
141
> ModelSim> mk all
142
 
143
Then the 'mk all' in the dp_repack_data library will not recompile the libraries that were already compiled by the 'mk all' in the common_pkg library. Similar if you clean the common_pkg library while the dp_repack_data library project is loaded:
144
 
145
> ModelSim> lp dp_repack_data
146
> ModelSim> mk clean common_pkg
147
> ModelSim> mk all
148
 
149
Then the 'mk all' in the dp_repack_data library will recompile and recreate the makefile for the common_pkg library, and then reompile the HDL files in the higher libraries (up to dp_repack_data) that directly or indirectly depend on a HDL file in the common_pkg library.
150
 
151
If a new VHDL file is added to a library or if a filename is changed, then it is necessary to rerun the modelsim_config and to do 'mk clean' on that library. It is important that Modelsim does not have that library open already, so either quit Modelsim first or 'lp' to another library first, before running modelsim_config. Typically it is not necessary to do 'mk clean all', nor is it necessary to delete the entire $RADIOHDL_BUILD_DIR library subdirectories.
152
 
153
### 3.3 Simulating the HDL
154
 
155
The simulation is done using a VHDL test bench (tb). These test bench files are made more recognizable by using the 'tb_' prefix. All HDL files that are listed at the test_bench_files key in the hdllib configuration file will have a simulation configuration icon in the Modelsim GUI. To simulate the tb_repack_data.vhd test bench in the dp_repack_data library do e.g.:
156
 
157
> ModelSim> lp dp_repack_data
158
> Manually load simulation by double clicking the tb_repack_data icon in the Modelsim Project window
159
 
160
Add all signals of 10 levels deep into of test bench hierarchy to the Wave Window:
161
> ModelSim> as 10
162
 
163
Run all until the test bench is done:
164
> ModelSim> run -a
165
 
166
This tb_dp_repack_data.vhd test bench is self checking and self stopping. In the Wave window the signals can be observed visually, see Figure 1.
167
 
168
 
169
![Figure 1](./wave_tb_dp_repack_data.jpg "wave_tb_dp_repack_data.jpg")
170
Figure 1: Modelsim wave window with hierarchical signals view using 'as' command
171
 
172
### 3.4 Developing the HDL
173
 
174
Edit one of the VHDL source files or for example do:
175
 
176
> \> touch $QS_DIR/cores/dp/dp_pkg/dp_stream_stimuli.vhd
177
 
178
Then in Modelsim GUI:
179
 
180
> ModelSim> mk all
181
> ModelSim> restart -f
182
> ModelSim> run -a
183
 
184
The 'mk all' will only compile the touched files and the files that depend on it. The 'restart -f' cleans the wave window but preserves the viewed signal. The 'run -a' runs the simulation.
185
 
186
The tb in the dp_repack_data library run as long as needed to apply the stimuli, and they are self checking. The tb_repack_data is instantiated into a multi test bench tb_tb_repack_data. By running this tb_tb_repack_data the entire dp_repack_data library gets verified in one simulation.
187
 
188
To change project library using 'lp ' first the current active simulation needs to be closed using 'quit -sim'. To quit Modelsim entirely, without having to acknowledge the pop up do 'quit -f'.
189
 
190
---
191
## 4 Appendix: configuration files
192
 
193
### 4.1 hdl_tool_modelsim.cfg
194
 
195
This appendix describes the keys that are used in the hdl_tool_modelsim configuration file that is located in $RADIOHDL_GEAR/config.
196
 
197
***model_tech_altera_lib***
198
Defines the path to where the compiled component libraries of a certain Quartus version are stored.
199
 
200
 
201
### 4.2 hdllib.cfg keys for Modelsim
202
 
203
This appendix describes the keys that are used in the [modelsim_project_file] section of the hdllib.cfg configuration file. Please see [2] for hdllib.cfg configuration file examples that use these Modelsim specific keys.
204
 
205
***modelsim_copy_files***
206
Copy listed all directories and files for simulation with Modelsim, used when tool_name_sim = modelsim in hdltool_.cfg. Can be used to eg. copy wave.do or data files from the source directory to the build directory where the Modelsim project file is. For data files that are read in VHDL the path within the build directory then becomes e.g. data/.
207
 
208
***modelsim_compile_ip_files***
209
This key lists one or more TCL scripts that are executed by the Modelsim mpf before it compiles the rest of the source code. E.g.:
210
 
211
- compile_ip.tcl : a TCL script that contains external IP sources that are fixed and need to be compiled before the synth_files. For the Altera IP the compile_ip.tcl is derived from the msim_setup.tcl that is generated by the MegaWizard or Qsys [2].
212
- copy_hex_files.tcl : a TCL script that is derived fromt yhe msim_setup.tcl and is used to copy ROM/RAM files initialization files from the generated IP directory to the simulation work directory.
213
- map_ip.tcl : a TCL script that maps a VHDL library name to another location (not use so far).
214
 
215
---
216
## 5 Appendix: hdl_tool_modelsim.cfg
217
 
218
Tool configuration file for Mentor/Modelsim from $RADIOHDL_GEAR/config.
219
```
220
# configuration file for defining the model installation on this system
221
model_tech_altera_lib     = ${MODELSIM_ALTERA_LIBS_DIR}/${SYNTH_TOOL_VERSION}
222
```
223
 
224
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.