ModelSim - vcom dependency order

A

andyesquire

Hi,

Does anybody know a way to automatically generate the correct compile
order in ModelSim without using the GUI?

Compiling via the GUI finds the correct compile order, but there does
not seem to be an equivalent way to do this from the command line or in
a TCL script - if you have 50 .vhd files, do you have to manually
figure out all the dependencies and manually enter the vcom commands in
the correct order? That would be very time consuming.

What I'm looking for is something like vcom -R toplevel.vhd where -R
means recursively compile but sadly this is lacking from the user
manual :)

TIA,

Andy.
 
M

Mike Treseler

Does anybody know a way to automatically generate the correct compile
order in ModelSim without using the GUI?

If you have "make" you use
modelsim "vmake" and say

vmake > Makefile
make test_my_design

Emacs vhdl-mode has a slightly fancier
makefile generator.

-- Mike Treseler
 
T

Tim Hubberstey

Mike said:
If you have "make" you use
modelsim "vmake" and say

vmake > Makefile
make test_my_design

Emacs vhdl-mode has a slightly fancier
makefile generator.

That works great, if you already have a successfully compiled design in
the 'work' library. If you don't . . .

A brute force, but very simple, method is to create a batch file that
compiles all the files, in any order, and then loops back to start over
if there is an error in any of the compiles. Eventually, all
dependencies will be resolved by one of the previous compile iterations
and the loop can exit. Then you can run the vmake steps Mike outlines
and get the correct compile order.

You can reduce the number of iterations by grouping the compiles so that
all packages compile before any sources. It is a truly nasty technique
but it does work and costs nothing but computer time so fire it up and
go to lunch.

There are some free tools available that will extract the hierarchy for
you, but you still end up having to translate the output into a compile
script. This way, you should be able to write a generic script and just
run it on each new project.

I don't usually use this technique (I update my build script each time I
add a new file) but it saves a lot of pain if you're taking over a
project that doesn't have a build script.
 
K

Klaus Falser

If you have "make" you use
modelsim "vmake" and say

vmake > Makefile
make test_my_design

Emacs vhdl-mode has a slightly fancier
makefile generator.

-- Mike Treseler

Vmake is able only to extract the dependencies from a
library. You have to compile your design at least once
manually in the correct order for using vmake.

If the question was about a tool which starts from a
top level entity and collects all subentities generating
a makefile, then vmake is of no help, but I believe
emacs vhdl-mode does the job.

Best regards
Klaus
 
A

Alan Fitch

Tim Hubberstey said:
That works great, if you already have a successfully compiled design in
the 'work' library. If you don't . . .

A brute force, but very simple, method is to create a batch file that
compiles all the files, in any order, and then loops back to start over
if there is an error in any of the compiles. Eventually, all
dependencies will be resolved by one of the previous compile iterations
and the loop can exit. Then you can run the vmake steps Mike outlines
and get the correct compile order.

You can reduce the number of iterations by grouping the compiles so that
all packages compile before any sources. It is a truly nasty technique
but it does work and costs nothing but computer time so fire it up and
go to lunch.

There are some free tools available that will extract the hierarchy for
you, but you still end up having to translate the output into a compile
script. This way, you should be able to write a generic script and just
run it on each new project.

I don't usually use this technique (I update my build script each time I
add a new file) but it saves a lot of pain if you're taking over a
project that doesn't have a build script.
 
A

Alan Fitch

Tim Hubberstey said:
That works great, if you already have a successfully compiled design in
the 'work' library. If you don't . . .

A brute force, but very simple, method is to create a batch file that
compiles all the files, in any order, and then loops back to start over
if there is an error in any of the compiles. Eventually, all
dependencies will be resolved by one of the previous compile iterations
and the loop can exit. Then you can run the vmake steps Mike outlines
and get the correct compile order.

You can reduce the number of iterations by grouping the compiles so that
all packages compile before any sources. It is a truly nasty technique
but it does work and costs nothing but computer time so fire it up and
go to lunch.

There are some free tools available that will extract the hierarchy for
you, but you still end up having to translate the output into a compile
script. This way, you should be able to write a generic script and just
run it on each new project.

I don't usually use this technique (I update my build script each time I
add a new file) but it saves a lot of pain if you're taking over a
project that doesn't have a build script.
--


Another thing you can try to create the correctly compiled library is
to
compile using vcom -just, e.g. compile packages, then entities, then
package
bodies, then architectures, then configurations. I.e.

vcom -just p *.vhd
vcom -just e *.vhd
vcom -just pb *.vhd
vcom -just a *.vhd
vcom -just c *.vhd

regards

Alan

--
Alan Fitch
Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project
Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24
1AW, UK
Tel: +44 (0)1425 471223 mail:
(e-mail address removed)
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com

The contents of this message may contain personal views which are not
the
views of Doulos Ltd., unless specifically stated.
 
T

Tim Hubberstey

Alan said:
Another thing you can try to create the correctly compiled library is
to
compile using vcom -just, e.g. compile packages, then entities, then
package
bodies, then architectures, then configurations. I.e.

vcom -just p *.vhd
vcom -just e *.vhd
vcom -just pb *.vhd
vcom -just a *.vhd
vcom -just c *.vhd

That will certainly result in many fewer errors but I don't think it
accounts for dependencies within configurations. If the configuration in
a.vhd calls out b.vhd, won't you be toast?


I decided that I should write a Windows script to do the iterative
compile method in case I need it later. I'm releasing it under GPL and
you can get it from:

<http://www.geocities.com/marmoteng/brute_vcom_v0.1.zip>

There's no documentation, for now, except what's in the source. OTOH,
there's no options either so it shouldn't need much documentation. Just
run it from a command window (Windows 2000 or XP) and it will
iteratively compile all .vhd files in the directory.

Suggestions through my homepage are welcome -- action on any suggestions
not guaranteed. ;)
 
A

andyesquire

Mike - Thanks that's a good solution, unfortunately I'm on Windows but
maybe I can get make under Cygwin to work, although as Klaus pointed
out this does require a fully compiled design.

Tim - The brute force approach, I like it but if I have to write any
code then I'd go all out and write a Java program but that's a few days
of effort (call me a masochist).

Alan - I'll try this, but does it work if there are dependencies at the
same level in the tree that are not compiled in the order elaborated by
the *.vhd wildcard?

Andy.
 
A

ALuPin

Hi,

try the following .do file (Execute Macro)
When opening Modelsim stand-alone you should CHANGE DIRECTORY to
D:/project_directory/simulation/modelsim

# Here starts the macro file
vlib work
cd D:/project_directory/simulation/modelsim
set SRC_DIR "D:/project_directory"

# Enter the correct order of files to compile
vcom ${SRC_DIR}/vhdl_file1.vhd
vcom ${SRC_DIR}/vhdl_file2.vhd
....
vcom ${SRC_DIR}/vhdl_file100.vhd

vcom ${SRC_DIR}/simulation/modelsim/tb_testbench.vhd

vsim tb_testbench

do wave.do

run 10ms -all

configure wave -signalnamewidth 1
set StdArithNoWarnings 1
set IgnoreWarning 1
set DefaultRadix unsigned
 
A

Alan Fitch

Mike - Thanks that's a good solution, unfortunately I'm on Windows but
maybe I can get make under Cygwin to work, although as Klaus pointed
out this does require a fully compiled design.

Tim - The brute force approach, I like it but if I have to write any
code then I'd go all out and write a Java program but that's a few days
of effort (call me a masochist).

Alan - I'll try this, but does it work if there are dependencies at the
same level in the tree that are not compiled in the order elaborated by
the *.vhd wildcard?

I don't think it does. But it "often" works :)

regards

Alan
 
H

Hans

Hi Andy,

I have a simple utility on my website to sort out dependency, this might
help you out, see:

http://www.ht-lab.com/freeutils/vhdlsort/vhdlsort.html

Hans.
www.ht-lab.com

|
| Hi,
|
| Does anybody know a way to automatically generate the correct compile
| order in ModelSim without using the GUI?
|
| Compiling via the GUI finds the correct compile order, but there does
| not seem to be an equivalent way to do this from the command line or in
| a TCL script - if you have 50 .vhd files, do you have to manually
| figure out all the dependencies and manually enter the vcom commands in
| the correct order? That would be very time consuming.
|
| What I'm looking for is something like vcom -R toplevel.vhd where -R
| means recursively compile but sadly this is lacking from the user
| manual :)
|
| TIA,
|
| Andy.
|
 
M

Mike Treseler

Tim said:
That works great, if you already have a successfully compiled design in
the 'work' library.

Actually vhdl-mode make will do the compiles also.

-- Mike Treseler
 
T

Tristan Gingold

Mike - Thanks that's a good solution, unfortunately I'm on Windows but
maybe I can get make under Cygwin to work, although as Klaus pointed
out this does require a fully compiled design.

Tim - The brute force approach, I like it but if I have to write any
code then I'd go all out and write a Java program but that's a few days
of effort (call me a masochist).

Alan - I'll try this, but does it work if there are dependencies at the
same level in the tree that are not compiled in the order elaborated by
the *.vhd wildcard?
You can also use ghdl (http://ghdl.free.fr), which is able to automatically
find an analysis order.

Tristan.
 
B

Bert Cuzeau

ALuPin said:
Hi,

try the following .do file (Execute Macro)
When opening Modelsim stand-alone you should CHANGE DIRECTORY to
D:/project_directory/simulation/modelsim

# Here starts the macro file
vlib work
cd D:/project_directory/simulation/modelsim

I would remove this "cd" line,
(If you're not there before creating work, it'll fail.)
or I would move "vlib work" after cd
set SRC_DIR "D:/project_directory"

# Enter the correct order of files to compile
vcom ${SRC_DIR}/vhdl_file1.vhd
vcom ${SRC_DIR}/vhdl_file2.vhd
...
vcom ${SRC_DIR}/vhdl_file100.vhd

vcom ${SRC_DIR}/simulation/modelsim/tb_testbench.vhd

vsim tb_testbench

do wave.do

run 10ms -all

???
either run -a
or
run 10ms ?

---
My $0.01 addition to the numerous posts :

Compile :
- Packages first
- Configurations last

In between compilation :
- is mostly order INdependent if you use components.
- must be bottom-up if you use direct instanciation of entities.
- if entities and arch are in separate files,
then entities must compile first.

In any case, test benches are often easy to spot if there
is an enforced naming convention in place and you can compile
them last (before configs) just in case.

If the naming conventions says (for example) that packages
end with _pk, test benches end with _tb and configs with _cf,
since .do files are Tcl, you can use simple regular expressions
to compile the .vhd files in the mentioned above order.
The only remaining issue is if you use direct instanciation
outside test benches.

BTW : I believe emacs vhdl mode does this dependancy checking
(not 100% sure though).

In practice, we do NOT do this above :
As someone else said, I don't like compiling just anything wildly
in a project ! Having a wrong file compiled in a project can be a major
source of frustration.
We have Tcl scripts for each project, and we carefully select the files
that we compile (and those we don't), and the compilation order comes
naturally.

A text file containing the list of design files to compile for a given
project is a true blessing : you can use it in your simulation script,
synthesis script (Quartus, Synplify, Leonardo, Precision...) and for
archival script (and make if you want) too.

Bert Cuzeau
 
M

Mike Treseler

Bert said:
In between compilation :
- is mostly order INdependent if you use components.
- must be bottom-up if you use direct instanciation of entities.

True. The downside to components
is keeping port changes lined up.
BTW : I believe emacs vhdl mode does this dependancy checking
(not 100% sure though).

True for the working library.
Other library references must be
pre-compiled and mapped before using
the emacs vhdl-generate-makefile command.
You can grab an ordered file list
with the shell commands:

make clean
make my_design_tb

-- Mike Treseler
 
E

Eric DELAGE

I use ModelSim on windows. Its embedded TCL interpreter has some
commands for you. You should type 'help project' in the interpreter to
see how it works.

There are things like project add <your_file>, project compileall, ...
The only limitation that I have found is that I still don't have
understand how I can associate such or such VHDL file to such or such
symbolic library name. Any idea?

Eric
 
M

Mike Treseler

Eric said:
I use ModelSim on windows. Its embedded TCL interpreter has some
commands for you. You should type 'help project' in the interpreter to
see how it works.
There are things like project add <your_file>, project compileall, ...
The only limitation that I have found is that I still don't have
understand how I can associate such or such VHDL file to such or such
symbolic library name.

try typing "vmap" from your source directory.
This will show you what is already available to USE.

Let's see what I get:

228 steptoe > vmap
Reading modelsim.ini
"work" maps to directory mylibdir.
"mylib" maps to directory mylibdir.
Reading /steptoe/usr1/modeltech/linux/../modelsim.ini
"std" maps to directory /steptoe/usr1/modeltech/linux/../std.
"ieee" maps to directory /steptoe/usr1/modeltech/linux/../ieee.
"verilog" maps to directory /steptoe/usr1/modeltech/linux/../verilog.
"vital2000" maps to directory /steptoe/usr1/modeltech/linux/../vital2000.

Next study and play with commands using library options:

vlib mylibdir
vcom -work mylibdir mycode.vhd
vdir -lib mylibdir
vmap mylib mylibdir
vmap
vmap work mylibdir
vmap
vcom mycode.vhd
vsim -c mycode
vdir

Modelsim does a good job on its
waveform, debug and shell windows.
I can't say anything nice about
the GUI project manager
so I won't say anything at all.


-- Mike Treseler
 
T

Tim Hubberstey

Mike said:
Modelsim does a good job on its waveform, debug and shell windows. I
can't say anything nice about the GUI project manager so I won't say
anything at all.

ModelSim's project manager GUI does one thing quite well... it allows
you to bypass it completely and do everything from the command line
and/or scripts. I haven't used the GUI for years. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top