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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [component.rb] - Diff between revs 9 and 10

Show entire file | Details | Blame | View Log

Rev 9 Rev 10
Line 59... Line 59...
 
 
 
 
  # name of the core  (mandatory)
  # name of the core  (mandatory)
  attr_accessor :name
  attr_accessor :name
 
 
  # version of the core  (mandatory)
  # ID of the core  (mandatory)
  attr_accessor :version
  attr_accessor :id
 
 
  # toplevel name (mandatory)
  # toplevel name (mandatory)
  attr_accessor :toplevel
  attr_accessor :toplevel
 
 
  # description of this core
  # description of this core
Line 104... Line 104...
  # Constructor
  # Constructor
  # The three attributes are required, and all other attributes
  # The three attributes are required, and all other attributes
  # can be given as a optinal hash
  # can be given as a optinal hash
  #
  #
  # *name*:: Name of this component
  # *name*:: Name of this component
  # *version*:: Version of this component
  # *id*:: Id of this component
  # *toplevel*:: Toplevel name of this component
  # *toplevel*:: Toplevel name of this component
  # *optional*:: Non-mandatory values, which can be set during initialization.
  # *optional*:: Non-mandatory values, which can be set during initialization.
  #
  #
  #
  #
  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
 
 
  #
  #
  # Encoder function (to yaml)
  # Encoder function (to yaml)
  #
  #
  # +coder+:: An instance of the Psych::Coder to encode this class to a YAML file
  # +coder+:: An instance of the Psych::Coder to encode this class to a YAML file
  #
  #
  def encode_with( coder )
  def encode_with( coder )
    %w[ name version description date license licensefile
    %w[ name id description date license licensefile
        author authormail vccmd toplevel interfaces
        author authormail vccmd toplevel interfaces
        functions inst_parameters static_parameters ].
        functions inst_parameters static_parameters ].
          each { |v| coder[ v ] = instance_variable_get "@#{v}" }
          each { |v| coder[ v ] = instance_variable_get "@#{v}" }
  end
  end
 
 
Line 145... Line 145...
      'The name must be of type string',
      'The name must be of type string',
      field:    'name'         )
      field:    'name'         )
    serr_if( @name.size  == 0,
    serr_if( @name.size  == 0,
      'Name not defined (size == 0)',
      'Name not defined (size == 0)',
      field:    'name'    )
      field:    'name'    )
    verr_if( !!SOCMaker::conf[ :name_regex ].match( @name ) == false,
 
         'The core name is invalid',
 
        instance: @name,
 
        field:    'name' )
 
 
 
    serr_if( coder[ 'version' ] == nil,
    serr_if( coder[ 'id' ] == nil,
      'Version not defined',
      'Id not defined',
      instance: @name,
      instance: @name,
      field:    'version' )
      field:    'id' )
    @version = coder[ 'version' ]
    @id = coder[ 'id' ]
    serr_if( @version.size == 0,
    serr_if( @id.size == 0,
      'Version not defined (size == 0)',
      'Id not defined (size == 0)',
      instance: @name,
      instance: @name,
      field:    'version' )
      field:    'id' )
 
 
    # cast from numeric to string, if not given as string
    verr_if( !@id.is_a?( String ),
    @version = @version.to_s if @version.is_a? ( Numeric )
 
    verr_if( !@version.is_a?( String ),
 
      'The name must be of type string or numeric',
      'The name must be of type string or numeric',
      field:    'name'         )
      field:    'name'         )
 
 
 
 
 
 
Line 256... Line 250...
            instance: @name+":"+name.to_s )
            instance: @name+":"+name.to_s )
    end
    end
 
 
  end
  end
 
 
 
  #
 
  # the directory name of this core
 
  #
 
  def dir_name
 
    @id.split(',').join("_")
 
  end
 
 
 
 
 
 
  #
  #
  # Runs a consistency check:
  # Runs a consistency check:
  # Iterate over all interfaces and check, if the interface is
  # Iterate over all interfaces and check, if the interface is
  # in the SOCMaker::Lib.
  # in the SOCMaker::Lib.
Line 268... Line 270...
  #
  #
  def consistency_check
  def consistency_check
    @interfaces.values.each_with_index do | ifc, i_ifc; ifc_def|
    @interfaces.values.each_with_index do | ifc, i_ifc; ifc_def|
 
 
      # get interface definition
      # get interface definition
      ifc_def = SOCMaker::lib.get_ifc( ifc.name, ifc.version )
      ifc_def = SOCMaker::lib.get_ifc( ifc.id )
 
 
 
 
      # check, if all mandatory ports are implemented by this interface
      # check, if all mandatory ports are implemented by this interface
      ifc_def.ports.each do | port_name, port |
      ifc_def.ports.each do | port_name, port |
        perr_if( port[ :mandatory ] == true &&
        perr_if( port[ :mandatory ] == true &&
Line 352... Line 354...
    end
    end
 
 
    @ifc_sel.values.each_with_index do | ifc, i_ifc; ifc_def|
    @ifc_sel.values.each_with_index do | ifc, i_ifc; ifc_def|
 
 
      # get interface definition
      # get interface definition
      ifc_def = SOCMaker::lib.get_ifc( ifc.name, ifc.version )
      ifc_def = SOCMaker::lib.get_ifc( ifc.id )
 
 
      # loop over ports in this interface
      # loop over ports in this interface
      ifc.ports.each_with_index do |(port_name, port_def), i_port |
      ifc.ports.each_with_index do |(port_name, port_def), i_port |
 
 
        # the reference to the port in the definition
        # the reference to the port in the definition
        defn_ref      = port_def.defn.to_sym
        defn_ref      = port_def.defn.to_sym
        perr_if( !ifc_def.ports.has_key?( defn_ref ),
        perr_if( !ifc_def.ports.has_key?( defn_ref ),
            "Can't find #{port_def} in" +
            "Can't find #{port_def} in" +
            "interface definition #{ifc_def.name} " +
            "interface definition #{ifc_def.name} " +
            "version #{ifc_def.version}" )
            "id #{ifc_def.id}" )
 
 
        _port_name    = port_name.to_s
        _port_name    = port_name.to_s
        _port_dir     = ifc_def.ports[ defn_ref ][:dir] ^ ifc.dir
        _port_dir     = ifc_def.ports[ defn_ref ][:dir] ^ ifc.dir
        _port_length  = port_def.len
        _port_length  = port_def.len
        _port_default = ifc_def.ports[ defn_ref ][ :default  ]
        _port_default = ifc_def.ports[ defn_ref ][ :default  ]
Line 384... Line 386...
  def ==(o)
  def ==(o)
 
 
    tmp    = ( o.class   == self.class )
    tmp    = ( o.class   == self.class )
    return tmp if !tmp
    return tmp if !tmp
 
 
    %w[ name version description date license licensefile
    %w[ name id description date license licensefile
        author authormail vccmd toplevel interfaces
        author authormail vccmd toplevel interfaces
        functions inst_parameters static_parameters ].
        functions inst_parameters static_parameters ].
          each do |v|
          each do |v|
      return false if instance_variable_get( "@#{v}" ) != o.instance_variable_get( "@#{v}" )
      return false if instance_variable_get( "@#{v}" ) != o.instance_variable_get( "@#{v}" )
    end
    end
Line 397... Line 399...
 
 
  #
  #
  # Returns a string describing this instance
  # Returns a string describing this instance
  #
  #
  def to_s
  def to_s
    "version:           #{@version}\n"              +
    "id:                #{@id}\n"              +
    "toplevel:          #{@toplevel}\n"             +
    "toplevel:          #{@toplevel}\n"             +
    "description:       #{@description}\n"          +
    "description:       #{@description}\n"          +
    "date:              #{@date}\n"                 +
    "date:              #{@date}\n"                 +
    "license:           #{@license}\n"              +
    "license:           #{@license}\n"              +
    "licensefile:       #{@licensefile}\n"          +
    "licensefile:       #{@licensefile}\n"          +

powered by: WebSVN 2.1.0

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