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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [ifc_port.rb] - Diff between revs 3 and 7

Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 7
###############################################################
###############################################################
#
#
#  File:      ifc_port.rb
#  File:      ifc_port.rb
#
#
#  Author:    Christian Hättich
#  Author:    Christian Hättich
#
#
#  Project:   System-On-Chip Maker
#  Project:   System-On-Chip Maker
#
#
#  Target:    Linux / Windows / Mac
#  Target:    Linux / Windows / Mac
#
#
#  Language:  ruby
#  Language:  ruby
#
#
#
#
###############################################################
###############################################################
#
#
#
#
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
#
#
#   This program is free software: you can redistribute it and/or modify
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#   (at your option) any later version.
#
#
#   This program is distributed in the hope that it will be useful,
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   GNU General Public License for more details.
#
#
#   You should have received a copy of the GNU General Public License
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see .
#   along with this program.  If not, see .
#
#
#
#
###############################################################
###############################################################
#
#
#   Description:
#   Description:
#
#
#
#
#     A small classes, used to group information
#     A small classes, used to group information
#     and to verify, auto-correct and auto-complete
#     and to verify, auto-correct and auto-complete
#     this information:
#     this information:
#     The class represents an interface port within
#     The class represents an interface port within
#     SOCMaker::IfcDef (see ifc_def.rb).
#     SOCMaker::IfcDef (see ifc_def.rb).
#     It is used to make a relation between the naming
#     It is used to make a relation between the naming
#     of IfcDef and IfcSpc.
#     of IfcDef and IfcSpc.
#     The two data fiels are
#     The two data fiels are
#        - defn (mandatory: must be the name of the port, defined in IfcSpc)
#        - defn (mandatory: must be the name of the port, defined in IfcSpc)
#        - len (optional, default is 1)
#        - len (optional, default is 1)
#
#
###############
###############
#
#
# TODO
# TODO
#     - Add test-code
#     - Add test-code
#     - Rename defn to something more meaningful
#     - Rename defn to something more meaningful
#
#
###############################################################
###############################################################
module SOCMaker
module SOCMaker
class IfcPort
class IfcPort
  include ERR
  include ERR
  attr_accessor :defn
  attr_accessor :defn
  attr_accessor :len
  attr_accessor :len
  def initialize( defn, len = 1 )
  def initialize( defn, len = 1 )
    init_with( 'defn' => defn,
    init_with( 'defn' => defn,
               'len'  => len )
               'len'  => len )
  end
  end
  def encode_with( coder )
  def encode_with( coder )
    %w[ defn len ].
    %w[ defn len ].
          each { |v| coder[ v ] = instance_variable_get "@#{v}" }
          each { |v| coder[ v ] = instance_variable_get "@#{v}" }
  end
  end
  def init_with( coder )
  def init_with( coder )
    serr_if( coder[ 'defn' ] == nil,
    serr_if( coder[ 'defn' ] == nil,
      'no relation to interface-definition is given for an interface port (nil)',
      'no relation to interface-definition is given for an interface port (nil)',
      field: "defn" )
      field: "defn" )
    @defn = coder[ 'defn' ]
    @defn = coder[ 'defn' ]
    verr_if( !@defn.is_a?( String ),
    verr_if( !@defn.is_a?( String ),
      'Relation to interface definition is not of type string',
      'Relation to interface definition is not of type string',
      instance: @defn.to_s,
      instance: @defn.to_s,
      field:    "defn")
      field:    "defn")
    verr_if( @defn.size == 0,
    verr_if( @defn.size == 0,
      'Relation to interface definition has zero length',
      'Relation to interface definition has zero length',
      instance: @defn.to_s,
      instance: @defn.to_s,
      field:    "defn")
      field:    "defn")
    @len = coder[ 'len' ] || 1
    @len = coder[ 'len' ] || 1
    verr_if( !( @len.is_a?( Fixnum ) || @len.is_a?( String ) ),
    verr_if( !( @len.is_a?( Fixnum ) || @len.is_a?( String ) ),
      'Length is not a fixnum',
      'Length is not a fixnum',
      instance: @defn.to_s,
      instance: @defn.to_s,
      field:    "defn")
      field:    "defn")
  end
  end
 
 
  def verify
 
  end
 
 
 
  def ==(o)
  def ==(o)
    o.class  == self.class   &&
    o.class  == self.class   &&
    o.defn   == self.defn    &&
    o.defn   == self.defn    &&
    o.len    == self.len
    o.len    == self.len
  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.