#NEWLINE# def create_shared_lib( model_name , c_wrapper_file , lib_file , vcd_en , vlinetrace ) : #NEWLINE# #INDENT# verilator_include_dir = os . environ . get ( 'PYMTL_VERILATOR_INCLUDE_DIR' ) #NEWLINE# if ( verilator_include_dir is None ) : #NEWLINE# #INDENT# cmd = [ 'pkg-config' , '--variable=includedir' , 'verilator' ] #NEWLINE# try : #NEWLINE# #INDENT# verilator_include_dir = check_output ( cmd , stderr = STDOUT ) . strip ( ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# error_msg = '\nError trying to find verilator include directories. The\nPYMTL_VERILATOR_INCLUDE_DIR environment variable was not set,\nso we attempted to use pkg-config to find where verilator was\ninstalled, but it looks like we had trouble finding or executing\npkg-config itself. Try running the following command on your own\nto debug the issue.\n\nCommand:\n{command}\n\nError:\n[Errno {errno}] {strerror}\n      ' #NEWLINE# raise VerilatorCompileError ( error_msg . format ( command = ' ' . join ( cmd ) , errno = e . errno , strerror = e . strerror ) ) #NEWLINE# #UNINDENT# except CalledProcessError as e : #NEWLINE# #INDENT# error_msg = '\nError trying to find verilator include directories. The\nPYMTL_VERILATOR_INCLUDE_DIR environment variable was not set,\nso we attempted to use pkg-config to find where verilator was\ninstalled, but it looks like pkg-config had trouble finding\nthe verilator.pc file installed by verilator. Is a recent\nversion of verilator installed? Older versions of verilator\ndid not have pkg-config support. Try running the following\ncommand on your own to debug the issue.\n\nCommand:\n{command}\n\nError:\n{error}\n      ' #NEWLINE# raise VerilatorCompileError ( error_msg . format ( command = ' ' . join ( e . cmd ) , error = e . output ) ) #NEWLINE# #UNINDENT# #UNINDENT# include_dirs = [ verilator_include_dir , ( verilator_include_dir + '/vltstd' ) ] #NEWLINE# obj_dir_prefix = 'obj_dir_{m}/V{m}' . format ( m = model_name ) #NEWLINE# cpp_sources_list = [ ] #NEWLINE# with open ( ( obj_dir_prefix + '_classes.mk' ) ) as mkfile : #NEWLINE# #INDENT# found = False #NEWLINE# for line in mkfile : #NEWLINE# #INDENT# if line . startswith ( 'VM_CLASSES_FAST += ' ) : #NEWLINE# #INDENT# found = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if found : #NEWLINE# #INDENT# if ( line . strip ( ) == '' ) : #NEWLINE# #INDENT# found = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# filename = line . strip ( ) [ : ( - 2 ) ] #NEWLINE# cpp_file = 'obj_dir_{m}/{f}.cpp' . format ( m = model_name , f = filename ) #NEWLINE# cpp_sources_list . append ( cpp_file ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# cpp_sources_list += [ ( vlinetrace + '__Syms.cpp' ) , ( verilator_include_dir + '/verilated.cpp' ) , ( verilator_include_dir + '/verilated_dpi.cpp' ) , c_wrapper_file ] #NEWLINE# if vcd_en : #NEWLINE# #INDENT# cpp_sources_list += [ ( verilator_include_dir + '/verilated_vcd_c.cpp' ) , ( obj_dir_prefix + '__Trace.cpp' ) , ( obj_dir_prefix + '__Trace__Slow.cpp' ) ] #NEWLINE# #UNINDENT# compile ( flags = '-O1 -fstrict-aliasing -fPIC -shared' , include_dirs = include_dirs , output_file = lib_file , input_files = cpp_sources_list )