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 3 and 5

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

Rev 3 Rev 5
Line 80... Line 80...
    end
    end
 
 
  end
  end
 
 
 
 
  def get_and_ensure_dst_dir!( core_name )
 
      dst_dir =  File.expand_path(
 
            File.join(
 
              SOCMaker::conf[ :build_dir ],
 
              SOCMaker::conf[ :hdl_dir   ],
 
              core_name ) )
 
      FileUtils.mkdir_p dst_dir
 
      return dst_dir
 
  end
 
 
 
 
 
 
 
 
 
  # SOCMaker::logger.error( "instantiation #{inst_name} is already in use" )
  # SOCMaker::logger.error( "instantiation #{inst_name} is already in use" )
Line 138... Line 129...
    return false
    return false
 
 
  end
  end
 
 
 
 
 
 
 
  def get_core_def( inst )
 
      if @cores[ inst.to_sym ] != nil
 
        return @cores[ inst.to_sym ].defn
 
      elsif inst == @name
 
        return self
 
      else
 
        perr_if( true,
 
          "Instance '#{inst}' does not exist in SOC '#{self.name}'" )
 
      end
 
  end
 
 
 
 
 
 
  def add_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
  def add_connection( inst1, ifc1_name, inst2, ifc2_name, con_name )
 
 
    return nil if inst_in_use?( con_name )
    return nil if inst_in_use?( con_name )
 
 
 
 
Line 149... Line 154...
     [ inst2, ifc2_name ] ].each do |sub_arr|
     [ inst2, ifc2_name ] ].each do |sub_arr|
      perr_if( ifc_in_use?( sub_arr[ 0 ], sub_arr[ 1 ] ),
      perr_if( ifc_in_use?( sub_arr[ 0 ], sub_arr[ 1 ] ),
          "Interface #{sub_arr[ 1 ]} of instance '#{sub_arr[ 0 ]}' is already in use " )
          "Interface #{sub_arr[ 1 ]} of instance '#{sub_arr[ 0 ]}' is already in use " )
    end
    end
 
 
    [ inst1, inst2 ].each do |inst|
 
      perr_if( @cores[ inst.to_sym ] == nil,
 
          "Instance '#{inst}' does not exist in SOC '#{self.name}'" )
 
    end
 
 
 
    # get the core-specs
    core_spec_1 = get_core_def( inst1 )
    core_spec_1 = SOCMaker::lib.get_core( @cores[ inst1.to_sym ].type )
    core_spec_2 = get_core_def( inst2 )
    core_spec_2 = SOCMaker::lib.get_core( @cores[ inst2.to_sym ].type )
 
 
 
    [ [ core_spec_1, ifc1_name ],
    [ [ core_spec_1, ifc1_name ],
      [ core_spec_2, ifc2_name ] ].each do |sub_arr|
      [ core_spec_2, ifc2_name ] ].each do |sub_arr|
        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}' " )
          "Interface '#{sub_arr[ 1 ]}' dosn't exist in core '#{sub_arr[0].name}' " )
Line 180... Line 181...
 
 
    @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 } ] }
 
    return false
  end
  end
 
 
  def set_param( instance, param, value )
  def set_param( instance, param, value )
 
 
    # get instance
    # get instance
Line 249... Line 250...
 
 
 
 
 
 
  def gen_toplevel( coder = VHDLCoder.new() )
  def gen_toplevel( coder = VHDLCoder.new() )
 
 
    file_name = @name
    file_name = @name.dup
 
 
    if coder.is_a?( VHDLCoder )
    if coder.is_a?( VHDLCoder )
      file_name << ".vhd"
      file_name << ".vhd"
    elsif coder.is_a?( VerilogCoder )
    elsif coder.is_a?( VerilogCoder )
      file_name << ".v"
      file_name << ".v"
Line 326... Line 327...
    src_inst            = {};
    src_inst            = {};
    dst_inst            = {};
    dst_inst            = {};
 
 
    # fetch somehow the spec
    # fetch somehow the spec
    ifc_spec = SOCMaker::lib.get_ifc(
    ifc_spec = SOCMaker::lib.get_ifc(
      @cores[ src.keys.first ].defn.interfaces[ src.values.first ].name,
      get_core_def( src.keys.first.to_s ).interfaces[ src.values.first ].name,
      @cores[ src.keys.first ].defn.interfaces[ src.values.first ].version )
      get_core_def( src.keys.first.to_s ).interfaces[ src.values.first ].version )
 
 
    length_tmp = {};
 
 
 
 
    port_used_tmp = {};
    ifc_spec.ports.keys.each do |_name|
    ifc_spec.ports.keys.each do |_name|
 
      # TODO: bis dahin konnte angenommen werden, dass self auch eine Art instanz ist,
 
      #       aber hier geht das nicht mehr, weil get_len nur für CoreInst definiert ist.
 
      #
 
 
 
 
      # create a length table
      # create a length table
      length_tmp[ _name ] = []
      port_used_tmp[ _name ] = false
      dst.each do |inst_name, ifc_name|
      dst.each do |inst_name, ifc_name|
        length_tmp[ _name ] << @cores[ inst_name ].get_len( ifc_name, _name )
        port_used_tmp[ _name ] ||= get_core_def( inst_name ).implements_port?( ifc_name, _name )
      end
      end
      src.each do |inst_name, ifc_name|
      src.each do |inst_name, ifc_name|
        length_tmp[ _name ] << @cores[ inst_name ].get_len( ifc_name, _name )
        port_used_tmp[ _name ] ||= get_core_def( inst_name ).implements_port?( ifc_name, _name )
      end
      end
 
 
    end
    end
 
 
    # getting the maximum length for each signal
    # getting the maximum length for each signal
    max_length = Hash[ length_tmp.map{ |key, arr| [ key, arr.max ] } ]
#    max_length = Hash[ length_tmp.map{ |key, arr| [ key, arr.max ] } ]
 
 
    coder.ifc_declaration( ifc_spec, name, max_length )
#    coder.ifc_declaration( ifc_spec, name, max_length )
 
 
 
 
 
 
    src.keys.each do |inst_name|
    src.keys.each do |inst_name|
      src_inst[ inst_name ]            = @cores[ inst_name ]
      src_inst[ inst_name ]            = @cores[ inst_name ]
Line 360... Line 363...
      dst_inst[ inst_name ]            = @cores[ inst_name ]
      dst_inst[ inst_name ]            = @cores[ inst_name ]
    end
    end
 
 
 
 
 
 
    coder.ifc_assignment( ifc_spec, name, max_length, src_inst, dst_inst, src, dst )
#    coder.ifc_assignment( ifc_spec, name, max_length, src_inst, dst_inst, src, dst )
 
 
  end
  end
 
 
  def copy_files
  def copy_files
 
 
Line 382... Line 385...
      dst_dir  = get_and_ensure_dst_dir!( core_def.name )
      dst_dir  = get_and_ensure_dst_dir!( core_def.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, file.to_s )
        dst_path = File.join( dst_dir, val.path )
        SOCMaker::logger.proc( "copy #{file_path} to #{ dst_path} " )
        SOCMaker::logger.proc( "copy #{file_path} to #{ dst_path} " )
 
        FileUtils.mkdir_p(File.dirname(dst_path))
        FileUtils.cp( file_path, dst_path )
        FileUtils.cp( file_path, dst_path )
      end
      end
 
 
 
 
 
 
Line 448... Line 452...
    o.static  == self.static  &&
    o.static  == self.static  &&
    super( o )
    super( o )
  end
  end
 
 
 
 
 
  def to_s
 
 
 
    tmp = "_________ SOC #{@name}: _______\n"     +
 
          super                                   +
 
          "\n__connections__\n"
 
 
 
    @cons.each do |_con_name, con_def|
 
      tmp += "#{_con_name}: #{con_def}\n"
 
    end
 
 
 
    tmp += "\n__cores__\n"
 
    @cores.each do |inst_name, inst|
 
      tmp += "#{inst_name}:\n#{inst}\n"
 
    end
 
    tmp += "'''''''''''''''''''''''''''''''''''\n"
 
    return tmp
 
  end
 
 
 
 
end # class SOCSpec
end # class SOCSpec
end # module SOCMaker
end # module SOCMaker
 
 
 
 
# vim: noai:ts=2:sw=2
# vim: noai:ts=2:sw=2

powered by: WebSVN 2.1.0

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