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 9 and 10

Show entire file | Details | Blame | View Log

Rev 9 Rev 10
Line 49... Line 49...
  include YAML_EXT
  include YAML_EXT
 
 
  attr_accessor :cores
  attr_accessor :cores
  attr_accessor :cons
  attr_accessor :cons
  attr_accessor :static
  attr_accessor :static
  def initialize( name, version, toplevel, optional = {} )
  def initialize( name, id, toplevel, optional = {} )
 
 
    init_with( { 'name'     => name,
    init_with( { 'name'     => name,
                 'version'  => version,
                 'id'       => id,
                 'toplevel' => toplevel }.merge( optional ) )
                 'toplevel' => toplevel }.merge( optional ) )
 
 
  end
  end
 
 
  def encode_with( coder )
  def encode_with( coder )
Line 101... Line 101...
    end
    end
    return true
    return true
  end
  end
 
 
 
 
  def add_core( name, version, inst_name )
  def add_core( id, inst_name )
 
 
    return false if inst_in_use?( inst_name )
    return false if inst_in_use?( inst_name )
 
 
    # check, if the core exits in our library
    # check, if the core exits in our library
    #  if not: an error will be raised
    #  if not: an error will be raised
    SOCMaker::lib.get_core( name, version )
    SOCMaker::lib.get_core( id )
 
 
    @cores[ inst_name.to_sym ] = SOCMaker::CoreInst.new( name+version )
    @cores[ inst_name.to_sym ] = SOCMaker::CoreInst.new( id )
  end
  end
 
 
 
 
  def ifc_in_use?( inst_name, ifc_name )
  def ifc_in_use?( inst_name, ifc_name )
 
 
Line 137... Line 137...
  end
  end
 
 
  def core_definition( inst )
  def core_definition( inst )
      if @cores[ inst.to_sym ] != nil
      if @cores[ inst.to_sym ] != nil
        return @cores[ inst.to_sym ].defn
        return @cores[ inst.to_sym ].defn
      elsif inst == @name
      elsif inst == @toplevel
        return self
        return self
      else
      else
        return nil
        return nil
      end
      end
  end
  end
 
 
 
 
 
 
 
 
  def add_to_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
  #def add_to_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
 
  def add_to_connection( *args )
 
 
 
    if args.size == 4
 
      inst1     = @toplevel
 
      ifc1_name = args[ 0 ]
 
      inst2     = args[ 1 ]
 
      ifc2_name = args[ 2 ]
 
      con_name  = args[ 3 ]
 
    elsif args.size == 5
 
      inst1     = args[ 0 ]
 
      ifc1_name = args[ 1 ]
 
      inst2     = args[ 2 ]
 
      ifc2_name = args[ 3 ]
 
      con_name  = args[ 4 ]
 
    else
 
      perr_if( true, "FATAL: wrong number of arguments (#{args.size}) for add_to_connection (3 or 4)" )
 
    end
 
 
 
 
    perr_if( @cons[ con_name.to_sym ]  == nil, "Connection instance #{con_name} not found" )
    perr_if( @cons[ con_name.to_sym ]  == nil, "Connection instance #{con_name} not found" )
    @cons[ con_name.to_sym ][:mapping][0][ inst1.to_sym ] = ifc1_name.to_sym
    @cons[ con_name.to_sym ][:mapping][0][ inst1.to_sym ] = ifc1_name.to_sym
    @cons[ con_name.to_sym ][:mapping][1][ inst2.to_sym ] = ifc2_name.to_sym
    @cons[ con_name.to_sym ][:mapping][1][ inst2.to_sym ] = ifc2_name.to_sym
  end
  end
 
 
 
 
 
 
  def add_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
  #def add_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
 
  def add_connection( *args )
 
 
 
    if args.size == 4
 
      inst1     = @toplevel
 
      ifc1_name = args[ 0 ]
 
      inst2     = args[ 1 ]
 
      ifc2_name = args[ 2 ]
 
      con_name  = args[ 3 ]
 
    elsif args.size == 5
 
      inst1     = args[ 0 ]
 
      ifc1_name = args[ 1 ]
 
      inst2     = args[ 2 ]
 
      ifc2_name = args[ 3 ]
 
      con_name  = args[ 4 ]
 
    else
 
      perr_if( true, "FATAL: wrong number of arguments (#{args.size}) for add_connection (3 or 4)" )
 
    end
 
 
    if @cores[ con_name.to_sym ] != nil
    if @cores[ con_name.to_sym ] != nil
      return nil
      return nil
    elsif @cons[ con_name.to_sym ]  != nil
    elsif @cons[ con_name.to_sym ]  != nil
      return add_to_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
      return add_to_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
Line 185... Line 221...
        perr_if( sub_arr[ 0 ].interfaces[ sub_arr[ 1 ].to_sym ] == nil,
        perr_if( sub_arr[ 0 ].interfaces[ sub_arr[ 1 ].to_sym ] == nil,
          "Interface '#{sub_arr[ 1 ]}' dosn't exist in core '#{sub_arr[0].name}' \n" +
          "Interface '#{sub_arr[ 1 ]}' dosn't exist in core '#{sub_arr[0].name}' \n" +
          "The following interfaces do exist:  '#{sub_arr[0].interfaces.keys}'"  )
          "The following interfaces do exist:  '#{sub_arr[0].interfaces.keys}'"  )
    end
    end
 
 
    # check name and version of the ifcs which will be connected
    # check id of the ifcs which will be connected
    perr_if( core_def_1.interfaces[ ifc1_name.to_sym ].name     !=
    perr_if( core_def_1.interfaces[ ifc1_name.to_sym ].id !=
             core_def_2.interfaces[ ifc2_name.to_sym ].name     ||
             core_def_2.interfaces[ ifc2_name.to_sym ].id,
             core_def_1.interfaces[ ifc1_name.to_sym ].version  !=
 
             core_def_2.interfaces[ ifc2_name.to_sym ].version,
 
          "Can't connect #{
          "Can't connect #{
            core_def_1.interfaces[ ifc1_name.to_sym ].name } - #{
             core_def_1.interfaces[ ifc1_name.to_sym ].id} with #{
            core_def_2.interfaces[ ifc2_name.to_sym ].name } : #{
             core_def_2.interfaces[ ifc2_name.to_sym ].id} " )
            core_def_1.interfaces[ ifc1_name.to_sym ].version } - #{
 
            core_def_2.interfaces[ ifc2_name.to_sym ].version }" )
 
 
 
 
 
    @cons[ con_name.to_sym ] = {
    @cons[ con_name.to_sym ] = {
          :rule    => "or",
          :rule    => "or",
          :mapping => [ { inst1.to_sym => ifc1_name.to_sym },
          :mapping => [ { inst1.to_sym => ifc1_name.to_sym },
                        { inst2.to_sym => ifc2_name.to_sym } ] }
                        { inst2.to_sym => ifc2_name.to_sym } ] }
Line 281... Line 312...
    @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|
 
 
      core_def = SOCMaker::lib.get_core( core_inst.type )
      core_def = SOCMaker::lib.get_core( core_inst.type )
 
 
      # create destination directory name and ensure, that it is exist
      # create destination directory name and ensure, that it is exist
      dst_dir  = Component.get_and_ensure_dst_dir!( core_def.name )
      dst_dir  = Component.get_and_ensure_dst_dir!( core_def.dir_name )
 
 
      # copy each file into destination dir
      # copy each file into destination dir
      core_def.hdlfiles.each do |file, val|
      core_def.hdlfiles.each do |file, val|
        file_path = File.join( core_def.dir, val.path )
        file_path = File.join( core_def.dir, val.path )
        dst_path = File.join( dst_dir, val.path )
        dst_path = File.join( dst_dir, val.path )
Line 327... Line 358...
 
 
        end
        end
 
 
        # create file paths
        # create file paths
        src_path = File.join( core_def.dir, sparam.path )
        src_path = File.join( core_def.dir, sparam.path )
        dst_dir  = Component::get_and_ensure_dst_dir!( core_def.name )
        dst_dir  = Component::get_and_ensure_dst_dir!( core_def.dir_name )
        dst_path = File.join( dst_dir, sparam.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

powered by: WebSVN 2.1.0

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