55# Copyright (c) 2014-2020, Lars Asplund lars.anders.asplund@gmail.com
66
77import sys
8- from os . path import join , exists , abspath , dirname
8+ from pathlib import Path
99from vunit .sim_if .factory import SIMULATOR_FACTORY
1010from vunit .vivado import (
1111 run_vivado ,
@@ -19,35 +19,40 @@ def add_vivado_ip(vunit_obj, output_path, project_file):
1919 Add vivado (and compile if necessary) vivado ip to vunit project.
2020 """
2121
22- if not exists (project_file ):
22+ if not Path (project_file ). exists ( ):
2323 print ("Could not find vivado project %s" % project_file )
2424 sys .exit (1 )
2525
26- standard_library_path = join (output_path , "standard" )
26+ opath = Path (output_path )
27+
28+ standard_library_path = str (opath / "standard" )
2729 compile_standard_libraries (vunit_obj , standard_library_path )
2830
29- project_ip_path = join ( output_path , "project_ip" )
31+ project_ip_path = str ( opath / "project_ip" )
3032 add_project_ip (vunit_obj , project_file , project_ip_path )
3133
3234
3335def compile_standard_libraries (vunit_obj , output_path ):
3436 """
3537 Compile Xilinx standard libraries using Vivado TCL command
3638 """
37- done_token = join ( output_path , "all_done.txt" )
39+ done_token = str ( Path ( output_path ) / "all_done.txt" )
3840
3941 simulator_class = SIMULATOR_FACTORY .select_simulator ()
4042
41- if not exists (done_token ):
42- print ("Compiling standard libraries into %s ..." % abspath (output_path ))
43+ if not Path (done_token ).exists ():
44+ print (
45+ "Compiling standard libraries into %s ..."
46+ % str (Path (output_path ).resolve ())
47+ )
4348 simname = simulator_class .name
4449
4550 # Vivado calls rivierapro for riviera
4651 if simname == "rivierapro" :
4752 simname = "riviera"
4853
4954 run_vivado (
50- join ( dirname (__file__ ), "tcl" , "compile_standard_libs.tcl" ),
55+ str ( Path (__file__ ). parent / "tcl" / "compile_standard_libs.tcl" ),
5156 tcl_args = [
5257 simname ,
5358 simulator_class .find_prefix ().replace ("\\ " , "/" ),
@@ -57,12 +62,13 @@ def compile_standard_libraries(vunit_obj, output_path):
5762
5863 else :
5964 print (
60- "Standard libraries already exists in %s, skipping" % abspath (output_path )
65+ "Standard libraries already exists in %s, skipping"
66+ % str (Path (output_path ).resolve ())
6167 )
6268
6369 for library_name in ["unisim" , "unimacro" , "unifast" , "secureip" , "xpm" ]:
64- path = join ( output_path , library_name )
65- if exists (path ):
70+ path = str ( Path ( output_path ) / library_name )
71+ if Path (path ). exists ( ):
6672 vunit_obj .add_external_library (library_name , path )
6773
6874 with open (done_token , "w" ) as fptr :
@@ -79,16 +85,16 @@ def add_project_ip(vunit_obj, project_file, output_path, vivado_path=None, clean
7985 returns the list of SourceFile objects added
8086 """
8187
82- compile_order_file = join ( output_path , "compile_order.txt" )
88+ compile_order_file = str ( Path ( output_path ) / "compile_order.txt" )
8389
84- if clean or not exists (compile_order_file ):
90+ if clean or not Path (compile_order_file ). exists ( ):
8591 create_compile_order_file (
8692 project_file , compile_order_file , vivado_path = vivado_path
8793 )
8894 else :
8995 print (
9096 "Vivado project Compile order already exists, re-using: %s"
91- % abspath ( compile_order_file )
97+ % str ( Path ( compile_order_file ). resolve () )
9298 )
9399
94100 return add_from_compile_order_file (vunit_obj , compile_order_file )
0 commit comments