1

In an Modelsim .do file, I tried:

vcom file1.vhd file2.vhd

which works fine.

But when I try:

set comp_files "file1.vhd file2.vhd"
vcom $comp_files

it didn't work and I got an error:

Error: (vcom-7) Failed to open design unit file "file1.vhd file2.vhd" in read mode.

Anyone know how to get the comp_files worked?

Cong Li
  • 369
  • 2
  • 5
  • 13
  • .do files are tcl scripts. Have you looked at a tcl language reference? There ought to be one in the Modelsim documentation. –  Mar 26 '18 at 10:41
  • @BrianDrummond I tried but I can't find a solution to my pb. I do this because I want to categorize my vhdl files like : design_files, testbench_files, XXX_files... – Cong Li Mar 26 '18 at 11:34

2 Answers2

3

You have to expand the list comp_files to individual arguments using {*} (Tcl 8.5):

set comp_files "file1.vhd file2.vhd"
vcom {*}$comp_files

Alternatively, you can use the legacy eval (should also work with Tcl versions < 8.5):

set comp_files "file1.vhd file2.vhd"
eval vcom $comp_files
Flopp
  • 1,887
  • 14
  • 24
1

So: set comp_files "file1.vhd file2.vhd" creates a list.

try llength $comp_files And it will return "2" = two elements.

So you can call vcom for each file in the list

foreach comp_file $comp_files { vcom $comp_file }
JHBonarius
  • 10,824
  • 3
  • 22
  • 41
  • I tried your solution, but it tells me `** Error: can't read "comp_file": no such variable` – Cong Li Mar 26 '18 at 13:36
  • @CongLi hmm, strange. Are you sure you did not mistype something? Works fine here. – JHBonarius Mar 26 '18 at 15:44
  • 1
    Technically, the first `set` command creates a string; the string gets parsed and interpreted as a list as soon as its passed as an argument to the first command expecting to receive a list. So if one wants to be absolutely sure (and that's a good thing!), it's better to use the `list` command explicitly: `set comp_files [list file1.vhd file2.vhd]` – kostix Mar 26 '18 at 18:26
  • @kostix of course, there's always a better way. Just telling the OP a possible solution – JHBonarius Mar 26 '18 at 18:36