diff --git a/tools/modelsim/commands.do b/tools/modelsim/commands.do
index d9cae9cb1262a52f32e4706338812a3fb627a696..01ce3567d4f8408f4965298c60b1964b541413d4 100644
--- a/tools/modelsim/commands.do
+++ b/tools/modelsim/commands.do
@@ -150,6 +150,19 @@ proc parse_for_libs arg_list {
     return $libs
 }
 
+# Create work library
+proc do_vlib arg_work {
+    set modelsimId [vsimId]
+    set dot_index [string first . $modelsimId]
+    set modelsimId [string range $modelsimId 0 [expr $dot_index-1]]
+    if {$modelsimId < 10} {
+        vlib $arg_work
+    } else {
+        # The makefile that is created by vmake relies on using directories in vlib
+        vlib -type directory $arg_work
+    }
+}
+
 # Extract this lib or all libs that it depends on for arg_lib
 proc extract_all_libs arg_lib {
     if {$arg_lib=="all"} {
@@ -214,7 +227,7 @@ proc mk_execute {arg_lib} {
         lp $arg_lib
         # create work library if it does not already exist
         if {![file exists "$sim/work"]} then {
-            vlib work
+            do_vlib work
         }
         global env   ;# Make global env() variable known locally. This is necessary for $env(*) in compile IP tcl script, alternatively use $::env(*) in compile IP tcl scrip
         foreach ip $compile_ip {
@@ -236,7 +249,7 @@ proc mk_compile {arg_lib} {
     if {[file exists "$sim/work"]} then {
         vdel -lib $sim/work -all
     }
-    vlib work
+    do_vlib work
     # and then first execute any IP compile scripts
     mk_execute $arg_lib
     # and then compile the HDL
@@ -263,7 +276,7 @@ proc mk_vmake {arg_lib} {
     }
     # recreate work library
     vdel -lib $sim/work -all
-    vlib work
+    do_vlib work
     # and then first execute any IP compile scripts
     mk_execute $arg_lib
 }