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 9 and 10

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

Rev 9 Rev 10
###############################################################
###############################################################
#
#
#  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 :id
  attr_accessor :ports
  attr_accessor :ports
 
 
  def initialize( name, version, optional = {} )
  def initialize( name, id, optional = {} )
    init_with( { 'name' => name,
    init_with( { 'name' => name,
                 'version' => version }.merge( optional ) )
                 'id' => id }.merge( optional ) )
  end
  end
  def encode_with( coder )
  def encode_with( coder )
    %w[ name version ports ].
    %w[ name id 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[ 'id' ] == nil,
      "Version is not defined",
      "Id is not defined",
      field: "version" )
      field: "id" )
    @version = coder[ 'version' ]
    @id = coder[ 'id' ]
    verr_if( !@version.is_a?( String ),
    verr_if( !@id.is_a?( String ),
        "Version is not defined as string",
        "Version is not defined as string",
      instance: @name,
      instance: @name,
      field:    "version" )
      field:    "id" )
    verr_if( @version.size == 0,
    verr_if( @id.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|
    @ports.each do |pname, port|
      verr_if( !port.is_a?( Hash ),
      verr_if( !port.is_a?( Hash ),
        "Port field must be organized as a hash",
        "Port field must be organized as a hash",
          instance: @name,
          instance: @name,
          field: "ports" )
          field: "ports" )
      verr_if( !port.has_key?( :dir ),
      verr_if( !port.has_key?( :dir ),
          "No port direction specified for #{pname}",
          "No port direction specified for #{pname}",
        instance: @name,
        instance: @name,
        field: "ports" )
        field: "ports" )
      verr_if( !port[ :dir ].is_a?( Fixnum ) ||
      verr_if( !port[ :dir ].is_a?( Fixnum ) ||
              ( port[ :dir ] != 0 && port[ :dir ] != 1 ),
              ( port[ :dir ] != 0 && port[ :dir ] != 1 ),
               "Port direction value for #{pname} is neither 0 nor 1",
               "Port direction value for #{pname} is neither 0 nor 1",
               instance: @name,
               instance: @name,
               field:    "ports" )
               field:    "ports" )
      port[ :mandatory ] = true if !port.has_key?( :mandatory )
      port[ :mandatory ] = true if !port.has_key?( :mandatory )
      port[ :default ]   ||= '0'
      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.