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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [ifc_spc.rb] - Diff between revs 7 and 8

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 7 Rev 8
###############################################################
###############################################################
#
#
#  File:      if_spec.rb
#  File:      if_spec.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:
#
#
#
#
#
#
#
#
###############################################################
###############################################################
module SOCMaker
module SOCMaker
class IfcSpc
class IfcSpc
  include ERR
  include ERR
  include YAML_EXT
  include YAML_EXT
  attr_accessor :name
  attr_accessor :name
  attr_accessor :version
  attr_accessor :version
  attr_accessor :ports
  attr_accessor :ports
  def initialize( name, version, options = {} )
  def initialize( name, version, options = {} )
    init_with( { 'name' => name,
    init_with( { 'name' => name,
                 'version' => version }.merge( options ) )
                 'version' => version }.merge( options ) )
  end
  end
  def encode_with( coder )
  def encode_with( coder )
    %w[ name version ports ].
    %w[ name version ports ].
          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 )
    verr_if( coder[ 'name' ] == nil,
    verr_if( coder[ 'name' ] == nil,
      "Name is not defined",
      "Name is not defined",
      field: "name" )
      field: "name" )
    @name = coder[ 'name' ]
    @name = coder[ 'name' ]
    verr_if( !@name.is_a?( String ),
    verr_if( !@name.is_a?( String ),
        "Name is not defined as string",
        "Name is not defined as string",
        field: "name" )
        field: "name" )
    verr_if( @name.size == 0,
    verr_if( @name.size == 0,
        "Name has zero length",
        "Name has zero length",
        field: "name" )
        field: "name" )
    verr_if( coder[ 'version' ] == nil,
    verr_if( coder[ 'version' ] == nil,
      "Version is not defined",
      "Version is not defined",
      field: "version" )
      field: "version" )
    @version = coder[ 'version' ]
    @version = coder[ 'version' ]
    verr_if( !@version.is_a?( String ),
    verr_if( !@version.is_a?( String ),
        "Version is not defined as string",
        "Version is not defined as string",
      instance: @name,
      instance: @name,
      field:    "version" )
      field:    "version" )
    verr_if( @version.size == 0,
    verr_if( @version.size == 0,
        "Version has zero length",
        "Version has zero length",
        field: "name" )
        field: "name" )
    @ports = coder[ 'ports' ] || {}
    @ports = coder[ 'ports' ] || {}
    @ports.each do |pname, port_dir|
    @ports.each do |pname, port|
      verr_if( !port_dir.is_a?( Fixnum ) ||
 
               ( port_dir != 0 && port_dir != 1 ),
      verr_if( !port.is_a?( Hash ),
        "Port direction value is neither 0 nor 1",
        "Port field must be organized as a hash",
        instance: @name,
        instance: @name,
        field:    "ports" )
        field:    "ports" )
 
 
 
      verr_if( !port.has_key?( :dir ),
 
          "No port direction specified for #{pname}",
 
        instance: @name,
 
        field: "ports" )
 
 
 
      verr_if( !port[ :dir ].is_a?( Fixnum ) ||
 
              ( port[ :dir ] != 0 && port[ :dir ] != 1 ),
 
               "Port direction value for #{pname} is neither 0 nor 1",
 
               instance: @name,
 
               field:    "ports" )
 
 
 
      port[ :mandatory ] = true if !port.has_key?( :mandatory )
 
      port[ :default ]   ||= '0'
 
 
    end
    end
  end
  end
end
end
end
end
# 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.