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 7 and 8

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

Rev 7 Rev 8
Line 217... Line 217...
 
 
  end
  end
 
 
 
 
  def consistency_check
  def consistency_check
 
    @interfaces.values.each_with_index do | ifc, i_ifc; ifc_def|
 
 
 
      # get interface definition
 
      ifc_def = SOCMaker::lib.get_ifc( ifc.name, ifc.version )
 
 
 
 
 
      # check, if all mandatory ports are implemented by this interface
 
      ifc_def.ports.each do | port_name, port |
 
        perr_if( port[ :mandatory ] == true &&
 
                  ifc.ports.select{ |key,port_def| port_def.defn.to_sym == port_name }.size == 0,
 
          "Mandatory port #{port_name} is not implemented in interface #{ifc.name}" )
 
      end
 
    end
 
 
  end
  end
 
 
 
 
  def get_files
  def get_files
Line 230... Line 243...
    end
    end
  end
  end
 
 
 
 
 
 
 
 
  def generics
  def generics
    @inst_parameters.each_with_index do |(name, val), i|
    @inst_parameters.each_with_index do |(name, val), i|
      yield( name.to_s, val.type, val.default, i == @inst_parameters.size-1 )
      yield( name.to_s, val.type, val.default, i == @inst_parameters.size-1 )
    end
    end
  end
  end
Line 257... Line 269...
  #   - port-name
  #   - port-name
  #   - port-definition
  #   - port-definition
  #   - info if last
  #   - info if last
  # as argument
  # as argument
  #
  #
 
  # An xor mechanism between port_dir and ifc=>dir is used
 
  # to determine the direction of a port, for example:
 
  #  If the interface is declared as input (1) and a port is declared as input (1)
 
  #  the resulting direction will be an output 1^1 = 0.
 
  #  But if the overall interface direction is an output (0) and a port is declared
 
  #  as input, the resulting direction will an input 0^1 = 1.
 
  # This allows to define a port-direction in the interface definition,
 
  # and toggle the directions on core-definition level.
  #
  #
  #
  #
  def ports( *args )
  def ports( *args )
 
 
    if args.size == 0
    if args.size == 0
Line 271... Line 291...
 
 
        # loop over ports in this interface
        # loop over ports in this interface
        ifc.ports.each_with_index do |(port_name, port_def), i_port; port_dir|
        ifc.ports.each_with_index do |(port_name, port_def), i_port; port_dir|
 
 
          # the reference to the port in the definition
          # the reference to the port in the definition
          defn_ref = port_def.defn
          defn_ref      = port_def.defn.to_sym
          port_dir = ifc_def.ports[ defn_ref.to_sym ]
          perr_if( !ifc_def.ports.has_key?( defn_ref ),
          perr_if( port_dir == nil,
              "Can't find #{port_def} in" +
                "Can't find #{defn_ref} in interface " +
              "interface definition #{ifc_def.name} " +
                "definition #{ifc_def.name} version "  +
              "version #{ifc_def.version}" )
                ifc_def.version + "==>>" + ifc_def.to_yaml )
 
 
 
          # An xor mechanism between port_dir and ifc=>dir is used
 
          # to determine the direction of a port, for example:
 
          #  If the interface is declared as input (1) and a port is declared as input (1)
 
          #  the resulting direction will be an output 1^1 = 0.
 
          #  But if the overall interface direction is an output (0) and a port is declared
 
          #  as input, the resulting direction will an input 0^1 = 1.
 
          # This allows to define a port-direction in the interface definition,
 
          # and toggle the directions on core-definition level.
 
 
 
          #  (name, direction, length, is_last)
 
          yield(  port_name.to_s,
          yield(  port_name.to_s,
                  port_dir ^ ifc.dir,
                  ifc_def.ports[ defn_ref ][:dir] ^ ifc.dir,
                  port_def.len,
                  port_def.len,
 
                  ifc_def.ports[ defn_ref ][ :default  ],
                  ( (i_port == ifc.ports.size-1 ) and (i_ifc == @interfaces.size-1 ) ) )
                  ( (i_port == ifc.ports.size-1 ) and (i_ifc == @interfaces.size-1 ) ) )
        end
        end
      end
      end
 
 
    elsif args.size == 1
    elsif args.size == 1
 
 
      # get interface (input is the name as string  )
      # get interface (input is the name as string  )
      ifc = @interfaces[ args.first.to_sym  ]
      ifc = @interfaces[ args.first.to_sym  ]
 
 
      ifc_def = SOCMaker::lib.get_ifc( ifc.name, ifc.version )
      ifc_def = SOCMaker::lib.get_ifc( ifc.name, ifc.version )
      ifc.ports.each do |port_name, port_def; port_dir|
 
        port_def = port_def.defn
      # loop over all ports of this interface
        port_dir = ifc_def.ports[ port_def.to_sym ]
      ifc.ports.each_with_index do |(port_name, port_def),i_port; port_dir|
        if port_dir == nil
        defn_ref      = port_def.defn.to_sym
          perr_if( port_dir==nil,
        perr_if( !ifc_def.ports.has_key?( defn_ref ),
              "Can't find #{port_def} in" +
            "Can't find #{defn_ref} in" +
              "interface definition #{ifc_def.name} " +
              "interface definition #{ifc_def.name} " +
              "version #{ifc_def.version}" )
              "version #{ifc_def.version}" )
        end
        yield(  port_name.to_s,
        yield(  port_def.to_s,
                ifc_def.ports[ defn_ref ][:dir] ^ ifc.dir,
                port_name.to_s,
                port_def.len,
                port_dir ^ ifc.dir )
                ifc_def.ports[ defn_ref ][ :default  ],
 
                ( (i_port == ifc.ports.size-1 ) )
 
              )
 
        #yield(  port_def.to_s,
 
                #port_name.to_s,
 
                #port_dir ^ ifc.dir,
 
                #port_default )
      end
      end
 
 
    else
    else
 
      # TODO
    end
    end
 
 
  end
  end
 
 
 
 
Line 379... Line 393...
end # module SOCMaker
end # module SOCMaker
 
 
 
 
# vim: noai:ts=2:sw=2
# 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.