#NEWLINE# def verilate_model( filename , model_name , vcd_en , lint ) : #NEWLINE# #INDENT# compile_cmd = 'verilator -cc {source} -top-module {model_name} --Mdir {obj_dir} {flags}' #NEWLINE# source = filename #NEWLINE# obj_dir = ( 'obj_dir_' + model_name ) #NEWLINE# flags = ' ' . join ( [ ( '-Wno-lint' if ( not lint ) else '' ) , '-Wno-UNOPTFLAT' , '--unroll-count 1000000' , '--unroll-stmts 1000000' , '--assert' , ( '--trace' if vcd_en else '' ) ] ) #NEWLINE# if os . path . exists ( obj_dir ) : #NEWLINE# #INDENT# shutil . rmtree ( obj_dir ) #NEWLINE# #UNINDENT# compile_cmd = compile_cmd . format ( ** vars ( ) ) #NEWLINE# try : #NEWLINE# #INDENT# result = check_output ( compile_cmd , stderr = STDOUT , shell = True ) #NEWLINE# #UNINDENT# except CalledProcessError as e : #NEWLINE# #INDENT# split_output = e . output . splitlines ( ) #NEWLINE# error = '\n' . join ( split_output [ : ( - 1 ) ] ) #NEWLINE# if ( not split_output [ ( - 1 ) ] . startswith ( '%Error: Command Failed' ) ) : #NEWLINE# #INDENT# error += ( '\n' + split_output [ ( - 1 ) ] ) #NEWLINE# #UNINDENT# error_msg = '\nSee "Errors and Warnings" section in the manual located here\nhttp://www.veripool.org/projects/verilator/wiki/Manual-verilator\nfor more details on various Verilator warnings and error messages.\n\n{error}' #NEWLINE# raise VerilatorCompileError ( error_msg . format ( command = e . cmd , error = error ) )