OpenCores
URL https://opencores.org/ocsvn/soc_maker/soc_maker/trunk

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [soc_def.rb] - Diff between revs 7 and 8

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 7 Rev 8
Line 271... Line 271...
 
 
  def copy_files
  def copy_files
 
 
    SOCMaker::logger.proc( "START of copying all HDL files" )
    SOCMaker::logger.proc( "START of copying all HDL files" )
 
 
 
 
    #
    #
    # Create a unique list of cores and
    # Create a unique list of cores and
    # for every core, create a directory and copy files
    # for every core, create a directory and copy files
    #
    #
    @cores.values.uniq{|x| x.type }.each do |core_inst; core_def, dst_dir|
    @cores.values.uniq{|x| x.type }.each do |core_inst; core_def, dst_dir|
Line 292... Line 293...
        FileUtils.mkdir_p(File.dirname(dst_path))
        FileUtils.mkdir_p(File.dirname(dst_path))
        FileUtils.cp( file_path, dst_path )
        FileUtils.cp( file_path, dst_path )
      end
      end
 
 
 
 
 
 
      #
      #
      # handle the static parameters
      # handle the static parameters
      #   (search and replace in pakckage/include files)
      #   (search and replace in pakckage/include files)
      core_def.static_parameters.each do |file, param|
      core_def.static_parameters.each do |file, sparam|
 
 
        token_val_map = {}
        token_val_map = {}
        param.parameters.each do |n,p|
        sparam.parameters.each do |n,sparam_entry|
 
 
          if  @static[ core_inst.type.to_sym ]      != nil and
          if  @static[ core_inst.type.to_sym ]      != nil and
              @static[ core_inst.type.to_sym ][ n ] != nil
              @static[ core_inst.type.to_sym ][ n ] != nil
 
 
            # use value defined in soc-spec
            # use value defined in soc-spec
            token_val_map[ p.token ] = @static[ core_inst.type.to_sym ][ n ]
            tmp = @static[ core_inst.type.to_sym ][ n ]
          else
          else
            # use default value from core-spec
            # use default value from core-spec
            token_val_map[ p.token ] =  p.default
            tmp =  sparam_entry.default
          end
          end
 
 
 
          if sparam_entry.type == "enum"
 
            token_val_map[ sparam_entry.token ] = sparam_entry.choice[ tmp ]
 
          elsif sparam_entry.type == "bool"
 
            if tmp == true
 
              token_val_map[ sparam_entry.token ] = sparam_entry.choice
 
            else
 
              token_val_map[ sparam_entry.token ] = ""
 
            end
 
          else
 
            token_val_map[ sparam_entry.token ] = tmp
 
          end
 
 
 
 
        end
        end
 
 
        # create file paths
        # create file paths
        src_path = File.join( core_def.dir, param.path )
        src_path = File.join( core_def.dir, sparam.path )
        dst_dir  = get_and_ensure_dst_dir!( core_def.name )
        dst_dir  = get_and_ensure_dst_dir!( core_def.name )
        dst_path = File.join( dst_dir, param.file_dst )
        dst_path = File.join( dst_dir, sparam.file_dst )
 
 
 
 
        # process each line of input file
        # process each line of input file
        # and replace tokens by value via
        # and replace tokens by value via
        # regular expression
        # regular expression
        File.open( dst_path, 'w' ) do |dst_f|
        File.open( dst_path, 'w' ) do |dst_f|
          File.open( src_path ) do |src_f|
          File.open( src_path ) do |src_f|
            SOCMaker::logger.proc( "create #{dst_path} from #{ src_path} " )
            SOCMaker::logger.proc( "create #{dst_path} from #{ src_path} " )
            while line = src_f.gets
            while line = src_f.gets
              token_val_map.each { |token, val| line = line.sub( Regexp.new( token.to_s ), val.to_s ) }
              token_val_map.each { |token, val| line = line.sub( Regexp.new( '\b' + token.to_s + '\b' ), val.to_s ) }
              dst_f.puts line
              dst_f.puts line
            end
            end
          end
          end
        end
        end
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.