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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [parameter.rb] - Diff between revs 8 and 9

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

Rev 8 Rev 9
###############################################################
###############################################################
#
#
#  File:      parameter.rb
#  File:      parameter.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:
#     This class represents an instance parameter for
#     This class represents an instance parameter for
#     a core with the following values:
#     a core with the following values:
#        - type (mandatory)
#        - type (mandatory)
#        - default
#        - default
#        - min
#        - min
#        - max
#        - max
#        - visible
#        - visible
#        - editable
#        - editable
#        - description
#        - description
#     Most of the fields are reserved for future implementations.
#     Most of the fields are reserved for future implementations.
#
#
###############################################################
###############################################################
module SOCMaker
module SOCMaker
class Parameter
class Parameter
  include ERR
  include ERR
  attr_accessor :type
  attr_accessor :type
  attr_accessor :default
  attr_accessor :default
  attr_accessor :min
  attr_accessor :min
  attr_accessor :max
  attr_accessor :max
  attr_accessor :visible
  attr_accessor :visible
  attr_accessor :editable
  attr_accessor :editable
  attr_accessor :description
  attr_accessor :description
  attr_accessor :choice
  attr_accessor :choice
 
 
  def initialize( type, options = {} )
  def initialize( type, optional = {} )
    init_with( { 'type' => type }.merge( options ) )
    init_with( { 'type' => type }.merge( optional ) )
  end
  end
  def encode_with( coder )
  def encode_with( coder )
    %w[ type default min max
    %w[ type default min max
        visible editable description ].
        visible editable description ].
          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[ 'type' ] == nil,
    serr_if( coder[ 'type' ] == nil,
      'no parameter type specified',
      'no parameter type specified',
      field: "type" )
      field: "type" )
    @type = coder[ 'type' ]
    @type = coder[ 'type' ]
    verr_if( !@type.is_a?( String ),
    verr_if( !@type.is_a?( String ),
      "Parameter type is not defined with string",
      "Parameter type is not defined with string",
      field: "parameter" )
      field: "parameter" )
    verr_if( @type.size == 0,
    verr_if( @type.size == 0,
      "Parameter type string has zero length",
      "Parameter type string has zero length",
      field: "parameter" )
      field: "parameter" )
    @default      = coder[ 'default'     ] || 0
    @default      = coder[ 'default'     ] || 0
    @min          = coder[ 'min'         ] || 0
    @min          = coder[ 'min'         ] || 0
    @max          = coder[ 'max'         ] || 0
    @max          = coder[ 'max'         ] || 0
    @visible      = coder[ 'visible'     ] || true
    @visible      = coder[ 'visible'     ] || true
    @editable     = coder[ 'editable'    ] || false
    @editable     = coder[ 'editable'    ] || false
    @description  = coder[ 'description' ] || ''
    @description  = coder[ 'description' ] || ''
    @choice       = coder[ 'choice'      ] || []
    @choice       = coder[ 'choice'      ] || []
  end
  end
  def ==(o)
  def ==(o)
    o.class         == self.class       &&
    o.class         == self.class       &&
      o.type        == self.type        &&
      o.type        == self.type        &&
      o.default     == self.default     &&
      o.default     == self.default     &&
      o.min         == self.min         &&
      o.min         == self.min         &&
      o.max         == self.max         &&
      o.max         == self.max         &&
      o.visible     == self.visible     &&
      o.visible     == self.visible     &&
      o.editable    == self.editable    &&
      o.editable    == self.editable    &&
      o.description == self.description &&
      o.description == self.description &&
      o.choice      == self.choice
      o.choice      == self.choice
  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.